fix bug in GC--JIT interaction: cont-mark stack pointer is pushed onto the runstack by JIT output, but the pointer is actually an integer

svn: r6222
This commit is contained in:
Matthew Flatt 2007-05-14 00:49:16 +00:00
parent b9f89b1cec
commit dfb33cc9c4
5 changed files with 30 additions and 17 deletions

View File

@ -3727,22 +3727,22 @@ static void copy_in_mark_stack(Scheme_Thread *p, Scheme_Cont_Mark *cont_mark_sta
if (needed > p->cont_mark_seg_count) {
Scheme_Cont_Mark **segs, **old_segs = p->cont_mark_stack_segments;
int newcount = needed, oldcount = p->cont_mark_seg_count;
int newcount = needed, oldcount = p->cont_mark_seg_count, npos;
/* Note: we perform allocations before changing p to avoid GC trouble,
since MzScheme adjusts a thread's cont_mark_stack_segments on GC. */
segs = MALLOC_N(Scheme_Cont_Mark *, needed);
while (needed--) {
if (needed < oldcount)
segs[needed] = old_segs[needed]; /* might be NULL due to GC! */
for (npos = needed; npos--; ) {
if (npos < oldcount)
segs[npos] = old_segs[npos]; /* might be NULL due to GC! */
else
segs[needed] = NULL;
segs[npos] = NULL;
if (!segs[needed]) {
if (!segs[npos]) {
Scheme_Cont_Mark *cm;
cm = scheme_malloc_allow_interior(sizeof(Scheme_Cont_Mark) * SCHEME_MARK_SEGMENT_SIZE);
segs[needed] = cm;
segs[npos] = cm;
}
}
@ -3996,7 +3996,7 @@ void prune_cont_marks(Scheme_Meta_Continuation *resume_mc, Scheme_Cont *cont, Sc
/* No pruning (nothing to compare against) or addition needed. */
return;
}
/* Compute the new set to have in the meta-continuation. */
ht = scheme_make_hash_table(SCHEME_hash_ptr);
@ -6362,7 +6362,7 @@ scheme_extract_one_cc_mark_with_meta(Scheme_Object *mark_set, Scheme_Object *key
MZ_MARK_POS_TYPE vpos = 0;
Scheme_Object *cache;
Scheme_Meta_Continuation *mc = NULL;
GC_CAN_IGNORE Scheme_Cont_Mark *seg;
Scheme_Cont_Mark *seg;
Scheme_Thread *p = scheme_current_thread;
do {

View File

@ -2088,6 +2088,7 @@ static int generate_app(Scheme_App_Rec *app, Scheme_Object **alt_rands, int num_
END_JIT_DATA(20);
if (num_rands >= MAX_SHARED_CALL_RANDS) {
LOG_IT(("<-many args\n"));
if (is_tail) {
if (direct_prim) {
generate_direct_prim_tail_call(jitter, num_rands);
@ -2115,9 +2116,11 @@ static int generate_app(Scheme_App_Rec *app, Scheme_Object **alt_rands, int num_
}
code = shared_tail_code[dp][num_rands];
if (direct_self) {
LOG_IT(("<-self\n"));
generate_self_tail_call(rator, jitter, num_rands, code, args_already_in_place);
CHECK_LIMIT();
} else {
LOG_IT(("<-tail\n"));
if (args_already_in_place) {
jit_movi_l(JIT_R2, args_already_in_place);
mz_set_local_p(JIT_R2, JIT_LOCAL2);
@ -2132,6 +2135,7 @@ static int generate_app(Scheme_App_Rec *app, Scheme_Object **alt_rands, int num_
code = generate_shared_call(num_rands, jitter, multi_ok, is_tail, direct_prim, direct_native);
shared_non_tail_code[dp][num_rands][mo] = code;
}
LOG_IT(("<-non-tail %d %d %d\n", dp, num_rands, mo));
code = shared_non_tail_code[dp][num_rands][mo];
(void)jit_calli(code);
@ -3699,6 +3703,9 @@ static int generate_non_tail(Scheme_Object *obj, mz_jit_state *jitter, int multi
if (mark_pos_ends)
generate_non_tail_mark_pos_prefix(jitter);
jit_ldi_p(JIT_R2, &scheme_current_cont_mark_stack);
/* mark stack is an integer... turn it into a pointer */
jit_lshi_l(JIT_R2, JIT_R2, 0x1);
jit_ori_l(JIT_R2, JIT_R2, 0x1);
mz_pushr_p(JIT_R2);
CHECK_LIMIT();
}
@ -3720,6 +3727,7 @@ static int generate_non_tail(Scheme_Object *obj, mz_jit_state *jitter, int multi
}
if (need_ends) {
mz_popr_p(JIT_R2);
jit_rshi_l(JIT_R2, JIT_R2, 0x1); /* pointer back to integer */
jit_sti_p(&scheme_current_cont_mark_stack, JIT_R2);
if (mark_pos_ends)
generate_non_tail_mark_pos_suffix(jitter);

View File

@ -927,6 +927,7 @@ static int cont_proc_MARK(void *p) {
gcMARK(c->runstack_saved);
gcMARK(c->prompt_id);
gcMARK(c->prompt_buf);
/* These shouldn't actually persist across a GC, but
just in case... */
@ -966,6 +967,7 @@ static int cont_proc_FIXUP(void *p) {
gcFIXUP(c->runstack_saved);
gcFIXUP(c->prompt_id);
gcFIXUP(c->prompt_buf);
/* These shouldn't actually persist across a GC, but
just in case... */

View File

@ -359,6 +359,7 @@ cont_proc {
gcMARK(c->runstack_saved);
gcMARK(c->prompt_id);
gcMARK(c->prompt_buf);
/* These shouldn't actually persist across a GC, but
just in case... */

View File

@ -6933,14 +6933,16 @@ static void prepare_thread_for_GC(Scheme_Object *t)
if (segpos < p->cont_mark_seg_count) {
Scheme_Cont_Mark *seg = p->cont_mark_stack_segments[segpos];
int stackpos = ((long)p->cont_mark_stack & SCHEME_MARK_SEGMENT_MASK);
for (i = stackpos; i < SCHEME_MARK_SEGMENT_SIZE; i++) {
if (seg[i].key) {
seg[i].key = NULL;
seg[i].val = NULL;
seg[i].cache = NULL;
} else {
/* NULL means we already cleared from here on. */
break;
if (seg) {
for (i = stackpos; i < SCHEME_MARK_SEGMENT_SIZE; i++) {
if (seg[i].key) {
seg[i].key = NULL;
seg[i].val = NULL;
seg[i].cache = NULL;
} else {
/* NULL means we already cleared from here on. */
break;
}
}
}
}