Moved immobile boxes to their own c file, moved immobile_boxes to NewGC struct
svn: r12269
This commit is contained in:
parent
4557c6cef1
commit
d158420c94
|
@ -44,3 +44,10 @@ typedef struct GC_Ephemeron {
|
|||
/* The rest is up to us: */
|
||||
struct GC_Ephemeron *next;
|
||||
} GC_Ephemeron;
|
||||
|
||||
typedef struct GC_Immobile_Box {
|
||||
void *p; /* this must be first or mred dies */
|
||||
struct GC_Immobile_Box *next;
|
||||
struct GC_Immobile_Box *prev;
|
||||
} GC_Immobile_Box;
|
||||
|
||||
|
|
49
src/mzscheme/gc2/immobile_boxes.c
Normal file
49
src/mzscheme/gc2/immobile_boxes.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*****************************************************************************/
|
||||
/* immobile boxes */
|
||||
/*****************************************************************************/
|
||||
void **GC_malloc_immobile_box(void *p)
|
||||
{
|
||||
GC_Immobile_Box *ib = malloc(sizeof(GC_Immobile_Box));
|
||||
if(!ib) GCERR((GCOUTF, "Couldn't allocate space for immobile box!\n"));
|
||||
ib->p = p;
|
||||
ib->next = GC->immobile_boxes;
|
||||
ib->prev = NULL;
|
||||
if(ib->next) ib->next->prev = ib;
|
||||
GC->immobile_boxes = ib;
|
||||
return (void**)ib;
|
||||
}
|
||||
|
||||
void GC_free_immobile_box(void **b)
|
||||
{
|
||||
GC_Immobile_Box *ib;
|
||||
|
||||
for(ib = GC->immobile_boxes; ib; ib = ib->next)
|
||||
if(PPTR(ib) == b) {
|
||||
if(ib->prev) ib->prev->next = ib->next;
|
||||
if(!ib->prev) GC->immobile_boxes = ib->next;
|
||||
if(ib->next) ib->next->prev = ib->prev;
|
||||
free(ib);
|
||||
return;
|
||||
}
|
||||
GCWARN((GCOUTF, "Attempted free of non-existent immobile box %p\n", b));
|
||||
}
|
||||
|
||||
#define traverse_immobiles(gcMUCK, set_bt_src) { \
|
||||
GC_Immobile_Box *ib; \
|
||||
for(ib = GC->immobile_boxes; ib; ib = ib->next) { \
|
||||
set_bt_src(ib, BT_IMMOBILE); \
|
||||
gcMUCK(ib->p); \
|
||||
} \
|
||||
}
|
||||
|
||||
inline static void mark_immobiles(void)
|
||||
{
|
||||
traverse_immobiles(gcMARK, set_backtrace_source);
|
||||
}
|
||||
|
||||
inline static void repair_immobiles(void)
|
||||
{
|
||||
traverse_immobiles(gcFIXUP, two_arg_no_op);
|
||||
}
|
||||
|
||||
|
|
@ -943,58 +943,7 @@ inline static void repair_roots()
|
|||
traverse_roots(gcFIXUP, two_arg_no_op);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* immobile boxes */
|
||||
/*****************************************************************************/
|
||||
struct immobile_box {
|
||||
void *p; /* this must be first or mred dies */
|
||||
struct immobile_box *next, *prev;
|
||||
};
|
||||
|
||||
static struct immobile_box *immobile_boxes = NULL;
|
||||
|
||||
void **GC_malloc_immobile_box(void *p)
|
||||
{
|
||||
struct immobile_box *ib = malloc(sizeof(struct immobile_box));
|
||||
if (!ib) out_of_memory();
|
||||
ib->p = p; ib->next = immobile_boxes; ib->prev = NULL;
|
||||
if(ib->next) ib->next->prev = ib;
|
||||
immobile_boxes = ib;
|
||||
return (void**)ib;
|
||||
}
|
||||
|
||||
void GC_free_immobile_box(void **b)
|
||||
{
|
||||
struct immobile_box *ib;
|
||||
|
||||
for(ib = immobile_boxes; ib; ib = ib->next)
|
||||
if(PPTR(ib) == b) {
|
||||
if(ib->prev) ib->prev->next = ib->next;
|
||||
if(!ib->prev) immobile_boxes = ib->next;
|
||||
if(ib->next) ib->next->prev = ib->prev;
|
||||
free(ib);
|
||||
return;
|
||||
}
|
||||
GCWARN((GCOUTF, "Attempted free of non-existent immobile box %p\n", b));
|
||||
}
|
||||
|
||||
#define traverse_immobiles(gcMUCK, set_bt_src) { \
|
||||
struct immobile_box *ib; \
|
||||
for(ib = immobile_boxes; ib; ib = ib->next) { \
|
||||
set_bt_src(ib, BT_IMMOBILE); \
|
||||
gcMUCK(ib->p); \
|
||||
} \
|
||||
}
|
||||
|
||||
inline static void mark_immobiles(void)
|
||||
{
|
||||
traverse_immobiles(gcMARK, set_backtrace_source);
|
||||
}
|
||||
|
||||
inline static void repair_immobiles(void)
|
||||
{
|
||||
traverse_immobiles(gcFIXUP, two_arg_no_op);
|
||||
}
|
||||
#include "immobile_boxes.c"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* finalizers */
|
||||
|
|
|
@ -114,6 +114,7 @@ typedef struct NewGC {
|
|||
GC_Weak_Box *weak_boxes;
|
||||
GC_Ephemeron *ephemerons;
|
||||
int num_last_seen_ephemerons;
|
||||
GC_Immobile_Box *immobile_boxes;
|
||||
} NewGC;
|
||||
|
||||
void NewGC_initialize(NewGC *newgc) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user