[amd64] Add some of the missing bits of gsharedvt.
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 8 Dec 2015 21:35:48 +0000 (16:35 -0500)
committerRodrigo Kumpera <kumpera@gmail.com>
Fri, 15 Jan 2016 21:26:01 +0000 (16:26 -0500)
This was enough to get mscorlib to FullAOT with gsharedvt enabled.

Makefile.am.in:
Don't exclude GSHAREDVT from the tests.
Removed DYNCALL too, as it's supported too.

mini-amd64.c (mono_arch_init):
Register mono_amd64_start_gsharedvt_call jit icall.

mini-amd64.c:
Fix a typo in the ifdef guarding inclusion of the gsharedvt extension.

mini-amd64.c (mono_arch_emit_outarg_vt):
Implement decomposing of ArgGSharedVtOnStack to a simple store on the stack.

mini-amd64.h:
define MONO_ARCH_GSHAREDVT_SUPPORTED
Export mono_amd64_start_gsharedvt_call

tramp-amd64.c (mono_arch_create_sdb_trampoline):
Add missing mono_profiler_code_buffer_new call.
Add a couple of functions to !ENABLE_GSHAREDVT

aot-compiler.c (arch_emit_gsharedvt_arg_trampoline):
Implement it for amd64 as a pair of GOT loads (same for other archs).

mono/mini/Makefile.am.in
mono/mini/aot-compiler.c
mono/mini/mini-amd64.c
mono/mini/mini-amd64.h
mono/mini/tramp-amd64.c

index 8d320c4e4c878c822f764f8adbfa010bdc03d060..17de03c02481664d3729f175cc97f36eb4376511 100755 (executable)
@@ -480,7 +480,6 @@ if AMD64
 arch_sources = $(amd64_sources)
 arch_built=cpu-amd64.h
 arch_define=__x86_64__
-ARCH_FULLAOT_EXCLUDE=--exclude DYNCALL --exclude GSHAREDVT
 endif
 
 if POWERPC
index b1b0c5b1d8e4803bec401d6c7cfdce673f61bbba..40f4e473666796b838d8054b802c7ac78faf7449 100644 (file)
@@ -2141,6 +2141,22 @@ arch_emit_imt_thunk (MonoAotCompile *acfg, int offset, int *tramp_size)
 #endif
 }
 
