From 263f0353d0331318d8488380b630a86233f94456 Mon Sep 17 00:00:00 2001
From: toy <toy>
Date: Thu, 9 Oct 2003 19:04:28 +0000
Subject: [PATCH] Use the new constants lowtagMask, pseudo_atomic_Value, and
 pseudo_atomic_InterruptedValue instead of the bare 7's, 4's, and 3's and 1's
 in the code.

---
 compiler/sparc/macros.lisp | 36 +++++++++++++++++++-----------------
 lisp/gencgc.c              | 19 ++++++++++---------
 lisp/sparc-arch.c          | 14 +++++++-------
 lisp/sparc-assem.S         | 29 ++++++++++++++---------------
 4 files changed, 50 insertions(+), 48 deletions(-)

diff --git a/compiler/sparc/macros.lisp b/compiler/sparc/macros.lisp
index 1de30e8f6..bae6caad6 100644
--- a/compiler/sparc/macros.lisp
+++ b/compiler/sparc/macros.lisp
@@ -5,11 +5,11 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/sparc/macros.lisp,v 1.25 2003/09/22 13:28:26 toy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/sparc/macros.lisp,v 1.26 2003/10/09 19:04:28 toy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
-;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/sparc/macros.lisp,v 1.25 2003/09/22 13:28:26 toy Exp $
+;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/sparc/macros.lisp,v 1.26 2003/10/09 19:04:28 toy Exp $
 ;;;
 ;;; This file contains various useful macros for generating SPARC code.
 ;;;
@@ -570,18 +570,20 @@
 ;;; PSEUDO-ATOMIC -- Handy macro for making sequences look atomic.
 ;;;
 (defmacro pseudo-atomic ((&key (extra 0)) &rest forms)
-  (let ((n-extra (gensym)))
-    `(let ((,n-extra ,extra))
-       ;; Set the pseudo-atomic flag
-       (without-scheduling ()
-	 (inst add alloc-tn 4))
-       ,@forms
-       ;; Reset the pseudo-atomic flag
-       (without-scheduling ()
-	;; Remove the pseudo-atomic flag
-	(inst add alloc-tn (- ,n-extra 4))
-	;; Check to see if pseudo-atomic interrupted flag is set (bit 0 = 1)
-	(inst andcc zero-tn alloc-tn 3)
-	;; The C code needs to process this correctly and fixup alloc-tn.
-	(inst t :ne pseudo-atomic-trap)
-	))))
+  (declare (ignore extra))
+  `(progn
+     ;; Set the pseudo-atomic flag
+     (without-scheduling ()
+       (inst add alloc-tn pseudo-atomic-value))
+     ,@forms
+     ;; Reset the pseudo-atomic flag
+     (without-scheduling ()
+       ;; Remove the pseudo-atomic flag.  (Could do subtraction here,
+       ;; but the disassembler prints some notes based on the add
+       ;; instruction.)
+       (inst add alloc-tn (- pseudo-atomic-value))
+       ;; Check to see if pseudo-atomic interrupted flag is set (bit 0 = 1)
+       (inst andcc zero-tn alloc-tn pseudo-atomic-interrupted-value)
+       ;; The C code needs to process this correctly and fixup alloc-tn.
+       (inst t :ne pseudo-atomic-trap)
+       )))
diff --git a/lisp/gencgc.c b/lisp/gencgc.c
index 5ef3f8cd7..1652616cc 100644
--- a/lisp/gencgc.c
+++ b/lisp/gencgc.c
@@ -7,7 +7,7 @@
  *
  * Douglas Crosher, 1996, 1997, 1998, 1999.
  *
- * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/gencgc.c,v 1.40 2003/10/08 16:49:34 toy Exp $
+ * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/gencgc.c,v 1.41 2003/10/09 19:04:28 toy Exp $
  *
  */
 
@@ -55,24 +55,25 @@
  * This value better not have any bits set there either!
  */
 #define set_alloc_pointer(value) \
-  (current_dynamic_space_free_pointer = (value) | ((unsigned long) current_dynamic_space_free_pointer & 7))
+  (current_dynamic_space_free_pointer = (value) \
+         | ((unsigned long) current_dynamic_space_free_pointer & lowtagMask))
 #define get_alloc_pointer() \
   (current_dynamic_space_free_pointer)
 #define get_binding_stack_pointer() \
   (current_binding_stack_pointer)
 #define get_pseudo_atomic_atomic() \
-  ((unsigned long)current_dynamic_space_free_pointer & 4)
+  ((unsigned long)current_dynamic_space_free_pointer & pseudo_atomic_Value)
 #define set_pseudo_atomic_atomic() \
   (current_dynamic_space_free_pointer \
-   = (lispobj*) ((unsigned long)current_dynamic_space_free_pointer | 4))
+   = (lispobj*) ((unsigned long)current_dynamic_space_free_pointer | pseudo_atomic_Value))
 #define clr_pseudo_atomic_atomic() \
   (current_dynamic_space_free_pointer \
-   = (lispobj*) ((unsigned long) current_dynamic_space_free_pointer & ~4))
+   = (lispobj*) ((unsigned long) current_dynamic_space_free_pointer & ~pseudo_atomic_Value))
 #define get_pseudo_atomic_interrupted() \
