help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] [PATCH 1/4] fix off by one sp for PUSH_LITERAL/MAKE_DIR


From: Paolo Bonzini
Subject: [Help-smalltalk] [PATCH 1/4] fix off by one sp for PUSH_LITERAL/MAKE_DIRTY_BLOCK combined bytecode
Date: Mon, 7 Oct 2013 10:17:45 +0200

libgst:
2013-10-07  Paolo Bonzini  <address@hidden>

        * libgst/genvm-parse.def: Emit definitions for UNDO_PREPARE_STACK.
        * libgst/vm.def: Wrap calls to _gst_make_block_closure with
        PREPARE_STACK and UNDO_PREPARE_STACK.  Otherwise, the sp
        that empty_context_stack saves in the context is off by one.
---
 libgst/ChangeLog     |  7 +++++++
 libgst/genvm-parse.y | 12 ++++++++++--
 libgst/vm.def        |  4 ++++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index c3bee00..822f86c 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,10 @@
+2013-10-07  Paolo Bonzini  <address@hidden>
+
+       * libgst/genvm-parse.def: Emit definitions for UNDO_PREPARE_STACK.
+       * libgst/vm.def: Wrap calls to _gst_make_block_closure with
+       PREPARE_STACK and UNDO_PREPARE_STACK.  Otherwise, the sp
+       that empty_context_stack saves in the context is off by one.
+
 2013-08-09  Holger Hans Peter Freyther  <address@hidden>
 
        * libgst/cint.c: Bind link, fsync, fdatasync and sync for
diff --git a/libgst/genvm-parse.y b/libgst/genvm-parse.y
index 483171c..691d9d4 100644
--- a/libgst/genvm-parse.y
+++ b/libgst/genvm-parse.y
@@ -625,6 +625,12 @@ emit_operation_invocation (operation_info *op, struct 
id_list *args, int sp, int
       filprintf (out_fil, "#define PREPARE_STACK() do { \\\n");
       emit_stack_update (sp, deepest_write, "    ", "; \\");
       filprintf (out_fil, "  } while (0)\n");
+      if (sp >= 0)
+        {
+          filprintf (out_fil, "#define UNDO_PREPARE_STACK() do { \\\n");
+          emit_stack_update (-sp, 0, "    ", "; \\");
+          filprintf (out_fil, "  } while (0)\n");
+        }
     }
 
   if (op->needs_branch_label)
@@ -644,8 +650,10 @@ emit_operation_invocation (operation_info *op, struct 
id_list *args, int sp, int
     filprintf (out_fil, "#undef BRANCH_LABEL\n\n");
 
   if (op->needs_prepare_stack)
-    filprintf (out_fil, "#undef PREPARE_STACK\n");
-
+    {
+      filprintf (out_fil, "#undef PREPARE_STACK\n");
+      filprintf (out_fil, "#undef UNDO_PREPARE_STACK\n");
+    }
   emit_id_list (op->read, "\n#undef ", "#undef ", "\n");
   emit_id_list (op->in, "\n#undef ", "#undef ", "\n");
   emit_id_list (op->out, "\n#undef ", "#undef ", "\n");
diff --git a/libgst/vm.def b/libgst/vm.def
index fb0b61b..7d48bdf 100644
--- a/libgst/vm.def
+++ b/libgst/vm.def
@@ -828,12 +828,15 @@ operation POP_STACK_TOP ( tos -- ) {
 }
 
 operation MAKE_DIRTY_BLOCK ( block -- closure ) {
+  PREPARE_STACK ();
   EXPORT_REGS ();
   closure = _gst_make_block_closure (block);
   IMPORT_REGS();
+  UNDO_PREPARE_STACK ();
 }
 
 operation RETURN_METHOD_STACK_TOP ( val -- val ) {
+  /* The current context dies here, so the stack need not be prepared.  */
   EXPORT_REGS ();
   if UNCOMMON (!unwind_method ())
     {
@@ -849,6 +852,7 @@ operation RETURN_METHOD_STACK_TOP ( val -- val ) {
 }
 
 operation RETURN_CONTEXT_STACK_TOP ( val -- val ) {
+  /* The current context dies here, so the stack need not be prepared.  */
   EXPORT_REGS ();
   unwind_context ();
   IMPORT_REGS ();
-- 
1.8.3.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]