[mono/mono] [3 commits] 3ee03145: [runtime] Use mini_get_nullified_class_init_trampoline () to reduce code duplication in the back ends.

"Zoltan Varga ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000141e017b921-2c1b029a-68ec-4e58-b8bc-1960d2c71cdb-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/f62ffb9b892a...d48b2f6a2986

   Commit: 3ee03145ff3ab52ce622d5aeb29a1600a8b2c863
   Author: Zoltan Varga <[email protected]> (vargaz)
     Date: 2013-10-22 12:04:50 GMT
      URL: https://github.com/mono/mono/commit/3ee03145ff3ab52ce622d5aeb29a1600a8b2c863

[runtime] Use mini_get_nullified_class_init_trampoline () to reduce code duplication in the back ends.

Changed paths:
  M mono/mini/tramp-amd64.c
  M mono/mini/tramp-arm.c
  M mono/mini/tramp-mips.c
  M mono/mini/tramp-ppc.c
  M mono/mini/tramp-x86.c

Modified: mono/mini/tramp-amd64.c
===================================================================
@@ -34,8 +34,6 @@
 
 #define IS_REX(inst) (((inst) >= 0x40) && ((inst) <= 0x4f))
 
-static guint8* nullified_class_init_trampoline;
-
 /*
  * mono_arch_get_unbox_trampoline:
  * @m: method pointer
@@ -336,6 +334,7 @@
 	guint8 buf [16];
 	MonoJitInfo *ji = NULL;
 	gboolean can_write;
+	gpointer tramp = mini_get_nullified_class_init_trampoline ();
 
 	if (mono_use_llvm) {
 		/* code - 7 might be before the start of the method */
@@ -360,7 +359,7 @@
 		vtable_slot = get_vcall_slot_addr (code, regs);
 		g_assert (vtable_slot);
 
