Eagerly transport list CDRs to linearize lists.
authorJoe Marshall <jmarshall@alum.mit.edu>
Sun, 24 Jan 2016 22:57:50 +0000 (14:57 -0800)
committerJoe Marshall <jmarshall@alum.mit.edu>
Sun, 24 Jan 2016 22:57:50 +0000 (14:57 -0800)
src/microcode/gcloop.c

index 9c2a2190c94bd81f4898a56acff42359ab3b4c01..d7153a725c393d3eec40bb3114cc181c2ac37d5b 100644 (file)
@@ -442,13 +442,23 @@ DEFINE_GC_TUPLE_HANDLER (gc_tuple)
 {
   SCHEME_OBJECT * from = (OBJECT_ADDRESS (tuple));
   SCHEME_OBJECT * new_address = (GC_PRECHECK_FROM (from));
+  if (new_address == 0) {
+    new_address = GC_TRANSPORT_WORDS (from, n_words, false);
+    /* A little hack to localize lists.  Transport CDRs eagerly. */
+    if (n_words == 2) {
+      SCHEME_OBJECT cdr = READ_TOSPACE(new_address + CONS_CDR);
+      while (OBJECT_TYPE(cdr) == TC_LIST &&
+             (GC_PRECHECK_FROM(OBJECT_ADDRESS(cdr)) == 0)) {
+        cdr = READ_TOSPACE(GC_TRANSPORT_WORDS(OBJECT_ADDRESS(cdr), 2, false) +
+                           CONS_CDR);
+      }
+    }
+  }
   return
-    (OBJECT_NEW_ADDRESS (tuple,
-                        ((new_address != 0)
-                         ? new_address
-                         : (GC_TRANSPORT_WORDS (from, n_words, false)))));
+      (OBJECT_NEW_ADDRESS(tuple, new_address));
 }
 
+
 DEFINE_GC_VECTOR_HANDLER (gc_vector)
 {
   SCHEME_OBJECT * from = (OBJECT_ADDRESS (vector));