2004-08-29 03:20:19 -04:00
|
|
|
bool gc_in_progress;
|
2005-02-17 21:19:27 -05:00
|
|
|
|
|
|
|
/* GC is off during heap walking */
|
|
|
|
bool heap_scan;
|
|
|
|
|
2005-03-21 20:59:30 -05:00
|
|
|
s64 gc_time;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2004-11-27 22:26:05 -05:00
|
|
|
/* Given a pointer to oldspace, copy it to newspace. */
|
|
|
|
INLINE void* copy_untagged_object(void* pointer, CELL size)
|
|
|
|
{
|
|
|
|
void* newpointer = allot(size);
|
|
|
|
memcpy(newpointer,pointer,size);
|
|
|
|
|
|
|
|
return newpointer;
|
|
|
|
}
|
|
|
|
|
2004-12-11 13:26:36 -05:00
|
|
|
CELL copy_object_impl(CELL pointer);
|
|
|
|
|
2005-05-10 22:30:58 -04:00
|
|
|
/* #define GC_DEBUG */
|
|
|
|
|
|
|
|
INLINE void gc_debug(char* msg, CELL x) {
|
|
|
|
#ifdef GC_DEBUG
|
|
|
|
printf("%s %d\n",msg,x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-02-19 23:25:21 -05:00
|
|
|
INLINE CELL copy_object(CELL pointer)
|
2004-12-11 13:26:36 -05:00
|
|
|
{
|
|
|
|
CELL tag;
|
|
|
|
CELL header;
|
2005-04-25 03:33:33 -04:00
|
|
|
CELL untagged;
|
2004-12-11 13:26:36 -05:00
|
|
|
|
2005-05-10 22:30:58 -04:00
|
|
|
gc_debug("copy object",pointer);
|
|
|
|
|
2004-12-11 13:26:36 -05:00
|
|
|
if(pointer == F)
|
2005-02-19 23:25:21 -05:00
|
|
|
return F;
|
2004-12-11 13:26:36 -05:00
|
|
|
|
|
|
|
tag = TAG(pointer);
|
|
|
|
|
|
|
|
if(tag == FIXNUM_TYPE)
|
2005-02-19 23:25:21 -05:00
|
|
|
return pointer;
|
2005-01-27 20:06:10 -05:00
|
|
|
|
2004-12-11 13:26:36 -05:00
|
|
|
header = get(UNTAG(pointer));
|
2005-04-25 03:33:33 -04:00
|
|
|
untagged = UNTAG(header);
|
|
|
|
if(TAG(header) != FIXNUM_TYPE && in_zone(&active,untagged))
|
2005-05-10 22:30:58 -04:00
|
|
|
{
|
|
|
|
gc_debug("forwarding",untagged);
|
2005-04-25 03:33:33 -04:00
|
|
|
return RETAG(untagged,tag);
|
2005-05-10 22:30:58 -04:00
|
|
|
}
|
2004-12-11 13:26:36 -05:00
|
|
|
else
|
2005-02-19 23:25:21 -05:00
|
|
|
return RETAG(copy_object_impl(pointer),tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define COPY_OBJECT(lvalue) lvalue = copy_object(lvalue)
|
|
|
|
|
|
|
|
INLINE void copy_handle(CELL* handle)
|
|
|
|
{
|
|
|
|
COPY_OBJECT(*handle);
|
2004-12-11 13:26:36 -05:00
|
|
|
}
|
|
|
|
|
2004-07-16 02:26:21 -04:00
|
|
|
void collect_roots(void);
|
2005-05-10 22:30:58 -04:00
|
|
|
void collect_cards(void);
|
|
|
|
void clear_cards(void);
|
2004-07-16 02:26:21 -04:00
|
|
|
void primitive_gc(void);
|
2004-10-12 23:49:43 -04:00
|
|
|
void maybe_garbage_collection(void);
|
2004-11-22 19:15:14 -05:00
|
|
|
void primitive_gc_time(void);
|