97f2e4eb8e6b990c3098ba2ac106d0a109defa16
[mono.git] / web / runtime
1 * The Mono runtime
2
3         The Mono runtime will implement the JIT engine (and a byte
4         code interpreter for quickly porting to new systems), the
5         class loader, the garbage collector, threading system and
6         metadata access libraries.
7
8         Currently the runtime has an image loader and metadata access
9         entry points.  The runtime comes with a simple interpreter
10         that can execute very simple programs. 
11
12 ** Executing MSIL/CIL images
13
14         The code will load an executable and map the references to
15         external assemblies to our own version of the assemblies on
16         Linux.
17
18         Our roadmap looks like this, this has been updated as of
19         <b>Jul 15, 2001</b>:
20
21         <ul>
22
23                 * Milestone 1: <b>Done</b> Fully read and parse all CIL byte-codes
24                   and metadata tokens (ie, a disassembler).  
25
26                 * Milestone 2: <b>Done</b> Complete an interpreter for CIL byte
27                   codes.  This interpreter can be used temporarly to
28                   run CIL byte code on a system where no JIT is
29                   available.
30
31                 * Milestone 3: <b>Done</b>Define an <i>lburg</i>-like
32                   instruction selector for the JITer for Intel.
33                   Although slower at JITing than a streaming JITer, it
34                   generates better code.  The same grammar can later
35                   be used for the stream jitter.
36
37                 * Milestone 4: Implement JITer.  This is where our
38                   current efforts are focused on, the JITer is 60% ready.
39
40                 * Milestone 5: Port of the JITer to non IA32 systems.
41         </ul>
42
43         A setup similar to the Kaffe JIT engine will be used to
44         layout the code to support non-IA32 architectures.  Our work
45         will be focused on getting a IA32 version running first.  
46
47         The JIT engine should work on Linux and Win32, although you
48         will need to install the CygWin32 development tools to get a
49         Unix-like compilation environment.
50
51 ** JIT Engine (<b>updated, Nov 16th, 2001</b>)
52
53         The JIT engine uses a code-generator generator approach for
54         compilation.  Given the properties of CIL byte codes, we can
55         take full advantage of a real instruction selector for our
56         code generator. 
57
58         There are a couple of books that deal with this technique: "A
59         Retargetable C Compiler" and "Advanced Compiler Design and
60         Implementation" are good references.  You can also get a
61         technical description of <a
62         href="http://research.microsoft.com/copyright/accept.asp?path=http://www.research.microsoft.com/~drh/pubs/iburg.pdf&pub=ACM">lbrug</a>.
63
64         A few papers that describe the instruction selector:
65
66         <ul>
67                 * <a href="http://research.microsoft.com/copyright/accept.asp?path=http://www.research.microsoft.com/~drh/pubs/interface.pdf&pub=wiley">A code generation interface for ANSI C</a>
68
69
70                 * <a href="http://research.microsoft.com/copyright/accept.asp?path=http://www.research.microsoft.com/~drh/pubs/iburg.pdf&pub=ACM">Engineering efficient code generators using tree matching and dynamic programming.</a>
71
72         </ul>
73
74 ** Garbage Collection
75
76         We have decided to implement a generational tracing garbage
77         collector, which is very similar to the one being used by
78         .NET.  For an introduction to the garbage collection system
79         used by Microsoft's CLR implementation, you can read this book
80         on <a
81         href="http://www.amazon.com/exec/obidos/ASIN/0471941484/o/qid=992556433/sr=2-1/ref=aps_sr_b_1_1/103-5866388-0492603">Garbage
82         Collection.</a>
83
84         Another consideration is to use the same interface that ORP
85         uses to its Garbage Collection system and reuse that GC system
86         instead of rolling our own, as the ORP system is pretty advanced
87         and is independent of the rest of ORP.
88
89         Although using a conservative garbage collector like Bohem's
90         would work, all the type information is available at runtime,
91         so we can actually implement a better collector than a
92         conservative collector.
93
94         <ul>
95                 * Garbage collection list and FAQ:<br>
96                   <a href="http://www.iecc.com/gclist/">http://www.iecc.com/gclist/</a>
97
98                 * "GC points in a Threaded Environment":<br>
99                   <a href="http://research.sun.com/techrep/1998/abstract-70.html">
100                   http://research.sun.com/techrep/1998/abstract-70.html</a>
101
102                 * "A Generational Mostly-concurrent Garbage Collector":
103                   <a href="http://research.sun.com/techrep/2000/abstract-88.html">
104                   http://research.sun.com/techrep/2000/abstract-88.html</a>
105
106                 * Details on The Microsoft .NET Garbage Collection Implementation:<br>
107                   <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp</a>
108                   <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI2.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI2.asp</a>
109         </ul>
110
111 ** IO and threading
112
113         The ECMA runtime and the .NET runtime assume an IO model and a
114         threading model that is very similar to the Win32 API.  Dick
115         Porter has been working on the Mono abstraction layer that allows
116         our runtime to execute code that depend on this behaviour.
117
118 ** Useful links
119
120         Paolo Molaro found a few interesting links:
121
122         <ul>
123                 * On compilation of stack-based languages:<br>
124                 <a href="http://www.complang.tuwien.ac.at/projects/rafts.html">
125                 http://www.complang.tuwien.ac.at/projects/rafts.html</a>
126
127                 * A paper on fast JIT compilation of a stack-based language:<br>
128                   <a href="http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf">
129                   http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf</a>
130
131                 * Vmgen generates much of the code for efficient virtual machine (VM)
132                   interpreters from simple descriptions of the VM instructions:<br>
133                   <a href="http://www.complang.tuwien.ac.at/anton/vmgen/">
134                   http://www.complang.tuwien.ac.at/anton/vmgen</a>
135         </ul>
136
137 ** PInvoke
138
139         PInvoke is the mechanism we are using to wrap Unix API calls
140         as well as talking to system libraries.
141
142         We hvae implemented PInvoke through libffi, but we are likely
143         going to roll our own system as the runtime matures, specially
144         as the interpreter is approaching completion, and we move into
145         the JITer.