Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / tramp-amd64.c
index 53e3bc2e834c53dd39f310e66e6f4da222d49f72..365b0ae81630cb6ef7d753bb016931ba1d2bcaf6 100644 (file)
@@ -144,6 +144,7 @@ mono_arch_patch_callsite (guint8 *method_start, guint8 *orig_code, guint8 *addr)
        if (((code [-13] == 0x49) && (code [-12] == 0xbb)) || (code [-5] == 0xe8)) {
                if (code [-5] != 0xe8) {
                        if (can_write) {
+                               g_assert ((guint64)(orig_code - 11) % 8 == 0);
                                InterlockedExchangePointer ((gpointer*)(orig_code - 11), addr);
                                VALGRIND_DISCARD_TRANSLATIONS (orig_code - 11, sizeof (gpointer));
                        }
@@ -705,8 +706,10 @@ mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info
 
        g_free (rgctx_null_jumps);
 
-       /* move the rgctx pointer to the VTABLE register */
-       amd64_mov_reg_reg (code, MONO_ARCH_VTABLE_REG, AMD64_ARG_REG1, sizeof(gpointer));
+       if (MONO_ARCH_VTABLE_REG != AMD64_ARG_REG1) {
+               /* move the rgctx pointer to the VTABLE register */
+               amd64_mov_reg_reg (code, MONO_ARCH_VTABLE_REG, AMD64_ARG_REG1, sizeof(gpointer));
+       }
 
        if (aot) {
                code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));