Make unsafe primitives back out of compiled code so that they don't
authorGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Wed, 31 May 1989 01:51:15 +0000 (01:51 +0000)
committerGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Wed, 31 May 1989 01:51:15 +0000 (01:51 +0000)
have to be treated specially by the compiler or the compiled code
interface.  This allows UUO linking of primitives, and applying
primitives from compiled code without going to the interpreter.

"Unsafe" primitives must use the new macro
PRIMITIVE_CANONICALIZE_CONTEXT before they start manipulating the
interpreter's state.

This macro will allow them to proceed if they have been invoked from
the interpreter, or will cause them to back into the interpreter and
restart if they have been invoked from compiled code.

21 files changed:
v7/src/microcode/bchmmg.c
v7/src/microcode/bchpur.c
v7/src/microcode/const.h
v7/src/microcode/dmpwrld.c
v7/src/microcode/fasload.c
v7/src/microcode/fhooks.c
v7/src/microcode/futures.h
v7/src/microcode/hooks.c
v7/src/microcode/intercom.c
v7/src/microcode/interp.c
v7/src/microcode/lookup.h
v7/src/microcode/memmag.c
v7/src/microcode/prims.h
v7/src/microcode/purify.c
v7/src/microcode/step.c
v7/src/microcode/utils.c
v7/src/microcode/version.h
v8/src/microcode/const.h
v8/src/microcode/interp.c
v8/src/microcode/lookup.h
v8/src/microcode/version.h

index 3e02a3603b31a53ac5d5c5b94f3119e3186c5f57..f2239003b44d94d4446996f181b6d8a724721887 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-Copyright (c) 1987, 1988 Massachusetts Institute of Technology
+Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -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.43 1989/03/27 23:13:56 jinx Exp $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchmmg.c,v 9.44 1989/05/31 01:49:41 jinx Exp $ */
 \f
 /* Memory management top level.  Garbage collection to disk.
 
@@ -856,6 +856,7 @@ DEFINE_PRIMITIVE ("GARBAGE-COLLECT", Prim_garbage_collect, 1, 1, 0)
   Pointer GC_Daemon_Proc;
   Primitive_1_Arg();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Arg_1_Type(TC_FIXNUM);
   if (Free > Heap_Top)
   {
index b36b2489baeea0a83b50e9e4a88df5371b0e3225..ae0ded48c3688c549ba8f530345952e3219cb831 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchpur.c,v 9.42 1989/03/27 23:14:03 jinx Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchpur.c,v 9.43 1989/05/31 01:49:47 jinx Exp $
 
-Copyright (c) 1987, 1988 Massachusetts Institute of Technology
+Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -490,6 +490,7 @@ DEFINE_PRIMITIVE ("PRIMITIVE-PURIFY", Prim_primitive_purify, 3, 3, 0)
   Pointer result;
   Primitive_3_Args();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   if ((Arg2 != SHARP_T) && (Arg2 != SHARP_F))
     Primitive_Error(ERR_ARG_2_WRONG_TYPE);
   Arg_3_Type(TC_FIXNUM);
index 5bb3c9f7beebb66e91484cb93baef7bcf1ee0089..157d9a8e105e62978ab0d4d67d7327e9280279ea 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/const.h,v 9.31 1989/05/24 05:32:23 jinx Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/const.h,v 9.32 1989/05/31 01:49:52 jinx Exp $
  *
  * Named constants used throughout the interpreter
  *
@@ -121,6 +121,7 @@ MIT in each case. */
 #define PRIM_POP_RETURN                        -7
 #define PRIM_TOUCH                     -8
 #define PRIM_APPLY_INTERRUPT           -9
+#define PRIM_REENTER                   -10
 
 #define ABORT_NAME_TABLE                                               \
 {                                                                      \
@@ -132,7 +133,8 @@ MIT in each case. */
   /* -6 */     "NO-TRAP_APPLY",                                        \
   /* -7 */     "POP-RETURN",                                           \
   /* -8 */     "TOUCH",                                                \
-  /* -9 */     "APPLY-INTERRUPT"                                       \
+  /* -9 */     "APPLY-INTERRUPT",                                      \
+  /* -10 */    "REENTER"                                               \
 }
 
 /* Some numbers of parameters which mean something special */
