From 00695dc7751bb43c586a84066434008585bba62b Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 23 Jun 1987 22:02:41 +0000 Subject: [PATCH] Define new variable `Constant_Top' to mark the upper limit of constant 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 | 13 +++++++------ v7/src/microcode/default.h | 34 ++++++++++++---------------------- v7/src/microcode/extern.h | 3 ++- v7/src/microcode/memmag.c | 15 ++++++++------- v7/src/microcode/stack.h | 12 +++++++----- v7/src/microcode/storage.c | 3 ++- 6 files changed, 38 insertions(+), 42 deletions(-) diff --git a/v7/src/microcode/bchmmg.c b/v7/src/microcode/bchmmg.c index 741a66788..3f724ef49 100644 --- a/v7/src/microcode/bchmmg.c +++ b/v7/src/microcode/bchmmg.c @@ -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() } 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; } diff --git a/v7/src/microcode/default.h b/v7/src/microcode/default.h index c5d6f53be..d702f0e42 100644 --- a/v7/src/microcode/default.h +++ b/v7/src/microcode/default.h @@ -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 -#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 - -/* 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 - + /* Used in BOOT.C */ #ifndef main_type diff --git a/v7/src/microcode/extern.h b/v7/src/microcode/extern.h index 91bf9c4ec..6a318ac59 100644 --- a/v7/src/microcode/extern.h +++ b/v7/src/microcode/extern.h @@ -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 */ diff --git a/v7/src/microcode/memmag.c b/v7/src/microcode/memmag.c index 8db6c3192..6221957ab 100644 --- a/v7/src/microcode/memmag.c +++ b/v7/src/microcode/memmag.c @@ -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; } diff --git a/v7/src/microcode/stack.h b/v7/src/microcode/stack.h index 5c6b44267..6118b9162 100644 --- a/v7/src/microcode/stack.h +++ b/v7/src/microcode/stack.h @@ -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. */ @@ -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() diff --git a/v7/src/microcode/storage.c b/v7/src/microcode/storage.c index 6b6c9381b..55fa1d1fd 100644 --- a/v7/src/microcode/storage.c +++ b/v7/src/microcode/storage.c @@ -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 */ -- 2.25.1