Extract the code to emit a memory barrier. Add a memory_barrier_kind field to MonoIns...
[mono.git] / mono / mini / mini-sparc.c
index eb94c7c862b2c0a1480b51266c098b00f931e09f..3812922658cf17d15a51b63439ee302e20a99c5f 100644 (file)
@@ -504,6 +504,8 @@ get_call_info (MonoCompile *cfg, MonoMethodSignature *sig, gboolean is_pinvoke)
                /* The address of the return value is passed in %o0 */
                add_general (&gr, &stack_size, &cinfo->ret, FALSE);
                cinfo->ret.reg += sparc_i0;
+               /* FIXME: Pass this after this as on other platforms */
+               NOT_IMPLEMENTED;
        }
 #endif
 
@@ -2257,84 +2259,6 @@ mono_sparc_is_virtual_call (guint32 *code)
        return FALSE;
 }
 
-/*
- * mono_arch_get_vcall_slot:
- *
- *  Determine the vtable slot used by a virtual call.
- */
-gpointer
-mono_arch_get_vcall_slot (guint8 *code8, mgreg_t *regs, int *displacement)
-{
-       guint32 *code = (guint32*)(gpointer)code8;
-       guint32 ins = code [0];
-       guint32 prev_ins = code [-1];
-
-       mono_sparc_flushw ();
-
-       *displacement = 0;
-
-       if (!mono_sparc_is_virtual_call (code))
-               return NULL;
-
-       if ((sparc_inst_op (ins) == 0x2) && (sparc_inst_op3 (ins) == 0x38)) {
-               if ((sparc_inst_op (prev_ins) == 0x3) && (sparc_inst_i (prev_ins) == 1) && (sparc_inst_op3 (prev_ins) == 0 || sparc_inst_op3 (prev_ins) == 0xb)) {
-                       /* ld [r1 + CONST ], r2; call r2 */
-                       guint32 base = sparc_inst_rs1 (prev_ins);
-                       gint32 disp = (((gint32)(sparc_inst_imm13 (prev_ins))) << 19) >> 19;
-                       gpointer base_val;
-
-                       g_assert (sparc_inst_rd (prev_ins) == sparc_inst_rs1 (ins));
-
-                       g_assert ((base >= sparc_o0) && (base <= sparc_i7));
-
-                       base_val = regs [base];
-
-                       *displacement = disp;
-
-                       return (gpointer)base_val;
-               }
-               else if ((sparc_inst_op (prev_ins) == 0x3) && (sparc_inst_i (prev_ins) == 0) && (sparc_inst_op3 (prev_ins) == 0)) {
-                       /* set r1, ICONST; ld [r1 + r2], r2; call r2 */
-                       /* Decode a sparc_set32 */
-                       guint32 base = sparc_inst_rs1 (prev_ins);
-                       guint32 disp;
-                       gpointer base_val;
-                       guint32 s1 = code [-3];
-                       guint32 s2 = code [-2];
-
-#ifdef SPARCV9
-                       NOT_IMPLEMENTED;
-#endif
-
-                       /* sparc_sethi */
-                       g_assert (sparc_inst_op (s1) == 0);
-                       g_assert (sparc_inst_op2 (s1) == 4);
-
-                       /* sparc_or_imm */
-                       g_assert (sparc_inst_op (s2) == 2);
-                       g_assert (sparc_inst_op3 (s2) == 2);
-                       g_assert (sparc_inst_i (s2) == 1);
-                       g_assert (sparc_inst_rs1 (s2) == sparc_inst_rd (s2));
-                       g_assert (sparc_inst_rd (s1) == sparc_inst_rs1 (s2));
-
-                       disp = ((s1 & 0x3fffff) << 10) | sparc_inst_imm13 (s2);
-
-                       g_assert ((base >= sparc_o0) && (base <= sparc_i7));
-
-                       base_val = regs [base];
-
-                       *displacement = disp;
-
-                       return (gpointer)base_val;
-               } else
-                       g_assert_not_reached ();
-       }
-       else
-               g_assert_not_reached ();
-
-       return NULL;
-}
-
 #define CMP_SIZE 3
 #define BR_SMALL_SIZE 2
 #define BR_LARGE_SIZE 2
@@ -2392,8 +2316,12 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
                                item->jmp_code = (guint8*)code;
                                sparc_branch (code, 0, sparc_bne, 0);
                                sparc_nop (code);
-                               sparc_set (code, ((guint32)(&(vtable->vtable [item->value.vtable_slot]))), sparc_g5);
-                               sparc_ld (code, sparc_g5, 0, sparc_g5);
+                               if (item->has_target_code) {
+                                       sparc_set (code, item->value.target_code, sparc_f5);
+                               } else {
+                                       sparc_set (code, ((guint32)(&(vtable->vtable [item->value.vtable_slot]))), sparc_g5);
+                                       sparc_ld (code, sparc_g5, 0, sparc_g5);
+                               }
                                sparc_jmpl (code, sparc_g5, sparc_g0, sparc_g0);
                                sparc_nop (code);
 
@@ -2453,7 +2381,7 @@ mono_arch_find_imt_method (mgreg_t *regs, guint8 *code)
 }
 
 gpointer
-mono_arch_get_this_arg_from_call (MonoGenericSharingContext *gsctx, MonoMethodSignature *sig, mgreg_t *regs, guint8 *code)
+mono_arch_get_this_arg_from_call (mgreg_t *regs, guint8 *code)
 {
        mono_sparc_flushw ();
 
@@ -3752,7 +3680,7 @@ mono_arch_register_lowlevel_calls (void)
 }
 
 void
-mono_arch_patch_code (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors)
+mono_arch_patch_code (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, MonoCodeManager *dyn_code_mp, gboolean run_cctors)
 {
        MonoJumpInfo *patch_info;
 
@@ -4192,7 +4120,7 @@ mono_arch_emit_epilog (MonoCompile *cfg)
        while (cfg->code_len + max_epilog_size > (cfg->code_size - 16)) {
                cfg->code_size *= 2;
                cfg->native_code = g_realloc (cfg->native_code, cfg->code_size);
-               mono_jit_stats.code_reallocs++;
+               cfg->stat_code_reallocs++;
        }
 
        code = (guint32*)(cfg->native_code + cfg->code_len);
@@ -4282,7 +4210,7 @@ mono_arch_emit_exceptions (MonoCompile *cfg)
        while (cfg->code_len + code_size > (cfg->code_size - 16)) {
                cfg->code_size *= 2;
                cfg->native_code = g_realloc (cfg->native_code, cfg->code_size);
-               mono_jit_stats.code_reallocs++;
+               cfg->stat_code_reallocs++;
        }
 
        code = (guint32*)(cfg->native_code + cfg->code_len);
@@ -4504,7 +4432,7 @@ MonoInst* mono_arch_get_domain_intrinsic (MonoCompile* cfg)
        return NULL;
 }
 
-gpointer
+mgreg_t
 mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
 {
        /* FIXME: implement */