cards_offset register was being clobbered, leading to runtime crashes from callback use
parent
2a989bad82
commit
fe28ef4ec6
10
native/gc.c
10
native/gc.c
|
@ -10,6 +10,14 @@ CELL init_zone(ZONE *z, CELL size, CELL base)
|
|||
return z->limit;
|
||||
}
|
||||
|
||||
/* update this global variable. since it is stored in a non-volatile register,
|
||||
we need to save its contents and re-initialize it when entering a callback,
|
||||
and restore its contents when leaving the callback. see stack.c */
|
||||
void update_cards_offset(void)
|
||||
{
|
||||
cards_offset = (CELL)cards - (heap_start >> CARD_BITS);
|
||||
}
|
||||
|
||||
/* input parameters must be 8 byte aligned */
|
||||
/* the heap layout is important:
|
||||
- two semispaces: tenured and prior
|
||||
|
@ -35,7 +43,7 @@ void init_arena(CELL gens, CELL young_size, CELL aging_size)
|
|||
|
||||
cards = safe_malloc(cards_size);
|
||||
cards_end = cards + cards_size;
|
||||
cards_offset = (CELL)cards - (heap_start >> CARD_BITS);
|
||||
update_cards_offset();
|
||||
|
||||
alloter = heap_start;
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ INLINE void* allot_object(CELL type, CELL length)
|
|||
return object;
|
||||
}
|
||||
|
||||
void update_cards_offset(void);
|
||||
CELL collect_next(CELL scan);
|
||||
void garbage_collection(CELL gen);
|
||||
void primitive_gc(void);
|
||||
|
|
|
@ -56,9 +56,11 @@ void nest_stacks(void)
|
|||
new_stacks->call_region = alloc_bounded_block(cs_size);
|
||||
new_stacks->next = stack_chain;
|
||||
stack_chain = new_stacks;
|
||||
|
||||
callframe = F;
|
||||
reset_datastack();
|
||||
reset_callstack();
|
||||
update_cards_offset();
|
||||
}
|
||||
|
||||
/* called when leaving a compiled callback */
|
||||
|
|
Loading…
Reference in New Issue