From f7c4343a23173288752298083b225bf3e63f2727 Mon Sep 17 00:00:00 2001
From: wlott <wlott>
Date: Thu, 7 Nov 1991 00:09:29 +0000
Subject: [PATCH] On the RT, we have to explicitly test the gc-trigger when
 allocating instead of catching the page fault.  So instead of having a lot of
 code to handle the page fault, we have a lot of code to handle a conditional
 trap.

---
 ldb/interrupt.c | 15 ++++++++-----
 ldb/rt-arch.c   | 60 ++++++++++++++++++++++++++++++++-----------------
 2 files changed, 50 insertions(+), 25 deletions(-)

diff --git a/ldb/interrupt.c b/ldb/interrupt.c
index 3d973ba2a..f6107ec32 100644
--- a/ldb/interrupt.c
+++ b/ldb/interrupt.c
@@ -1,4 +1,4 @@
-/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/ldb/Attic/interrupt.c,v 1.30 1991/10/22 18:38:06 wlott Exp $ */
+/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/ldb/Attic/interrupt.c,v 1.31 1991/11/07 00:08:17 wlott Exp $ */
 
 /* Interrupt handing magic. */
 
@@ -279,7 +279,6 @@ struct sigcontext *context;
 \****************************************************************/
 
 #ifndef ibmrt
-
 static boolean gc_trigger_hit(context)
      struct sigcontext *context;
 {
@@ -293,15 +292,23 @@ static boolean gc_trigger_hit(context)
 		badaddr < current_dynamic_space + DYNAMIC_SPACE_SIZE);
     }
 }
+#endif
+
 
 boolean interrupt_maybe_gc(context)
 struct sigcontext *context;
 {
-    if (!foreign_function_call_active && gc_trigger_hit(context)) {
+    if (!foreign_function_call_active
+#ifndef ibmrt
+		  && gc_trigger_hit(context)
+#endif
+	) {
 #ifdef mips
 	set_global_pointer(saved_global_pointer);
 #endif
+#ifndef ibmrt
 	clear_auto_gc_trigger();
+#endif
 
 	if (
 #ifdef mips
@@ -332,8 +339,6 @@ struct sigcontext *context;
 	return FALSE;
 }
 
-#endif
-
 /****************************************************************\
 * Noise to install handlers.                                     *
 \****************************************************************/
diff --git a/ldb/rt-arch.c b/ldb/rt-arch.c
index 8f78cc8c4..a08bebcc5 100644
--- a/ldb/rt-arch.c
+++ b/ldb/rt-arch.c
@@ -35,31 +35,51 @@ static sigtrap_handler(signal, code, context)
      int signal, code;
      struct sigcontext *context;
 {
-    switch (*((unsigned short *)context->sc_iar+1)) {
-      case trap_PendingInterrupt:
-	interrupt_handle_pending(context);
-	break;
+    switch (*((char *)context->sc_iar)) {
+      case 0xCC:
+	/* trap-immediate instruction. */
+	switch (*((unsigned short *)context->sc_iar+1)) {
+	  case trap_PendingInterrupt:
+	    interrupt_handle_pending(context);
+	    break;
 
-      case trap_Halt:
-	crap_out("%primitive halt called; the party is over.\n");
+	  case trap_Halt:
+	    crap_out("%primitive halt called; the party is over.\n");
 
-      case trap_Error:
-      case trap_Cerror:
-	interrupt_internal_error(signal, code, context, code==trap_Cerror);
-	break;
+	  case trap_Error:
+	  case trap_Cerror:
+	    interrupt_internal_error(signal, code, context, code==trap_Cerror);
+	    break;
+
+	  case trap_Breakpoint:
+	    sigsetmask(context->sc_mask);
+	    fake_foreign_function_call(context);
+	    handle_breakpoint(signal, code, context);
+	    undo_fake_foreign_function_call(context);
+	    break;
+
+	  case trap_FunctionEndBreakpoint:
+	    sigsetmask(context->sc_mask);
+	    fake_foreign_function_call(context);
+	    handle_function_end_breakpoint(signal, code, context);
+	    undo_fake_foreign_function_call(context);
+	    break;
 
-      case trap_Breakpoint:
-	sigsetmask(context->sc_mask);
-	fake_foreign_function_call(context);
-	handle_breakpoint(signal, code, context);
-	undo_fake_foreign_function_call(context);
+	  default:
+	    interrupt_handle_now(signal, code, context);
+	    break;
+	}
 	break;
 
-      case trap_FunctionEndBreakpoint:
-	sigsetmask(context->sc_mask);
-	fake_foreign_function_call(context);
-	handle_function_end_breakpoint(signal, code, context);
-	undo_fake_foreign_function_call(context);
+      case 0xBE:
+	/* Trap Less Than instruction. */
+	if (SymbolValue(ALLOCATION_POINTER)>SymbolValue(INTERNAL_GC_TRIGGER)) {
+	    SetSymbolValue(INTERNAL_GC_TRIGGER, fixnum(-1));
+	    interrupt_maybe_gc(context);
+	    context->sc_iar += 2;
+	}
+	else
+	    interrupt_handle_now(signal, code, context);
 	break;
 
       default:
-- 
GitLab