-  ((unsigned long) current_dynamic_space_free_pointer & 1)
+  ((unsigned long) current_dynamic_space_free_pointer & pseudo_atomic_InterruptedValue)
 #define clr_pseudo_atomic_interrupted() \
   (current_dynamic_space_free_pointer \
-   = (lispobj*) ((unsigned long) current_dynamic_space_free_pointer & ~1))
+   = (lispobj*) ((unsigned long) current_dynamic_space_free_pointer & ~pseudo_atomic_InterruptedValue))
 
 #else
 #error gencgc is not supported on this platform
@@ -6861,8 +6862,8 @@ void do_pending_interrupt (void);
 char *
 alloc (int nbytes)
 {
-  gc_assert (((unsigned) SymbolValue (CURRENT_REGION_FREE_POINTER) & 0x7) == 0);
-  gc_assert ((nbytes & 0x7) == 0);
+  gc_assert (((unsigned) SymbolValue (CURRENT_REGION_FREE_POINTER) & lowtagMask) == 0);
+  gc_assert ((nbytes & lowtagMask) == 0);
   gc_assert (get_pseudo_atomic_atomic ());
 
   bytes_allocated_sum += nbytes;
diff --git a/lisp/sparc-arch.c b/lisp/sparc-arch.c
index b63770eb7..2d55b60c8 100644
--- a/lisp/sparc-arch.c
+++ b/lisp/sparc-arch.c
@@ -1,6 +1,6 @@
 /*
 
- $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/sparc-arch.c,v 1.14 2003/08/27 16:45:56 toy Exp $
+ $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/sparc-arch.c,v 1.15 2003/10/09 19:04:28 toy Exp $
 
  This code was written as part of the CMU Common Lisp project at
  Carnegie Mellon University, and has been placed in the public domain.
@@ -87,12 +87,12 @@ unsigned char *arch_internal_error_arguments(struct sigcontext *scp)
 
 boolean arch_pseudo_atomic_atomic(struct sigcontext *scp)
 {
-    return (SC_REG(scp, reg_ALLOC) & 4);
+    return (SC_REG(scp, reg_ALLOC) & pseudo_atomic_Value);
 }
 
 void arch_set_pseudo_atomic_interrupted(struct sigcontext *scp)
 {
-    SC_REG(scp, reg_ALLOC) |= 1;
+    SC_REG(scp, reg_ALLOC) |= pseudo_atomic_InterruptedValue;
 }
 
 unsigned long arch_install_breakpoint(void *pc)
@@ -203,13 +203,13 @@ static int pseudo_atomic_trap_p(struct sigcontext *context)
       previnst = pc[-1];
       /*
        * Check to see if the previous instruction was an andcc alloc-tn,
-       * 3, zero-tn instruction.
+       * pseudo_atomic_InterruptedValue, zero-tn instruction.
        */
       if (((previnst >> 30) == 2) && (((previnst >> 19) & 0x3f) == 0x11)
           && (((previnst >> 14) & 0x1f) == reg_ALLOC)
           && (((previnst >> 25) & 0x1f) == reg_ZERO)
           && (((previnst >> 13) & 1) == 1)
-          && ((previnst & 0x1fff) == 3))
+          && ((previnst & 0x1fff) == pseudo_atomic_InterruptedValue))
         {
           result = 1;
         }
@@ -428,7 +428,7 @@ static void sigill_handler(HANDLER_ARGS)
                to fixup up alloc-tn to remove the interrupted flag,
                skip over the trap instruction, and then handle the
                pending interrupt(s). */
-            SC_REG(context, reg_ALLOC) &= ~7;
+            SC_REG(context, reg_ALLOC) &= ~lowtagMask;
             arch_skip_instruction(context);
             interrupt_handle_pending(context);
           }
@@ -483,7 +483,7 @@ static void sigemt_handler(HANDLER_ARGS)
 	    result = op1 - op2;
 	else
 	    result = op1 + op2;
-	SC_REG(context, reg_ALLOC) = result & ~7;
+	SC_REG(context, reg_ALLOC) = result & ~lowtagMask;
 	arch_skip_instruction(context);
 	interrupt_handle_pending(context);
 	return;
