2010-06-11 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Fri, 11 Jun 2010 00:43:45 +0000 (00:43 -0000)
committerZoltan Varga <vargaz@gmail.com>
Fri, 11 Jun 2010 00:43:45 +0000 (00:43 -0000)
* object.c (mono_method_add_generic_virtual_invocation): Fix the computation of the
IMT slot which is passed to callbacks.get_imt_trampoline.

svn path=/trunk/mono/; revision=158819

mono/metadata/ChangeLog
mono/metadata/object.c

index 39d08da3f352f0909b4445116bda4ed0fed5fe48..b4fa1a92a4051e712d5cb94efc921cd1f2b61262 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-11  Zoltan Varga  <vargaz@gmail.com>
+
+       * object.c (mono_method_add_generic_virtual_invocation): Fix the computation of the
+       IMT slot which is passed to callbacks.get_imt_trampoline.
+
 2010-06-11  Zoltan Varga  <vargaz@gmail.com>
 
        * object.c: Use a callback to create IMT trampolines, allowing the usage of one
index 5a0ed5540c6ef58805013784a87a1e1942d0cd2c..9411fddbb11750775d60d8c8e6c325595af0fa0b 100644 (file)
@@ -1667,14 +1667,19 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab
 
        if (++gvc->count == THUNK_THRESHOLD) {
                gpointer *old_thunk = *vtable_slot;
-               gpointer vtable_trampoline = callbacks.get_vtable_trampoline ? callbacks.get_vtable_trampoline ((gpointer*)vtable_slot - (gpointer*)vtable) : NULL;
+               gpointer vtable_trampoline = NULL;
                gpointer imt_trampoline = NULL;
 
                if ((gpointer)vtable_slot < (gpointer)vtable) {
+                       int displacement = (gpointer*)vtable_slot - (gpointer*)vtable;
+                       int imt_slot = MONO_IMT_SIZE + displacement;
+
                        /* Force the rebuild of the thunk at the next call */
-                       imt_trampoline = callbacks.get_imt_trampoline (((gpointer*)vtable - (gpointer*)vtable_slot) + 1);
+                       imt_trampoline = callbacks.get_imt_trampoline (imt_slot);
                        *vtable_slot = imt_trampoline;
                } else {
+                       vtable_trampoline = callbacks.get_vtable_trampoline ? callbacks.get_vtable_trampoline ((gpointer*)vtable_slot - (gpointer*)vtable->vtable) : NULL;
+
                        entries = get_generic_virtual_entries (domain, vtable_slot);
 
                        sorted = imt_sort_slot_entries (entries);