libgst: 2013-10-07 Paolo Bonzini <bonz...@gnu.org> * 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 <bonz...@gnu.org> + + * 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 <hol...@moiji-mobile.com> * 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 _______________________________________________ help-smalltalk mailing list help-smalltalk@gnu.org https://lists.gnu.org/mailman/listinfo/help-smalltalk