From: Taylor R Campbell <campbell@mumble.net>
Date: Wed, 18 Sep 2019 01:50:37 +0000 (+0000)
Subject: Fix tospace/newspace confusion.
X-Git-Tag: mit-scheme-pucked-10.1.20~11^2~48^2
X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=6be9604d29f64fb0605563183f301798d0a9e2c9;p=mit-scheme.git

Fix tospace/newspace confusion.

This did not manifest in my testing on NetBSD because it happened
that on NetBSD, the tospace and newspace are always separated by more
than 4 GB, so the bogus jmprel32_offset was never used during GC,
e.g.:

   newspace=0x17dd7f8 tospace=0x7f7feeb00000 delta=17523427132673

I suspect it is the cause of Chris's problems on macOS, so this
should fix Chris's issue on macOS and speed things up even more for
everyone.
---

diff --git a/src/microcode/cmpintmd/x86-64.c b/src/microcode/cmpintmd/x86-64.c
index 84b9f6214..bf28fa1f4 100644
--- a/src/microcode/cmpintmd/x86-64.c
+++ b/src/microcode/cmpintmd/x86-64.c
@@ -226,7 +226,8 @@ write_uuo_target (insn_t * target, SCHEME_OBJECT * saddr)
      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]));
+      ptrdiff_t jmprel32_offset =
+	(target - ((const insn_t *) (tospace_to_newspace (&addr[15]))));
       if ((INT32_MIN <= jmprel32_offset) && (jmprel32_offset <= INT32_MAX))
 	{
 	  (addr[10]) = 0xe9;	/* JMP rel32 */