2010-01-20 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Wed, 20 Jan 2010 03:22:41 +0000 (03:22 -0000)
committerZoltan Varga <vargaz@gmail.com>
Wed, 20 Jan 2010 03:22:41 +0000 (03:22 -0000)
* exceptions-<ARCH>.c: Introduce a MONO_ARCH_HAVE_THROW_EXCEPTION_BY_NAME
define for platforms still using it (s390). Get rid of the
mono_arch_get_throw_exception_by_name () routines on all other platforms.

svn path=/trunk/mono/; revision=149873

12 files changed:
mono/mini/ChangeLog
mono/mini/aot-compiler.c
mono/mini/exceptions-amd64.c
mono/mini/exceptions-arm.c
mono/mini/exceptions-ia64.c
mono/mini/exceptions-ppc.c
mono/mini/exceptions-sparc.c
mono/mini/exceptions-x86.c
mono/mini/mini-exceptions.c
mono/mini/mini-s390.h
mono/mini/mini-s390x.h
mono/mini/mini.c

index b8bf399ae03972c37f53cfcccdfc790bb2e0adb0..06394345c206fa8bce8c79c05cd78d5bfc0b381d 100755 (executable)
@@ -1,5 +1,9 @@
 2010-01-20  Zoltan Varga  <vargaz@gmail.com>
 
+       * exceptions-<ARCH>.c: Introduce a MONO_ARCH_HAVE_THROW_EXCEPTION_BY_NAME
+       define for platforms still using it (s390). Get rid of the
+       mono_arch_get_throw_exception_by_name () routines on all other platforms.
+
        * exceptions-x86.c: Rework the throw trampolines so there is only one function
        which can generate throw/rethrow/corlib trampolines for llvm/not llvm code.
 
@@ -8,7 +12,7 @@
 
        * mini-llvm.c: Enable throwing exceptions on x86.
 
-       * mini-posix.c (SIG_HANDLER_SIGNATURE): Avoid 
+       * mini-posix.c (SIG_HANDLER_SIGNATURE): Avoid
        "Thread (nil) may have been prematurely finalized" messages if this is called
        on a thread not registered with the runtime.
 
index 1056c28a0953d5e14a261477eccf94a6cf1f14ef..941610e5b208e52dc05502d35aeba7db5d42ac5a 100644 (file)
@@ -3545,8 +3545,10 @@ emit_trampolines (MonoAotCompile *acfg)
                emit_trampoline (acfg, "throw_exception", code, code_size, acfg->got_offset, ji, NULL);
                code = mono_arch_get_rethrow_exception_full (&code_size, &ji, TRUE);
                emit_trampoline (acfg, "rethrow_exception", code, code_size, acfg->got_offset, ji, NULL);
+#ifdef MONO_ARCH_HAVE_THROW_EXCEPTION_BY_NAME
                code = mono_arch_get_throw_exception_by_name_full (&code_size, &ji, TRUE);
                emit_trampoline (acfg, "throw_exception_by_name", code, code_size, acfg->got_offset, ji, NULL);
+#endif
                code = mono_arch_get_throw_corlib_exception_full (&code_size, &ji, TRUE);
                emit_trampoline (acfg, "throw_corlib_exception", code, code_size, acfg->got_offset, ji, NULL);
 
index 73c8bf8c83c79a890a3f619bdea4b71489d44f24..9f1caecab021d971b03e1d0d79b3769e3579c6ad 100644 (file)
@@ -434,26 +434,6 @@ mono_arch_get_rethrow_exception_full (guint32 *code_size, MonoJumpInfo **ji, gbo
        return get_throw_trampoline (TRUE, code_size, ji, aot);
 }
 
