[Mono-list] Why mono_marshal_get_runtime_invoke() ?

Paolo Molaro lupus@ximian.com
Tue, 15 Jul 2003 16:02:50 +0200


On 07/04/03 Vivek, Bharath Varma (IE10) wrote:
> 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?

The main reason, as Dietmar explained, is to handle exceptions: the
generated method has a filter exception clause. This lets the C code
easily intercept exceptions if needed. The other main reason is that
the calling convention used by the managed methods may be different from
the calling convention of functions in the C code: you need a wrapper
that does the appropriate conversions.

lupus

-- 
-----------------------------------------------------------------
lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better