* ResourceReaderTest.cs: Add a little logic for finding
[mono.git] / mono / jit / trampoline.c
index 13948c47d6f45aa617e35e7da5a6949328d37bf1..5bbfd7fb3d3d690d3c5998e2c3cfc2ad95365d36 100644 (file)
@@ -13,6 +13,7 @@
 #include <mono/metadata/appdomain.h>
 #include <mono/metadata/tabledefs.h>
 #include <mono/arch/x86/x86-codegen.h>
+#include <mono/metadata/mono-debug-debugger.h>
 
 #include "jit.h"
 #include "codegen.h"
@@ -103,8 +104,8 @@ x86_magic_trampoline (int eax, int ecx, int edx, int esi, int edi,
                        *((guint32*)(code + 2)) = (guint)addr - ((guint)code + 1) - 5; 
                        return addr;
                } else {
-                       printf ("%x %x %x %x %x %x \n", code [0], code [1], code [2], code [3],
-                               code [4], code [5]);
+                       printf ("Invalid trampoline sequence: %x %x %x %x %x %x %x\n", code [0], code [1], code [2], code [3],
+                               code [4], code [5], code [6]);
                        g_assert_not_reached ();
                }
        }
@@ -155,9 +156,7 @@ x86_magic_trampoline (int eax, int ecx, int edx, int esi, int edi,
 gpointer
 arch_create_jit_trampoline (MonoMethod *method)
 {
-       MonoDomain *domain = mono_domain_get ();
        guint8 *code, *buf;
-       GHashTable *jit_code_hash;
 
        /* previously created trampoline code */
        if (method->info)
@@ -174,20 +173,20 @@ arch_create_jit_trampoline (MonoMethod *method)
            (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)) {
                MonoMethod *nm;
                
-               nm = mono_marshal_get_native_wrapper (method);
-               method->info = mono_compile_method (nm);
-               return method->info;
-       }
-
-       /* check if we already have JITed code */
-       if (mono_jit_share_code)
-               jit_code_hash = mono_root_domain->jit_code_hash;
-       else
-               jit_code_hash = domain->jit_code_hash;
+               if (!method->addr && (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
+                       mono_lookup_pinvoke_call (method);
 
-       if ((code = g_hash_table_lookup (jit_code_hash, method))) {
-               mono_jit_stats.methods_lookups++;
-               return code;
+#ifdef MONO_USE_EXC_TABLES
+               if (mono_method_blittable (method)) {
+                       method->info = method->addr;
+               } else {
+#endif
+                       nm = mono_marshal_get_native_wrapper (method);
+                       method->info = mono_compile_method (nm);
+#ifdef MONO_USE_EXC_TABLES
+               }
+#endif
+               return method->info;
        }
 
        if (!mono_generic_trampoline_code) {