From 689da8bf97534063f1800caf544a694de81d511e Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Mon, 16 Sep 2019 23:50:23 -0700 Subject: [PATCH] Workaround for inexplicable fatal error on macOS. --- src/microcode/cmpintmd/x86-64.c | 38 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/microcode/cmpintmd/x86-64.c b/src/microcode/cmpintmd/x86-64.c index 84b9f6214..8edfd8baa 100644 --- a/src/microcode/cmpintmd/x86-64.c +++ b/src/microcode/cmpintmd/x86-64.c @@ -224,24 +224,26 @@ write_uuo_target (insn_t * target, SCHEME_OBJECT * saddr) But if the target is a compiled closure pointing into a block somewhere else, the block may not have been relocated yet and so we don't know where the PC will be in the newspace. */ - if ((((int64_t *) (newspace_to_tospace (target)))[-1]) == 0) - { - ptrdiff_t jmprel32_offset = (target - (&addr[15])); - if ((INT32_MIN <= jmprel32_offset) && (jmprel32_offset <= INT32_MAX)) - { - (addr[10]) = 0xe9; /* JMP rel32 */ - (* ((int32_t *) (&addr[11]))) = jmprel32_offset; - } - else - { - (addr[10]) = 0x48; /* MOV RAX,imm64 */ - (addr[11]) = 0xb8; - (* ((insn_t **) (&addr[12]))) = target; - (addr[20]) = 0xff; /* JMP RAX */ - (addr[21]) = 0xe0; - } - } - else + + // **** For unknown reasons this optimization doesn't work right on macOS. + // if ((((int64_t *) (newspace_to_tospace (target)))[-1]) == 0) + // { + // ptrdiff_t jmprel32_offset = (target - (&addr[15])); + // if ((INT32_MIN <= jmprel32_offset) && (jmprel32_offset <= INT32_MAX)) + // { + // (addr[10]) = 0xe9; /* JMP rel32 */ + // (* ((int32_t *) (&addr[11]))) = jmprel32_offset; + // } + // else + // { + // (addr[10]) = 0x48; /* MOV RAX,imm64 */ + // (addr[11]) = 0xb8; + // (* ((insn_t **) (&addr[12]))) = target; + // (addr[20]) = 0xff; /* JMP RAX */ + // (addr[21]) = 0xe0; + // } + // } + // else { (addr[10]) = 0x48; /* MOV RAX,-8(RCX) */ (addr[11]) = 0x8b; -- 2.25.1