fix closure GC handling when closure is only half-formed
This commit is contained in:
parent
503485b5a4
commit
240d95ada6
|
@ -10,55 +10,58 @@
|
||||||
if (data) {
|
if (data) {
|
||||||
/* GLOBAL ASSUMPTION: prefix is at the end of a closure */
|
/* GLOBAL ASSUMPTION: prefix is at the end of a closure */
|
||||||
Scheme_Prefix *pf = (Scheme_Prefix *)c->vals[closure_size - 1];
|
Scheme_Prefix *pf = (Scheme_Prefix *)c->vals[closure_size - 1];
|
||||||
/* Since pf hasn't been marked, we don't need a GC_resolve(): */
|
|
||||||
int *use_bits = PREFIX_TO_USE_BITS(pf);
|
|
||||||
uintptr_t map;
|
|
||||||
|
|
||||||
if (!pf->next_final) {
|
if (pf) {
|
||||||
/* We're the first to look at this prefix... */
|
/* Since pf hasn't been marked, we don't need a GC_resolve(): */
|
||||||
if (pf->num_stxes) {
|
int *use_bits = PREFIX_TO_USE_BITS(pf);
|
||||||
/* Mark all syntax-object references */
|
uintptr_t map;
|
||||||
for (i = pf->num_stxes+1; i--;) {
|
|
||||||
gcMARK2(pf->a[i+pf->num_toplevels], gc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Add it to the chain of prefixes to finish after
|
|
||||||
all other marking: */
|
|
||||||
pf->next_final = scheme_prefix_finalize;
|
|
||||||
scheme_prefix_finalize = pf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mark just the elements of the prefix that are (newly) used: */
|
if (!pf->next_final) {
|
||||||
if ((uintptr_t)data->tl_map & 0x1) {
|
/* We're the first to look at this prefix... */
|
||||||
map = ((uintptr_t)data->tl_map) >> 1;
|
if (pf->num_stxes) {
|
||||||
for (i = 0; i < 31; i++) {
|
/* Mark all syntax-object references */
|
||||||
if (map & (1 << i)) {
|
for (i = pf->num_stxes+1; i--;) {
|
||||||
if (!(use_bits[0] & (1 << i))) {
|
gcMARK2(pf->a[i+pf->num_toplevels], gc);
|
||||||
if ((i < pf->num_toplevels) || !pf->num_stxes)
|
|
||||||
gcMARK2(pf->a[i], gc);
|
|
||||||
else
|
|
||||||
gcMARK2(pf->a[i + pf->num_stxes + 1], gc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Add it to the chain of prefixes to finish after
|
||||||
|
all other marking: */
|
||||||
|
pf->next_final = scheme_prefix_finalize;
|
||||||
|
scheme_prefix_finalize = pf;
|
||||||
}
|
}
|
||||||
use_bits[0] |= (map & 0x7FFFFFFF);
|
|
||||||
} else {
|
|
||||||
int *u = (int *)GC_resolve2(data->tl_map, gc), j, pos;
|
|
||||||
|
|
||||||
for (i = u[0]; i--; ) {
|
/* Mark just the elements of the prefix that are (newly) used: */
|
||||||
map = u[i+1];
|
if ((uintptr_t)data->tl_map & 0x1) {
|
||||||
for (j = 0; j < 32; j++) {
|
map = ((uintptr_t)data->tl_map) >> 1;
|
||||||
if (map & (1 << j)) {
|
for (i = 0; i < 31; i++) {
|
||||||
if (!(use_bits[i] & (1 << j))) {
|
if (map & (1 << i)) {
|
||||||
pos = (i * 32) + j;
|
if (!(use_bits[0] & (1 << i))) {
|
||||||
if ((pos < pf->num_toplevels) || !pf->num_stxes)
|
if ((i < pf->num_toplevels) || !pf->num_stxes)
|
||||||
gcMARK2(pf->a[pos], gc);
|
gcMARK2(pf->a[i], gc);
|
||||||
else
|
else
|
||||||
gcMARK2(pf->a[pos + pf->num_stxes + 1], gc);
|
gcMARK2(pf->a[i + pf->num_stxes + 1], gc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
use_bits[i] |= map;
|
use_bits[0] |= (map & 0x7FFFFFFF);
|
||||||
|
} else {
|
||||||
|
int *u = (int *)GC_resolve2(data->tl_map, gc), j, pos;
|
||||||
|
|
||||||
|
for (i = u[0]; i--; ) {
|
||||||
|
map = u[i+1];
|
||||||
|
for (j = 0; j < 32; j++) {
|
||||||
|
if (map & (1 << j)) {
|
||||||
|
if (!(use_bits[i] & (1 << j))) {
|
||||||
|
pos = (i * 32) + j;
|
||||||
|
if ((pos < pf->num_toplevels) || !pf->num_stxes)
|
||||||
|
gcMARK2(pf->a[pos], gc);
|
||||||
|
else
|
||||||
|
gcMARK2(pf->a[pos + pf->num_stxes + 1], gc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
use_bits[i] |= map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user