#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"
+/*
+ * Address of the x86 trampoline code. This is used by the debugger to check
+ * whether a method is a trampoline.
+ */
+guint8 *mono_generic_trampoline_code = NULL;
+
/*
* get_unbox_trampoline:
* @m: method pointer
*((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 ();
}
}
gpointer
arch_create_jit_trampoline (MonoMethod *method)
{
- MonoDomain *domain = mono_domain_get ();
guint8 *code, *buf;
- static guint8 *vc = NULL;
- GHashTable *jit_code_hash;
/* previously created trampoline code */
if (method->info)
(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)) {
MonoMethod *nm;
- nm = mono_marshal_get_native_wrapper (method);
- method->info = mono_compile_method (nm);
- return method->info;
- }
+ if (!method->addr && (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
+ mono_lookup_pinvoke_call (method);
- /* 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 ((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 (!vc) {
- vc = buf = g_malloc (256);
+ if (!mono_generic_trampoline_code) {
+ mono_generic_trampoline_code = buf = g_malloc (256);
/* save caller save regs because we need to do a call */
x86_push_reg (buf, X86_EDX);
x86_push_reg (buf, X86_EAX);
/* call the compiled method */
x86_jump_reg (buf, X86_EAX);
- g_assert ((buf - vc) <= 256);
+ g_assert ((buf - mono_generic_trampoline_code) <= 256);
}
code = buf = g_malloc (16);
x86_push_imm (buf, method);
- x86_jump_code (buf, vc);
+ x86_jump_code (buf, mono_generic_trampoline_code);
g_assert ((buf - code) <= 16);
/* store trampoline address */