runtime 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. * The Mono runtime
  2. The Mono runtime engine is considered feature complete.
  3. It implements a Just-in-Time compiler engine for the CIL
  4. virtual machine, the class loader, the garbage collector,
  5. 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. We are using the Bohem conservative garbage collector.
  15. The Mono runtime can be used as a stand-alone process, or it
  16. can be <a href="embedded-api">embedded into applications</a> (see
  17. the documentation in mono/samples/embed for more details).
  18. Embedding the Mono runtime allows applications to be extended
  19. in C# while reusing all of the existing C and C++ code.
  20. Paolo Molaro did a presentation on the current JIT engine and
  21. the new JIT engine. You can find his <a
  22. href="http://primates.ximian.com/~lupus/slides/jit/">slides
  23. here</a>
  24. ** Current JIT Engine: technical details (<b>updated, July 8th, 2002</b>)
  25. The JIT engine uses a code-generator generator approach for
  26. compilation. Given the properties of CIL byte codes, we can
  27. take full advantage of a real instruction selector for our
  28. code generator.
  29. The JIT engine implements a number of optimizations:
  30. <ul>
  31. * Opcode cost estimates (our architecture allows
  32. us to generate different code paths depending
  33. on the target CPU dynamically).
  34. * Inlining.
  35. * Constant folding.
  36. Although compilers typically do
  37. constant folding, the combination of inlining with
  38. constant folding gives some very good results.
  39. * Linear scan register allocation. In the past,
  40. register allocation was our achilles heel, but now
  41. we have left this problem behind.
  42. </ul>
  43. There are a couple of books that deal with this technique: "A
  44. Retargetable C Compiler" and "Advanced Compiler Design and
  45. Implementation" are good references. You can also get a
  46. technical description of <a
  47. href="http://research.microsoft.com/copyright/accept.asp?path=http://www.research.microsoft.com/~drh/pubs/iburg.pdf&pub=ACM">lbrug</a>.
  48. A few papers that describe the instruction selector:
  49. <ul>
  50. * <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>
  51. * <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>
  52. </ul>
  53. ** New JIT engine.
  54. We are working on a new JIT engine. The new JIT engine
  55. focuses on portability and in two intermediate representations
  56. that simplify the development of optimizations. This together
  57. with the Ahead-of-Time compilation will allow developers to
  58. deploy applications that match the speed of natively compiled code.
  59. ** Garbage Collection
  60. We are using the Boehm conservative GC. We might consider
  61. adopting other GC engines in the future, like the Intel ORP GC
  62. engine. The Intel ORP GC engine as it provides a precise
  63. garbage collector engine, similar to what is available on the
  64. .NET environment.
  65. <ul>
  66. * Garbage collection list and FAQ:<br>
  67. <a href="http://www.iecc.com/gclist/">http://www.iecc.com/gclist/</a>
  68. * "GC points in a Threaded Environment":<br>
  69. <a href="http://research.sun.com/techrep/1998/abstract-70.html">
  70. http://research.sun.com/techrep/1998/abstract-70.html</a>
  71. * "A Generational Mostly-concurrent Garbage Collector":
  72. <a href="http://research.sun.com/techrep/2000/abstract-88.html">
  73. http://research.sun.com/techrep/2000/abstract-88.html</a>
  74. * Details on The Microsoft .NET Garbage Collection Implementation:<br>
  75. <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>
  76. <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>
  77. </ul>
  78. ** IO and threading
  79. The ECMA runtime and the .NET runtime assume an IO model and a
  80. threading model that is very similar to the Win32 API.
  81. Dick Porter has developed WAPI: the Mono abstraction layer
  82. that allows our runtime to execute code that depend on this
  83. behaviour.
  84. ** Useful links
  85. Paolo Molaro found a few interesting links:
  86. <ul>
  87. * On compilation of stack-based languages:<br>
  88. <a href="http://www.complang.tuwien.ac.at/projects/rafts.html">
  89. http://www.complang.tuwien.ac.at/projects/rafts.html</a>
  90. * A paper on fast JIT compilation of a stack-based language:<br>
  91. <a href="http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf">
  92. http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf</a>
  93. * Vmgen generates much of the code for efficient virtual machine (VM)
  94. interpreters from simple descriptions of the VM instructions:<br>
  95. <a href="http://www.complang.tuwien.ac.at/anton/vmgen/">
  96. http://www.complang.tuwien.ac.at/anton/vmgen</a>
  97. </ul>
  98. ** PInvoke
  99. PInvoke is the mechanism we are using to wrap Unix API calls
  100. as well as talking to system libraries.
  101. Initially we used libffi, but it was fairly slow, so we have
  102. reused parts of the JIT work to create efficient PInvoke
  103. trampolines.
  104. ** Remoting
  105. Mono has support for remoting and proxy objects, just like
  106. .NET does. The runtime provides these facilities.
  107. ** Porting
  108. If you are interested in porting the Mono runtime to other
  109. platforms, you might find the pre-compiled <a
  110. href="archive/mono-tests.tar.gz">Mono regression test
  111. suite</a> useful to debug your implementation.
  112. * COM and XPCOM
  113. We plan on adding support for XPCOM on Unix and COM on Microsoft
  114. Windows later in our development process.