-gpointer 
-mono_arch_get_throw_exception_by_name_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
-{      
-       guint8* start;
-       guint8 *code;
-
-       start = code = mono_global_codeman_reserve (64);
-
-       *ji = NULL;
-
-       /* Not used on amd64 */
-       amd64_breakpoint (code);
-
-       mono_arch_flush_icache (start, code - start);
-
-       *code_size = code - start;
-
-       return start;
-}
-
 /**
  * mono_arch_get_throw_corlib_exception:
  *
index 25593b6bedd8fb0486cab101f41b65e048cf3e1b..f9c486c594ddc8c39bc2640d29d7481f8474b63b 100644 (file)
@@ -324,24 +324,6 @@ mono_arch_get_throw_exception_full (guint32 *code_size, MonoJumpInfo **ji, gbool
        return mono_arch_get_throw_exception_generic (132, FALSE, FALSE, code_size, ji, aot);
 }
 
-gpointer 
-mono_arch_get_throw_exception_by_name_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
-{      
-       guint8* start;
-       guint8 *code;
-
-       *ji = NULL;
-
-       start = code = mono_global_codeman_reserve (64);
-
-       /* Not used on ARM */
-       ARM_DBRK (code);
-
-       *code_size = code - start;
-
-       return start;
-}
-
 /**
  * mono_arch_get_throw_corlib_exception:
  *
index 414b61e3495853813f604d033affa12bfb38dd10..a7d04a568487c7697a4afe24b7f24baae939db09 100644 (file)
@@ -386,26 +386,6 @@ mono_arch_get_rethrow_exception (void)
        return start;
 }
 
-gpointer 
-mono_arch_get_throw_exception_by_name (void)
-{      
-       guint8* start;
-       Ia64CodegenState code;
-
-       start = mono_global_codeman_reserve (64);
-
-       /* Not used on ia64 */
-       ia64_codegen_init (code, start);
-       ia64_break_i (code, 1001);
-       ia64_codegen_close (code);
-
-       g_assert ((code.buf - start) <= 256);
-
-       mono_arch_flush_icache (start, code.buf - start);
-
-       return start;
-}
-
 /**
  * mono_arch_get_throw_corlib_exception:
  *
index a62503a19699441d4c7a5847f7f99e0a5d754d23..ef7fc5c479c3784b3f287f237a117e109e0ff1f2 100644 (file)
@@ -481,34 +481,6 @@ mono_arch_get_throw_exception_full (guint32 *code_size, MonoJumpInfo **ji, gbool
        return mono_arch_get_throw_exception_generic (size, code_size, ji, FALSE, FALSE, aot);
 }
 
-/**
- * arch_get_throw_exception_by_name:
- *
- * Returns a function pointer which can be used to raise 
- * corlib exceptions. The returned function has the following 
- * signature: void (*func) (char *exc_name); 
- * For example to raise an arithmetic exception you can use:
- *
- * x86_push_imm (code, "ArithmeticException"); 
- * x86_call_code (code, arch_get_throw_exception_by_name ()); 
- *
- */
-gpointer
-mono_arch_get_throw_exception_by_name_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
-{
-       guint8 *start, *code;
-       int size = 64;
-
-       *ji = NULL;
-
-       /* Not used on PPC */   
-       start = code = mono_global_codeman_reserve (size);
-       ppc_break (code);
-       mono_arch_flush_icache (start, code - start);
-       *code_size = code - start;
-       return start;
-}
-
 /**
  * mono_arch_get_throw_corlib_exception:
  *
index 39ffeae899c97958b6598723f388d3cf78c3966e..1f34788a5c362ca4afe22d924036a69e9dc61ded 100644 (file)
@@ -245,59 +245,6 @@ mono_arch_get_rethrow_exception (void)
        return start;
 }
 
-/**
- * mono_arch_get_throw_exception_by_name:
- *
- * Returns a function pointer which can be used to raise 
- * corlib exceptions. The returned function has the following 
- * signature: void (*func) (char *exc_name, gpointer ip); 
- */
-gpointer 
-mono_arch_get_throw_exception_by_name (void)
-{
-       static guint32 *start;
-       static int inited = 0;
-       guint32 *code;
-       int reg;
-
-       if (inited)
-               return start;
-
-       inited = 1;
-       code = start = mono_global_codeman_reserve (64 * sizeof (guint32));
-
-#ifdef SPARCV9
-       reg = sparc_g4;
-#else
-       reg = sparc_g1;
-#endif
-
-       sparc_save_imm (code, sparc_sp, -160, sparc_sp);
-
-       sparc_mov_reg_reg (code, sparc_i0, sparc_o2);
-       sparc_set (code, mono_defaults.corlib, sparc_o0);
-       sparc_set (code, "System", sparc_o1);
-       sparc_set (code, mono_exception_from_name, sparc_o7);
-       sparc_jmpl (code, sparc_o7, sparc_g0, sparc_callsite);
-       sparc_nop (code);
-
-       /* Return to the caller, so exception handling does not see this frame */
-       sparc_restore (code, sparc_o0, sparc_g0, sparc_o0);
-
-       /* Put original return address into %o7 */
-       sparc_mov_reg_reg (code, sparc_o1, sparc_o7);
-       sparc_set (code, mono_arch_get_throw_exception (), reg);
-       /* Use a jmp instead of a call so o7 is preserved */
-       sparc_jmpl_imm (code, reg, 0, sparc_g0);
-       sparc_nop (code);
-
-       g_assert ((code - start) < 32);
-
-       mono_arch_flush_icache ((guint8*)start, (guint8*)code - (guint8*)start);
-
-       return start;
-}
-
 /**
  * mono_arch_get_throw_corlib_exception:
  *
index 7b22122f7559a1abac887af7dd3c4534195e1624..77ac3aff0727d924301e6ac33ac430d43c344c46 100644 (file)
@@ -555,35 +555,6 @@ mono_arch_get_rethrow_exception (void)
        return get_throw_exception ("rethrow_exception_trampoline", TRUE, FALSE, FALSE);
 }
 
-/**
- * mono_arch_get_throw_exception_by_name:
- *
- * Returns a function pointer which can be used to raise 
- * corlib exceptions. The returned function has the following 
- * signature: void (*func) (gpointer ip, char *exc_name); 
- * For example to raise an arithmetic exception you can use:
- *
- * x86_push_imm (code, "ArithmeticException"); 
- * x86_push_imm (code, <IP>)
- * x86_jump_code (code, arch_get_throw_exception_by_name ()); 
- *
- */
-gpointer 
-mono_arch_get_throw_exception_by_name (void)
-{
-       guint8* start;
-       guint8 *code;
-
-       start = code = mono_global_codeman_reserve (32);
-
-       /* Not used */
-       x86_breakpoint (code);
-
-       mono_arch_flush_icache (start, code - start);
-
-       return start;
-}
-
 /**
  * mono_arch_get_throw_corlib_exception:
  *
index 35b330474d1ec88fa333e442e582a7074c9cadea..350068ca9ee371c87264603f4bd0f3f216da6273 100644 (file)
@@ -129,6 +129,8 @@ mono_get_restore_context (void)
 gpointer
 mono_get_throw_exception_by_name (void)
 {
+#ifdef MONO_ARCH_HAVE_THROW_EXCEPTION_BY_NAME
+
        gpointer code = NULL;
 #ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
        guint32 code_size;
@@ -152,6 +154,13 @@ mono_get_throw_exception_by_name (void)
 
        throw_exception_by_name_func = code;
 
+#else
+
+       throw_exception_by_name_func = NULL;
+
+       g_assert_not_reached ();
+#endif
+
        return throw_exception_by_name_func;
 }
 
index dd542f85dfd2365a8b9582931f4ce1aeb285d104..eab5ebe8fadeb98e7e14a7e6a62fcac06d1a8cab 100644 (file)
@@ -59,6 +59,7 @@ typedef struct
 // #define MONO_ARCH_SIGSEGV_ON_ALTSTACK               1
 // #define MONO_ARCH_SIGNAL_STACK_SIZE         65536
 // #define MONO_ARCH_HAVE_THROW_CORLIB_EXCEPTION       1
+#define MONO_ARCH_HAVE_THROW_EXCEPTION_BY_NAME 1
 
 #define MONO_ARCH_USE_SIGACTION        1
 
index 3de7f0b0e2b68ee40b27e96f8b6ba4eb61c5beef..62545a57e87c29fd89ae5f9e83c1b1d6371c6d29 100644 (file)
@@ -74,6 +74,7 @@ typedef struct
 #define MONO_ARCH_SIGNAL_STACK_SIZE            256*1024
 #define MONO_ARCH_HAVE_DECOMPOSE_OPTS 1
 // #define MONO_ARCH_HAVE_THROW_CORLIB_EXCEPTION       1
+#define MONO_ARCH_HAVE_THROW_EXCEPTION_BY_NAME 1
 
 #define MONO_ARCH_USE_SIGACTION        1
 
index 64e3a910bef30829bcb2de63790e61d5773ea804..b7aa6554d576bcd85dc3e225ce9c028ea1b94a9a 100644 (file)
@@ -5448,7 +5448,9 @@ mini_init (const char *filename, const char *runtime_version)
 
        register_icall (mono_get_throw_exception (), "mono_arch_throw_exception", "void object", TRUE);
        register_icall (mono_get_rethrow_exception (), "mono_arch_rethrow_exception", "void object", TRUE);
+#ifdef MONO_ARCH_HAVE_THROW_EXCEPTION_BY_NAME
        register_icall (mono_get_throw_exception_by_name (), "mono_arch_throw_exception_by_name", "void ptr", TRUE); 
+#endif
 #if MONO_ARCH_HAVE_THROW_CORLIB_EXCEPTION
        register_icall (mono_get_throw_corlib_exception (), "mono_arch_throw_corlib_exception", 
                                 "void ptr", TRUE);