diff --git a/lisp/sparc-assem.S b/lisp/sparc-assem.S
index 190eb9f60..17990f57f 100644
--- a/lisp/sparc-assem.S
+++ b/lisp/sparc-assem.S
@@ -51,7 +51,6 @@
 #define store(reg, sym) \
         sethi %hi(sym), reg_L0; st reg, [reg_L0+%lo(sym)]
 
-
 /*
  * Our frame size needs to be large enough to hold our window, 
  * the structure return pointer, and some temp space.  The temp space
@@ -92,7 +91,7 @@ _call_into_lisp:
         set     NIL, reg_NIL
 
 	/* Set the pseudo-atomic flag. */
-	set	4, reg_ALLOC
+	set	pseudo_atomic_Value, reg_ALLOC
 
 	/* Turn off foreign function call. */
         sethi   %hi(_foreign_function_call_active), reg_NL0
@@ -106,8 +105,8 @@ _call_into_lisp:
         load(_current_control_frame_pointer, reg_OCFP)
 
         /* No longer atomic, and check for interrupt. */
-	sub	reg_ALLOC, 4, reg_ALLOC
-	andcc	reg_ALLOC, 3, reg_ZERO
+	sub	reg_ALLOC, pseudo_atomic_Value, reg_ALLOC
+	andcc	reg_ALLOC, pseudo_atomic_InterruptedValue, reg_ZERO
 	tne	trap_PseudoAtomic
 
         /* Pass in the args. */
@@ -142,10 +141,10 @@ lra:
         mov     reg_A0, %i0
 
         /* Turn on pseudo_atomic */
-	add	reg_ALLOC, 4, reg_ALLOC
+	add	reg_ALLOC, pseudo_atomic_Value, reg_ALLOC
 
         /* Store LISP state */
-	andn	reg_ALLOC, 7, reg_NL1
+	andn	reg_ALLOC, lowtagMask, reg_NL1
         store(reg_NL1,_current_dynamic_space_free_pointer)
         store(reg_BSP,_current_binding_stack_pointer)
         store(reg_CSP,_current_control_stack_pointer)
@@ -155,8 +154,8 @@ lra:
         store(reg_NL1,_foreign_function_call_active)
 
         /* Were we interrupted? */
-	sub	reg_ALLOC, 4, reg_ALLOC
-	andcc	reg_ALLOC, 3, reg_ZERO
+	sub	reg_ALLOC, pseudo_atomic_Value, reg_ALLOC
+	andcc	reg_ALLOC, pseudo_atomic_InterruptedValue, reg_ZERO
 	tne	trap_PseudoAtomic
 
         /* Back to C we go. */
@@ -186,7 +185,7 @@ _call_into_c:
         st      reg_CODE, [reg_CFP+8]
 
         /* Turn on pseudo-atomic. */
-	add	reg_ALLOC, 4, reg_ALLOC
+	add	reg_ALLOC, pseudo_atomic_Value, reg_ALLOC
 
 	/* Convert the return address to an offset and save it on the stack. */
 	sub	reg_LIP, reg_CODE, reg_L0
@@ -199,7 +198,7 @@ _call_into_c:
         store(reg_CFP,_current_control_frame_pointer)
 
 	/* Use reg_CFP as a work register, and restore it */
-	andn	reg_ALLOC, 7, reg_CFP
+	andn	reg_ALLOC, lowtagMask, reg_CFP
         store(reg_CFP,_current_dynamic_space_free_pointer)
 		load(_current_control_frame_pointer, reg_CFP)
 
@@ -207,8 +206,8 @@ _call_into_c:
         store(reg_CSP,_foreign_function_call_active)
 
         /* Were we interrupted? */
-	sub	reg_ALLOC, 4, reg_ALLOC
-	andcc	reg_ALLOC, 3, reg_ZERO
+	sub	reg_ALLOC, pseudo_atomic_Value, reg_ALLOC
+	andcc	reg_ALLOC, pseudo_atomic_InterruptedValue, reg_ZERO
 	tne	trap_PseudoAtomic
 
         /* Into C we go. */
@@ -225,7 +224,7 @@ _call_into_c:
         set     NIL, reg_NIL
 
 	/* Atomic. */
-	set	4, reg_ALLOC
+	set	pseudo_atomic_Value, reg_ALLOC
 
         /* No longer in foreign function call. */
         sethi   %hi(_foreign_function_call_active), reg_NL2
@@ -245,8 +244,8 @@ _call_into_c:
 	sub	reg_LIP, type_OtherPointer, reg_LIP
 
         /* No longer atomic. */
-	sub	reg_ALLOC, 4, reg_ALLOC
-	andcc	reg_ALLOC, 3, reg_ZERO
+	sub	reg_ALLOC, pseudo_atomic_Value, reg_ALLOC
+	andcc	reg_ALLOC, pseudo_atomic_InterruptedValue, reg_ZERO
 	tne	trap_PseudoAtomic
 
         /* Reset the lisp stack. */
-- 
GitLab