2003-11-26 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / docs / mini-doc.txt
index cfe1a91d365b1ccb52ee51376966bd7df55910fc..052421e391ae1145f1274b54516e2bdb8653bdc9 100644 (file)
@@ -8,13 +8,21 @@
 
        Mini is a new compilation engine for the Mono runtime.  The
        new engine is designed to bring new code generation
-       optimizations, portability and precompilation. 
+       optimizations, portability and pre-compilation. 
 
        In this document we describe the design decisions and the
        architecture of the new compilation engine. 
 
 * Introduction
 
+       Mono is a Open Source implementation of the .NET Framework: it
+       is made up of a runtime engine that implements the ECMA Common
+       Language Infrastructure (CLI), a set of compilers that target
+       the CLI and a large collection of class libraries.
+
+       This article discusses the new code generation facilities that
+       have been added to the Mono runtime.  
+
        First we discuss the overall architecture of the Mono runtime,
        and how code generation fits into it; Then we discuss the
        development and basic architecture of our first JIT compiler
         inferred. 
 
        At this point the JIT would pass the constructed forest of
-       trees to the architecture-dependant JIT compiler.  
+       trees to the architecture-dependent JIT compiler.  
 
        The architecture dependent code then performed register
        allocation (optionally using linear scan allocation for
        The difference is on the set of optimizations that are turned
        on for each mode: Just-in-Time compilation should be as fast
        as possible, while Ahead-of-Time compilation can take as long
-       as required, because this is not done at a time criticial
+       as required, because this is not done at a time critical
        time. 
 
        With AOT compilation, we can afford to turn all of the
        assembler, which generates a loadable module.
 
        At execution time, when an assembly is loaded from the disk,
-       the runtime engine will probe for the existance of a
+       the runtime engine will probe for the existence of a
        pre-compiled image.  If the pre-compiled image exists, then it
        is loaded, and the method invocations are resolved to the code
        contained in the loaded module.
 
 * SSA-based optimizations
 
-       SSA form simplifies many optimization because each variable has exactly
-       one definition site. All uses of a variable are "dominated" by its
-       definition, which enables us to implement algorithm like:
+       SSA form simplifies many optimization because each variable
+       has exactly one definition site.  This means that each
+       variable is only initialized once.  
+
+       For example, code like this:
+
+           a = 1
+           ..
+           a = 2
+           call (a)
+
+       Is internally turned into:
+
+           a1 = 1
+           ..
+           a2 = 2
+           call (a2)
+
+       In the presence of branches, like:
 
-               * conditional constant propagation
+           if (x)
+                a = 1
+           else
+                a = 2
 
-               * array bound check removal
+            call (a)
 
-               * dead code elimination
+       The code is turned into:
 
-       And we can implement those algorithm in a efficient way using SSA. 
+           if (x)
+                a1 = 1;
+           else
+                a2 = 2;
+           a3 = phi (a1, a2)
+           call (a3)
 
+       All uses of a variable are "dominated" by its definition
+
+       This representation is useful as it simplifies the
+       implementation of a number of optimizations like conditional
+       constant propagation, array bounds check removal and dead code
+       elimination. 
 
 * Register allocation.
 
 
         2) liveness information for the variables
 
-        3) (optionally) loop info to favour variables that are used in
+        3) (optionally) loop info to favor variables that are used in
         inner loops.
 
        During instruction selection phase, symbolic registers are
        registers, fixed registers and clobbered registers by each
        operation.
 
-
-----------
-* Bootstrap 
-
-       The Mini bootstrap parses the arguments passed on the command
-       line, and initializes the JIT runtime. Each time the
-       mini_init() routine is invoked, a new Application Domain will
-       be returned.
-
-* Signal handlers
-
-       mono_runtime_install_handlers
-
 * BURG Code Generator Generator
 
        monoburg was written by Dietmar Maurer. It is based on the