[Mono-dev] Registering internal calls at runtime

Robert Jordan robertj at gmx.net
Tue Jul 13 17:26:21 EDT 2010


On 13.07.2010 23:08, Robert Jordan wrote:
> On 13.07.2010 21:17, Michel Boissé wrote:
>>               class Program
>>               {
>>                   static void Main(string[] args)
>>                   {
>>                       Registrar.RegisterMethods();
>>                       Console.Write(InternallyImplementedClass.InternalMethod());
>>                   }
>
> You cannot register the icall from within a method that eventually
> calls the icall because the JIT does not know about the icall
> at the time it compiles the method.
>
> Something like that should work:
>
> static void Main(string[] args)
> {
>       Registrar.RegisterMethods();
>       DoWork();
> }

Just in case, inlining should be disabled for this method:

[MethodImplAttribute(MethodImplOptions.NoInlining)]
static void DoWork()
{
       Console.Write(InternallyImplementedClass.InternalMethod());
}

Robert



More information about the Mono-devel-list mailing list