X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fmini-trampolines.c;h=f65dab8c1e77f6220613e59111a84dd927597b90;hb=ccbd0b1a0d36f4b1d0f5d413eca791e589277de1;hp=99c050e0e73b7b39df638ebc1a7ba1b1899074a7;hpb=abe94a1faa4c52000f2def759bdee872b77568f7;p=mono.git diff --git a/mono/mini/mini-trampolines.c b/mono/mini/mini-trampolines.c index 99c050e0e73..f65dab8c1e7 100644 --- a/mono/mini/mini-trampolines.c +++ b/mono/mini/mini-trampolines.c @@ -22,14 +22,14 @@ */ guint8* mono_trampoline_code [MONO_TRAMPOLINE_NUM]; -static GHashTable *class_init_hash_addr = NULL; -static GHashTable *rgctx_lazy_fetch_trampoline_hash = NULL; -static GHashTable *rgctx_lazy_fetch_trampoline_hash_addr = NULL; +static GHashTable *class_init_hash_addr; +static GHashTable *rgctx_lazy_fetch_trampoline_hash; +static GHashTable *rgctx_lazy_fetch_trampoline_hash_addr; static guint32 trampoline_calls, jit_trampolines, unbox_trampolines, static_rgctx_trampolines; -#define mono_trampolines_lock() EnterCriticalSection (&trampolines_mutex) -#define mono_trampolines_unlock() LeaveCriticalSection (&trampolines_mutex) -static CRITICAL_SECTION trampolines_mutex; +#define mono_trampolines_lock() mono_mutex_lock (&trampolines_mutex) +#define mono_trampolines_unlock() mono_mutex_unlock (&trampolines_mutex) +static mono_mutex_t trampolines_mutex; #ifdef MONO_ARCH_GSHARED_SUPPORTED @@ -138,8 +138,6 @@ mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr) } #endif -#ifdef MONO_ARCH_HAVE_IMT - /* * Either IMPL_METHOD or AOT_ADDR will be set on return. */ @@ -243,7 +241,6 @@ __attribute__ ((noinline)) } } } -#endif /* * This is a super-ugly hack to fix bug #616463. @@ -406,7 +403,6 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram orig_vtable_slot = vtable_slot; vtable_slot_to_patch = vtable_slot; -#ifdef MONO_ARCH_HAVE_IMT /* IMT call */ if (vt && (gpointer)vtable_slot < (gpointer)vt) { MonoMethod *impl_method = NULL; @@ -464,7 +460,6 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram m = impl_method; } } -#endif /* * The virtual check is needed because is_generic_method_definition (m) could @@ -484,9 +479,7 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram else g_assert (!m->klass->generic_container); -#ifdef MONO_ARCH_HAVE_IMT generic_virtual = mono_arch_find_imt_method (regs, code); -#endif if (generic_virtual) { g_assert (generic_virtual->is_inflated); context.method_inst = ((MonoMethodInflated*)generic_virtual)->context.method_inst; @@ -524,7 +517,6 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram g_assert_not_reached (); #endif } else { -#ifdef MONO_ARCH_HAVE_IMT MonoObject *this_argument = mono_arch_get_this_arg_from_call (regs, code); vt = this_argument->vtable; @@ -537,9 +529,6 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram mono_class_setup_supertypes (this_argument->vtable->klass); klass = this_argument->vtable->klass->supertypes [m->klass->idepth - 1]; } -#else - NOT_IMPLEMENTED; -#endif } g_assert (vtable_slot || klass); @@ -816,11 +805,9 @@ mono_generic_virtual_remoting_trampoline (mgreg_t *regs, guint8 *code, MonoMetho else g_assert (!m->klass->generic_container); -#ifdef MONO_ARCH_HAVE_IMT imt_method = mono_arch_find_imt_method (regs, code); if (imt_method->is_inflated) context.method_inst = ((MonoMethodInflated*)imt_method)->context.method_inst; -#endif m = mono_class_inflate_generic_method (declaring, &context); m = mono_marshal_get_remoting_invoke_with_check (m); @@ -996,7 +983,7 @@ create_delegate_trampoline_data (MonoDomain *domain, MonoClass *klass, MonoMetho invoke = mono_get_delegate_invoke (klass); g_assert (invoke); - tramp_data = mono_domain_alloc (domain, sizeof (MonoDelegateTrampInfo)); + tramp_data = mono_domain_alloc0 (domain, sizeof (MonoDelegateTrampInfo)); tramp_data->invoke = invoke; tramp_data->invoke_sig = mono_method_signature (invoke); tramp_data->impl_this = mono_arch_get_delegate_invoke_impl (mono_method_signature (invoke), TRUE); @@ -1303,7 +1290,7 @@ create_trampoline_code (MonoTrampolineType tramp_type) void mono_trampolines_init (void) { - InitializeCriticalSection (&trampolines_mutex); + mono_mutex_init_recursive (&trampolines_mutex); if (mono_aot_only) return; @@ -1348,7 +1335,7 @@ mono_trampolines_cleanup (void) if (rgctx_lazy_fetch_trampoline_hash_addr) g_hash_table_destroy (rgctx_lazy_fetch_trampoline_hash_addr); - DeleteCriticalSection (&trampolines_mutex); + mono_mutex_destroy (&trampolines_mutex); } guint8 * @@ -1584,6 +1571,19 @@ mono_create_delegate_trampoline (MonoDomain *domain, MonoClass *klass) #endif } +gpointer +mono_create_delegate_virtual_trampoline (MonoDomain *domain, MonoClass *klass, MonoMethod *method) +{ +#ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE + MonoMethod *invoke = mono_get_delegate_invoke (klass); + g_assert (invoke); + + return mono_get_delegate_virtual_invoke_impl (mono_method_signature (invoke), method); +#else + return NULL; +#endif +} + gpointer mono_create_rgctx_lazy_fetch_trampoline (guint32 offset) {