Author: zoltan
Date: 2008-02-17 14:03:42 -0500 (Sun, 17 Feb 2008)
New Revision: 95993

Modified:
   trunk/mono/mono/mini/exceptions-arm.c
Log:
2008-02-09  Zoltan Varga  <[EMAIL PROTECTED]>

        * mini-arm.h mini-arm.c exceptions-arm.c: Modify the exception throwing 
code and
        the IMT code so it is AOT friendly. Enable AOT for methods which call 
interface
        methods.


Modified: trunk/mono/mono/mini/exceptions-arm.c
===================================================================
--- trunk/mono/mono/mini/exceptions-arm.c       2008-02-17 19:02:58 UTC (rev 
95992)
+++ trunk/mono/mono/mini/exceptions-arm.c       2008-02-17 19:03:42 UTC (rev 
95993)
@@ -25,8 +25,6 @@
 #include "mini.h"
 #include "mini-arm.h"
 
-static gboolean arch_handle_exception (MonoContext *ctx, gpointer obj, 
gboolean test_only);
-
 /*
 
 struct sigcontext {
@@ -219,11 +217,11 @@
  * Returns a function pointer which can be used to raise 
  * exceptions. The returned function has the following 
  * signature: void (*func) (MonoException *exc); or
- * void (*func) (char *exc_name);
+ * void (*func) (guint32 ex_token, guint8* ip);
  *
  */
 static gpointer 
-mono_arch_get_throw_exception_generic (guint8 *start, int size, int by_name, 
gboolean rethrow)
+mono_arch_get_throw_exception_generic (guint8 *start, int size, int by_token, 
gboolean rethrow)
 {
        guint8 *code;
        int alloc_size, pos, i;
@@ -234,24 +232,26 @@
        ARM_MOV_REG_REG (code, ARMREG_IP, ARMREG_SP);
        ARM_PUSH (code, MONO_ARM_REGSAVE_MASK);
 
-       if (by_name) {
-               /* r0 has the name of the exception: get the object */
-               ARM_MOV_REG_REG (code, ARMREG_R2, ARMREG_R0);
+       if (by_token) {
+               /* r0 has the type token of the exception: get the object */
+               ARM_PUSH1 (code, ARMREG_R1);
+               ARM_MOV_REG_REG (code, ARMREG_R1, ARMREG_R0);
                code = mono_arm_emit_load_imm (code, ARMREG_R0, 
GPOINTER_TO_UINT (mono_defaults.corlib));
-               code = mono_arm_emit_load_imm (code, ARMREG_R1, 
GPOINTER_TO_UINT ("System"));
-               code = mono_arm_emit_load_imm (code, ARMREG_IP, 
GPOINTER_TO_UINT (mono_exception_from_name));
+               code = mono_arm_emit_load_imm (code, ARMREG_IP, 
GPOINTER_TO_UINT (mono_exception_from_token));
                ARM_MOV_REG_REG (code, ARMREG_LR, ARMREG_PC);
                ARM_MOV_REG_REG (code, ARMREG_PC, ARMREG_IP);
+               ARM_POP1 (code, ARMREG_R1);
        }
 
        /* call throw_exception (exc, ip, sp, int_regs, fp_regs) */
        /* caller sp */
        ARM_ADD_REG_IMM8 (code, ARMREG_R2, ARMREG_SP, 10 * 4); /* 10 saved regs 
*/
        /* exc is already in place in r0 */
-       if (by_name)
-               ARM_LDR_IMM (code, ARMREG_R1, ARMREG_SP, 9 * 4); /* pos on the 
stack were lr was saved */
-       else
+       if (by_token) {
+               /* The caller ip is already in R1 */
+       } else {
                ARM_MOV_REG_REG (code, ARMREG_R1, ARMREG_LR); /* caller ip */
+       }
        /* FIXME: pointer to the saved fp regs */
        /*pos = alloc_size - sizeof (double) * MONO_SAVED_FREGS;
        ppc_addi (code, ppc_r7, ppc_sp, pos);*/
@@ -315,20 +315,37 @@
        return start;
 }
 
+gpointer 
+mono_arch_get_throw_exception_by_name (void)
+{      
+       static guint8* start;
+       static gboolean inited = FALSE;
+       guint8 *code;
+
+       if (inited)
+               return start;
+
+       start = code = mono_global_codeman_reserve (64);
+
+       /* Not used on ARM */
+       ARM_DBRK (code);
+
+       return start;
+}
+
 /**
- * arch_get_throw_exception_by_name:
+ * mono_arch_get_throw_corlib_exception:
  *
  * 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 ()); 
- *
+ * signature: void (*func) (guint32 ex_token, guint32 offset); 
+ * Here, offset is the offset which needs to be substracted from the caller IP 
+ * to get the IP of the throw. Passing the offset has the advantage that it 
+ * needs no relocations in the caller.
+ * On ARM, the ip is passed instead of an offset.
  */
 gpointer 
-mono_arch_get_throw_exception_by_name (void)
+mono_arch_get_throw_corlib_exception (void)
 {
        static guint8 start [168];
        static int inited = 0;

_______________________________________________
Mono-patches maillist  -  Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to