Merge pull request #2698 from esdrubal/iosxmlarray
[mono.git] / mono / mini / mini-amd64.c
index abafb597fecc07b7eaf3ab31f9ef86e969298378..b1cdaaf8dfe52c3628d5cf17cbd099beac77bf86 100644 (file)
@@ -501,11 +501,11 @@ typedef struct {
        /* Only if storage == ArgValuetypeInReg */
        ArgStorage pair_storage [2];
        gint8 pair_regs [2];
-       /* The size of each pair */
+       /* The size of each pair (bytes) */
        int pair_size [2];
        int nregs;
        /* Only if storage == ArgOnStack */
-       int arg_size;
+       int arg_size; // Bytes, will always be rounded up/aligned to 8 byte boundary
 } ArgInfo;
 
 typedef struct {
@@ -523,16 +523,6 @@ typedef struct {
 
 #define DEBUG(a) if (cfg->verbose_level > 1) a
 
-#ifdef TARGET_WIN32
-static AMD64_Reg_No param_regs [] = { AMD64_RCX, AMD64_RDX, AMD64_R8, AMD64_R9 };
-
-static AMD64_Reg_No return_regs [] = { AMD64_RAX, AMD64_RDX };
-#else
-static AMD64_Reg_No param_regs [] = { AMD64_RDI, AMD64_RSI, AMD64_RDX, AMD64_RCX, AMD64_R8, AMD64_R9 };
-
- static AMD64_Reg_No return_regs [] = { AMD64_RAX, AMD64_RDX };
-#endif
-
 static void inline
 add_general (guint32 *gr, guint32 *stack_size, ArgInfo *ainfo)
 {
@@ -552,12 +542,6 @@ add_general (guint32 *gr, guint32 *stack_size, ArgInfo *ainfo)
     }
 }
 
-#ifdef TARGET_WIN32
-#define FLOAT_PARAM_REGS 4
-#else
-#define FLOAT_PARAM_REGS 8
-#endif
-
 static void inline
 add_float (guint32 *gr, guint32 *stack_size, ArgInfo *ainfo, gboolean is_double)
 {
@@ -3942,21 +3926,6 @@ emit_setup_lmf (MonoCompile *cfg, guint8 *code, gint32 lmf_offset, int cfa_offse
        return code;
 }
 
-#define REAL_PRINT_REG(text,reg) \
-mono_assert (reg >= 0); \
-amd64_push_reg (code, AMD64_RAX); \
-amd64_push_reg (code, AMD64_RDX); \
-amd64_push_reg (code, AMD64_RCX); \
-amd64_push_reg (code, reg); \
-amd64_push_imm (code, reg); \
-amd64_push_imm (code, text " %d %p\n"); \
-amd64_mov_reg_imm (code, AMD64_RAX, printf); \
-amd64_call_reg (code, AMD64_RAX); \
-amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, 3*4); \
-amd64_pop_reg (code, AMD64_RCX); \
-amd64_pop_reg (code, AMD64_RDX); \
-amd64_pop_reg (code, AMD64_RAX);
-
 /* benchmark and set based on cpu */
 #define LOOP_ALIGNMENT 8
 #define bb_is_loop_start(bb) ((bb)->loop_body_start && (bb)->nesting)
@@ -5928,7 +5897,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        amd64_alu_reg_imm (code, X86_CMP, AMD64_RAX, X86_FP_C0);
                        amd64_pop_reg (code, AMD64_RAX);
                        amd64_fstp (code, 0);
-                       EMIT_COND_SYSTEM_EXCEPTION (X86_CC_EQ, FALSE, "ArithmeticException");
+                       EMIT_COND_SYSTEM_EXCEPTION (X86_CC_EQ, FALSE, "OverflowException");
                        amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, 16);
                        break;
                case OP_TLS_GET: {
@@ -7095,11 +7064,15 @@ mono_arch_emit_prolog (MonoCompile *cfg)
        /* Stack alignment check */
 #if 0
        {
+               guint8 *buf;
+
                amd64_mov_reg_reg (code, AMD64_RAX, AMD64_RSP, 8);
                amd64_alu_reg_imm (code, X86_AND, AMD64_RAX, 0xf);
                amd64_alu_reg_imm (code, X86_CMP, AMD64_RAX, 0);
-               x86_branch8 (code, X86_CC_EQ, 2, FALSE);
+               buf = code;
+               x86_branch8 (code, X86_CC_EQ, 1, FALSE);
                amd64_breakpoint (code);
+               amd64_patch (buf, code);
        }
 #endif
 
@@ -7609,8 +7582,7 @@ mono_arch_emit_exceptions (MonoCompile *cfg)
 
                        amd64_patch (patch_info->ip.i + cfg->native_code, code);
 
-                       exc_class = mono_class_from_name (mono_defaults.corlib, "System", patch_info->data.name);
-                       g_assert (exc_class);
+                       exc_class = mono_class_load_from_name (mono_defaults.corlib, "System", patch_info->data.name);
                        throw_ip = patch_info->ip.i;
 
                        //x86_breakpoint (code);