mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
When directly incrementing or aligning bytecode pos during code generation,
ensure there is enough space just as when emitting.
This commit is contained in:
parent
d6b66a32fd
commit
607d70c6a0
4 changed files with 15 additions and 3 deletions
2
eval.c
2
eval.c
|
@ -303,7 +303,7 @@ void sexp_shrink_bcode (sexp ctx, sexp_uint_t i) {
|
|||
}
|
||||
}
|
||||
|
||||
void sexp_expand_bcode (sexp ctx, sexp_uint_t size) {
|
||||
void sexp_expand_bcode (sexp ctx, sexp_sint_t size) {
|
||||
sexp tmp;
|
||||
if (sexp_bytecode_length(sexp_context_bc(ctx))
|
||||
< (sexp_unbox_fixnum(sexp_context_pos(ctx)))+size) {
|
||||
|
|
|
@ -76,7 +76,7 @@ SEXP_API void sexp_bless_bytecode (sexp ctx, sexp bc);
|
|||
#endif
|
||||
SEXP_API sexp sexp_complete_bytecode (sexp ctx);
|
||||
SEXP_API void sexp_shrink_bcode (sexp ctx, sexp_uint_t i);
|
||||
SEXP_API void sexp_expand_bcode (sexp ctx, sexp_uint_t size);
|
||||
SEXP_API void sexp_expand_bcode (sexp ctx, sexp_sint_t size);
|
||||
SEXP_API void sexp_stack_trace (sexp ctx, sexp out);
|
||||
SEXP_API sexp sexp_free_vars (sexp context, sexp x, sexp fv);
|
||||
SEXP_API int sexp_param_index (sexp ctx, sexp lambda, sexp name);
|
||||
|
|
|
@ -1119,7 +1119,7 @@ SEXP_API sexp sexp_make_unsigned_integer(sexp ctx, sexp_luint_t x);
|
|||
#define sexp_context_exception(x) (sexp_vector_ref(sexp_context_specific(x), SEXP_SIX))
|
||||
|
||||
#if SEXP_USE_ALIGNED_BYTECODE
|
||||
#define sexp_context_align_pos(ctx) sexp_context_pos(ctx) = (sexp)sexp_make_fixnum(sexp_word_align((sexp_uint_t)sexp_unbox_fixnum(sexp_context_pos(ctx))))
|
||||
SEXP_API void sexp_context_align_pos(sexp ctx);
|
||||
#else
|
||||
#define sexp_context_align_pos(ctx)
|
||||
#endif
|
||||
|
|
12
vm.c
12
vm.c
|
@ -82,7 +82,19 @@ sexp sexp_stack_trace_op (sexp ctx, sexp self, sexp_sint_t n, sexp out) {
|
|||
|
||||
/************************* code generation ****************************/
|
||||
|
||||
#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 new_pos = sexp_word_align(pos);
|
||||
if (new_pos > pos) {
|
||||
sexp_expand_bcode(ctx, (sexp_sint_t)new_pos - pos);
|
||||
sexp_context_pos(ctx) = sexp_make_fixnum(new_pos);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void sexp_inc_context_pos(sexp ctx, sexp_sint_t off) {
|
||||
sexp_expand_bcode(ctx, off);
|
||||
sexp_context_pos(ctx) = sexp_fx_add(sexp_context_pos(ctx), sexp_make_fixnum(off));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue