runtime 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. * The Mono runtime
  2. The Mono runtime implements a JIT engine for the CIL virtual
  3. machine (as well as a byte code interpreter, this is to
  4. quickly port it to new systems), the class loader, the garbage
  5. collector, threading system and metadata access libraries.
  6. We currently have two runtimes:
  7. <ul>
  8. * <b>mono:</b> The Just In Time compiler implemented
  9. using a BURS instruction selector. We only support
  10. x86 machines in the JIT engine at this point.
  11. * <b>mint:</b> The Mono interpreter. This is an
  12. easy-to-port runtime engine.
  13. </ul>
  14. Currently we are using the Bohem conservative garbage
  15. collector, but we working on incorporating the ORP GC engine.
  16. ** Executing MSIL/CIL images
  17. The code will load an executable and map the references to
  18. external assemblies to our own version of the assemblies on
  19. Linux.
  20. Our roadmap looks like this, this has been updated as of
  21. <b>Dec 18, 2001</b>:
  22. <ul>
  23. * Milestone 1: <b>Done</b> Fully read and parse all CIL byte-codes
  24. and metadata tokens (ie, a disassembler).
  25. * Milestone 2: <b>Done</b> Complete an interpreter for CIL byte
  26. codes. This interpreter can be used temporarly to
  27. run CIL byte code on a system where no JIT is
  28. available.
  29. * Milestone 3: <b>Done</b>Define an <i>lburg</i>-like
  30. instruction selector for the JITer for Intel.
  31. * Milestone 4: <b>Done</b> Implement JITer. This is where our
  32. current efforts are focused on, the JITer currently runs
  33. all of the code we have tested on it. The major limitation
  34. is that our class libraries are not complete, and hence not
  35. every application can be ran.
  36. * Milestone 5: Port of the JITer to non IA32 systems.
  37. </ul>
  38. A setup similar to the Kaffe JIT engine will be used to
  39. layout the code to support non-IA32 architectures. Our work
  40. will be focused on getting a IA32 version running first.
  41. The JIT engine works on Linux and Win32, although you
  42. will need to install the CygWin32 development tools to get a
  43. Unix-like compilation environment (mostly we use GNU make in
  44. a few of the makefiles).
  45. ** JIT Engine (<b>updated, July 8th, 2002</b>)
  46. The JIT engine uses a code-generator generator approach for
  47. compilation. Given the properties of CIL byte codes, we can
  48. take full advantage of a real instruction selector for our
  49. code generator.
  50. The JIT engine implements a number of optimizations:
  51. <ul>
  52. * Opcode cost estimates (our architecture allows
  53. us to generate different code paths depending
  54. on the target CPU dynamically).
  55. * Inlining.
  56. * Constant folding.
  57. Although compilers typically do
  58. constant folding, the combination of inlining with
  59. constant folding gives some very good results.
  60. * Linear scan register allocation. In the past,
  61. register allocation was our achilles heel, but now
  62. we have left this problem behind.
  63. </ul>
  64. There are a couple of books that deal with this technique: "A
  65. Retargetable C Compiler" and "Advanced Compiler Design and
  66. Implementation" are good references. You can also get a
  67. technical description of <a
  68. href="http://research.microsoft.com/copyright/accept.asp?path=http://www.research.microsoft.com/~drh/pubs/iburg.pdf&pub=ACM">lbrug</a>.
  69. A few papers that describe the instruction selector:
  70. <ul>
  71. * <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>
  72. * <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>
  73. </ul>
  74. ** Future plans
  75. We are evaluating the future directions for the JIT engine:
  76. both from our needs (optimizations like inlining, better register allocation,
  77. instruction scheduling, and porting to other CPUs).
  78. We have not yet decided how we will evolve the JIT engine. We
  79. might just upgrade our current architecture, and provide optimizations as
  80. an extra layer.
  81. ** Garbage Collection
  82. Currently we are using the Boehm conservative GC. Although our plans
  83. are to move to the Intel ORP GC engine, our plans on a next generation
  84. dual-JIT engine have to be taken into account.
  85. We will be using the Intel ORP GC engine as it provides a precise
  86. garbage collector engine, similar to what is available on the
  87. .NET environment.
  88. Although using a conservative garbage collector like Bohem's
  89. would work, all the type information is available at runtime,
  90. so we can actually implement a better collector than a
  91. conservative collector.
  92. <ul>
  93. * Garbage collection list and FAQ:<br>
  94. <a href="http://www.iecc.com/gclist/">http://www.iecc.com/gclist/</a>
  95. * "GC points in a Threaded Environment":<br>
  96. <a href="http://research.sun.com/techrep/1998/abstract-70.html">
  97. http://research.sun.com/techrep/1998/abstract-70.html</a>
  98. * "A Generational Mostly-concurrent Garbage Collector":
  99. <a href="http://research.sun.com/techrep/2000/abstract-88.html">
  100. http://research.sun.com/techrep/2000/abstract-88.html</a>
  101. * Details on The Microsoft .NET Garbage Collection Implementation:<br>
  102. <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>
  103. <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>
  104. </ul>
  105. ** IO and threading
  106. The ECMA runtime and the .NET runtime assume an IO model and a
  107. threading model that is very similar to the Win32 API.
  108. Dick Porter has been working on the Mono abstraction layer
  109. that allows our runtime to execute code that depend on this
  110. behaviour.
  111. ** Useful links
  112. Paolo Molaro found a few interesting links:
  113. <ul>
  114. * On compilation of stack-based languages:<br>
  115. <a href="http://www.complang.tuwien.ac.at/projects/rafts.html">
  116. http://www.complang.tuwien.ac.at/projects/rafts.html</a>
  117. * A paper on fast JIT compilation of a stack-based language:<br>
  118. <a href="http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf">
  119. http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf</a>
  120. * Vmgen generates much of the code for efficient virtual machine (VM)
  121. interpreters from simple descriptions of the VM instructions:<br>
  122. <a href="http://www.complang.tuwien.ac.at/anton/vmgen/">
  123. http://www.complang.tuwien.ac.at/anton/vmgen</a>
  124. </ul>
  125. ** PInvoke
  126. PInvoke is the mechanism we are using to wrap Unix API calls
  127. as well as talking to system libraries.
  128. Initially we used libffi, but it was fairly slow, so we have
  129. reused parts of the JIT work to create efficient PInvoke trampolines.
  130. ** Remoting
  131. Mono has support for remoting and proxy objects, just like
  132. .NET does. The runtime provides these facilities.
  133. ** Porting
  134. If you are interested in porting the Mono runtime to other
  135. platforms, you might find the pre-compiled <a
  136. href="archive/mono-tests.tar.gz">Mono regression test
  137. suite</a> useful to debug your implementation.
  138. * COM and XPCOM
  139. We plan on adding support for XPCOM on Unix and COM on Microsoft
  140. Windows later in our development process.