-		*vtable_slot = nullified_class_init_trampoline;
+		*vtable_slot = tramp;
 	} else if (buf [2] == 0xe8) {
 		/* call <TARGET> */
 		//guint8 *buf = code - 2;
@@ -378,11 +377,11 @@
 		buf [4] = 0x90;
 		*/
 
-		mono_arch_patch_callsite (code - 5, code, nullified_class_init_trampoline);
+		mono_arch_patch_callsite (code - 5, code, tramp);
 	} else if ((buf [5] == 0xff) && x86_modrm_mod (buf [6]) == 3 && x86_modrm_reg (buf [6]) == 2) {
 		/* call *<reg> */
 		/* Generated by the LLVM JIT or on platforms without MAP_32BIT set */
-		mono_arch_patch_callsite (code - 13, code, nullified_class_init_trampoline);
+		mono_arch_patch_callsite (code - 13, code, tramp);
 	} else if (buf [4] == 0x90 || buf [5] == 0xeb || buf [6] == 0x66) {
 		/* Already changed by another thread */
 		;
@@ -396,10 +395,7 @@
 void
 mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
 {
-	if (mono_aot_only && !nullified_class_init_trampoline)
-		nullified_class_init_trampoline = mono_aot_get_trampoline ("nullified_class_init_trampoline");
-
-	mono_arch_patch_plt_entry (code, NULL, regs, nullified_class_init_trampoline);
+	mono_arch_patch_plt_entry (code, NULL, regs, mini_get_nullified_class_init_trampoline ());
 }
 
 static void
@@ -720,11 +716,6 @@
 
 	mono_arch_flush_icache (buf, code - buf);
 
-	if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT) {
-		/* Initialize the nullified class init trampoline used in the AOT case */
-		nullified_class_init_trampoline = mono_arch_get_nullified_class_init_trampoline (NULL);
-	}
-
 	if (info) {
 		tramp_name = mono_get_generic_trampoline_name (tramp_type);
 		*info = mono_tramp_info_create (tramp_name, buf, code - buf, ji, unwind_ops);

Modified: mono/mini/tramp-arm.c
===================================================================
@@ -22,9 +22,6 @@
 
 #define ALIGN_TO(val,align) ((((guint64)val) + ((align) - 1)) & ~((align) - 1))
 
-static guint8* nullified_class_init_trampoline;
-
-
 #ifdef USE_JUMP_TABLES
 
 static guint16
@@ -131,16 +128,13 @@
 void
 mono_arch_nullify_class_init_trampoline (guint8 *code, mgreg_t *regs)
 {
-	mono_arch_patch_callsite (NULL, code, nullified_class_init_trampoline);
+	mono_arch_patch_callsite (NULL, code, mini_get_nullified_class_init_trampoline ());
 }
 
 void
 mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
 {
-	if (mono_aot_only && !nullified_class_init_trampoline)
-		nullified_class_init_trampoline = mono_aot_get_trampoline ("nullified_class_init_trampoline");
-
-	mono_arch_patch_plt_entry (code, NULL, regs, nullified_class_init_trampoline);
+	mono_arch_patch_plt_entry (code, NULL, regs, mini_get_nullified_class_init_trampoline ());
 }
 
 #ifndef DISABLE_JIT
@@ -452,10 +446,6 @@
 	/* Sanity check */
 	g_assert ((code - buf) <= buf_len);
 
-	if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT)
-		/* Initialize the nullified class init trampoline used in the AOT case */
-		nullified_class_init_trampoline = mono_arch_get_nullified_class_init_trampoline (NULL);
-
 	if (info) {
 		tramp_name = mono_get_generic_trampoline_name (tramp_type);
 		*info = mono_tramp_info_create (tramp_name, buf, code - buf, ji, unwind_ops);

Modified: mono/mini/tramp-mips.c
===================================================================
@@ -24,8 +24,6 @@
 #include "mini.h"
 #include "mini-mips.h"
 
-static guint8* nullified_class_init_trampoline;
-
 /*
  * get_unbox_trampoline:
  * @m: method pointer
@@ -116,10 +114,7 @@
 void
 mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
 {
-	if (mono_aot_only && !nullified_class_init_trampoline)
-		nullified_class_init_trampoline = mono_aot_get_trampoline ("nullified_class_init_trampoline");
-
-	mono_arch_patch_plt_entry (code, NULL, regs, nullified_class_init_trampoline);
+	mono_arch_patch_plt_entry (code, NULL, regs, mini_get_nullified_class_init_trampoline ());
 }
 
 void
@@ -314,10 +309,6 @@
 	/* Sanity check */
 	g_assert ((code - buf) <= max_code_len);
 
-	if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT)
-		/* Initialize the nullified class init trampoline used in the AOT case */
-		nullified_class_init_trampoline = mono_arch_get_nullified_class_init_trampoline (NULL);
-
 	if (info) {
 		tramp_name = mono_get_generic_trampoline_name (tramp_type);
 		*info = mono_tramp_info_create (tramp_name, buf, code - buf, ji, unwind_ops);

Modified: mono/mini/tramp-ppc.c
===================================================================
@@ -22,8 +22,6 @@
 #include "mini.h"
 #include "mini-ppc.h"
 
-static guint8* nullified_class_init_trampoline;
-
 /* Same as mono_create_ftnptr, but doesn't require a domain */
 static gpointer
 mono_ppc_create_ftnptr (guint8 *code)
@@ -200,16 +198,13 @@
 void
 mono_arch_nullify_class_init_trampoline (guint8 *code, mgreg_t *regs)
 {
-	mono_arch_patch_callsite (NULL, code, nullified_class_init_trampoline);
+	mono_arch_patch_callsite (NULL, code, mini_get_nullified_class_init_trampoline ());
 }
 
 void
 mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
 {
-	if (mono_aot_only && !nullified_class_init_trampoline)
-		nullified_class_init_trampoline = mono_aot_get_trampoline ("nullified_class_init_trampoline");
-
-	mono_arch_patch_plt_entry (code, NULL, regs, nullified_class_init_trampoline);
+	mono_arch_patch_plt_entry (code, NULL, regs, mini_get_nullified_class_init_trampoline ());
 }
 
 /* Stack size for trampoline function 
@@ -440,11 +435,6 @@
 	/* Sanity check */
 	g_assert ((code - buf) <= size);
 
-	if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT) {
-		/* Initialize the nullified class init trampoline */
-		nullified_class_init_trampoline = mono_ppc_create_ftnptr (mono_arch_get_nullified_class_init_trampoline (NULL));
-	}
-
 	if (info) {
 		tramp_name = mono_get_generic_trampoline_name (tramp_type);
 		*info = mono_tramp_info_create (tramp_name, buf, code - buf, ji, unwind_ops);

Modified: mono/mini/tramp-x86.c
===================================================================
@@ -25,8 +25,6 @@
 #include "mini.h"
 #include "mini-x86.h"
 
-static guint8* nullified_class_init_trampoline;
-
 /*
  * mono_arch_get_unbox_trampoline:
  * @m: method pointer
@@ -239,6 +237,7 @@
 {
 	guint8 buf [16];
 	gboolean can_write = mono_breakpoint_clean_code (NULL, code, 6, buf, sizeof (buf));
+	gpointer tramp = mini_get_nullified_class_init_trampoline ();
 
 	if (!can_write)
 		return;
@@ -273,7 +272,7 @@
 			//VALGRIND_DISCARD_TRANSLATIONS (code, 8);
 		}
 #elif defined(__native_client_codegen__)
-		mono_arch_patch_callsite (code, code + 5, nullified_class_init_trampoline);
+		mono_arch_patch_callsite (code, code + 5, tramp);
 #endif
 	} else if (code [0] == 0x90 || code [0] == 0xeb) {
 		/* Already changed by another thread */
@@ -285,7 +284,7 @@
 		vtable_slot = get_vcall_slot_addr (code + 5, regs);
 		g_assert (vtable_slot);
 
-		*vtable_slot = nullified_class_init_trampoline;
+		*vtable_slot = tramp;
 	} else {
 			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]);
