Define new variable `Constant_Top' to mark the upper limit of constant
authorChris Hanson <org/chris-hanson/cph>
Tue, 23 Jun 1987 22:02:41 +0000 (22:02 +0000)
committerChris Hanson <org/chris-hanson/cph>
Tue, 23 Jun 1987 22:02:41 +0000 (22:02 +0000)
space.  Do not use unallocated parts of constant space for the stack;
the stack size is fixed at the beginning of time.  This fixes a bug in
which the constant space overflowed into the stack space, without
signalling any error.

v7/src/microcode/bchmmg.c
v7/src/microcode/default.h
v7/src/microcode/extern.h
v7/src/microcode/memmag.c
v7/src/microcode/stack.h
v7/src/microcode/storage.c

index 741a66788a0c9126a1357a290959003e9f281ed4..3f724ef492a8badec4d06f4a5f221d2cb3237306 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchmmg.c,v 9.31 1987/06/15 19:25:57 jinx Exp $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchmmg.c,v 9.32 1987/06/23 22:00:37 cph Rel $ */
 
 /* Memory management top level.  Garbage collection to disk.
 
@@ -167,15 +167,16 @@ close_gc_file()
 }
 \f
 void 
-Clear_Memory(Our_Heap_Size, Our_Stack_Size, Our_Constant_Size)
+Clear_Memory (Our_Heap_Size, Our_Stack_Size, Our_Constant_Size)
      int Our_Heap_Size, Our_Stack_Size, Our_Constant_Size;
 {
-  Heap_Top = Heap_Bottom + Our_Heap_Size;
-  Set_Mem_Top(Heap_Top - GC_Reserve);
+  Heap_Top = (Heap_Bottom + Our_Heap_Size);
+  Set_Mem_Top (Heap_Top - GC_Reserve);
   Free = Heap_Bottom;
+  Constant_Top = (Constant_Space + Our_Constant_Size);
   Free_Constant = Constant_Space;
-  Set_Pure_Top();
-  Initialize_Stack();
+  Set_Pure_Top ();
+  Initialize_Stack ();
   return;
 }
 
index c5d6f53be635067ab60cf65291cc12ec55f50d98..d702f0e4288f2c0125e435355754f2a61fd52d81 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/default.h,v 9.24 1987/06/18 19:54:28 jinx Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/default.h,v 9.25 1987/06/23 22:02:41 cph Exp $
  *
  * This file contains default definitions for some hooks which 
  * various machines require.  These machines define these hooks
@@ -80,40 +80,30 @@ extern Pointer Swap_Temp;
 (Swap_Temp = *(P), *(P) = (S), Swap_Temp) 
 #endif
 \f
-#ifndef Set_Pure_Top
 #ifndef USE_STACKLETS
-#define Set_Pure_Top()                         \
-  Align_Float(Free_Constant);                  \
-  Set_Stack_Guard(Free_Constant+STACK_GUARD_SIZE)
-#define Test_Pure_Space_Top(New_Top)           \
-  ((New_Top+STACK_GUARD_SIZE) <= Stack_Pointer)
-#define Absolute_Stack_Base    Free_Constant
+
+#define Absolute_Stack_Base Constant_Top
 
 #ifndef Initialize_Stack
 #define Initialize_Stack()                                             \
+do                                                                     \
+{                                                                      \
   Stack_Top = Highest_Allocated_Address;                               \
   Stack_Pointer = Stack_Top;                                           \
-  Set_Stack_Guard(Free_Constant + STACK_GUARD_SIZE)
+  Set_Stack_Guard (Absolute_Stack_Base + STACK_GUARD_SIZE);            \
+} while (0)
 #endif
 
-#else  /* Stacklets in use */
-
-#define Set_Pure_Top() Align_Float(Free_Constant)
-#define Test_Pure_Space_Top(New_Top)           \
-   (New_Top <= Highest_Allocated_Address)
-#endif
 #endif
-\f
-/* Character IO hooks.  Used extensively. */
 
-#ifndef OS_Put_C
-#define        OS_Put_C                putc
+#ifndef Set_Pure_Top
+#define Set_Pure_Top() Align_Float (Free_Constant)
 #endif
 
-#ifndef OS_Get_C
-#define OS_Get_C               getc
+#ifndef Test_Pure_Space_Top
+#define Test_Pure_Space_Top(New_Top) ((New_Top) <= Constant_Top)
 #endif
-
+\f
 /* Used in BOOT.C */
 
 #ifndef main_type
index 91bf9c4ec9f58ecf141af1fe4b989913094e1606..6a318ac5982d74212fa38b50d64b9299aba81f0a 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/extern.h,v 9.26 1987/06/05 04:13:51 jinx Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/extern.h,v 9.27 1987/06/23 22:01:36 cph Rel $
  *
  * External declarations.
  *
@@ -81,6 +81,7 @@ extern Pointer
  *Free_Stacklets,      /* Free list of stacklets */
  *Constant_Space,      /* Bottom of constant+pure space */
  *Free_Constant,       /* Next free cell in constant+pure area */
+ *Constant_Top,                /* Top of constant+pure space */
  *Heap_Top,            /* Top of current heap space */
  *Heap_Bottom,         /* Bottom of current heap space */
  *Unused_Heap_Top,     /* Top of unused heap for GC */
index 8db6c3192a144b57664a13d691fcb378c7680b60..6221957abe1fb546c7cd58a19bbf05fac5ddd208 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/memmag.c,v 9.29 1987/04/21 15:01:18 cph Exp $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/memmag.c,v 9.30 1987/06/23 22:00:09 cph Rel $ */
 
 /* Memory management top level.
 
@@ -82,17 +82,18 @@ extern void Clear_Memory(), Setup_Memory(), Reset_Memory();
    special: it always points to a cell which is in use. */
 
 void
-Clear_Memory(Our_Heap_Size, Our_Stack_Size, Our_Constant_Size)
+Clear_Memory (Our_Heap_Size, Our_Stack_Size, Our_Constant_Size)
      int Our_Heap_Size, Our_Stack_Size, Our_Constant_Size;
 {
-  Heap_Top = Heap_Bottom + Our_Heap_Size;
+  Heap_Top = (Heap_Bottom + Our_Heap_Size);
   Local_Heap_Base = Heap_Bottom;
-  Unused_Heap_Top = Heap_Bottom + 2*Our_Heap_Size;
-  Set_Mem_Top(Heap_Top - GC_Reserve);
+  Unused_Heap_Top = (Heap_Bottom + (2 * Our_Heap_Size));
+  Set_Mem_Top (Heap_Top - GC_Reserve);
   Free = Heap_Bottom;
+  Constant_Top = (Constant_Space + Our_Constant_Size);
   Free_Constant = Constant_Space;
-  Set_Pure_Top();
-  Initialize_Stack();
+  Set_Pure_Top ();
+  Initialize_Stack ();
   return;
 }
 
index 5c6b44267db535b457c1636c4ec705f808a74a40..6118b9162a3b6bdbe785b4ef28977a65ead83282 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/stack.h,v 9.21 1987/04/16 02:29:23 jinx Exp $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/stack.h,v 9.22 1987/06/23 22:01:13 cph Rel $ */
 
 /* This file contains macros for manipulating stacks and stacklets. */
 \f
@@ -234,17 +234,19 @@ Pushed()
 /* Full size stack in a statically allocated area */
 
 #define Stack_Check(P)                                                 \
+do                                                                     \
 {                                                                      \
   if ((P) <= Stack_Guard)                                              \
-    { if ((P) <= Absolute_Stack_Base)                                  \
+    {                                                                  \
+      if ((P) <= Absolute_Stack_Base)                                  \
        Microcode_Termination (TERM_STACK_OVERFLOW);                    \
       Request_Interrupt (INT_Stack_Overflow);                          \
     }                                                                  \
-}
+} while (0)
 
-#define Internal_Will_Push(N)          Stack_Check(Stack_Pointer - (N))
+#define Internal_Will_Push(N) Stack_Check(Stack_Pointer - (N))
 
-#define Stack_Allocation_Size(Stack_Blocks)    (Stack_Blocks)
+#define Stack_Allocation_Size(Stack_Blocks) (Stack_Blocks)
 
 #define Terminate_Old_Stacklet()
 
index 6b6c9381b5418a392fe3285d9365d9a7034925fa..55fa1d1fd580f5c9d6105e6ea6b3738ad8a0775e 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/storage.c,v 9.34 1987/06/05 04:15:27 jinx Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/storage.c,v 9.35 1987/06/23 22:01:53 cph Rel $
 
 This file defines the storage for global variables for
 the Scheme Interpreter. */
@@ -52,6 +52,7 @@ Pointer
  *Free_Stacklets,      /* Free list of stacklets */
  *Constant_Space,      /* Bottom of constant+pure space */
  *Free_Constant,       /* Next free cell in constant+pure area */
+ *Constant_Top,                /* Top of constant+pure space */
  *Heap_Top,            /* Top of current heap */
  *Heap_Bottom,         /* Bottom of current heap */
  *Unused_Heap_Top,     /* Top of other heap */