From: Matt Birkholz <puck@birchwood-abbey.net>
Date: Sat, 25 Jul 2015 21:46:13 +0000 (-0700)
Subject: Punt gc_space_needed when SMPing.  The local heap is empty after GC.
X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=72055968f0e7cce548422f83acc940e7ab4c7d8d;p=mit-scheme.git

Punt gc_space_needed when SMPing.  The local heap is empty after GC.
---

diff --git a/src/microcode/extern.h b/src/microcode/extern.h
index b3f5eca2e..7ea08cdd1 100644
--- a/src/microcode/extern.h
+++ b/src/microcode/extern.h
@@ -197,7 +197,9 @@ extern SCHEME_OBJECT * memory_block_end;
 extern unsigned long heap_reserved;
 
 /* Amount of space needed when GC requested */
+#ifndef ENABLE_SMP
 extern unsigned long gc_space_needed;
+#endif
 
 /* Number of new ephemerons requested from the GC.  */
 extern unsigned long n_ephemerons_requested;
@@ -363,7 +365,9 @@ extern void termination_init_error (void) NORETURN;
 extern void termination_end_of_computation (void) NORETURN;
 extern void termination_trap (void) NORETURN;
 extern void termination_no_error_handler (void) NORETURN;
+#ifndef ENABLE_SMP
 extern void termination_gc_out_of_space (void) NORETURN;
+#endif
 extern void termination_eof (void) NORETURN;
 extern void termination_signal (const char * signal_name) NORETURN;
 
diff --git a/src/microcode/interp.c b/src/microcode/interp.c
index ceed11d13..420bb0d12 100644
--- a/src/microcode/interp.c
+++ b/src/microcode/interp.c
@@ -1076,10 +1076,12 @@ Interpret (int pop_return_p)
 
     case RC_NORMAL_GC_DONE:
       SET_VAL (GET_EXP);
+#ifndef ENABLE_SMP
       /* Paranoia */
       if (GC_NEEDED_P (gc_space_needed))
 	termination_gc_out_of_space ();
       gc_space_needed = 0;
+#endif
       EXIT_CRITICAL_SECTION ({ SAVE_CONT (); });
       break;
 
diff --git a/src/microcode/memmag.c b/src/microcode/memmag.c
index 7a7a56bb0..963565e2b 100644
--- a/src/microcode/memmag.c
+++ b/src/microcode/memmag.c
@@ -486,9 +486,13 @@ the primitive GC daemons before returning.")
 
   Will_Push (CONTINUATION_SIZE);
   SET_RC (RC_NORMAL_GC_DONE);
+#ifndef ENABLE_SMP
   SET_EXP (ULONG_TO_FIXNUM ((HEAP_AVAILABLE > gc_space_needed)
 			    ? (HEAP_AVAILABLE - gc_space_needed)
 			    : 0));
+#else
+  SET_EXP (ULONG_TO_FIXNUM (HEAP_AVAILABLE));
+#endif
   SAVE_CONT ();
   Pushed ();
 
@@ -597,8 +601,10 @@ std_gc_pt2 (void)
 	 (ephemeron_count + n_ephemerons_requested));
     if (EPHEMERON_GC_NEEDED (length, n_ephemerons_requested))
       {
+#ifndef ENABLE_SMP
 	if (ephemeron_request_hard_p)
 	  gc_space_needed += (VECTOR_DATA + length);
+#endif
 	length = (compute_ephemeron_array_length (ephemeron_count));
 #ifdef ENABLE_GC_DEBUGGING_TOOLS
 	/* This should never trigger, because we discard the previous
diff --git a/src/microcode/memmag.h b/src/microcode/memmag.h
index ebe2866b4..c4c6653cf 100644
--- a/src/microcode/memmag.h
+++ b/src/microcode/memmag.h
@@ -61,11 +61,18 @@ USA.
    ? ((unsigned long) (heap_end - Free))				\
    : 0)
 
+#ifndef ENABLE_SMP
 #define REQUEST_GC(n_words) do						\
 {									\
   REQUEST_INTERRUPT (INT_GC);						\
   gc_space_needed = (n_words);						\
 } while (0)
+#else
+#define REQUEST_GC(n_words) do						\
+{									\
+  REQUEST_INTERRUPT (INT_GC);						\
+} while (0)
+#endif
 
 #define RESET_HEAP_ALLOC_LIMIT() do					\
 {									\
diff --git a/src/microcode/purify.c b/src/microcode/purify.c
index 3aba0e697..e1c88867e 100644
--- a/src/microcode/purify.c
+++ b/src/microcode/purify.c
@@ -75,11 +75,15 @@ PURE? is ignored.")
 
  Will_Push (CONTINUATION_SIZE);
   SET_RC (RC_NORMAL_GC_DONE);
+#ifndef ENABLE_SMP
   SET_EXP
     (cons (SHARP_T,
 	   (ULONG_TO_FIXNUM ((HEAP_AVAILABLE > gc_space_needed)
 			     ? (HEAP_AVAILABLE - gc_space_needed)
 			     : 0))));
+#else
+  SET_EXP (cons (SHARP_T, (ULONG_TO_FIXNUM (HEAP_AVAILABLE))));
+#endif
   SAVE_CONT ();
  Pushed ();
 
diff --git a/src/microcode/storage.c b/src/microcode/storage.c
index ab97ddd77..dec79782c 100644
--- a/src/microcode/storage.c
+++ b/src/microcode/storage.c
@@ -94,8 +94,10 @@ SCHEME_OBJECT * memory_block_end;
 
 unsigned long heap_reserved;
 
+#ifndef ENABLE_SMP
 /* Amount of space needed when GC requested */
 unsigned long gc_space_needed;
+#endif
 
 /* Number of new ephemerons requested from the GC.  */
 unsigned long n_ephemerons_requested;
diff --git a/src/microcode/term.c b/src/microcode/term.c
index 5af7fc6c0..53a1be120 100644
--- a/src/microcode/term.c
+++ b/src/microcode/term.c
@@ -232,6 +232,7 @@ termination_no_error_handler (void)
   termination_suffix (TERM_NO_ERROR_HANDLER, 1, true);
 }
 
+#ifndef ENABLE_SMP
 void
 termination_gc_out_of_space (void)
 {
@@ -246,6 +247,7 @@ termination_gc_out_of_space (void)
 	      gc_space_needed, HEAP_AVAILABLE);
   termination_suffix_trace (TERM_GC_OUT_OF_SPACE);
 }
+#endif
 
 void
 termination_eof (void)