contributed by <HuangWenChen
> , <aweimeow
>
Fork jit-construct
閱讀 README.md 依序安裝操作
The Just-In-Time (JIT) compiler is a component of the Java™ Runtime Environment that improves the performance of Java applications by compiling bytecodes into native machine code at run time.
Just-In-Time (JIT) compiler 是 Java™ Runtime Environment 的一部分,在執行時可以藉由編譯位元組碼成原生本機機器碼改善 Java 應用程式的效能。
Just-in-time (JIT) compilation, also known as dynamic translation, is compilation done during execution of a program – at run time – rather than prior to execution. Most often this consists of translation to machine code, which is then executed directly, but can also refer to translation to another format.
just-in-time (JIT) compilation 也被稱為動態編譯 (dynamic translation),是在程序執行期間 - 在運行時完成編譯 - 而不是執行之前。因為通常大部分都是由編譯可直接執行的機械碼組成,但是也可以參考編譯成另一種格式。
JIT compilation is a combination of the two traditional approaches to translation to machine code – ahead-of-time compilation (AOT), and interpretation.
JIT compilation 是一個結合兩種傳統方法去編譯成機械碼,一種是 ahead-of-time compilation (AOT),另一種是 interpretation
Ahead-of-time (AOT) compilation is the act of compiling a high-level programming language such as C or C++, or an intermediate language such as Java bytecode or .NET Common Intermediate Language (CIL) code, into a native (system-dependent) machine code with the intention of executing the resulting binary file natively.
Ahead-of-time (AOT) compilation 是一個編譯高階程式語言 (C 或 C++) 或是中階語言(Java bytecode 或 .NET Common Intermediate Language (CIL) code) 成本機機械碼的行為,並產生本機可執行二進制文件檔案。
AOT produces machine optimized code, just like a "standard" native compiler. The difference is that AOT transforms the bytecode of an existing VM into machine code.
AOT 產生機械優化代碼就像是一個"標準"本機編譯器。而與本機編譯器不同的地方是 AOT 會轉換一個已存在虛擬機的位元組碼成機械碼。
An interpreter is a computer program that directly executes, i.e. performs, instructions written in a programming or scripting language, without previously compiling them into a machine language program.
interpreter 是一個電腦語言,不用先前編譯程式語言成機械語言程式就能直接執行。
An interpreter generally uses one of the following strategies for program execution:
interpreter 使用下列其中一個策略讓程式執行:
- 解析原始碼並直接執行動作。
- 轉換原始碼成一些有效的中間語言並立刻執行。
- 以直譯器包含的編譯器對高階語言編譯,並指示處理器執行編譯後的程式
Brainfuck,是一種極小化、符合圖靈完全思想的程式語言,是由只有八個簡單的指令與一個指令指標所組成的。
Brainfuck | C | 描述 |
---|---|---|
> | ++p | 增加資料指標指向下一個 cell |
< | –p | 減少資料指標指向上一個 cell |
+ | ++*p | 資料指標指向的位元組值加一 |
- | –*p | 資料指標指向的位元組值減一 |
. | putchar(*p) | 輸出資料指標指向的位元組值 |
, | *p=getchar() | 輸入一個位元組值並存到資料指標 |
[ | while(*p){ | 如果資料指標指向的位元組值為零,向後跳轉到對應的]指令的次一指令處 |
] | } | 如果資料指標指向的位元組值不為零,向前跳轉到對應的[指令的次一指令處 |
在 brainfuck optimization strategies提到以下最佳化策略:
未最佳化之數據
此方法是將多餘運算整併,例如 +++++ ,其實就是+=5,實作方法可在遇到+ - > < 時檢查是否為連續出現。而在此我們保留 inc 在只有出現一次的時候,可使效能最佳化。