index d9bcdbca1066b3017f0f79d400fb3393b05c2af2..2e5a9e0c4ba813eca542dd6b4f4baaa7f6d33e5c 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-Copyright (c) 1987, 1988 Massachusetts Institute of Technology
+Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -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/dmpwrld.c,v 9.28 1988/10/21 00:12:33 cph Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/dmpwrld.c,v 9.29 1989/05/31 01:49:57 jinx Rel $
  *
  * This file contains a primitive to dump an executable version of Scheme.
  * It uses unexec.c from GNU Emacs.
@@ -189,6 +189,7 @@ DEFINE_PRIMITIVE ("DUMP-WORLD", Prim_dump_world, 1, 1, 0)
   long Buflen;
   Primitive_1_Arg();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Arg_1_Type(TC_CHARACTER_STRING);
 
   if (there_are_open_files())
index f083f47bca79217dbdb27c1a184b428e97ce6e72..0f86618ced1335779808660cccf73e7f5d37e952 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-Copyright (c) 1987, 1988 Massachusetts Institute of Technology
+Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -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/fasload.c,v 9.39 1989/03/27 23:14:58 jinx Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/fasload.c,v 9.40 1989/05/31 01:50:02 jinx Exp $
 
    The "fast loader" which reads in and relocates binary files and then
    interns symbols.  It is called with one argument: the (character
@@ -737,6 +737,7 @@ DEFINE_PRIMITIVE ("LOAD-BAND", Prim_band_load, 1, 1, 0)
   Boolean load_file_failed;
   Primitive_1_Arg();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   saved_free = Free;
   Free = Heap_Bottom;
   saved_memtop = MemTop;
index e344ef35eba89573c152f9e26b487af84aa12962..9675141042b37c2b58773b39cad7b8f00c4ce507 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-Copyright (c) 1988 Massachusetts Institute of Technology
+Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -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/fhooks.c,v 9.29 1988/09/29 04:58:22 jinx Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/fhooks.c,v 9.30 1989/05/31 01:50:09 jinx Rel $
  *
  * This file contains hooks and handles for the new fluid bindings
  * scheme for multiprocessors.
@@ -78,6 +78,7 @@ DEFINE_PRIMITIVE ("WITH-SAVED-FLUID-BINDINGS", Prim_with_saved_fluid_bindings, 1
 {
   Primitive_1_Arg();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Pop_Primitive_Frame(1);
 
   /* Save previous fluid bindings for later restore */
@@ -90,6 +91,7 @@ DEFINE_PRIMITIVE ("WITH-SAVED-FLUID-BINDINGS", Prim_with_saved_fluid_bindings, 1
   Push(STACK_FRAME_HEADER);
  Pushed();
   PRIMITIVE_ABORT(PRIM_APPLY);
+  /*NOTREACHED*/
 }
 \f
 /* Utilities for the primitives below. */
index 38c036fa2e7dfc20cc14c8a37aaafe23d2c5d3c2..b4ed7085281e91d3d9829bb3c64c1446d4b62644 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-Copyright (c) 1987, 1988 Massachusetts Institute of Technology
+Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -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/futures.h,v 9.24 1988/08/15 20:47:48 cph Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/futures.h,v 9.25 1989/05/31 01:50:14 jinx Rel $
  *
  * This file contains macros useful for dealing with futures
  */
@@ -124,6 +124,9 @@ MIT in each case. */
    ASSUMPTION: The SYMBOL slot of a VARIABLE does NOT contain a future, nor
    do the cached lexical address slots.
 
+   ASSUMPTION: Environment structure, which is created only by the
+   interpreter, never contains FUTUREs on its spine.
+
    ASSUMPTION: History objects are never created using futures.
 
    ASSUMPTION: State points, which are created only by the interpreter,
index 69f0de265a6e2ff0950bf6bcd2002486a9f62500..58e5e4a08f48278a6c2e41eb19053ae01fae75a2 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/hooks.c,v 9.35 1989/03/27 23:15:12 jinx Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/hooks.c,v 9.36 1989/05/31 01:50:19 jinx Rel $
 
 Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
@@ -51,7 +51,7 @@ DEFINE_PRIMITIVE ("APPLY", Prim_apply, 2, 2, 0)
 {
   fast Pointer scan_list, *scan_stack;
   fast long number_of_args, i;
-#ifdef butterfly
+#ifdef PARALLEL_PROCESSOR
   Pointer *saved_stack_pointer;
 #endif
   Primitive_2_Args();
@@ -67,11 +67,13 @@ DEFINE_PRIMITIVE ("APPLY", Prim_apply, 2, 2, 0)
      list into a linear (vector-like) form, so as to avoid the
      overhead of traversing the list twice.  Unfortunately, the
      overhead of maintaining this other form (e.g. PRIMITIVE_GC_If_Needed)
-     is sufficiently high that it probably makes up for the time saved. */
+     is sufficiently high that it probably makes up for the time saved.
+   */
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Touch_In_Primitive( Arg2, scan_list);
   number_of_args = 0;
-  while (Type_Code( scan_list) == TC_LIST)
+  while (OBJECT_TYPE( scan_list) == TC_LIST)
   {
     number_of_args += 1;
     Touch_In_Primitive( Vector_Ref( scan_list, CONS_CDR), scan_list);
@@ -90,7 +92,7 @@ DEFINE_PRIMITIVE ("APPLY", Prim_apply, 2, 2, 0)
   Pop_Primitive_Frame( 2);
 \f
  Will_Push( (number_of_args + STACK_ENV_EXTRA_SLOTS + 1));
-#ifdef butterfly
+#ifdef PARALLEL_PROCESSOR
   saved_stack_pointer = Stack_Pointer;
 #endif
   scan_stack = Simulate_Pushing (number_of_args);
@@ -99,9 +101,9 @@ DEFINE_PRIMITIVE ("APPLY", Prim_apply, 2, 2, 0)
   Touch_In_Primitive (Arg2, scan_list);
   while (i > 0)
   {
-#ifdef butterfly
+#ifdef PARALLEL_PROCESSOR
     /* Check for abominable case of someone bashing the arg list. */
-    if (Type_Code( scan_list) != TC_LIST)
+    if (OBJECT_TYPE( scan_list) != TC_LIST)
     {
       Stack_Pointer = saved_stack_pointer;
       signal_error_from_primitive (ERR_ARG_2_BAD_RANGE);
@@ -239,6 +241,7 @@ DEFINE_PRIMITIVE ("CALL-WITH-CURRENT-CONTINUATION", Prim_catch, 1, 1, 0)
   Pointer Control_Point;
   Primitive_1_Arg ();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   CWCC (RC_RESTORE_HISTORY);
   Vector_Set (Control_Point, STACKLET_REUSE_FLAG, NIL);
   PRIMITIVE_ABORT (PRIM_APPLY);
@@ -250,6 +253,8 @@ DEFINE_PRIMITIVE ("NON-REENTRANT-CALL-WITH-CURRENT-CONTINUATION", Prim_non_reent
   Pointer Control_Point;
   Primitive_1_Arg ();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
+
 #ifdef USE_STACKLETS
 
   CWCC (RC_RESTORE_DONT_COPY_HISTORY);
@@ -305,6 +310,7 @@ DEFINE_PRIMITIVE ("ERROR-PROCEDURE", Prim_error_procedure, 3, 3, 0)
 {
   Primitive_3_Args();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   /*
     This is done outside the Will_Push because the space for it
     is guaranteed by the interpreter before it gets here.
@@ -364,6 +370,7 @@ DEFINE_PRIMITIVE ("FORCE", Prim_force, 1, 1, 0)
     case FIXNUM_ZERO:
       {
        /* New-style thunk used by compiled code. */
+       PRIMITIVE_CANONICALIZE_CONTEXT();
        Pop_Primitive_Frame (1);
        Will_Push (CONTINUATION_SIZE + STACK_ENV_EXTRA_SLOTS + 1);
        Store_Return (RC_SNAP_NEED_THUNK);
@@ -379,6 +386,7 @@ DEFINE_PRIMITIVE ("FORCE", Prim_force, 1, 1, 0)
     default:
       {
        /* Old-style thunk used by interpreted code. */
+       PRIMITIVE_CANONICALIZE_CONTEXT();
        Pop_Primitive_Frame (1);
        Will_Push (CONTINUATION_SIZE);
        Store_Return (RC_SNAP_NEED_THUNK);
@@ -405,6 +413,7 @@ DEFINE_PRIMITIVE ("EXECUTE-AT-NEW-STATE-POINT", Prim_execute_at_new_point, 4, 4,
   Pointer New_Point, Old_Point;
   Primitive_4_Args();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   guarantee_state_point();
   if (Arg1 == NIL)
     Old_Point = Current_State_Point;
@@ -542,7 +551,8 @@ DEFINE_PRIMITIVE ("SCODE-EVAL", Prim_scode_eval, 2, 2, 0)
 {
   Primitive_2_Args();
 
-  if (Type_Code(Arg2) != GLOBAL_ENV)
+  PRIMITIVE_CANONICALIZE_CONTEXT();
+  if (OBJECT_TYPE(Arg2) != GLOBAL_ENV)
     Arg_2_Type(TC_ENVIRONMENT);
   Pop_Primitive_Frame(2);
   Store_Env(Arg2);
@@ -625,6 +635,7 @@ DEFINE_PRIMITIVE ("SET-CURRENT-HISTORY!", Prim_set_current_history, 1, 1, 0)
 {
   Primitive_1_Arg();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   if (!(HUNK3_P(Arg1)))
     error_wrong_type_arg (1);
 
@@ -679,6 +690,7 @@ DEFINE_PRIMITIVE ("TRANSLATE-TO-STATE-POINT", Prim_translate_to_point, 1, 1, 0)
 {
   Primitive_1_Arg();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Arg_1_Type(TC_VECTOR);
   if (Vector_Ref(Arg1, STATE_POINT_TAG) != Get_Fixed_Obj_Slot(State_Point_Tag))
     signal_error_from_primitive(ERR_ARG_1_WRONG_TYPE);
@@ -701,6 +713,7 @@ DEFINE_PRIMITIVE ("WITH-HISTORY-DISABLED", Prim_with_history_disabled, 1, 1, 0)
   Pointer *First_Rib, *Rib, *Second_Rib;
   Primitive_1_Arg();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   /* Remove one reduction from the history before saving it */
   First_Rib = Get_Pointer(History[HIST_RIB]);
   Second_Rib = Get_Pointer(First_Rib[RIB_NEXT_REDUCTION]);
@@ -734,6 +747,7 @@ DEFINE_PRIMITIVE ("WITH-INTERRUPT-MASK", Prim_with_interrupt_mask, 2, 2, 0)
   Pointer mask;
   Primitive_2_Args();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Arg_1_Type(TC_FIXNUM);
   Pop_Primitive_Frame(2);
   mask = MAKE_SIGNED_FIXNUM(FETCH_INTERRUPT_MASK());
@@ -759,6 +773,7 @@ DEFINE_PRIMITIVE ("WITH-INTERRUPTS-REDUCED", Prim_with_interrupts_reduced, 2, 2,
   long new_interrupt_mask, old_interrupt_mask;
   Primitive_2_Args();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Arg_1_Type(TC_FIXNUM);
   Pop_Primitive_Frame(2);
   mask = MAKE_SIGNED_FIXNUM(FETCH_INTERRUPT_MASK());
@@ -795,6 +810,7 @@ DEFINE_PRIMITIVE ("WITHIN-CONTROL-POINT", Prim_within_control_point, 2, 2, 0)
 {
   Primitive_2_Args();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Arg_1_Type(TC_CONTROL_POINT);
   Our_Throw(false, Arg1);
   Within_Stacklet_Backout();
index 26d80cada8dff99f98d7164684f6163f66bb5294..2436b9df9183d914c01c828c9d4c5f5887a2af58 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-Copyright (c) 1987, 1988 Massachusetts Institute of Technology
+Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -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/intercom.c,v 9.25 1988/08/15 20:49:47 cph Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/intercom.c,v 9.26 1989/05/31 01:50:26 jinx Rel $
  *
  * Single-processor simulation of locking, propagating, and
  * communicating stuff.
@@ -65,8 +65,9 @@ MIT in each case. */
 DEFINE_PRIMITIVE ("GLOBAL-INTERRUPT", Prim_send_global_interrupt, 3, 3, 0)
 {
   long Saved_Zone, Which_Level;
-  
   Primitive_3_Args();
+
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Arg_1_Type(TC_FIXNUM);
   Range_Check(Which_Level, Arg1, 0, 3, ERR_ARG_1_BAD_RANGE);
   Save_Time_Zone(Zone_Global_Int);
@@ -192,9 +193,11 @@ DEFINE_PRIMITIVE ("PEEK-AT-WORK-QUEUE", Prim_peek_queue, 0, 0, 0)
 DEFINE_PRIMITIVE ("GET-WORK", Prim_get_work, 1, 1, 0)
 {
   Pointer Get_Work();
+  Pointer result;
   Primitive_1_Arg();
 
-  PRIMITIVE_RETURN(Get_Work(Arg1));
+  result = Get_Work(Arg1);
+  PRIMITIVE_RETURN(result);
 }
 
 Pointer Get_Work(Arg1)
@@ -203,13 +206,14 @@ Pointer Get_Work(Arg1)
   Pointer The_Queue, Queue_Head, Result, The_Prim;
 
   /* This gets this primitive's code which is in the expression register. */
-  The_Prim = Fetch_Expression();
+  The_Prim = Regs[REGBLOCK_PRIMITIVE];
   The_Queue = Get_Fixed_Obj_Slot(The_Work_Queue);
   if (The_Queue != NIL)
   {
     Queue_Head = Vector_Ref(The_Queue, CONS_CAR);
   }
   if ((The_Queue == NIL) || (Queue_Head == NIL))
+  {
     if (Arg1 == NIL)
     {
       printf("\nNo work available, but some has been requested!\n");
@@ -217,6 +221,7 @@ Pointer Get_Work(Arg1)
     }
     else
     {
+      PRIMITIVE_CANONICALIZE_CONTEXT();
       Pop_Primitive_Frame(1);
      Will_Push(2 * (STACK_ENV_EXTRA_SLOTS + 1) + 1 + CONTINUATION_SIZE);
       Push(NIL);       /* Upon return, no hope if there is no work */
@@ -229,6 +234,7 @@ Pointer Get_Work(Arg1)
       Push(STACK_FRAME_HEADER);
      Pushed();
       PRIMITIVE_ABORT(PRIM_APPLY);
+    }
   }
   Result = Vector_Ref(Queue_Head, CONS_CAR);
   Queue_Head = Vector_Ref(Queue_Head, CONS_CDR);
@@ -337,6 +343,7 @@ DEFINE_PRIMITIVE ("MASTER-GC-LOOP", Prim_master_gc, 1, 1, 0)
   extern Pointer make_primitive();
   Primitive_1_Arg();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   if (gc_prim == NIL)
   {
     gc_prim = make_primitive("GARBAGE-COLLECT");
index 50f88d54f68416b277b92ecafa22506368282e13..c4fe6dd87dd4912a6ed6a331c6c775bbc0a1e7ea 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/interp.c,v 9.49 1989/03/28 20:39:19 jinx Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/interp.c,v 9.50 1989/05/31 01:50:31 jinx Exp $
  *
  * This file contains the heart of the Scheme Scode
  * interpreter
@@ -454,6 +454,12 @@ Repeat_Dispatch:
       PROCEED_AFTER_PRIMITIVE();
     case CODE_MAP(PRIM_POP_RETURN):
       goto Pop_Return;
+
+    case PRIM_REENTER:
+      BACK_OUT_AFTER_PRIMITIVE();
+      LOG_FUTURES();
+    case CODE_MAP(PRIM_REENTER):
+      goto Perform_Application;
 \f
     case PRIM_TOUCH:
     {
@@ -463,9 +469,8 @@ Repeat_Dispatch:
       BACK_OUT_AFTER_PRIMITIVE();
       Val = temp;
       LOG_FUTURES();
-      /* fall through */
     }
-
+    /* fall through */
     case CODE_MAP(PRIM_TOUCH):
       TOUCH_SETUP(Val);
       goto Internal_Apply;
index 33bf6e126e1ddd2894c058c1baae77f283bd129e..d20bc9d8594a0167c477a47b2a994b9e601654d5 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/lookup.h,v 9.41 1988/09/29 05:02:21 jinx Exp $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/lookup.h,v 9.42 1989/05/31 01:50:41 jinx Rel $ */
 
 /* Macros and declarations for the variable lookup code. */
 
@@ -268,6 +268,14 @@ label:                                                                     \
 
 extern long extend_frame();
 
+/* Definition recaches eagerly by default. */
+
+#ifndef DEFINITION_RECACHES_LAZILY
+#ifndef DEFINITION_RECACHES_EAGERLY
+#define DEFINITION_RECACHES_EAGERLY
+#endif
+#endif
+
 #ifndef DEFINITION_RECACHES_EAGERLY
 
 extern long compiler_uncache();
index d28c7b1601cf8aacec22bb1782f0c0189c7f58b7..e8496571dee7f6964a1d18a4bbfae7030f3f7633 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-Copyright (c) 1987, 1988 Massachusetts Institute of Technology
+Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -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.36 1989/03/27 23:15:41 jinx Exp $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/memmag.c,v 9.37 1989/05/31 01:50:46 jinx Exp $ */
 
 /* Memory management top level.
 
@@ -383,6 +383,7 @@ DEFINE_PRIMITIVE ("GARBAGE-COLLECT", Prim_garbage_collect, 1, 1, 0)
   Pointer GC_Daemon_Proc;
   Primitive_1_Arg();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Arg_1_Type(TC_FIXNUM);
   if (Free > Heap_Top)
   {
index 61974b17c43d52d1c5e62993b14d7f3044ebe68e..805974319f4d5f027a7a1aac13dea5604176ad29 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-Copyright (c) 1987 Massachusetts Institute of Technology
+Copyright (c) 1987, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -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/prims.h,v 9.33 1988/08/15 20:53:04 cph Exp $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prims.h,v 9.34 1989/05/31 01:50:51 jinx Rel $ */
 
 /* This file contains some macros for defining primitives,
    for argument type or value checking, and for accessing
@@ -66,6 +66,13 @@ Pointer fn_name ()
 #define PRIMITIVE_RETURN(value)        return (value)
 
 #define PRIMITIVE_ABORT(action)        longjmp(*Back_To_Eval, (action))
+
+extern void canonicalize_primitive_context();
+
+#define PRIMITIVE_CANONICALIZE_CONTEXT()                               \
+{                                                                      \
+  canonicalize_primitive_context();                                    \
+}
 \f
 /* Preambles for primitive procedures.  These store the arguments into
  * local variables for fast access.
index 22ef48cd3b45b7a63fe072bc2f82054a11829ab8..bbd2717bb5a39c1310db5cd2162be5738e4e2936 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-Copyright (c) 1988 Massachusetts Institute of Technology
+Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -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/purify.c,v 9.37 1989/03/27 23:15:46 jinx Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/purify.c,v 9.38 1989/05/31 01:50:57 jinx Exp $
  *
  * This file contains the code that copies objects into pure
  * and constant space.
@@ -504,6 +504,7 @@ DEFINE_PRIMITIVE ("PRIMITIVE-PURIFY", Prim_primitive_purify, 3, 3, 0)
   Pointer Object, Lost_Objects, Purify_Result, Daemon;
   Primitive_3_Args();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Save_Time_Zone(Zone_Purify);
   if ((Arg2 != SHARP_T) && (Arg2 != NIL))
     Primitive_Error(ERR_ARG_2_WRONG_TYPE);
index 0e473da47db8940aeb87f030e07a960e5d7512ed..b4a5e027d31562c79f74238fac422f041a1b2699 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-Copyright (c) 1987, 1988 Massachusetts Institute of Technology
+Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -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/step.c,v 9.25 1988/08/15 20:55:24 cph Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/step.c,v 9.26 1989/05/31 01:51:02 jinx Rel $
  *
  * Support for the stepper
  */
@@ -85,6 +85,7 @@ DEFINE_PRIMITIVE ("PRIMITIVE-EVAL-STEP", Prim_eval_step, 3, 3, 0)
 {
   Primitive_3_Args();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Install_Traps(Arg3, false);
   Pop_Primitive_Frame(3);
   Store_Expression(Arg1);
@@ -109,6 +110,7 @@ DEFINE_PRIMITIVE ("PRIMITIVE-APPLY-STEP", Prim_apply_step, 3, 3, 0)
   long Number_Of_Args, i;
   Primitive_3_Args();
 
+  PRIMITIVE_CANONICALIZE_CONTEXT();
   Arg_3_Type(TC_HUNK3);
   Number_Of_Args = 0;
   Next_From_Slot = Arg2;
index 0eeb764556f1ee8aafa4ea2ee95626b66ff3aa15..f2df22854a8d284e22302d44bc51e0a26c06cbdf 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/utils.c,v 9.41 1989/05/24 15:11:28 jinx Exp $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utils.c,v 9.42 1989/05/31 01:51:07 jinx Rel $ */
 
 /* This file contains utilities for interrupts, errors, etc. */
 
@@ -212,6 +212,41 @@ Back_Out_Of_Primitive ()
   return;
 }
 \f
+/*
+  canonicalize_primitive_context should be used by "unsafe" primitives
+  to guarantee that their execution context is the expected one, ie.
+  they are called from the interpreter.
+  If they are called from compiled code, they should abort to the
+  interpreter and reenter.
+  Note: This is called only from the macro PRIMITIVE_CANONICALIZE_CONTEXT,
+  so that the work can be divided between them if it is an issue.
+ */
+
+extern void canonicalize_primitive_context();
+
+void
+canonicalize_primitive_context()
+{
+  long nargs;
+  Pointer primitive;
+
+  primitive = Regs[REGBLOCK_PRIMITIVE];
+  if (OBJECT_TYPE(primitive) != TC_PRIMITIVE)
+  {
+    fprintf(stderr,
+           "\ncanonicalize_primitive_context invoked when not in primitive!\n");
+    Microcode_Termination(TERM_BAD_BACK_OUT);
+  }
+  nargs = PRIMITIVE_N_ARGUMENTS(primitive);
+  if ((OBJECT_TYPE(Stack_Ref(nargs))) != TC_COMPILED_ENTRY)
+  {
+    return;
+  }
+  /* The primitive has been invoked from compiled code. */
+  PRIMITIVE_ABORT(PRIM_REENTER);
+  /*NOTREACHED*/
+}
+\f
 /* Useful error procedures */
 
 /* Note that backing out of the primitives happens after aborting,
@@ -933,6 +968,12 @@ Find_State_Space (State_Point)
         at the root, indicating that the microcode variable rather
         than the state space contains the current state space
         location.
+
+   NOTE: This procedure is invoked both by primitives and the interpreter
+   itself.  As such, it is using the pun that PRIMITIVE_ABORT is just a
+   (non-local) return to the interpreter.  This should be cleaned up.
+   NOTE: Any primitive that invokes this procedure must do a
+   PRIMITIVE_CANONICALIZE_CONTEXT() first!
 */
 \f
 void
@@ -1030,7 +1071,11 @@ Pointer
 Compiler_Get_Fixed_Objects()
 {
   if (Valid_Fixed_Obj_Vector())
+  {
     return (Get_Fixed_Obj_Slot(Me_Myself));
+  }
   else
+  {
     return (NIL);
+  }
 }
index 3f754543796ff991b24f67206ba6886807031eaf..535b4494b8376b0090e4ffbcdc59870dea3a5532 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 10.78 1989/05/26 20:22:19 jinx Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 10.79 1989/05/31 01:51:15 jinx Exp $
 
 Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
@@ -46,7 +46,7 @@ MIT in each case. */
 #define VERSION                10
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     78
+#define SUBVERSION     79
 #endif
 
 #ifndef UCODE_TABLES_FILENAME
index 64a9de960160906f8b2858bf930820e30411b02d..16e7b628fe6f9832ca1ea607f41146e1e445be84 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/v8/src/microcode/const.h,v 9.31 1989/05/24 05:32:23 jinx Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/const.h,v 9.32 1989/05/31 01:49:52 jinx Exp $
  *
  * Named constants used throughout the interpreter
  *
@@ -121,6 +121,7 @@ MIT in each case. */
 #define PRIM_POP_RETURN                        -7
 #define PRIM_TOUCH                     -8
 #define PRIM_APPLY_INTERRUPT           -9
+#define PRIM_REENTER                   -10
 
 #define ABORT_NAME_TABLE                                               \
 {                                                                      \
@@ -132,7 +133,8 @@ MIT in each case. */
   /* -6 */     "NO-TRAP_APPLY",                                        \
   /* -7 */     "POP-RETURN",                                           \
   /* -8 */     "TOUCH",                                                \
-  /* -9 */     "APPLY-INTERRUPT"                                       \
+  /* -9 */     "APPLY-INTERRUPT",                                      \
+  /* -10 */    "REENTER"                                               \
 }
 
 /* Some numbers of parameters which mean something special */
index 3a87abd22c65a1ac5a8f2aeff56975ef79c4f238..f9eab214a93605c20c1db01ed8e1e3b5faa88741 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/v8/src/microcode/interp.c,v 9.49 1989/03/28 20:39:19 jinx Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/interp.c,v 9.50 1989/05/31 01:50:31 jinx Exp $
  *
  * This file contains the heart of the Scheme Scode
  * interpreter
@@ -454,6 +454,12 @@ Repeat_Dispatch:
       PROCEED_AFTER_PRIMITIVE();
     case CODE_MAP(PRIM_POP_RETURN):
       goto Pop_Return;
+
+    case PRIM_REENTER:
+      BACK_OUT_AFTER_PRIMITIVE();
+      LOG_FUTURES();
+    case CODE_MAP(PRIM_REENTER):
+      goto Perform_Application;
 \f
     case PRIM_TOUCH:
     {
@@ -463,9 +469,8 @@ Repeat_Dispatch:
       BACK_OUT_AFTER_PRIMITIVE();
       Val = temp;
       LOG_FUTURES();
-      /* fall through */
     }
-
+    /* fall through */
     case CODE_MAP(PRIM_TOUCH):
       TOUCH_SETUP(Val);
       goto Internal_Apply;
index 4d918aeafce7fccc5080bda2c46c44547d41acf3..cc69294b913902c8fc9489ec1ad012f5771d7213 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/v8/src/microcode/lookup.h,v 9.41 1988/09/29 05:02:21 jinx Exp $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/lookup.h,v 9.42 1989/05/31 01:50:41 jinx Rel $ */
 
 /* Macros and declarations for the variable lookup code. */
 
@@ -268,6 +268,14 @@ label:                                                                     \
 
 extern long extend_frame();
 
+/* Definition recaches eagerly by default. */
+
+#ifndef DEFINITION_RECACHES_LAZILY
+#ifndef DEFINITION_RECACHES_EAGERLY
+#define DEFINITION_RECACHES_EAGERLY
+#endif
+#endif
+
 #ifndef DEFINITION_RECACHES_EAGERLY
 
 extern long compiler_uncache();
index ee76d97f25bf69fe56181fed3f2191d3b89ad4a0..f4f076d026872ce1c65d8bd40b309fb0b15b915f 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 10.78 1989/05/26 20:22:19 jinx Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 10.79 1989/05/31 01:51:15 jinx Exp $
 
 Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
@@ -46,7 +46,7 @@ MIT in each case. */
 #define VERSION                10
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     78
+#define SUBVERSION     79
 #endif
 
 #ifndef UCODE_TABLES_FILENAME