fix JIT bug

that caused incorrect compilation of a non-tail call as
 a self non-tail call (but why hasn't this deep and old bug caused
 more trouble over the years?)
This commit is contained in:
Matthew Flatt 2011-06-30 08:21:36 -06:00
parent 69ad39d45c
commit 0025ff968d
2 changed files with 11 additions and 3 deletions

View File

@ -1513,7 +1513,7 @@ static int generate_branch(Scheme_Object *obj, mz_jit_state *jitter, int is_tail
GC_CAN_IGNORE jit_insn *ref2; GC_CAN_IGNORE jit_insn *ref2;
int pushed_marks; int pushed_marks;
int nsrs, nsrs1, g1, g2, amt, need_sync, flostack, flostack_pos; int nsrs, nsrs1, g1, g2, amt, need_sync, flostack, flostack_pos;
int else_is_empty = 0, i, can_chain_branch, chain_true, chain_false; int else_is_empty = 0, i, can_chain_branch, chain_true, chain_false, old_self_pos;
#ifdef NEED_LONG_JUMPS #ifdef NEED_LONG_JUMPS
int then_short_ok, else_short_ok; int then_short_ok, else_short_ok;
#else #else
@ -1533,6 +1533,8 @@ static int generate_branch(Scheme_Object *obj, mz_jit_state *jitter, int is_tail
else_short_ok = (is_short(branch->fbranch, 32) > 0); else_short_ok = (is_short(branch->fbranch, 32) > 0);
#endif #endif
old_self_pos = jitter->self_pos;
for_this_branch.addrs = addrs; for_this_branch.addrs = addrs;
for_this_branch.addrs_size = NUM_QUICK_INFO_ADDRS; for_this_branch.addrs_size = NUM_QUICK_INFO_ADDRS;
for_this_branch.addrs_count = 0; for_this_branch.addrs_count = 0;
@ -1648,6 +1650,9 @@ static int generate_branch(Scheme_Object *obj, mz_jit_state *jitter, int is_tail
jitter->pushed_marks = pushed_marks; jitter->pushed_marks = pushed_marks;
if (need_sync) mz_rs_sync_0(); if (need_sync) mz_rs_sync_0();
if (old_self_pos != jitter->self_pos)
scheme_signal_error("internal error: self position moved across branch");
/* False branch */ /* False branch */
mz_CLEAR_R0_STATUS(); mz_CLEAR_R0_STATUS();
scheme_mz_runstack_saved(jitter); scheme_mz_runstack_saved(jitter);

View File

@ -476,6 +476,9 @@ int scheme_mz_compute_runstack_restored(mz_jit_state *jitter, int adj, int skip)
c >>= 2; c >>= 2;
if (c > 0) if (c > 0)
amt += c; amt += c;
else {
if (adj) jitter->self_pos += c;
}
} }
} else if (c & 0x2) { } else if (c & 0x2) {
/* single procedure */ /* single procedure */