[Mono-list] Why mono_marshal_get_runtime_invoke() ?

Jonathan Pryor jonpryor@vt.edu
04 Jul 2003 12:39:48 -0400


This is just a guess, but it's probably because we *don't* know the
managed applications entry point.  We certainly can't assume that it's
"Main".

There are two (related) reasons why:
 1: CIL uses the .entrypoint instruction to specify the entry point, not
    the function name.  This is done because not all languages require
    that the entrypoint function be named "Main" (ILASM and Java are two
    examples).
 2: Consider an assembly that has multiple "Main" functions.  This is
    permitted by CSC and mcs, you just need to provide the
    -class:<ClassName/> parameter.  In such a situation, you can't "just
    load" the "Main" function, as you wouldn't know which one to
    execute.

 - Jon

On Fri, 2003-07-04 at 12:23, Vivek, Bharath Varma (IE10) wrote:
> Hi,
> 
> I noticed that there is some dynamic generation of IL wrapper code happening
> within the runtime when I run a managed application using mono. 
> 
> For the "Main" of my HelloWorld.exe application, this dynamically generated
> IL code gets compiled to a function that in turn makes a call to the
> runtime's function called "mono_ldftn"(load function token), which
> eventually goes on to compile my HelloWorld.exe's "Main". 
> If we know the managed application's entry point method("Main") why don't we
> compile and call it directly? Why do we create a function which in turn
> calls the entry point method? 
> 
> I found that this mechanism is used for certain other functions too(some of
> which are functions that support opcode emulation). What's basis for
> deciding which functions in the runtime will need this dynamic IL wrapper
> mechanism?
> 
> Any pointers to this please..
> Hope the question is clear, if not I guess I'll write a longer email with
> more details....
> 
> TIA
> Vivek
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list