factor/native/gc.h

67 lines
1.2 KiB
C
Raw Normal View History

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
/* 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;
}
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)
{
CELL tag;
CELL header;
CELL untagged;
2005-05-10 22:30:58 -04:00
gc_debug("copy object",pointer);
if(pointer == F)
2005-02-19 23:25:21 -05:00
return F;
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
header = get(UNTAG(pointer));
untagged = UNTAG(header);
if(TAG(header) != FIXNUM_TYPE && in_zone(&active,untagged))
2005-05-10 22:30:58 -04:00
{
gc_debug("forwarding",untagged);
return RETAG(untagged,tag);
2005-05-10 22:30:58 -04: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-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);
void maybe_garbage_collection(void);
2004-11-22 19:15:14 -05:00
void primitive_gc_time(void);