[Mono-dev] Method attributes in Full-AOT code

Martin Däumler mdae at cs.tu-chemnitz.de
Wed May 25 07:01:20 EDT 2011


On 13.05.11 16:31, Jonathan Pryor wrote:
> On May 13, 2011, at 3:49 AM, Martin Däumler wrote:
>> I learned that PInvoke and Internal Call methods are
>> quite the same.
>
> Not quite the same. P/Invoke marshals arguments, internal calls do not.
>
> For a glaring difference between these, consider System.String arguments. With P/Invoke, they become `char*` or `unsigned short*` values (depending on whether it's UTF-8 or UTF-16 marshaling), and may involve copying the data (for UTF-8 conversion). With Internal calls, the native code gets a MonoString*, no marshaling at all.
>
> Internal calls can also get any managed type passed to them (e.g. System.Object); they just become a MonoObject* in native code. Not all types can be used with P/Invoke (e.g. System.Object can't be used in P/Invoke).


Hello,

thank you for your answer! That helped me a lot. However, now
I have another question:

How do runtime calls like

	System.Threading.ThreadStart:Invoke(),
	System.Threading.WaitOrTimerCallback:Invoke() or
	System.UnhandledExceptionEventHandler:Invoke()

(there are more of it) work? Do I understand it right and
all runtime calls are delegates that are called through
"mono_runtime_invoke()", thereby using a delegate trampoline?


With kind regards,
Martin Däumler


More information about the Mono-devel-list mailing list