X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fmini-trampolines.c;h=a63b8ea322368427b297bc4a29397b1d97facadc;hb=6649f23b27e947abd19aeb8b12d3a204313ca9ec;hp=737c6a3700255a9ac98f292227f6051d630790b0;hpb=4d1c90a812469fcf288a3b042cc9e74cedd3ed24;p=mono.git diff --git a/mono/mini/mini-trampolines.c b/mono/mini/mini-trampolines.c index 737c6a37002..a63b8ea3223 100644 --- a/mono/mini/mini-trampolines.c +++ b/mono/mini/mini-trampolines.c @@ -1,4 +1,5 @@ -/* +/** + * \file * (C) 2003 Ximian, Inc. * (C) 2003-2011 Novell, Inc. * Copyright 2011 Xamarin, Inc (http://www.xamarin.com) @@ -67,8 +68,8 @@ rgctx_tramp_info_hash (gconstpointer data) /** * mono_create_static_rgctx_trampoline: - * @m: the mono method to create a trampoline for - * @addr: the address to jump to (where the compiled code for M lives) + * \param m the mono method to create a trampoline for + * \param addr the address to jump to (where the compiled code for M lives) * * Creates a static rgctx trampoline for M which branches to ADDR which should * point to the compiled code of M. @@ -82,7 +83,7 @@ rgctx_tramp_info_hash (gconstpointer data) * * On PPC addr should be an ftnptr and the return value is an ftnptr too. * - * Returns the generated static rgctx trampoline. + * \returns the generated static rgctx trampoline. */ gpointer mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr) @@ -119,7 +120,7 @@ mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr) if (mono_aot_only) res = mono_aot_get_static_rgctx_trampoline (ctx, addr); else - res = mono_arch_get_static_rgctx_trampoline (m, (MonoMethodRuntimeGenericContext *)ctx, addr); + res = mono_arch_get_static_rgctx_trampoline (ctx, addr); mono_domain_lock (domain); /* Duplicates inserted while we didn't hold the lock are OK */ @@ -823,19 +824,19 @@ gpointer mono_magic_trampoline (mgreg_t *regs, guint8 *code, gpointer arg, guint8* tramp) { gpointer res; + MonoError error; - MONO_ENTER_GC_UNSAFE_UNBALANCED; + MONO_REQ_GC_UNSAFE_MODE; - MonoError error; + g_assert (mono_thread_is_gc_unsafe_mode ()); trampoline_calls ++; res = common_call_trampoline (regs, code, (MonoMethod *)arg, NULL, NULL, &error); - mono_error_set_pending_exception (&error); - - mono_interruption_checkpoint_from_trampoline (); - - MONO_EXIT_GC_UNSAFE_UNBALANCED; + if (!is_ok (&error)) { + mono_error_set_pending_exception (&error); + return NULL; + } return res; } @@ -1272,68 +1273,6 @@ mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *arg, guint8* tr return code; } -#ifdef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD -static gpointer -mono_handler_block_guard_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_info, guint8* tramp) -{ - MONO_REQ_GC_UNSAFE_MODE; - - MonoContext ctx; - MonoException *exc; - MonoJitTlsData *jit_tls = (MonoJitTlsData *)mono_tls_get_jit_tls (); - gpointer resume_ip = jit_tls->handler_block_return_address; - - memcpy (&ctx, &jit_tls->handler_block_context, sizeof (MonoContext)); - MONO_CONTEXT_SET_IP (&ctx, jit_tls->handler_block_return_address); - - jit_tls->handler_block_return_address = NULL; - jit_tls->handler_block = NULL; - - if (!resume_ip) /*this should not happen, but we should avoid crashing */ - exc = mono_get_exception_execution_engine ("Invalid internal state, resuming abort after handler block but no resume ip found"); - else - exc = mono_thread_resume_interruption (TRUE); - - if (exc) { - mono_handle_exception (&ctx, (MonoObject *)exc); - mono_restore_context (&ctx); - } - - return resume_ip; -} - -gpointer -mono_create_handler_block_trampoline (void) -{ - static gpointer code; - - if (code) - return code; - - if (mono_aot_only) { - gpointer tmp = mono_aot_get_trampoline ("handler_block_trampoline"); - g_assert (tmp); - mono_memory_barrier (); - code = tmp; - return code; - } - - mono_trampolines_lock (); - if (!code) { - MonoTrampInfo *info; - gpointer tmp; - - tmp = mono_arch_create_handler_block_trampoline (&info, FALSE); - mono_tramp_info_register (info, NULL); - mono_memory_barrier (); - code = tmp; - } - mono_trampolines_unlock (); - - return code; -} -#endif - /* * mono_get_trampoline_func: * @@ -1365,10 +1304,6 @@ mono_get_trampoline_func (MonoTrampolineType tramp_type) #endif case MONO_TRAMPOLINE_VCALL: return mono_vcall_trampoline; -#ifdef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD - case MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD: - return mono_handler_block_guard_trampoline; -#endif default: g_assert_not_reached (); return NULL; @@ -1408,10 +1343,6 @@ mono_trampolines_init (void) mono_trampoline_code [MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING] = create_trampoline_code (MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING); #endif mono_trampoline_code [MONO_TRAMPOLINE_VCALL] = create_trampoline_code (MONO_TRAMPOLINE_VCALL); -#ifdef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD - mono_trampoline_code [MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD] = create_trampoline_code (MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD); - mono_create_handler_block_trampoline (); -#endif mono_counters_register ("Calls to trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &trampoline_calls); mono_counters_register ("JIT trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &jit_trampolines); @@ -1739,8 +1670,7 @@ static const char*tramp_names [MONO_TRAMPOLINE_NUM] = { "delegate", "restore_stack_prot", "generic_virtual_remoting", - "vcall", - "handler_block_guard" + "vcall" }; /*