factor/native/scan.h

52 lines
1018 B
C
Raw Normal View History

2005-02-14 21:58:07 -05:00
/* A heap walk allows useful things to be done, like finding all
references to an object for debugging purposes. */
2005-02-17 21:19:27 -05:00
CELL heap_scan_ptr;
/* End of heap when walk was started; prevents infinite loop if
walk consing */
CELL heap_scan_end;
2005-02-14 21:58:07 -05:00
/* Begin iterating through the heap. This is not re-entrant. */
2005-02-17 21:19:27 -05:00
INLINE void begin_heap_scan(void)
2005-02-14 21:58:07 -05:00
{
2005-02-17 21:19:27 -05:00
heap_scan_ptr = active.base;
2005-02-14 21:58:07 -05:00
}
2005-02-14 22:29:40 -05:00
INLINE CELL heap_step(CELL* size, CELL* type)
2005-02-14 21:58:07 -05:00
{
2005-02-17 21:19:27 -05:00
CELL value = get(heap_scan_ptr);
CELL obj = heap_scan_ptr;
2005-02-14 21:58:07 -05:00
if(headerp(value))
{
2005-02-17 21:19:27 -05:00
*size = align8(untagged_object_size(heap_scan_ptr));
2005-02-14 21:58:07 -05:00
*type = untag_header(value);
}
else
{
*size = CELLS * 2;
*type = CONS_TYPE;
}
2005-02-17 21:19:27 -05:00
heap_scan_ptr += *size;
2005-02-14 21:58:07 -05:00
if(*type < HEADER_TYPE)
obj = RETAG(obj,*type);
else
obj = RETAG(obj,OBJECT_TYPE);
return obj;
}
INLINE bool walk_donep(void)
{
2005-02-17 21:19:27 -05:00
return (heap_scan_ptr >= active.here);
2005-02-14 21:58:07 -05:00
}
void primitive_heap_stats(void);
void primitive_instances(void);
2005-02-17 21:19:27 -05:00
void primitive_begin_scan(void);
void primitive_next_object(void);
void primitive_end_scan(void);