2004-09-06 Dick Porter <dick@ximian.com>
[mono.git] / docs / aot-compiler.txt
1 Mono Ahead Of Time Compiler
2 ===========================
3
4 The new mono JIT has sophisticated optimization features. It uses SSA and has a
5 pluggable architecture for further optimizations. This makes it possible and
6 efficient to use the JIT also for AOT compilation.
7
8
9 * file format: We use the native object format of the platform. That way it is
10   possible to reuse existing tools like objdump and the dynamic loader. All we
11   need is a working assembler, i.e. we write out a text file which is then
12   passed to gas (the gnu assembler) to generate the object file.
13
14 * file names: we simply add ".so" to the generated file. For example:
15   basic.exe -> basic.exe.so
16   corlib.dll -> corlib.dll.so
17
18 * staring the AOT compiler: mini --aot assembly_name
19
20 The following things are saved in the object file:
21
22 * version infos: 
23
24 * native code: this is labeled with method_XXXXXXXX: where XXXXXXXX is the
25   hexadecimal token number of the method.
26
27 * additional informations needed by the runtime: For example we need to store
28   the code length and the exception tables. We also need a way to patch
29   constants only available at runtime (for example vtable and class
30   addresses). This is stored i a binary blob labeled method_info_XXXXXXXX:
31
32 PROBLEMS:
33
34 - all precompiled methods must be domain independent, or we add patch infos to
35   patch the target doamin.
36
37 - the main problem is how to patch runtime related addresses, for example:
38
39   - current application domain
40   - string objects loaded with LDSTR
41   - address of MonoClass data
42   - static field offsets 
43   - method addreses
44   - virtual function and interface slots