make SGC work with ephemerons

svn: r1532
This commit is contained in:
Matthew Flatt 2005-12-05 21:42:38 +00:00
parent be96f9c22b
commit de552808de
2 changed files with 18 additions and 6 deletions

View File

@ -3528,6 +3528,7 @@ static void prepare_stack_collect()
#endif
e = collect_stack[--collect_stack_count];
s = collect_stack[--collect_stack_count];
e += PTR_ALIGNMENT - 1;
PUSH_COLLECT(s, e, source);
semi_collect_stack(0);
@ -4113,6 +4114,8 @@ static void do_disappear_and_finals()
}
}
if (GC_push_last_roots_again) { GC_push_last_roots_again(); collect(); }
/* Deregister dangling disappearings: */
trim_disappearing(&disappearing);
trim_disappearing(&late_disappearing);

View File

@ -1763,11 +1763,21 @@ Scheme_Object *scheme_make_ephemeron(Scheme_Object *key, Scheme_Object *val)
return GC_malloc_ephemeron(key, val);
#else
Scheme_Ephemeron *e;
int can_gc = 1;
e = (Scheme_Ephemeron *)scheme_malloc_atomic(sizeof(Scheme_Ephemeron));
if (SCHEME_INTP(val) || !GC_base(val))
can_gc = 0;
if (can_gc) {
e = (Scheme_Ephemeron *)scheme_malloc_atomic(sizeof(Scheme_Ephemeron));
} else {
e = (Scheme_Ephemeron *)scheme_malloc(sizeof(Scheme_Ephemeron));
}
e->so.type = scheme_ephemeron_type;
e->next = ephemerons;
ephemerons = e;
if (can_gc) {
e->next = ephemerons;
ephemerons = e;
}
e->key = key;
e->val = val;
@ -1814,9 +1824,8 @@ static int mark_ephemerons()
for (e = ephemerons; e; e = next) {
next = e->next;
if (e->key) {
if (!GC_is_marked(e)
|| (!SCHEME_INTP(e->key) && !GC_is_marked(e->key))) {
if (e->key) {
if (!GC_is_marked(e) || !GC_is_marked(e->key)) {
/* No reason to mark, yet. Randomly put this one back
into one of the keep lists: */
if (mix & 0x1) {