From 60dc9ee0a55c7b98ff49f105a4699f044bf2954d Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sat, 26 Sep 1992 02:55:06 +0000 Subject: [PATCH] Change `(Registers[REGBLOCK_STACK_GUARD])' to be a cache for the C variable `Stack_Guard'. Change COMPILER_SETUP_INTERRUPT so that compiled code doesn't signal GC or stack-overflow interrupts when the corresponding interrupt enable bit is not set. Change compiled-code interface to assume this, and eliminate back-out code; this eliminates the _SKIPPED_CHECK_OFFSET constants built into the microcode, allowing the compiled code more coding flexibility. --- v7/src/microcode/cmpint.c | 161 +++++++++++------------------- v7/src/microcode/cmpintmd/alpha.h | 6 +- v7/src/microcode/cmpintmd/hppa.h | 8 +- v7/src/microcode/cmpintmd/i386.h | 5 +- v7/src/microcode/cmpintmd/mc68k.h | 8 +- v7/src/microcode/cmpintmd/mips.h | 8 +- v7/src/microcode/cmpintmd/vax.h | 8 +- v7/src/microcode/default.h | 4 +- v7/src/microcode/dossig.c | 5 +- v7/src/microcode/extern.h | 3 +- v7/src/microcode/gc.h | 25 ++--- v7/src/microcode/interp.c | 8 +- v7/src/microcode/interp.h | 3 +- v7/src/microcode/intrpt.h | 57 +++++------ v7/src/microcode/stack.h | 8 +- v7/src/microcode/storage.c | 3 +- v7/src/microcode/utils.c | 6 +- v7/src/microcode/version.h | 4 +- v8/src/microcode/cmpint.c | 161 +++++++++++------------------- v8/src/microcode/cmpintmd/hppa.h | 8 +- v8/src/microcode/interp.c | 8 +- v8/src/microcode/version.h | 4 +- 22 files changed, 195 insertions(+), 316 deletions(-) diff --git a/v7/src/microcode/cmpint.c b/v7/src/microcode/cmpint.c index 2ccfc3829..2febecfef 100644 --- a/v7/src/microcode/cmpint.c +++ b/v7/src/microcode/cmpint.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: cmpint.c,v 1.49 1992/09/11 02:04:05 cph Exp $ +$Id: cmpint.c,v 1.50 1992/09/26 02:54:55 cph Exp $ Copyright (c) 1989-92 Massachusetts Institute of Technology @@ -40,7 +40,6 @@ MIT in each case. */ * */ -#ifdef HAS_COMPILER_SUPPORT /* * Procedures in this file belong to the following categories: * @@ -98,6 +97,8 @@ MIT in each case. */ #include "prim.h" /* Primitive_Procedure_Table, etc. */ #define IN_CMPINT_C #include "cmpgc.h" /* Compiled code object relocation */ + +#ifdef HAS_COMPILER_SUPPORT #ifndef FLUSH_I_CACHE_REGION # define FLUSH_I_CACHE_REGION(addr, nwords) NOP() @@ -1335,116 +1336,76 @@ DEFUN (comutil_operator_4_0_trap, } /* INTERRUPT/GC from Scheme - The next four procedures are called from compiled code at the start - (respectively) of a closure, continuation, interpreter compatible - procedure, or ordinary (not closed) procedure if an interrupt has - been detected. They return to the interpreter if the interrupt is - invalid after saving the state necessary to restart the compiled - code. - - The code that handles RC_COMP_INTERRUPT_RESTART in interp.c will - return control to comp_interrupt_restart (below). This assumes - that the Scheme stack contains a compiled code entry address (start - of continuation, procedure, etc.). The Expression register saved - with the continuation is a piece of state that will be returned to - Val and Env (both) upon return. -*/ -#define GC_DESIRED_P() (Free >= MemTop) + These procedures are called from compiled code at the start + (respectively) of a procedure or continuation if an interrupt has + been detected. They must not be called unless there is an + interrupt to be serviced. -#define TEST_GC_NEEDED() \ -{ \ - if (GC_DESIRED_P()) \ - { \ - Request_GC(Free-MemTop); \ - } \ -} + The code that handles RC_COMP_INTERRUPT_RESTART in "interp.c" will + return control to comp_interrupt_restart (below). This assumes + that the Scheme stack contains a compiled code entry address + (start of continuation, procedure, etc.). The Expression register + saved with the continuation is a piece of state that will be + returned to Val and Env (both) upon return. -/* Called with no arguments, closure at top of (Scheme) stack. - If the interrupt is disabled, the closure is re-invoked. - */ -SCHEME_UTILITY struct utility_result -DEFUN (comutil_interrupt_closure, - (ignore_1, ignore_2, ignore_3, ignore_4), - long ignore_1 AND long ignore_2 AND long ignore_3 AND long ignore_4) -{ - TEST_GC_NEEDED (); - Stack_Check (Stack_Pointer); - if ((PENDING_INTERRUPTS()) == 0) - { - SCHEME_OBJECT entry_point; + */ - EXTRACT_CLOSURE_ENTRY_ADDRESS (entry_point, - (OBJECT_ADDRESS (STACK_REF (0)))); - ADJUST_CLOSURE_AT_CALL (entry_point, (STACK_REF (0))); - RETURN_TO_SCHEME (((instruction *) entry_point) + - CLOSURE_SKIPPED_CHECK_OFFSET); - } - else - { - /* Return to interpreter to handle interrupt */ - - STACK_PUSH (SHARP_F); - Store_Expression (SHARP_F); - Store_Return (RC_COMP_INTERRUPT_RESTART); - Save_Cont (); - RETURN_TO_C (PRIM_INTERRUPT); - } +#define MAYBE_REQUEST_INTERRUPTS() \ +{ \ + if (Free >= MemTop) \ + Request_GC (Free - MemTop); \ + if (Stack_Pointer <= Stack_Guard) \ + REQUEST_INTERRUPT (INT_Stack_Overflow); \ } - -/* State is the live data; no entry point on the stack. - */ static struct utility_result -DEFUN (compiler_interrupt_common, - (entry_point, offset, state), - instruction *entry_point AND - long offset AND +DEFUN (compiler_interrupt_common, (entry_point, state), + instruction * entry_point AND SCHEME_OBJECT state) { - TEST_GC_NEEDED (); - Stack_Check (Stack_Pointer); - if ((PENDING_INTERRUPTS()) == 0) - { - Store_Env (state); - Val = state; - RETURN_TO_SCHEME (entry_point + offset); - } - else - { + MAYBE_REQUEST_INTERRUPTS (); + if (entry_point != 0) STACK_PUSH (ENTRY_TO_OBJECT (entry_point)); - STACK_PUSH (state); - Store_Expression (SHARP_F); - Store_Return (RC_COMP_INTERRUPT_RESTART); - Save_Cont (); - RETURN_TO_C (PRIM_INTERRUPT); - } + STACK_PUSH (state); + Store_Expression (SHARP_F); + Store_Return (RC_COMP_INTERRUPT_RESTART); + Save_Cont (); + RETURN_TO_C (PRIM_INTERRUPT); } SCHEME_UTILITY struct utility_result -DEFUN (comutil_interrupt_dlink, - (entry_point, dlink, ignore_3, ignore_4), - instruction * entry_point - AND SCHEME_OBJECT * dlink - AND long ignore_3 AND long ignore_4) +DEFUN (comutil_interrupt_closure, (ignore_1, ignore_2, ignore_3, ignore_4), + long ignore_1 AND + long ignore_2 AND + long ignore_3 AND + long ignore_4) +{ + return (compiler_interrupt_common (0, SHARP_F)); +} + +SCHEME_UTILITY struct utility_result +DEFUN (comutil_interrupt_dlink, (entry_point, dlink, ignore_3, ignore_4), + instruction * entry_point AND + SCHEME_OBJECT * dlink AND + long ignore_3 AND + long ignore_4) { return - (compiler_interrupt_common(entry_point, - ENTRY_SKIPPED_CHECK_OFFSET, - MAKE_POINTER_OBJECT(TC_STACK_ENVIRONMENT, - dlink))); + (compiler_interrupt_common + (entry_point, (MAKE_POINTER_OBJECT (TC_STACK_ENVIRONMENT, dlink)))); } SCHEME_UTILITY struct utility_result DEFUN (comutil_interrupt_procedure, (entry_point, ignore_2, ignore_3, ignore_4), - instruction * entry_point - AND long ignore_2 AND long ignore_3 AND long ignore_4) + instruction * entry_point AND + long ignore_2 AND + long ignore_3 AND + long ignore_4) { - return (compiler_interrupt_common(entry_point, - ENTRY_SKIPPED_CHECK_OFFSET, - SHARP_F)); + return (compiler_interrupt_common (entry_point, SHARP_F)); } /* Val has live data, and there is no entry address on the stack */ @@ -1452,12 +1413,12 @@ DEFUN (comutil_interrupt_procedure, SCHEME_UTILITY struct utility_result DEFUN (comutil_interrupt_continuation, (return_address, ignore_2, ignore_3, ignore_4), - instruction * return_address - AND long ignore_2 AND long ignore_3 AND long ignore_4) + instruction * return_address AND + long ignore_2 AND + long ignore_3 AND + long ignore_4) { - return (compiler_interrupt_common (return_address, - ENTRY_SKIPPED_CHECK_OFFSET, - Val)); + return (compiler_interrupt_common (return_address, Val)); } /* Env has live data; no entry point on the stack */ @@ -1465,12 +1426,12 @@ DEFUN (comutil_interrupt_continuation, SCHEME_UTILITY struct utility_result DEFUN (comutil_interrupt_ic_procedure, (entry_point, ignore_2, ignore_3, ignore_4), - instruction * entry_point - AND long ignore_2 AND long ignore_3 AND long ignore_4) + instruction * entry_point AND + long ignore_2 AND + long ignore_3 AND + long ignore_4) { - return (compiler_interrupt_common (entry_point, - ENTRY_SKIPPED_CHECK_OFFSET, - (Fetch_Env()))); + return (compiler_interrupt_common (entry_point, (Fetch_Env ()))); } C_TO_SCHEME long diff --git a/v7/src/microcode/cmpintmd/alpha.h b/v7/src/microcode/cmpintmd/alpha.h index ea05e025d..aa7aadb97 100644 --- a/v7/src/microcode/cmpintmd/alpha.h +++ b/v7/src/microcode/cmpintmd/alpha.h @@ -1,6 +1,6 @@ /* -*- C -*- -$Id: alpha.h,v 1.2 1992/08/29 12:53:22 jinx Exp $ +$Id: alpha.h,v 1.3 1992/09/26 02:54:49 cph Exp $ Copyright (c) 1992 Digital Equipment Corporation (D.E.C.) @@ -234,10 +234,6 @@ Code sequence 5 (call interrupt handler): /* The length of code sequence 1, above */ #define ENTRY_PREFIX_LENGTH (2 INSTRUCTIONS) -/* Skip over this many BYTES to bypass the GC check code (ordinary - procedures and continuations differ from closures) */ -#define ENTRY_SKIPPED_CHECK_OFFSET (3 INSTRUCTIONS) /* Code Seq 2 */ -#define CLOSURE_SKIPPED_CHECK_OFFSET (6 INSTRUCTIONS) /* Code Seq 3 */ /* Compiled closures */ diff --git a/v7/src/microcode/cmpintmd/hppa.h b/v7/src/microcode/cmpintmd/hppa.h index 69d20b59a..4416249c5 100644 --- a/v7/src/microcode/cmpintmd/hppa.h +++ b/v7/src/microcode/cmpintmd/hppa.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/cmpintmd/hppa.h,v 1.33 1992/05/23 01:18:45 jinx Exp $ +$Id: hppa.h,v 1.34 1992/09/26 02:54:50 cph Exp $ Copyright (c) 1989-1992 Massachusetts Institute of Technology @@ -417,12 +417,6 @@ DEFUN_VOID (flush_i_cache_initialize) /* Interrupt/GC polling. */ -/* Skip over this many BYTES to bypass the GC check code (ordinary -procedures and continuations differ from closures) */ - -#define ENTRY_SKIPPED_CHECK_OFFSET 4 -#define CLOSURE_SKIPPED_CHECK_OFFSET 16 - /* The length of the GC recovery code that precedes an entry. On the HP-PA a "ble, ldi" instruction sequence. */ diff --git a/v7/src/microcode/cmpintmd/i386.h b/v7/src/microcode/cmpintmd/i386.h index 2273ffcd3..926de11c0 100644 --- a/v7/src/microcode/cmpintmd/i386.h +++ b/v7/src/microcode/cmpintmd/i386.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: i386.h,v 1.18 1992/09/18 02:03:13 jinx Exp $ +$Id: i386.h,v 1.19 1992/09/26 02:54:51 cph Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -218,11 +218,8 @@ typedef unsigned short format_word; /* See the encodings above. */ -#define ENTRY_SKIPPED_CHECK_OFFSET 4 #define ENTRY_PREFIX_LENGTH 3 -#define CLOSURE_SKIPPED_CHECK_OFFSET 11 - # define COMPILED_CLOSURE_ENTRY_SIZE \ ((2 * (sizeof (format_word))) + 6) diff --git a/v7/src/microcode/cmpintmd/mc68k.h b/v7/src/microcode/cmpintmd/mc68k.h index 44ae5a8e5..2129c1827 100644 --- a/v7/src/microcode/cmpintmd/mc68k.h +++ b/v7/src/microcode/cmpintmd/mc68k.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: mc68k.h,v 1.31 1992/09/25 01:19:03 cph Exp $ +$Id: mc68k.h,v 1.32 1992/09/26 02:54:52 cph Exp $ Copyright (c) 1989-1992 Massachusetts Institute of Technology @@ -85,12 +85,6 @@ typedef unsigned short format_word; #define PC_ZERO_BITS 1 -/* Skip over this many BYTES to bypass the GC check code (ordinary -procedures and continuations differ from closures) */ - -#define ENTRY_SKIPPED_CHECK_OFFSET 4 -#define CLOSURE_SKIPPED_CHECK_OFFSET 10 - /* The length of the GC recovery code that precedes an entry. On the 68K a "jsr n(a6)" instruction. */ diff --git a/v7/src/microcode/cmpintmd/mips.h b/v7/src/microcode/cmpintmd/mips.h index 033efad2b..d55a464a9 100644 --- a/v7/src/microcode/cmpintmd/mips.h +++ b/v7/src/microcode/cmpintmd/mips.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: mips.h,v 1.15 1992/08/29 13:30:29 jinx Exp $ +$Id: mips.h,v 1.16 1992/09/26 02:54:53 cph Exp $ Copyright (c) 1989-1992 Massachusetts Institute of Technology @@ -198,12 +198,6 @@ typedef unsigned short format_word; /* Interrupt/GC polling. */ -/* Skip over this many BYTES to bypass the GC check code (ordinary -procedures and continuations differ from closures) */ - -#define ENTRY_SKIPPED_CHECK_OFFSET 12 -#define CLOSURE_SKIPPED_CHECK_OFFSET 28 - /* The length of the GC recovery code that precedes an entry. On the MIPS a "addi, jalr, addi" instruction sequence. */ diff --git a/v7/src/microcode/cmpintmd/vax.h b/v7/src/microcode/cmpintmd/vax.h index 1384b027f..746db0c8b 100644 --- a/v7/src/microcode/cmpintmd/vax.h +++ b/v7/src/microcode/cmpintmd/vax.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/cmpintmd/vax.h,v 1.5 1992/02/12 15:27:27 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/cmpintmd/vax.h,v 1.6 1992/09/26 02:54:54 cph Exp $ Copyright (c) 1991-1992 Massachusetts Institute of Technology @@ -83,12 +83,6 @@ typedef unsigned short format_word; #define PC_ZERO_BITS 0 -/* Skip over this many BYTES to bypass the GC check code (ordinary -procedures and continuations differ from closures) */ - -#define ENTRY_SKIPPED_CHECK_OFFSET 5 -#define CLOSURE_SKIPPED_CHECK_OFFSET 12 - /* The length of the GC recovery code that precedes an entry. On the Vax a "movl s^code,r0; jsb b^n(r10)" sequence. */ diff --git a/v7/src/microcode/default.h b/v7/src/microcode/default.h index 73cd11af8..694de5bea 100644 --- a/v7/src/microcode/default.h +++ b/v7/src/microcode/default.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/default.h,v 9.38 1992/02/10 13:52:06 jinx Exp $ +$Id: default.h,v 9.39 1992/09/26 02:54:57 cph Exp $ Copyright (c) 1988-1992 Massachusetts Institute of Technology @@ -88,7 +88,7 @@ do \ { \ Stack_Top = Highest_Allocated_Address; \ Stack_Pointer = Stack_Top; \ - Set_Stack_Guard (Absolute_Stack_Base + STACK_GUARD_SIZE); \ + SET_STACK_GUARD (Absolute_Stack_Base + STACK_GUARD_SIZE); \ } while (0) #endif diff --git a/v7/src/microcode/dossig.c b/v7/src/microcode/dossig.c index 16cba1bec..3b46a66c1 100644 --- a/v7/src/microcode/dossig.c +++ b/v7/src/microcode/dossig.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: dossig.c,v 1.9 1992/09/25 21:42:38 jinx Exp $ +$Id: dossig.c,v 1.10 1992/09/26 02:54:57 cph Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -1026,8 +1026,7 @@ DEFUN (install_exception_handlers, (get_vector, set_handler, restore), handler = exception_handler; if ((under_DPMI_p ()) && (enable_DPMI_exceptions_p ()) - && ((DPMI_alloc_scheme_stack (&scheme_ds, &scheme_ss, - (Regs[REGBLOCK_STACK_GUARD]))) + && ((DPMI_alloc_scheme_stack (&scheme_ds, &scheme_ss, Stack_Guard)) == DOS_SUCCESS)) { Scheme_Stack_Segment_Selector = scheme_ss; diff --git a/v7/src/microcode/extern.h b/v7/src/microcode/extern.h index 57695e9be..dcc8f3592 100644 --- a/v7/src/microcode/extern.h +++ b/v7/src/microcode/extern.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: extern.h,v 9.48 1992/09/18 16:54:40 jinx Exp $ +$Id: extern.h,v 9.49 1992/09/26 02:54:58 cph Exp $ Copyright (c) 1987-1992 Massachusetts Institute of Technology @@ -93,6 +93,7 @@ extern SCHEME_OBJECT * MemTop, /* Top of heap space available */ * Ext_Stack_Pointer, /* Next available slot in control stack */ * Stack_Top, /* Top of control stack */ + * Stack_Guard, /* Guard area at end of stack */ * Free_Stacklets, /* Free list of stacklets */ * Constant_Space, /* Bottom of constant+pure space */ * Free_Constant, /* Next free cell in constant+pure area */ diff --git a/v7/src/microcode/gc.h b/v7/src/microcode/gc.h index ad044c883..68fb53067 100644 --- a/v7/src/microcode/gc.h +++ b/v7/src/microcode/gc.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/gc.h,v 9.31 1992/07/29 19:54:53 cph Exp $ +$Id: gc.h,v 9.32 1992/09/26 02:54:59 cph Exp $ Copyright (c) 1987-92 Massachusetts Institute of Technology @@ -104,29 +104,30 @@ MIT in each case. */ /* Overflow detection, various cases */ -#define GC_ENABLED_P() (INTERRUPT_ENABLED_P(INT_GC)) +#define GC_ENABLED_P() (INTERRUPT_ENABLED_P (INT_GC)) #define GC_Check(Amount) \ -(((Amount + Free) >= MemTop) && (GC_ENABLED_P())) + (((Amount + Free) >= MemTop) && (GC_ENABLED_P ())) #define Space_Before_GC() \ -((GC_ENABLED_P()) ? \ - ((Free <= MemTop) ? (MemTop - Free) : 0) : \ - (Heap_Top - Free)) + ((GC_ENABLED_P ()) \ + ? ((Free <= MemTop) ? (MemTop - Free) : 0) \ + : (Heap_Top - Free)) #define Request_GC(Amount) \ { \ - REQUEST_INTERRUPT(INT_GC); \ + REQUEST_INTERRUPT (INT_GC); \ GC_Space_Needed = Amount; \ } -#define SET_MEMTOP(Addr) \ +#define SET_MEMTOP(addr) \ { \ - MemTop = Addr; \ - COMPILER_SET_MEMTOP(); \ + MemTop = (addr); \ + COMPILER_SETUP_INTERRUPT (); \ } -#define Set_Stack_Guard(Addr) \ +#define SET_STACK_GUARD(addr) \ { \ - (Regs[REGBLOCK_STACK_GUARD]) = ((SCHEME_OBJECT) (Addr)); \ + Stack_Guard = (addr); \ + COMPILER_SETUP_INTERRUPT (); \ } diff --git a/v7/src/microcode/interp.c b/v7/src/microcode/interp.c index 600666f4b..51272f17b 100644 --- a/v7/src/microcode/interp.c +++ b/v7/src/microcode/interp.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: interp.c,v 9.68 1992/09/14 20:34:40 cph Exp $ +$Id: interp.c,v 9.69 1992/09/26 02:55:00 cph Exp $ Copyright (c) 1988-92 Massachusetts Institute of Technology @@ -402,10 +402,10 @@ DEFUN (abort_to_interpreter, (argument), int argument) { interpreter_throw_argument = argument; { - long old_mask = IntEnb; - set_IntEnb (0); + long old_mask = (FETCH_INTERRUPT_MASK ()); + SET_INTERRUPT_MASK (0); dstack_set_position (interpreter_catch_dstack_position); - set_IntEnb (old_mask); + SET_INTERRUPT_MASK (old_mask); } obstack_free ((&scratch_obstack), 0); obstack_init (&scratch_obstack); diff --git a/v7/src/microcode/interp.h b/v7/src/microcode/interp.h index fbe3da5d6..053cdf828 100644 --- a/v7/src/microcode/interp.h +++ b/v7/src/microcode/interp.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/interp.h,v 9.35 1992/07/29 19:54:54 cph Exp $ +$Id: interp.h,v 9.36 1992/09/26 02:55:01 cph Exp $ Copyright (c) 1987-92 Massachusetts Institute of Technology @@ -90,7 +90,6 @@ extern int EXFUN (abort_to_interpreter_argument, (void)); #define Val Regs[REGBLOCK_VAL] #define Expression Regs[REGBLOCK_EXPR] #define Return Regs[REGBLOCK_RETURN] -#define Stack_Guard ((SCHEME_OBJECT *) (Regs[REGBLOCK_STACK_GUARD])) /* Internal_Will_Push is in stack.h. */ diff --git a/v7/src/microcode/intrpt.h b/v7/src/microcode/intrpt.h index d74748be3..2dc62683d 100644 --- a/v7/src/microcode/intrpt.h +++ b/v7/src/microcode/intrpt.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: intrpt.h,v 1.10 1992/09/14 20:34:20 cph Exp $ +$Id: intrpt.h,v 1.11 1992/09/26 02:55:03 cph Exp $ Copyright (c) 1987-92 Massachusetts Institute of Technology @@ -33,18 +33,6 @@ promotional, or sales literature without prior written consent from MIT in each case. */ /* Interrupt manipulation utilities. */ - -/* The interrupt control registers. */ - -/* interrupts requesting */ -#define IntCode ((long) (Registers[REGBLOCK_INT_CODE])) -#define set_IntCode(code) \ - (Registers[REGBLOCK_INT_CODE]) = ((SCHEME_OBJECT) (code)) - -/* interrupts enabled */ -#define IntEnb ((long) (Registers[REGBLOCK_INT_MASK])) -#define set_IntEnb(mask) \ - (Registers[REGBLOCK_INT_MASK]) = ((SCHEME_OBJECT) (mask)) /* Interrupt bits -- scanned from LSB (1) to MSB (16) */ @@ -70,52 +58,57 @@ MIT in each case. */ /* Utility macros. */ -#define PENDING_INTERRUPTS() (IntEnb & IntCode) +#define PENDING_INTERRUPTS() \ + ((FETCH_INTERRUPT_MASK ()) & (FETCH_INTERRUPT_CODE ())) -#define INTERRUPT_QUEUED_P(mask) ((IntCode & (mask)) != 0) +#define INTERRUPT_QUEUED_P(mask) (((FETCH_INTERRUPT_CODE ()) & (mask)) != 0) -#define INTERRUPT_ENABLED_P(mask) ((IntEnb & (mask)) != 0) +#define INTERRUPT_ENABLED_P(mask) (((FETCH_INTERRUPT_MASK ()) & (mask)) != 0) -#define INTERRUPT_PENDING_P(mask) (((PENDING_INTERRUPTS()) & (mask)) != 0) +#define INTERRUPT_PENDING_P(mask) (((PENDING_INTERRUPTS ()) & (mask)) != 0) #define COMPILER_SETUP_INTERRUPT() \ { \ - (Regs [REGBLOCK_MEMTOP]) = \ + (Registers[REGBLOCK_MEMTOP]) = \ ((INTERRUPT_PENDING_P (INT_Mask)) \ ? ((SCHEME_OBJECT) -1) \ - : ((SCHEME_OBJECT) MemTop)); \ + : (INTERRUPT_ENABLED_P (INT_GC)) \ + ? ((SCHEME_OBJECT) MemTop) \ + : ((SCHEME_OBJECT) Heap_Top)); \ + (Registers[REGBLOCK_STACK_GUARD]) = \ + ((INTERRUPT_ENABLED_P (INT_Stack_Overflow)) \ + ? ((SCHEME_OBJECT) Stack_Guard) \ + : ((SCHEME_OBJECT) Absolute_Stack_Base)); \ } -#define FETCH_INTERRUPT_MASK() (IntEnb) +#define FETCH_INTERRUPT_MASK() ((long) (Registers[REGBLOCK_INT_MASK])) #define SET_INTERRUPT_MASK(mask) \ { \ - set_IntEnb (mask); \ + (Registers[REGBLOCK_INT_MASK]) = ((SCHEME_OBJECT) (mask)); \ COMPILER_SETUP_INTERRUPT (); \ } -#define FETCH_INTERRUPT_CODE() (IntCode) +#define FETCH_INTERRUPT_CODE() ((long) (Registers[REGBLOCK_INT_CODE])) -#define CLEAR_INTERRUPT(code) \ +#define REQUEST_INTERRUPT(code) \ { \ - set_IntCode (IntCode &~ (code)); \ + (Registers[REGBLOCK_INT_CODE]) = \ + ((SCHEME_OBJECT) ((FETCH_INTERRUPT_CODE ()) | (code))); \ COMPILER_SETUP_INTERRUPT (); \ } -#define REQUEST_INTERRUPT(code) \ +#define CLEAR_INTERRUPT(code) \ { \ - set_IntCode (IntCode | (code)); \ + (Registers[REGBLOCK_INT_CODE]) = \ + ((SCHEME_OBJECT) ((FETCH_INTERRUPT_CODE ()) &~ (code))); \ COMPILER_SETUP_INTERRUPT (); \ } #define INITIALIZE_INTERRUPTS() \ { \ - set_IntEnb (0); \ - set_IntCode (0); \ + (Registers[REGBLOCK_INT_MASK]) = ((SCHEME_OBJECT) 0); \ + (Registers[REGBLOCK_INT_CODE]) = ((SCHEME_OBJECT) 0); \ SET_INTERRUPT_MASK (INT_Mask); \ CLEAR_INTERRUPT (INT_Mask); \ } - -/* Compatibility */ - -#define COMPILER_SET_MEMTOP COMPILER_SETUP_INTERRUPT diff --git a/v7/src/microcode/stack.h b/v7/src/microcode/stack.h index bc09f44eb..88a9f35e9 100644 --- a/v7/src/microcode/stack.h +++ b/v7/src/microcode/stack.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: stack.h,v 9.32 1992/09/18 05:53:14 jinx Exp $ +$Id: stack.h,v 9.33 1992/09/26 02:55:03 cph Exp $ Copyright (c) 1987-1992 Massachusetts Institute of Technology @@ -59,7 +59,7 @@ extern void EXFUN (dos386_stack_reset, (void)); { \ Microcode_Termination(TERM_STACK_ALLOCATION_FAILED); \ } \ - Set_Stack_Guard (Free + STACKLET_HEADER_SIZE); \ + SET_STACK_GUARD (Free + STACKLET_HEADER_SIZE); \ *Free = \ (MAKE_OBJECT (TC_MANIFEST_VECTOR, (Default_Stacklet_Size - 1))); \ Free += Default_Stacklet_Size; \ @@ -140,7 +140,7 @@ extern void EXFUN (dos386_stack_reset, (void)); SCHEME_OBJECT Our_Where; \ \ Our_Where = (Where); \ - Set_Stack_Guard (MEMORY_LOC (Our_Where, STACKLET_HEADER_SIZE)); \ + SET_STACK_GUARD (MEMORY_LOC (Our_Where, STACKLET_HEADER_SIZE)); \ Stack_Pointer = Previous_Stack_Pointer(Our_Where); \ } @@ -261,7 +261,7 @@ Pushed() MEMORY_SET (Older_Stacklet, STACKLET_REUSE_FLAG, SHARP_F); \ } \ temp = Free; \ - Set_Stack_Guard (& (temp[STACKLET_HEADER_SIZE])); \ + SET_STACK_GUARD (& (temp[STACKLET_HEADER_SIZE])); \ temp[STACKLET_LENGTH] = Old_Stacklet_Top[STACKLET_LENGTH]; \ Unused_Length = \ OBJECT_DATUM (Old_Stacklet_Top[STACKLET_UNUSED_LENGTH]) + \ diff --git a/v7/src/microcode/storage.c b/v7/src/microcode/storage.c index 4f30ec27f..e9fa28da2 100644 --- a/v7/src/microcode/storage.c +++ b/v7/src/microcode/storage.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: storage.c,v 9.51 1992/09/11 21:58:44 cph Exp $ +$Id: storage.c,v 9.52 1992/09/26 02:55:04 cph Exp $ Copyright (c) 1987-92 Massachusetts Institute of Technology @@ -49,6 +49,7 @@ SCHEME_OBJECT * Free, /* Next free word in storage */ * Ext_Stack_Pointer, /* Next available slot in control stack */ * Stack_Top, /* Top of control stack */ + * Stack_Guard, /* Guard area at end of stack */ * Free_Stacklets, /* Free list of stacklets */ * Constant_Space, /* Bottom of constant+pure space */ * Free_Constant, /* Next free cell in constant+pure area */ diff --git a/v7/src/microcode/utils.c b/v7/src/microcode/utils.c index 7ece804c8..698991860 100644 --- a/v7/src/microcode/utils.c +++ b/v7/src/microcode/utils.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utils.c,v 9.53 1992/07/29 19:54:56 cph Exp $ +$Id: utils.c,v 9.54 1992/09/26 02:55:05 cph Exp $ Copyright (c) 1987-92 Massachusetts Institute of Technology @@ -828,7 +828,7 @@ DEFUN (Allocate_New_Stacklet, (N), long N) } } Free[STACKLET_LENGTH] = MAKE_OBJECT (TC_MANIFEST_VECTOR, (size - 1)); - Set_Stack_Guard (& (Free[STACKLET_HEADER_SIZE])); + SET_STACK_GUARD (& (Free[STACKLET_HEADER_SIZE])); Free += size; Stack_Pointer = Free; } @@ -843,7 +843,7 @@ DEFUN (Allocate_New_Stacklet, (N), long N) ((SCHEME_OBJECT *) Free_Stacklets[STACKLET_FREE_LIST_LINK]); Stack_Pointer = &New_Stacklet[1 + (OBJECT_DATUM (New_Stacklet[STACKLET_LENGTH]))]; - Set_Stack_Guard (& (New_Stacklet[STACKLET_HEADER_SIZE])); + SET_STACK_GUARD (& (New_Stacklet[STACKLET_HEADER_SIZE])); } Old_Expression = Fetch_Expression(); Old_Return = Fetch_Return(); diff --git a/v7/src/microcode/version.h b/v7/src/microcode/version.h index ae219d84e..c6ad5a865 100644 --- a/v7/src/microcode/version.h +++ b/v7/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: version.h,v 11.120 1992/09/12 00:08:33 cph Exp $ +$Id: version.h,v 11.121 1992/09/26 02:55:06 cph Exp $ Copyright (c) 1988-92 Massachusetts Institute of Technology @@ -46,5 +46,5 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 120 +#define SUBVERSION 121 #endif diff --git a/v8/src/microcode/cmpint.c b/v8/src/microcode/cmpint.c index 2ccfc3829..2febecfef 100644 --- a/v8/src/microcode/cmpint.c +++ b/v8/src/microcode/cmpint.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: cmpint.c,v 1.49 1992/09/11 02:04:05 cph Exp $ +$Id: cmpint.c,v 1.50 1992/09/26 02:54:55 cph Exp $ Copyright (c) 1989-92 Massachusetts Institute of Technology @@ -40,7 +40,6 @@ MIT in each case. */ * */ -#ifdef HAS_COMPILER_SUPPORT /* * Procedures in this file belong to the following categories: * @@ -98,6 +97,8 @@ MIT in each case. */ #include "prim.h" /* Primitive_Procedure_Table, etc. */ #define IN_CMPINT_C #include "cmpgc.h" /* Compiled code object relocation */ + +#ifdef HAS_COMPILER_SUPPORT #ifndef FLUSH_I_CACHE_REGION # define FLUSH_I_CACHE_REGION(addr, nwords) NOP() @@ -1335,116 +1336,76 @@ DEFUN (comutil_operator_4_0_trap, } /* INTERRUPT/GC from Scheme - The next four procedures are called from compiled code at the start - (respectively) of a closure, continuation, interpreter compatible - procedure, or ordinary (not closed) procedure if an interrupt has - been detected. They return to the interpreter if the interrupt is - invalid after saving the state necessary to restart the compiled - code. - - The code that handles RC_COMP_INTERRUPT_RESTART in interp.c will - return control to comp_interrupt_restart (below). This assumes - that the Scheme stack contains a compiled code entry address (start - of continuation, procedure, etc.). The Expression register saved - with the continuation is a piece of state that will be returned to - Val and Env (both) upon return. -*/ -#define GC_DESIRED_P() (Free >= MemTop) + These procedures are called from compiled code at the start + (respectively) of a procedure or continuation if an interrupt has + been detected. They must not be called unless there is an + interrupt to be serviced. -#define TEST_GC_NEEDED() \ -{ \ - if (GC_DESIRED_P()) \ - { \ - Request_GC(Free-MemTop); \ - } \ -} + The code that handles RC_COMP_INTERRUPT_RESTART in "interp.c" will + return control to comp_interrupt_restart (below). This assumes + that the Scheme stack contains a compiled code entry address + (start of continuation, procedure, etc.). The Expression register + saved with the continuation is a piece of state that will be + returned to Val and Env (both) upon return. -/* Called with no arguments, closure at top of (Scheme) stack. - If the interrupt is disabled, the closure is re-invoked. - */ -SCHEME_UTILITY struct utility_result -DEFUN (comutil_interrupt_closure, - (ignore_1, ignore_2, ignore_3, ignore_4), - long ignore_1 AND long ignore_2 AND long ignore_3 AND long ignore_4) -{ - TEST_GC_NEEDED (); - Stack_Check (Stack_Pointer); - if ((PENDING_INTERRUPTS()) == 0) - { - SCHEME_OBJECT entry_point; + */ - EXTRACT_CLOSURE_ENTRY_ADDRESS (entry_point, - (OBJECT_ADDRESS (STACK_REF (0)))); - ADJUST_CLOSURE_AT_CALL (entry_point, (STACK_REF (0))); - RETURN_TO_SCHEME (((instruction *) entry_point) + - CLOSURE_SKIPPED_CHECK_OFFSET); - } - else - { - /* Return to interpreter to handle interrupt */ - - STACK_PUSH (SHARP_F); - Store_Expression (SHARP_F); - Store_Return (RC_COMP_INTERRUPT_RESTART); - Save_Cont (); - RETURN_TO_C (PRIM_INTERRUPT); - } +#define MAYBE_REQUEST_INTERRUPTS() \ +{ \ + if (Free >= MemTop) \ + Request_GC (Free - MemTop); \ + if (Stack_Pointer <= Stack_Guard) \ + REQUEST_INTERRUPT (INT_Stack_Overflow); \ } - -/* State is the live data; no entry point on the stack. - */ static struct utility_result -DEFUN (compiler_interrupt_common, - (entry_point, offset, state), - instruction *entry_point AND - long offset AND +DEFUN (compiler_interrupt_common, (entry_point, state), + instruction * entry_point AND SCHEME_OBJECT state) { - TEST_GC_NEEDED (); - Stack_Check (Stack_Pointer); - if ((PENDING_INTERRUPTS()) == 0) - { - Store_Env (state); - Val = state; - RETURN_TO_SCHEME (entry_point + offset); - } - else - { + MAYBE_REQUEST_INTERRUPTS (); + if (entry_point != 0) STACK_PUSH (ENTRY_TO_OBJECT (entry_point)); - STACK_PUSH (state); - Store_Expression (SHARP_F); - Store_Return (RC_COMP_INTERRUPT_RESTART); - Save_Cont (); - RETURN_TO_C (PRIM_INTERRUPT); - } + STACK_PUSH (state); + Store_Expression (SHARP_F); + Store_Return (RC_COMP_INTERRUPT_RESTART); + Save_Cont (); + RETURN_TO_C (PRIM_INTERRUPT); } SCHEME_UTILITY struct utility_result -DEFUN (comutil_interrupt_dlink, - (entry_point, dlink, ignore_3, ignore_4), - instruction * entry_point - AND SCHEME_OBJECT * dlink - AND long ignore_3 AND long ignore_4) +DEFUN (comutil_interrupt_closure, (ignore_1, ignore_2, ignore_3, ignore_4), + long ignore_1 AND + long ignore_2 AND + long ignore_3 AND + long ignore_4) +{ + return (compiler_interrupt_common (0, SHARP_F)); +} + +SCHEME_UTILITY struct utility_result +DEFUN (comutil_interrupt_dlink, (entry_point, dlink, ignore_3, ignore_4), + instruction * entry_point AND + SCHEME_OBJECT * dlink AND + long ignore_3 AND + long ignore_4) { return - (compiler_interrupt_common(entry_point, - ENTRY_SKIPPED_CHECK_OFFSET, - MAKE_POINTER_OBJECT(TC_STACK_ENVIRONMENT, - dlink))); + (compiler_interrupt_common + (entry_point, (MAKE_POINTER_OBJECT (TC_STACK_ENVIRONMENT, dlink)))); } SCHEME_UTILITY struct utility_result DEFUN (comutil_interrupt_procedure, (entry_point, ignore_2, ignore_3, ignore_4), - instruction * entry_point - AND long ignore_2 AND long ignore_3 AND long ignore_4) + instruction * entry_point AND + long ignore_2 AND + long ignore_3 AND + long ignore_4) { - return (compiler_interrupt_common(entry_point, - ENTRY_SKIPPED_CHECK_OFFSET, - SHARP_F)); + return (compiler_interrupt_common (entry_point, SHARP_F)); } /* Val has live data, and there is no entry address on the stack */ @@ -1452,12 +1413,12 @@ DEFUN (comutil_interrupt_procedure, SCHEME_UTILITY struct utility_result DEFUN (comutil_interrupt_continuation, (return_address, ignore_2, ignore_3, ignore_4), - instruction * return_address - AND long ignore_2 AND long ignore_3 AND long ignore_4) + instruction * return_address AND + long ignore_2 AND + long ignore_3 AND + long ignore_4) { - return (compiler_interrupt_common (return_address, - ENTRY_SKIPPED_CHECK_OFFSET, - Val)); + return (compiler_interrupt_common (return_address, Val)); } /* Env has live data; no entry point on the stack */ @@ -1465,12 +1426,12 @@ DEFUN (comutil_interrupt_continuation, SCHEME_UTILITY struct utility_result DEFUN (comutil_interrupt_ic_procedure, (entry_point, ignore_2, ignore_3, ignore_4), - instruction * entry_point - AND long ignore_2 AND long ignore_3 AND long ignore_4) + instruction * entry_point AND + long ignore_2 AND + long ignore_3 AND + long ignore_4) { - return (compiler_interrupt_common (entry_point, - ENTRY_SKIPPED_CHECK_OFFSET, - (Fetch_Env()))); + return (compiler_interrupt_common (entry_point, (Fetch_Env ()))); } C_TO_SCHEME long diff --git a/v8/src/microcode/cmpintmd/hppa.h b/v8/src/microcode/cmpintmd/hppa.h index df918e6b7..4416249c5 100644 --- a/v8/src/microcode/cmpintmd/hppa.h +++ b/v8/src/microcode/cmpintmd/hppa.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/cmpintmd/hppa.h,v 1.33 1992/05/23 01:18:45 jinx Exp $ +$Id: hppa.h,v 1.34 1992/09/26 02:54:50 cph Exp $ Copyright (c) 1989-1992 Massachusetts Institute of Technology @@ -417,12 +417,6 @@ DEFUN_VOID (flush_i_cache_initialize) /* Interrupt/GC polling. */ -/* Skip over this many BYTES to bypass the GC check code (ordinary -procedures and continuations differ from closures) */ - -#define ENTRY_SKIPPED_CHECK_OFFSET 4 -#define CLOSURE_SKIPPED_CHECK_OFFSET 16 - /* The length of the GC recovery code that precedes an entry. On the HP-PA a "ble, ldi" instruction sequence. */ diff --git a/v8/src/microcode/interp.c b/v8/src/microcode/interp.c index 600666f4b..51272f17b 100644 --- a/v8/src/microcode/interp.c +++ b/v8/src/microcode/interp.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: interp.c,v 9.68 1992/09/14 20:34:40 cph Exp $ +$Id: interp.c,v 9.69 1992/09/26 02:55:00 cph Exp $ Copyright (c) 1988-92 Massachusetts Institute of Technology @@ -402,10 +402,10 @@ DEFUN (abort_to_interpreter, (argument), int argument) { interpreter_throw_argument = argument; { - long old_mask = IntEnb; - set_IntEnb (0); + long old_mask = (FETCH_INTERRUPT_MASK ()); + SET_INTERRUPT_MASK (0); dstack_set_position (interpreter_catch_dstack_position); - set_IntEnb (old_mask); + SET_INTERRUPT_MASK (old_mask); } obstack_free ((&scratch_obstack), 0); obstack_init (&scratch_obstack); diff --git a/v8/src/microcode/version.h b/v8/src/microcode/version.h index ae219d84e..c6ad5a865 100644 --- a/v8/src/microcode/version.h +++ b/v8/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: version.h,v 11.120 1992/09/12 00:08:33 cph Exp $ +$Id: version.h,v 11.121 1992/09/26 02:55:06 cph Exp $ Copyright (c) 1988-92 Massachusetts Institute of Technology @@ -46,5 +46,5 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 120 +#define SUBVERSION 121 #endif -- 2.25.1