@@ -296,10 +295,7 @@
 void
 mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
 {
-	if (mono_aot_only && !nullified_class_init_trampoline)
-		nullified_class_init_trampoline = mono_aot_get_trampoline ("nullified_class_init_trampoline");
-
-	mono_arch_patch_plt_entry (code, NULL, regs, nullified_class_init_trampoline);
+	mono_arch_patch_plt_entry (code, NULL, regs, mini_get_nullified_class_init_trampoline ());
 }
 
 guchar*
@@ -543,11 +539,6 @@
 		g_free (tramp_name);
 	}
 
-	if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT) {
-		/* Initialize the nullified class init trampoline used in the AOT case */
-		nullified_class_init_trampoline = mono_arch_get_nullified_class_init_trampoline (NULL);
-	}
-
 	return buf;
 }
 

   Commit: 9be988fc336ebd6ad4bc60835ca3df24589bd599
   Author: Zoltan Varga <[email protected]> (vargaz)
     Date: 2013-10-22 12:05:43 GMT
      URL: https://github.com/mono/mono/commit/9be988fc336ebd6ad4bc60835ca3df24589bd599

[runtime] Use mini_exception_id_by_name () on ARM.

Changed paths:
  M mono/mini/mini-arm.c

Modified: mono/mini/mini-arm.c
===================================================================
@@ -5691,30 +5691,6 @@ enum {
 
 }
 
