[interp] support stelem for g{,u}int64
[mono.git] / mono / mini / mini-amd64-gsharedvt.c
index aec01c44b08d1b93e93f6a93e7b94e4b41f1357f..c4518da3deda497facfea4dd426603893915f970 100644 (file)
@@ -17,7 +17,6 @@
 #include <mono/metadata/appdomain.h>
 #include <mono/metadata/marshal.h>
 #include <mono/metadata/tabledefs.h>
-#include <mono/metadata/mono-debug-debugger.h>
 #include <mono/metadata/profiler-private.h>
 #include <mono/metadata/gc-internals.h>
 #include <mono/arch/amd64/amd64-codegen.h>
@@ -149,13 +148,11 @@ get_arg_slots (ArgInfo *ainfo, int **out_slots, gboolean is_source_argument)
                src [0] = map_reg (sreg);
                break;
        case ArgValuetypeInReg:
-       case ArgValuetypeAddrInIReg:
                nsrc = ainfo->nregs;
                src = g_malloc (nsrc * sizeof (int));
                for (i = 0; i < ainfo->nregs; ++i)
                        src [i] = map_reg (ainfo->pair_regs [i]);
                break;
-       case ArgValuetypeAddrOnStack:
        case ArgOnStack:
                nsrc = ainfo->arg_size / SLOT_BYTE_SIZE;
                src = g_malloc (nsrc * sizeof (int));
@@ -170,6 +167,18 @@ get_arg_slots (ArgInfo *ainfo, int **out_slots, gboolean is_source_argument)
                src = g_malloc (nsrc * sizeof (int));
                src [0] = map_freg (sreg);
                break;
+       case ArgValuetypeAddrInIReg:
+               nsrc = 1;
+               src = g_malloc (nsrc * sizeof (int));
+               src [0] = map_reg (ainfo->pair_regs [0]);
+               break;
+       case ArgValuetypeAddrOnStack:
+               nsrc = 1;
+               src = g_malloc (nsrc * sizeof (int));
+               // is_source_argument adds 2 because we're skipping over the old BBP and the return address
+               // XXX this is a very fragile setup as changes in alignment for the caller reg array can cause the magic number be 3
+               src [0] = map_stack_slot (sslot + (is_source_argument ? 2 : 0));
+               break;
        default:
                NOT_IMPLEMENTED;
                break;
@@ -503,6 +512,9 @@ mono_arch_get_gsharedvt_call_info (gpointer addr, MonoMethodSignature *normal_si
 
        info->stack_usage = ALIGN_TO (info->stack_usage, MONO_ARCH_FRAME_ALIGNMENT);
 
+       g_free (callee_cinfo);
+       g_free (caller_cinfo);
+
        DEBUG_AMD64_GSHAREDVT_PRINT ("allocated an info at %p stack usage %d\n", info, info->stack_usage);
        return info;
 }