+
+#if defined (TARGET_AMD64)
+
+static void
+amd64_emit_load_got_slot (MonoAotCompile *acfg, int dreg, int got_slot)
+{
+
+       g_assert (acfg->fp);
+       emit_unset_mode (acfg);
+
+       fprintf (acfg->fp, "mov %s+%d(%%rip), %s\n", acfg->got_symbol, (unsigned int) ((got_slot * sizeof (gpointer))), mono_arch_regname (dreg));
+}
+
+#endif
+
+
 /*
  * arch_emit_gsharedvt_arg_trampoline:
  *
@@ -2206,6 +2222,14 @@ arch_emit_gsharedvt_arg_trampoline (MonoAotCompile *acfg, int offset, int *tramp
        emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (gpointer)) + 4);
 #elif defined(TARGET_ARM64)
        arm64_emit_gsharedvt_arg_trampoline (acfg, offset, tramp_size);
+#elif defined (TARGET_AMD64)
+
+       amd64_emit_load_got_slot (acfg, AMD64_RAX, offset);
+       amd64_emit_load_got_slot (acfg, MONO_ARCH_IMT_SCRATCH_REG, offset + 1);
+       g_assert (AMD64_R11 == MONO_ARCH_IMT_SCRATCH_REG);
+       fprintf (acfg->fp, "jmp *%%r11\n");
+
+       *tramp_size = 0x11;
 #else
        g_assert_not_reached ();
 #endif
index a1e877743ae410b190a1083f1abbe3a355900435..a6e07c05e5b697393af7438a82c77aab7b88c283 100644 (file)
@@ -1461,6 +1461,9 @@ mono_arch_init (void)
        mono_aot_register_jit_icall ("mono_amd64_throw_corlib_exception", mono_amd64_throw_corlib_exception);
        mono_aot_register_jit_icall ("mono_amd64_resume_unwind", mono_amd64_resume_unwind);
        mono_aot_register_jit_icall ("mono_amd64_get_original_ip", mono_amd64_get_original_ip);
+#if defined(ENABLE_GSHAREDVT)
+       mono_aot_register_jit_icall ("mono_amd64_start_gsharedvt_call", mono_amd64_start_gsharedvt_call);
+#endif
 
        if (!mono_aot_only)
                bp_trampoline = mini_get_breakpoint_trampoline ();
@@ -2604,7 +2607,7 @@ mono_arch_emit_outarg_vt (MonoCompile *cfg, MonoInst *ins, MonoInst *src)
                mono_call_inst_add_outarg_reg (cfg, call, src->dreg, ainfo->reg, FALSE);
                break;
        case ArgGSharedVtOnStack:
-               g_assert_not_reached ();
+               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, AMD64_RSP, ainfo->offset, src->dreg);
                break;
        default:
                if (size == 8) {
@@ -8816,4 +8819,4 @@ mono_arch_opcode_supported (int opcode)
 
 #include "../../../mono-extensions/mono/mini/mini-amd64-gsharedvt.c"
 
-#endif /* !MONOTOUCH */
+#endif /* !ENABLE_GSHAREDVT */
index 526e5b00c195d3652e55a35ef1766472b3ed90b5..e0494a42d9abe7c8a2a1541a5aa83d6de7d659cf 100644 (file)
@@ -350,6 +350,7 @@ typedef struct {
 #define MONO_ARCH_HAVE_CONTEXT_SET_INT_REG 1
 #define MONO_ARCH_HAVE_SETUP_ASYNC_CALLBACK 1
 #define MONO_ARCH_HAVE_CREATE_LLVM_NATIVE_THUNK 1
+#define MONO_ARCH_GSHAREDVT_SUPPORTED 1
 #define MONO_ARCH_HAVE_OP_TAIL_CALL 1
 #define MONO_ARCH_HAVE_TRANSLATE_TLS_OFFSET 1
 #define MONO_ARCH_HAVE_DUMMY_INIT 1
@@ -401,6 +402,9 @@ mono_amd64_resume_unwind (guint64 dummy1, guint64 dummy2, guint64 dummy3, guint6
                                                  guint64 dummy5, guint64 dummy6,
                                                  MonoContext *mctx, guint32 dummy7, gint64 dummy8);
 
+gpointer
+mono_amd64_start_gsharedvt_call (GSharedVtCallInfo *info, gpointer *caller, gpointer *callee, gpointer mrgctx_reg);
+
 guint64
 mono_amd64_get_original_ip (void);
 
index 8e054b99dadf150db4a8e4631565b94862e145f9..b89d952ed1774b6ff1b16f147d709c25c6049eb1 100644 (file)
@@ -966,6 +966,7 @@ mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gbo
        amd64_ret (code);
 
        mono_arch_flush_icache (code, code - buf);
+       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
        g_assert (code - buf <= tramp_size);
 
        const char *tramp_name = single_step ? "sdb_single_step_trampoline" : "sdb_breakpoint_trampoline";
@@ -978,4 +979,20 @@ mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gbo
 
 #include "../../../mono-extensions/mono/mini/tramp-amd64-gsharedvt.c"
 
+#else
+
+gpointer
+mono_amd64_start_gsharedvt_call (GSharedVtCallInfo *info, gpointer *caller, gpointer *callee, gpointer mrgctx_reg)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
+gpointer
+mono_arch_get_gsharedvt_trampoline (MonoTrampInfo **info, gboolean aot)
+{
+       *info = NULL;
+       return NULL;
+}
+
 #endif /* !ENABLE_GSHAREDVT */