[Mono-list] Re: Time problems on Mono
Mon, 13 Dec 2004 20:54:51 -0500
On Mon, 2004-12-13 at 04:31 -0800, Jordi wrote:
> Thanks for the explanation Jon...its good to know things like that.
> I guess that the both of them (Mono JIT and Mono interpreter) are the
> runtimes that could be used. Aren't they?.
Yes, though it should also be mentioned that the interpreter is barely
maintained anymore, may be (is?) very buggy, and no one cares about it.
The JIT is much more interesting and important for most developers, and
is the only runtime that supports Generics, among other things.
> What I was told about Mono, is that firstly builds up a pre-compiled
> native code, and then, this code is compiled by the just-in-time
> runtime depending on the processor you are using (ie: x86, SPARC,...).
> Is this right?.
Not exactly. Assuming the JIT is used, code is compiled at least twice
before being executed:
1. By the language compiler (mcs), compiling the input language (C#)
into Common Intermediate Language (CIL). This creates the
assemblies (.dll and .exe files) that we all know and love.
2. By the JIT compiler during program execution. This converts the
CIL into machine code for the executing processor (x86, etc.).
(1) can't be avoided. (2) can be avoided by using Ahead Of Time
compilation (also referred to as "pre-JITing" in some literature).
Under Mono, this involves using ``mono --aot'', while under .NET this
uses NGEN.EXE. The idea is to precompile the CIL into machine code,
thus eliminating the need to generate code at runtime.
Skipping (2) may or may not result in faster performing code, for a
variety of reasons (which differ between Mono and .NET). You'd have to
test your particular program to know for sure.