-/* remove once throw_exception_by_name is eliminated */
-static int
-exception_id_by_name (const char *name)
-{
-	if (strcmp (name, "IndexOutOfRangeException") == 0)
-		return MONO_EXC_INDEX_OUT_OF_RANGE;
-	if (strcmp (name, "OverflowException") == 0)
-		return MONO_EXC_OVERFLOW;
-	if (strcmp (name, "ArithmeticException") == 0)
-		return MONO_EXC_ARITHMETIC;
-	if (strcmp (name, "DivideByZeroException") == 0)
-		return MONO_EXC_DIVIDE_BY_ZERO;
-	if (strcmp (name, "InvalidCastException") == 0)
-		return MONO_EXC_INVALID_CAST;
-	if (strcmp (name, "NullReferenceException") == 0)
-		return MONO_EXC_NULL_REF;
-	if (strcmp (name, "ArrayTypeMismatchException") == 0)
-		return MONO_EXC_ARRAY_TYPE_MISMATCH;
-	if (strcmp (name, "ArgumentException") == 0)
-		return MONO_EXC_ARGUMENT;
-	g_error ("Unknown intrinsic exception %s\n", name);
-	return -1;
-}
-
 void
 mono_arch_emit_exceptions (MonoCompile *cfg)
 {
@@ -5737,7 +5713,7 @@ enum {
 	 */
 	for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
 		if (patch_info->type == MONO_PATCH_INFO_EXC) {
-			i = exception_id_by_name (patch_info->data.target);
+			i = mini_exception_id_by_name (patch_info->data.target);
 			if (!exc_throw_found [i]) {
 				max_epilog_size += 32;
 				exc_throw_found [i] = TRUE;
@@ -5760,7 +5736,7 @@ enum {
 			MonoClass *exc_class;
 			unsigned char *ip = patch_info->ip.i + cfg->native_code;
 
-			i = exception_id_by_name (patch_info->data.target);
+			i = mini_exception_id_by_name (patch_info->data.target);
 			if (exc_throw_pos [i]) {
 				arm_patch (ip, exc_throw_pos [i]);
 				patch_info->type = MONO_PATCH_INFO_NONE;

   Commit: d48b2f6a29866ce05af2e60023c893280a99ff8b
   Author: Zoltan Varga <[email protected]> (vargaz)
     Date: 2013-10-22 12:12:38 GMT
      URL: https://github.com/mono/mono/commit/d48b2f6a29866ce05af2e60023c893280a99ff8b

[runtime] Use mono_restore_context () to reduce code duplication in the back ends.

Changed paths:
  M mono/mini/debugger-agent.c
  M mono/mini/exceptions-amd64.c
  M mono/mini/exceptions-arm.c
  M mono/mini/exceptions-mips.c
  M mono/mini/exceptions-ppc.c
  M mono/mini/exceptions-s390x.c
  M mono/mini/exceptions-x86.c
  M mono/mini/mini-exceptions.c

Modified: mono/mini/debugger-agent.c
===================================================================
@@ -4602,10 +4602,6 @@ static void CALLBACK notify_thread_apc (ULONG_PTR param)
 {
 	DebuggerTlsData *tls;
 	MonoContext orig_restore_ctx, ctx;
-	static void (*restore_context) (void *);
-
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
 
 	tls = mono_native_tls_get_value (debugger_tls_id);
 	/* Have to save/restore the restore_ctx as we can be called recursively during invokes etc. */
@@ -4617,7 +4613,7 @@ static void CALLBACK notify_thread_apc (ULONG_PTR param)
 	/* This is called when resuming from a signal handler, so it shouldn't return */
 	memcpy (&ctx, &tls->restore_ctx, sizeof (MonoContext));
 	memcpy (&tls->restore_ctx, &orig_restore_ctx, sizeof (MonoContext));
-	restore_context (&ctx);
+	mono_restore_context (&ctx);
 	g_assert_not_reached ();
 }
 
@@ -6388,13 +6384,9 @@ static void CALLBACK notify_thread_apc (ULONG_PTR param)
 	int id;
 	int i, err, mindex;
 	Buffer buf;
-	static void (*restore_context) (void *);
 	MonoContext restore_ctx;
 	guint8 *p;
 
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
-
 	tls = mono_native_tls_get_value (debugger_tls_id);
 	g_assert (tls);
 

Modified: mono/mini/exceptions-amd64.c
===================================================================
@@ -347,12 +347,8 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 							mgreg_t *regs, mgreg_t rip,
 							MonoObject *exc, gboolean rethrow)
 {
-	static void (*restore_context) (MonoContext *);
 	MonoContext ctx;
 
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
-
 	ctx.rsp = regs [AMD64_RSP];
 	ctx.rip = rip;
 	ctx.rbx = regs [AMD64_RBX];
@@ -383,7 +379,7 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 			ctx_cp.rip = rip - 5;
 
 			if (mono_debugger_handle_exception (&ctx_cp, exc)) {
-				restore_context (&ctx_cp);
+				mono_restore_context (&ctx_cp);
 				g_assert_not_reached ();
 			}
 		}
@@ -393,8 +389,7 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 	ctx.rip -= 1;
 
 	mono_handle_exception (&ctx, exc);
-	restore_context (&ctx);
-
+	mono_restore_context (&ctx);
 	g_assert_not_reached ();
 }
 
@@ -757,10 +752,6 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 {
 	MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
 	MonoContext ctx;
-	static void (*restore_context) (MonoContext *);
-
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
 
 	memcpy (&ctx, &jit_tls->ex_ctx, sizeof (MonoContext));
 
@@ -769,7 +760,7 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 
 	mono_handle_exception (&ctx, obj);
 
-	restore_context (&ctx);
+	mono_restore_context (&ctx);
 }
 
 void
@@ -885,22 +876,20 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 static void
 altstack_handle_and_restore (void *sigctx, gpointer obj, gboolean stack_ovf)
 {
-	void (*restore_context) (MonoContext *);
 	MonoContext mctx;
 
-	restore_context = mono_get_restore_context ();
 	mono_arch_sigctx_to_monoctx (sigctx, &mctx);
 
 	if (mono_debugger_handle_exception (&mctx, (MonoObject *)obj)) {
 		if (stack_ovf)
 			prepare_for_guard_pages (&mctx);
-		restore_context (&mctx);
+		mono_restore_context (&mctx);
 	}
 
 	mono_handle_exception (&mctx, obj);
 	if (stack_ovf)
 		prepare_for_guard_pages (&mctx);
-	restore_context (&mctx);
+	mono_restore_context (&mctx);
 }
 
 void

Modified: mono/mini/exceptions-arm.c
===================================================================
@@ -135,13 +135,9 @@
 void
 mono_arm_throw_exception (MonoObject *exc, mgreg_t pc, mgreg_t sp, mgreg_t *int_regs, gdouble *fp_regs)
 {
-	static void (*restore_context) (MonoContext *);
 	MonoContext ctx;
 	gboolean rethrow = pc & 1;
 
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
-
 	pc &= ~1; /* clear the optional rethrow bit */
 	/* adjust eip so that it point into the call instruction */
 	pc -= 4;
@@ -159,7 +155,7 @@
 			mono_ex->stack_trace = NULL;
 	}
 	mono_handle_exception (&ctx, exc);
-	restore_context (&ctx);
+	mono_restore_context (&ctx);
 	g_assert_not_reached ();
 }
 
@@ -517,16 +513,12 @@
 {
 	MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
 	MonoContext ctx;
-	static void (*restore_context) (MonoContext *);
-
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
 
 	memcpy (&ctx, &jit_tls->ex_ctx, sizeof (MonoContext));
 
 	mono_handle_exception (&ctx, obj);
 
-	restore_context (&ctx);
+	mono_restore_context (&ctx);
 }
 
 /*

Modified: mono/mini/exceptions-mips.c
===================================================================
@@ -174,7 +174,6 @@
 static void
 throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, gboolean rethrow)
 {
-	static void (*restore_context) (MonoContext *);
 	MonoContext ctx;
 
 #ifdef DEBUG_EXCEPTIONS
@@ -182,9 +181,6 @@
 		 exc, (void *)eip, (void *) esp, rethrow);
 #endif
 
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
-
 	/* adjust eip so that it point into the call instruction */
 	eip -= 8;
 
@@ -207,7 +203,7 @@
 		 (void *) ctx.sc_pc, (void *) ctx.sc_regs[mips_sp],
 		 (void *) ctx.sc_regs[mips_fp], &ctx);
 #endif
-	restore_context (&ctx);
+	mono_restore_context (&ctx);
 
 	g_assert_not_reached ();
 }
@@ -518,16 +514,12 @@
 {
 	MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
 	MonoContext ctx;
-	static void (*restore_context) (MonoContext *);
-
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
 
 	memcpy (&ctx, &jit_tls->ex_ctx, sizeof (MonoContext));
 
 	mono_handle_exception (&ctx, obj);
 
-	restore_context (&ctx);
+	mono_restore_context (&ctx);
 }
 
 /*

Modified: mono/mini/exceptions-ppc.c
===================================================================
@@ -316,12 +316,8 @@ struct ucontext {
 void
 mono_ppc_throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, mgreg_t *int_regs, gdouble *fp_regs, gboolean rethrow)
 {
-	static void (*restore_context) (MonoContext *);
 	MonoContext ctx;
 
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
-
 	/* adjust eip so that it point into the call instruction */
 	eip -= 4;
 
@@ -339,7 +335,7 @@ struct ucontext {
 			mono_ex->stack_trace = NULL;
 	}
 	mono_handle_exception (&ctx, exc);
-	restore_context (&ctx);
+	mono_restore_context (&ctx);
 
 	g_assert_not_reached ();
 }
