fixing subtle bug where heapsize was set wrong at some points

This commit is contained in:
JeffBezanson 2010-07-06 23:13:54 +00:00
parent 8ea6157c15
commit 561e0b07e1
1 changed files with 6 additions and 5 deletions

View File

@ -529,6 +529,9 @@ void gc(int mustgrow)
fl_readstate_t *rs; fl_readstate_t *rs;
curheap = tospace; curheap = tospace;
if (grew)
lim = curheap+heapsize*2-sizeof(cons_t);
else
lim = curheap+heapsize-sizeof(cons_t); lim = curheap+heapsize-sizeof(cons_t);
if (fl_throwing_frame > curr_frame) { if (fl_throwing_frame > curr_frame) {
@ -584,14 +587,12 @@ void gc(int mustgrow)
// more space to fill next time. if we grew tospace last time, // more space to fill next time. if we grew tospace last time,
// grow the other half of the heap this time to catch up. // grow the other half of the heap this time to catch up.
if (grew || ((lim-curheap) < (int)(heapsize/5)) || mustgrow) { if (grew || ((lim-curheap) < (int)(heapsize/5)) || mustgrow) {
temp = LLT_REALLOC(tospace, grew ? heapsize : heapsize*2); temp = LLT_REALLOC(tospace, heapsize*2);
if (temp == NULL) if (temp == NULL)
fl_raise(memory_exception_value); fl_raise(memory_exception_value);
tospace = temp; tospace = temp;
if (!grew) { if (grew) {
heapsize*=2; heapsize*=2;
}
else {
temp = bitvector_resize(consflags, heapsize/sizeof(cons_t), 1); temp = bitvector_resize(consflags, heapsize/sizeof(cons_t), 1);
if (temp == NULL) if (temp == NULL)
fl_raise(memory_exception_value); fl_raise(memory_exception_value);