[jit] Fix an unpatched jump in the monitor exit trampoline on amd64.
[mono.git] / mono / mini / mini-x86.c
index 7f213efd28da480380e4a6098b60a75866c25a08..8328084702c68fd9cd9996d1037e93d9d56042d1 100644 (file)
@@ -392,12 +392,10 @@ get_call_info_internal (MonoGenericSharingContext *gsctx, CallInfo *cinfo, MonoM
        {
                ret_type = mini_type_get_underlying_type (gsctx, sig->ret);
                switch (ret_type->type) {
-               case MONO_TYPE_BOOLEAN:
                case MONO_TYPE_I1:
                case MONO_TYPE_U1:
                case MONO_TYPE_I2:
                case MONO_TYPE_U2:
-               case MONO_TYPE_CHAR:
                case MONO_TYPE_I4:
                case MONO_TYPE_U4:
                case MONO_TYPE_I:
@@ -517,14 +515,12 @@ get_call_info_internal (MonoGenericSharingContext *gsctx, CallInfo *cinfo, MonoM
                }
                ptype = mini_type_get_underlying_type (gsctx, sig->params [i]);
                switch (ptype->type) {
-               case MONO_TYPE_BOOLEAN:
                case MONO_TYPE_I1:
                case MONO_TYPE_U1:
                        add_general (&gr, param_regs, &stack_size, ainfo);
                        break;
                case MONO_TYPE_I2:
                case MONO_TYPE_U2:
-               case MONO_TYPE_CHAR:
                        add_general (&gr, param_regs, &stack_size, ainfo);
                        break;
                case MONO_TYPE_I4:
@@ -590,17 +586,20 @@ get_call_info_internal (MonoGenericSharingContext *gsctx, CallInfo *cinfo, MonoM
                add_general (&gr, param_regs, &stack_size, &cinfo->sig_cookie);
        }
 
+       if (cinfo->vtype_retaddr) {
+               /* if the function returns a struct on stack, the called method already does a ret $0x4 */
+               cinfo->callee_stack_pop = 4;
+       } else if (CALLCONV_IS_STDCALL (sig) && sig->pinvoke) {
+               /* Have to compensate for the stack space popped by the native callee */
+               cinfo->callee_stack_pop = stack_size;
+       }
+
        if (mono_do_x86_stack_align && (stack_size % MONO_ARCH_FRAME_ALIGNMENT) != 0) {
                cinfo->need_stack_align = TRUE;
                cinfo->stack_align_amount = MONO_ARCH_FRAME_ALIGNMENT - (stack_size % MONO_ARCH_FRAME_ALIGNMENT);
                stack_size += cinfo->stack_align_amount;
        }
 
-       if (cinfo->vtype_retaddr) {
-               /* if the function returns a struct on stack, the called method already does a ret $0x4 */
-               cinfo->callee_stack_pop = 4;
-       }
-
        cinfo->stack_usage = stack_size;
        cinfo->reg_usage = gr;
        cinfo->freg_usage = fr;
@@ -3383,6 +3382,10 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        x86_ret (code);
                        break;
                }
+               case OP_GET_EX_OBJ:
+                       if (ins->dreg != X86_EAX)
+                               x86_mov_reg_reg (code, ins->dreg, X86_EAX, sizeof (gpointer));
+                       break;
 
                case OP_LABEL:
                        ins->inst_c0 = code - cfg->native_code;