-
Notifications
You must be signed in to change notification settings - Fork 0
/
Compilation,_JIT,_preprocessor.mw
41 lines (35 loc) · 3.72 KB
/
Compilation,_JIT,_preprocessor.mw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
= Compilation =
<blockquote>A compiler is a computer program (or a set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language), with the latter often having a binary form known as object code.[1] The most common reason for converting source code is to create an executable program.</blockquote>
<blockquote>The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower level language (e.g., assembly language or machine code). If the compiled program can run on a computer whose CPU or operating system is different from the one on which the compiler runs, the compiler is known as a cross-compiler. More generally, compilers are a specific type of translator.</blockquote>
Source wikipedia.
* Here you have specific optimisation (SIMD, see below) to do the software CPU specific to improve the performance using the full instruction set
* Generic optimisation as unroll loop, ...
* This mode don't take care of compilation time, mean it can do more advanced optimisation than JIT
= JIT =
<blockquote>In computing, 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.[1] Most often this consists of translation to machine code, which is then executed directly, but can also refer to translation to another format.</blockquote>
Source wikipedia.
What is the change against the compilation?
* Use all the instruction set of the cpu, allow usage of SIMD (MMX, SSE, AVX, ...) to improve the performance without change the code (as multi-thread programming)
* Take care of one time loaded variable:
var toto=config[Toto]
if(toto==X)
do something
else
do another thing
The jit will detect that's and do:
if(true)//the condition is always true/false
do something
else
do another thing
And will optimise as:
do something
Mean: Less register used (high speed memory block of 32Bits if the cpu is 32Bits), deterministic behaviour and more optimisation possibility, lighter context and less context change
* Less CPU cache (L1, L2) flush
* Better usage of the branch predictor: <blockquote>In computer architecture, a branch predictor is a digital circuit that tries to guess which way a branch (e.g. an if-then-else structure) will go before this is known for sure. The purpose of the branch predictor is to improve the flow in the instruction pipeline. Branch predictors play a critical role in achieving high effective performance in many modern pipelined microprocessor architectures such as x86.</blockquote>
Source wikipedia.
* In some case it use opcode (Java, ...), that's allow do the generic optimisation before the JIT part and offload part of the work: The JIT is only hear to compil into assembly and do the platform/assembly specific optimisation
= Preprocessor =
<blockquote>In computer science, a preprocessor is a program that processes its input data to produce output that is used as input to another program. The output is said to be a preprocessed form of the input data, which is often used by some subsequent programs like compilers. The amount and kind of processing done depends on the nature of the preprocessor; some preprocessors are only capable of performing relatively simple textual substitutions and macro expansions, while others have the power of full-fledged programming languages.</blockquote>
Source wikipedia.
* The Preprocessor into C or C++ and achieve most of JIT part by putting it at compilation time, by this config can't be changed (you need recompil it).
* This allow drop some code to have less size (usefull for embedded), disable code with potential security problem