From 438346fc26b35e5555441398c7b54b36169b0fa9 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Wed, 3 Jun 2015 22:29:38 +0900 Subject: [PATCH] When aligning bytecode, pad the skipped bytes with the previous opcode. This allows for instructions which want to save the previous ip to simply subtract their operands without needing to preserve the original ip in advance. --- vm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vm.c b/vm.c index e0631dfc..7f61bad6 100644 --- a/vm.c +++ b/vm.c @@ -84,10 +84,14 @@ sexp sexp_stack_trace_op (sexp ctx, sexp self, sexp_sint_t n, sexp out) { #if SEXP_USE_ALIGNED_BYTECODE void sexp_context_align_pos(sexp ctx) { - sexp_uint_t pos = sexp_unbox_fixnum(sexp_context_pos(ctx)); + sexp_uint_t i, pos = sexp_unbox_fixnum(sexp_context_pos(ctx)); sexp_uint_t new_pos = sexp_word_align(pos); if (new_pos > pos) { sexp_expand_bcode(ctx, (sexp_sint_t)new_pos - pos); + if (pos > 0) + for (i=pos; i