@@ -669,13 +665,11 @@ struct ucontext {
 static void
 altstack_handle_and_restore (void *sigctx, gpointer obj)
 {
-	void (*restore_context) (MonoContext *);
 	MonoContext mctx;
 
-	restore_context = mono_get_restore_context ();
 	mono_arch_sigctx_to_monoctx (sigctx, &mctx);
 	mono_handle_exception (&mctx, obj);
-	restore_context (&mctx);
+	mono_restore_context (&mctx);
 }
 
 void
@@ -754,16 +748,12 @@ struct ucontext {
 {
 	MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
 	MonoContext ctx;
-	static void (*restore_context) (MonoContext *);
-
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
 
 	memcpy (&ctx, &jit_tls->ex_ctx, sizeof (MonoContext));
 
 	mono_handle_exception (&ctx, obj);
 
-	restore_context (&ctx);
+	mono_restore_context (&ctx);
 }
 
 static void

Modified: mono/mini/exceptions-s390x.c
===================================================================
@@ -237,11 +237,7 @@ gboolean mono_arch_handle_exception (void     *ctx,
 {
 	MonoContext ctx;
 	int iReg;
-	static void (*restore_context) (MonoContext *);
 
-	if (!restore_context)
-		restore_context = mono_get_restore_context();
-	
 	memset(&ctx, 0, sizeof(ctx));
 
 	setup_context(&ctx);
@@ -267,7 +263,7 @@ gboolean mono_arch_handle_exception (void     *ctx,
 	}
 //	mono_arch_handle_exception (&ctx, exc, FALSE);
 	mono_handle_exception (&ctx, exc);
-	restore_context(&ctx);
+	mono_restore_context(&ctx);
 
 	g_assert_not_reached ();
 }

Modified: mono/mini/exceptions-x86.c
===================================================================
@@ -473,12 +473,8 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 mono_x86_throw_exception (mgreg_t *regs, MonoObject *exc, 
 						  mgreg_t eip, gboolean rethrow)
 {
-	static void (*restore_context) (MonoContext *);
 	MonoContext ctx;
 
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
-
 	ctx.esp = regs [X86_ESP];
 	ctx.eip = eip;
 	ctx.ebp = regs [X86_EBP];
@@ -511,7 +507,7 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 			ctx_cp.eip = eip - 5;
 
 			if (mono_debugger_handle_exception (&ctx_cp, exc)) {
-				restore_context (&ctx_cp);
+				mono_restore_context (&ctx_cp);
 				g_assert_not_reached ();
 			}
 		}
@@ -522,7 +518,7 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 
 	mono_handle_exception (&ctx, exc);
 
-	restore_context (&ctx);
+	mono_restore_context (&ctx);
 
 	g_assert_not_reached ();
 }
@@ -989,10 +985,6 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 {
 	MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
 	MonoContext ctx;
-	static void (*restore_context) (MonoContext *);
-
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
 
 	memcpy (&ctx, &jit_tls->ex_ctx, sizeof (MonoContext));
 
@@ -1001,7 +993,7 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 
 	mono_handle_exception (&ctx, obj);
 
-	restore_context (&ctx);
+	mono_restore_context (&ctx);
 }
 
 /*
@@ -1149,22 +1141,20 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
 static void
 altstack_handle_and_restore (MonoContext *ctx, gpointer obj, gboolean stack_ovf)
 {
-	void (*restore_context) (MonoContext *);
 	MonoContext mctx;
 
-	restore_context = mono_get_restore_context ();
 	mctx = *ctx;
 
 	if (mono_debugger_handle_exception (&mctx, (MonoObject *)obj)) {
 		if (stack_ovf)
 			prepare_for_guard_pages (&mctx);
-		restore_context (&mctx);
+		mono_restore_context (&mctx);
 	}
 
 	mono_handle_exception (&mctx, obj);
 	if (stack_ovf)
 		prepare_for_guard_pages (&mctx);
-	restore_context (&mctx);
+	mono_restore_context (&mctx);
 }
 
 void

Modified: mono/mini/mini-exceptions.c
===================================================================
@@ -1520,7 +1520,6 @@
 	MonoDomain *domain = mono_domain_get ();
 	MonoJitInfo *ji, *prev_ji;
 	static int (*call_filter) (MonoContext *, gpointer) = NULL;
-	static void (*restore_context) (void *);
 	MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
 	MonoLMF *lmf = mono_get_lmf ();
 	MonoException *mono_ex;
@@ -1591,9 +1590,6 @@
 	if (!call_filter)
 		call_filter = mono_get_call_filter ();
 
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
-
 	g_assert (jit_tls->end_of_stack);
 	g_assert (jit_tls->abort_func);
 
@@ -2496,7 +2492,6 @@
 mono_resume_unwind (MonoContext *ctx)
 {
 	MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
-	static void (*restore_context) (MonoContext *);
 	MonoContext new_ctx;
 
 	MONO_CONTEXT_SET_IP (ctx, MONO_CONTEXT_GET_IP (&jit_tls->resume_state.ctx));
@@ -2505,10 +2500,7 @@
 
 	mono_handle_exception_internal (&new_ctx, jit_tls->resume_state.ex_obj, TRUE, NULL);
 
-	if (!restore_context)
-		restore_context = mono_get_restore_context ();
-
-	restore_context (&new_ctx);
+	mono_restore_context (&new_ctx);
 }
 
 #ifdef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD
@@ -2717,11 +2709,8 @@
 static void
 mono_raise_exception_with_ctx (MonoException *exc, MonoContext *ctx)
 {
-	void (*restore_context) (MonoContext *);
-	restore_context = mono_get_restore_context ();
-
 	mono_handle_exception (ctx, exc);
-	restore_context (ctx);
+	mono_restore_context (ctx);
 }
 
 /*FIXME Move all monoctx -> sigctx conversion to signal handlers once all archs support utils/mono-context */


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.