[Mono-dev] [PATCH] Generic sharing: Static field access

Zoltan Varga vargaz at gmail.com
Tue Nov 20 07:19:54 EST 2007


Hi,

 I was referring to Mark's code which does have a managed-to-unmanaged
transition. Your approach looks fine to me.

           Zoltan

On Nov 20, 2007 10:34 AM, Paolo Molaro <lupus at ximian.com> wrote:
> On 11/19/07 Zoltan Varga wrote:
> >   The problem with the trampoline is that since the class to init is dynamically
> > decided, there is nothing to patch, so all calls will go through the
> > generic trampoline
> > code, which is much slower than a simple managed-to-native transition.
>
> No, here is again the trampoline pseudo code I described in the first
> email (vtable is in a register):
>
>         deref vtable->initialized
>         cmp/and/test
>         condbranch slow_path:
>         ret
> slow_path:
>         call class_init
>         ret
>
> We do the unmanaged transition only when the cctor has not been run yet.
> The x86 implementation could be something like (with vtable in edx):
>
>         test $INIT_BIT,initialize_offset(%edx)
>         jz slow_path
>         ret
> slow_path:
>         call class_init
>         ret
>
> The common path is 3 instructions, we need a single trampoline for all
> the process and this works for both generics and AOT.
> I think the tiny amount of arch-specific code is worth writing to avoid
> the increased memory usage with the other solutions.
> BTW, for AOT code we could put the above code inside the AOT image
> itself, so it would be a direct call with no PLT entry involved.
>
>
> lupus
>
> --
> -----------------------------------------------------------------
> lupus at debian.org                                     debian/rules
> lupus at ximian.com                             Monkeys do it better
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>



More information about the Mono-devel-list mailing list