[Mono-list] Jit Method Compilation
Thu, 8 Jan 2004 17:47:49 +0100
> On 01/07/04 Marco Dubacher wrote:
> > I'm about reading the code of the jit engine. I asked me know where the
> > compiled code of the main-method gets actually executed. It must be
> > somewhere within the architecture dependend code (e.g. mini-x86.c).
> > somebody point me to this method or line of code?
> The jit uses mono_runtime_run_main() defined in metadata/object.c,
> this in tunr calls mono_runtime_exec_main() which eventually calls
> mono_runtime_invoke() is the function that is needed to go into the
> managed world from the unmanaged one: it deals with a number of issues,
> like call convention differences, exception handling etc.
> The runtime invoke function is specific to an execution engine, so
> the jit-specific one is in mini.c: mono_jit_runtime_invoke().
> To make porting easier, the code that handles the unmanaged->managed
> transition is created at runtime as IL code (using
> mono_marshal_get_runtime_invoke()): this code is jitted and run
> from inside mono_jit_runtime_invoke().
Thanks for the answer. I really appreciate your hints ...
At the point of mono_jit_runtime_invoke the IL-method hasn't been compiled
yet? Through some further calls the function mini_method_compile is called
in which with the functions mono_method_to_ir, decompose_pass (and others)
transform the IL-code stepwise into native code. Finally the method
mono_codegen is executed. Up to now no IL-code has been actually executed, I
think? Sorry if I should be completely wrong ...
My question is: We have now some native code in the cfg-structure. This code
must be copied into an executable memory area and finally has somehow be
executed. Where and how is this step done?