mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
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.
This commit is contained in:
parent
6d6adc0cbf
commit
438346fc26
1 changed files with 5 additions and 1 deletions
6
vm.c
6
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
|
#if SEXP_USE_ALIGNED_BYTECODE
|
||||||
void sexp_context_align_pos(sexp ctx) {
|
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);
|
sexp_uint_t new_pos = sexp_word_align(pos);
|
||||||
if (new_pos > pos) {
|
if (new_pos > pos) {
|
||||||
sexp_expand_bcode(ctx, (sexp_sint_t)new_pos - pos);
|
sexp_expand_bcode(ctx, (sexp_sint_t)new_pos - pos);
|
||||||
|
if (pos > 0)
|
||||||
|
for (i=pos; i<new_pos; ++i)
|
||||||
|
sexp_bytecode_data(sexp_context_bc(ctx))[i] =
|
||||||
|
sexp_bytecode_data(sexp_context_bc(ctx))[pos-1];
|
||||||
sexp_context_pos(ctx) = sexp_make_fixnum(new_pos);
|
sexp_context_pos(ctx) = sexp_make_fixnum(new_pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue