2001-10-11 Jeffrey Stedfast <fejj@ximian.com>
[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         GNU/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: 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: Define an <i>lburg</i>-like instruction
32                   selector for the JITer for Intel.  Although slower
33                   at JITing than a streaming JITer, it generates
34                   better code.  The same grammar can later be used for
35                   the stream jitter. 
36
37                 * Milestone 4: Implement JITer.
38
39                 * Milestone 5: Port of the JITer to non IA32 systems.
40         </ul>
41
42         A setup similar to the Kaffe JIT engine can be used to
43         layout the code to support non-IA32 architectures.  Our work
44         will be focused on getting a IA32 version running first.  
45
46         The JIT engine should work on Linux and Win32, although you
47         will need to install the CygWin32 development tools to get a
48         Unix-like compilation environment.
49
50 ** JIT Engine (<b>updated, Jul 14th, 2001</b>)
51
52         We will be using a code-generator generator approach for our
53         JITer.  Given the properties of CIL byte codes, we can take
54         full advantage of a real instruction selector for our code
55         generator. 
56
57         There are a couple of books that deal with this technique: "A
58         Retargetable C Compiler" and "Advanced Compiler Design and
59         Implementation" are good references.  You can also get a
60         technical description of <a
61         href="http://research.microsoft.com/copyright/accept.asp?path=http://www.research.microsoft.com/~drh/pubs/iburg.pdf&pub=ACM">lbrug</a>
62
63         Previously we had looked at a number of JIT engines and tools,
64         but they would not take full advantage of the CIL properties: 
65
66         <ul>
67                 * <a
68                   href="http://www.intel.com/research/mrl/orp/">ORP</a>
69
70                 * <a
71                   href="http://www.gnu.org/software/lightning/">GNU
72                   Lightning</a>
73
74                 * <a href="http://www.eecs.harvard.edu/~nr/toolkit/">NJ Machine
75                   Toolkit</a>.).
76
77                 * VCODE.
78         </ul>
79
80 ** Garbage Collection
81
82         We have decided to implement a generational tracing garbage
83         collector, which is very similar to the one being used by
84         .NET.  For an introduction to the garbage collection system
85         used by Microsoft's CLR implementation, you can read this book
86         on <a
87         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
88         Collection.</a>
89
90         Another consideration is to use the same interface that ORP
91         uses to its Garbage Collection system and reuse that GC system
92         instead of rolling our own, as the ORP system is pretty advanced
93         and is independent of the rest of ORP.
94
95         Although using a conservative garbage collector like Bohem's
96         would work, all the type information is available at runtime,
97         so we can actually implement a better collector than a
98         conservative collector.
99
100         <ul>
101                 * Garbage collection list and FAQ:<br>
102                   <a href="http://www.iecc.com/gclist/">http://www.iecc.com/gclist/</a>
103
104                 * "GC points in a Threaded Environment":<br>
105                   <a href="http://research.sun.com/techrep/1998/abstract-70.html">
106                   http://research.sun.com/techrep/1998/abstract-70.html</a>
107
108                 * "A Generational Mostly-concurrent Garbage Collector":
109                   <a href="http://research.sun.com/techrep/2000/abstract-88.html">
110                   http://research.sun.com/techrep/2000/abstract-88.html</a>
111
112                 * Details on The Microsoft .NET Garbage Collection Implementation:<br>
113                   <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>
114                   <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>
115         </ul>
116
117 ** Useful links
118
119         Paolo Molaro found a few interesting links:
120
121         <ul>
122                 * On compilation of stack-based languages:<br>
123                 <a href="http://www.complang.tuwien.ac.at/projects/rafts.html">
124                 http://www.complang.tuwien.ac.at/projects/rafts.html</a>
125
126                 * A paper on fast JIT compilation of a stack-based language:<br>
127                   <a href="http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf">
128                   http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf</a>
129
130                 * Vmgen generates much of the code for efficient virtual machine (VM)
131                   interpreters from simple descriptions of the VM instructions:<br>
132                   <a href="http://www.complang.tuwien.ac.at/anton/vmgen/">
133                   http://www.complang.tuwien.ac.at/anton/vmgen</a>
134         </ul>
135
136 ** PInvoke
137
138         PInvoke is the mechanism we are using to wrap Unix API calls
139         as well as talking to system libraries.
140
141         We hvae implemented PInvoke through libffi, but we are likely
142         going to roll our own system as the runtime matures, specially
143         as the interpreter is approaching completion, and we move into
144         the JITer.