2005-01-25 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mono / mini / tramp-ppc.c
index b304600e59d9b217fd1c1c9dfd4cbedf37a92b11..8a22eb95ab65bbc3d1157615f7fc178c2164e8ab 100644 (file)
@@ -101,6 +101,7 @@ ppc_magic_trampoline (MonoMethod *method, guint32 *code, char *sp)
 {
        char *o = NULL;
        gpointer addr;
+        MonoJitInfo *ji, *target_ji;
        int reg, offset = 0;
 
        addr = mono_compile_method(method);
@@ -111,6 +112,12 @@ ppc_magic_trampoline (MonoMethod *method, guint32 *code, char *sp)
                return addr;
        }
 
+       /* We can't trampoline across domains */
+       ji = mono_jit_info_table_find (mono_domain_get (), code);
+       target_ji = mono_jit_info_table_find (mono_domain_get (), addr);
+       if (!mono_method_same_domain (ji, target_ji))
+               return addr;
+
        /* Locate the address of the method-specific trampoline. The call using
        the vtable slot that took the processing flow to 'arch_create_jit_trampoline' 
        looks something like this:
@@ -185,11 +192,12 @@ ppc_magic_trampoline (MonoMethod *method, guint32 *code, char *sp)
           we won't have an object, but the actual pointer to the 
           valuetype as the this argument
         */
-       if (method->klass->valuetype)
+       if (method->klass->valuetype && !mono_aot_is_got_entry (code, o))
                addr = get_unbox_trampoline (method, addr);
 
        o += offset;
-       *((gpointer *)o) = addr;
+       if (mono_aot_is_got_entry (code, o) || mono_domain_owns_vtable_slot (mono_domain_get (), o))
+               *((gpointer *)o) = addr;
        return addr;
 }
 
@@ -489,20 +497,15 @@ mono_arch_create_jit_trampoline (MonoMethod *method)
        guint8 *tramp;
        MonoJitInfo *ji;
        MonoDomain* domain = mono_domain_get ();
-
-       /* previously created trampoline code */
-       if (method->info)
-               return method->info;
-
-       if (method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
-               return mono_arch_create_jit_trampoline (mono_marshal_get_synchronized_wrapper (method));
+       gpointer code_start;
 
        tramp = create_trampoline_code (MONO_TRAMPOLINE_GENERIC);
-       /* FIXME: should pass the domain down tohis function */
+       /* FIXME: should pass the domain down to this function */
        ji = create_specific_tramp (method, tramp, domain);
-       /* Store trampoline address */
-       method->info = ji->code_start;
-       return ji->code_start;
+       code_start = ji->code_start;
+       g_free (ji);
+
+       return code_start;
 }
 
 /**