From 6c1ca8fa117d8e68551ae755e1fd60ae543aa10a Mon Sep 17 00:00:00 2001
From: Chris Hanson <org/chris-hanson/cph>
Date: Wed, 22 Jun 1988 21:25:16 +0000
Subject: [PATCH] Change the stack parser to ignore frames of type
 RESTORE-TO-STATE-POINT unless they contain a state point whose space is the
 system state space.

---
 v7/src/runtime/conpar.scm  | 12 ++++++++++--
 v7/src/runtime/runtime.pkg |  5 ++++-
 v7/src/runtime/version.scm |  4 ++--
 v7/src/runtime/wind.scm    | 17 ++++++++++++++++-
 v8/src/runtime/conpar.scm  | 12 ++++++++++--
 v8/src/runtime/runtime.pkg |  5 ++++-
 6 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/v7/src/runtime/conpar.scm b/v7/src/runtime/conpar.scm
index 90c0b1ff0..f1d5ef2af 100644
--- a/v7/src/runtime/conpar.scm
+++ b/v7/src/runtime/conpar.scm
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/conpar.scm,v 14.3 1988/06/21 04:21:49 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/conpar.scm,v 14.4 1988/06/22 21:24:16 cph Exp $
 
 Copyright (c) 1988 Massachusetts Institute of Technology
 
@@ -321,7 +321,15 @@ MIT in each case. |#
 
 (define (parser/restore-dynamic-state type elements state)
   (make-restore-frame type elements state
-		      (vector-ref elements 0)
+		      ;; Possible problem: the dynamic state really
+		      ;; consists of all of the state spaces in
+		      ;; existence.  Probably we should have some
+		      ;; mechanism for keeping track of them all.
+		      (let ((dynamic-state (vector-ref elements 0)))
+			(if (eq? system-state-space
+				 (state-point/space dynamic-state))
+			    dynamic-state
+			    (parser-state/dynamic-state state)))
 		      (parser-state/fluid-bindings state)
 		      (parser-state/interrupt-mask state)
 		      (parser-state/history state)
diff --git a/v7/src/runtime/runtime.pkg b/v7/src/runtime/runtime.pkg
index 7a0aa9265..46e1e9e15 100644
--- a/v7/src/runtime/runtime.pkg
+++ b/v7/src/runtime/runtime.pkg
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/runtime.pkg,v 14.6 1988/06/22 21:09:42 jrm Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/runtime.pkg,v 14.7 1988/06/22 21:23:58 cph Exp $
 
 Copyright (c) 1988 Massachusetts Institute of Technology
 
@@ -1426,6 +1426,9 @@ MIT in each case. |#
 	  set-current-dynamic-state!
 	  set-fluid-bindings!
 	  translate-to-state-point)
+  (export (runtime continuation-parser)
+	  state-point/space
+	  system-state-space)
   (initialization (initialize-package!)))
 
 (define-package (runtime stream)
diff --git a/v7/src/runtime/version.scm b/v7/src/runtime/version.scm
index 0fcf84cf9..cf78207f4 100644
--- a/v7/src/runtime/version.scm
+++ b/v7/src/runtime/version.scm
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/version.scm,v 14.6 1988/06/21 05:51:30 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/version.scm,v 14.7 1988/06/22 21:25:16 cph Exp $
 
 Copyright (c) 1988 Massachusetts Institute of Technology
 
@@ -40,4 +40,4 @@ MIT in each case. |#
 (define (initialize-package!)
   (add-identification!
    "Microcode" microcode-id/version microcode-id/modification)
-  (add-identification! "Runtime" 14 6))
\ No newline at end of file
+  (add-identification! "Runtime" 14 7))
\ No newline at end of file
diff --git a/v7/src/runtime/wind.scm b/v7/src/runtime/wind.scm
index ba494f387..ddbc042d1 100644
--- a/v7/src/runtime/wind.scm
+++ b/v7/src/runtime/wind.scm
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/wind.scm,v 14.1 1988/06/13 12:00:51 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/wind.scm,v 14.2 1988/06/22 21:24:34 cph Exp $
 
 Copyright (c) 1988 Massachusetts Institute of Technology
 
@@ -59,6 +59,21 @@ MIT in each case. |#
 		 (current-dynamic-state))
     ((ucode-primitive set-fixed-objects-vector!) fixed-objects)))
 
+(define-structure (state-point (type vector)
+			       (initial-offset 1)
+			       (constructor false)
+			       (conc-name state-point/))
+  (before-thunk false read-only true)
+  (after-thunk false read-only true)
+  (nearer-point false read-only true)
+  (distance-to-root false read-only true))
+
+(define (state-point/space point)
+  (let ((next (state-point/nearer-point point)))
+    (if (positive? (state-point/distance-to-root point))
+	(state-point/space next)
+	next)))
+
 (define-primitives
   execute-at-new-state-point
   translate-to-state-point
diff --git a/v8/src/runtime/conpar.scm b/v8/src/runtime/conpar.scm
index 0d2bc3d12..6c574caa6 100644
--- a/v8/src/runtime/conpar.scm
+++ b/v8/src/runtime/conpar.scm
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/conpar.scm,v 14.3 1988/06/21 04:21:49 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/conpar.scm,v 14.4 1988/06/22 21:24:16 cph Exp $
 
 Copyright (c) 1988 Massachusetts Institute of Technology
 
@@ -321,7 +321,15 @@ MIT in each case. |#
 
 (define (parser/restore-dynamic-state type elements state)
   (make-restore-frame type elements state
-		      (vector-ref elements 0)
+		      ;; Possible problem: the dynamic state really
+		      ;; consists of all of the state spaces in
+		      ;; existence.  Probably we should have some
+		      ;; mechanism for keeping track of them all.
+		      (let ((dynamic-state (vector-ref elements 0)))
+			(if (eq? system-state-space
+				 (state-point/space dynamic-state))
+			    dynamic-state
+			    (parser-state/dynamic-state state)))
 		      (parser-state/fluid-bindings state)
 		      (parser-state/interrupt-mask state)
 		      (parser-state/history state)
diff --git a/v8/src/runtime/runtime.pkg b/v8/src/runtime/runtime.pkg
index 50f80cef3..70f4d72a2 100644
--- a/v8/src/runtime/runtime.pkg
+++ b/v8/src/runtime/runtime.pkg
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/runtime.pkg,v 14.6 1988/06/22 21:09:42 jrm Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/runtime.pkg,v 14.7 1988/06/22 21:23:58 cph Exp $
 
 Copyright (c) 1988 Massachusetts Institute of Technology
 
@@ -1426,6 +1426,9 @@ MIT in each case. |#
 	  set-current-dynamic-state!
 	  set-fluid-bindings!
 	  translate-to-state-point)
+  (export (runtime continuation-parser)
+	  state-point/space
+	  system-state-space)
   (initialization (initialize-package!)))
 
 (define-package (runtime stream)
-- 
2.25.1