Commit c51700b1 authored by Laszlo Domoszlai's avatar Laszlo Domoszlai
Browse files

properly GC unboxed arrays

parent 2866c938
......@@ -59,15 +59,7 @@ void gc()
if(ptr->desc == (Desc*) __ARRAY__)
{
if(ptr->_array.is_boxed)
{
size = sizeof (Desc) + sizeof (Array) + (ptr->_array.bytes_per_elem * ptr->_array.length);
}
else
{
// TODO: other cases
}
size = sizeof (Desc) + sizeof (Array) + (ptr->_array.bytes_per_elem * ptr->_array.length);
}
else
{
......@@ -86,6 +78,9 @@ void gc()
#ifdef DEBUG_GC
printf("ALLOC AFTER FIRST STAGE: %i\n", allocptr - heap_base_swap);
#endif
int arity;
Thunk** args = NULL;
while(scanptr < allocptr)
{
......@@ -94,15 +89,27 @@ void gc()
if(ptr->desc == (Desc*) __ARRAY__)
{
scanptr += sizeof (Desc) + sizeof (Array) + (ptr->_array.bytes_per_elem * ptr->_array.length);
if(ptr->_array.is_boxed)
{
arity = 0;
}
else
{
arity = ptr->_array.length;
args = ptr->_array._elems;
}
}
else
{
scanptr += ptr->desc->thunk_size;
arity = ptr->desc->arity;
args = ptr->_args;
}
for(int i=0; i<ptr->desc->arity; i++)
for(int i=0; i<arity; i++)
{
Thunk* arg = (Thunk*) ptr->_args[i];
Thunk* arg = (Thunk*) args[i];
// do not copy forward pointers
// also do it outside, because the final thunk may be out of the heap
......@@ -128,15 +135,7 @@ void gc()
if(arg->desc == (Desc*) __ARRAY__)
{
if(arg->_array.is_boxed)
{
size = sizeof (Desc) + sizeof (Array) + (arg->_array.bytes_per_elem * arg->_array.length);
}
else
{
// TODO: other cases
}
size = sizeof (Desc) + sizeof (Array) + (arg->_array.bytes_per_elem * arg->_array.length);
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment