Save off and restore all THREAD_LOCALS when switching GCs
svn: r12805
This commit is contained in:
parent
4cc0633218
commit
1af924d8de
|
@ -1528,12 +1528,27 @@ void GC_construct_child_gc() {
|
|||
newgc->primoridal_gc = MASTERGC;
|
||||
}
|
||||
|
||||
static inline void save_globals_to_gc(NewGC *gc) {
|
||||
gc->saved_mark_stack = mark_stack;
|
||||
gc->saved_GC_variable_stack = GC_variable_stack;
|
||||
gc->saved_GC_gen0_alloc_page_ptr = GC_gen0_alloc_page_ptr;
|
||||
gc->saved_GC_gen0_alloc_page_end = GC_gen0_alloc_page_end;
|
||||
}
|
||||
|
||||
static inline void restore_globals_from_gc(NewGC *gc) {
|
||||
mark_stack = gc->saved_mark_stack;
|
||||
GC_variable_stack = gc->saved_GC_variable_stack;
|
||||
GC_gen0_alloc_page_ptr = gc->saved_GC_gen0_alloc_page_ptr;
|
||||
GC_gen0_alloc_page_end = gc->saved_GC_gen0_alloc_page_end;
|
||||
}
|
||||
|
||||
void GC_switch_out_master_gc() {
|
||||
static int initialized = 0;
|
||||
|
||||
if(!initialized) {
|
||||
initialized = 1;
|
||||
MASTERGC = GC_get_GC();
|
||||
save_globals_to_gc(MASTERGC);
|
||||
GC_construct_child_gc();
|
||||
}
|
||||
else {
|
||||
|
@ -1544,9 +1559,9 @@ void GC_switch_out_master_gc() {
|
|||
|
||||
void GC_switch_in_master_gc() {
|
||||
GC_set_GC(MASTERGC);
|
||||
restore_globals_from_gc(MASTERGC);
|
||||
}
|
||||
|
||||
|
||||
void GC_gcollect(void)
|
||||
{
|
||||
NewGC *gc = GC_get_GC();
|
||||
|
|
|
@ -147,8 +147,6 @@ typedef struct NewGC {
|
|||
AccountHook *hooks;
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned long number_of_gc_runs;
|
||||
unsigned int since_last_full;
|
||||
unsigned long last_full_mem_use;
|
||||
|
@ -157,6 +155,13 @@ typedef struct NewGC {
|
|||
unsigned long peak_memory_use;
|
||||
unsigned long num_minor_collects;
|
||||
unsigned long num_major_collects;
|
||||
|
||||
/* THREAD_LOCAL variables that need to be saved off */
|
||||
MarkSegment *saved_mark_stack;
|
||||
void *saved_GC_variable_stack;
|
||||
unsigned long saved_GC_gen0_alloc_page_ptr;
|
||||
unsigned long saved_GC_gen0_alloc_page_end;
|
||||
|
||||
|
||||
/* Callbacks */
|
||||
void (*GC_collect_start_callback)(void);
|
||||
|
|
Loading…
Reference in New Issue
Block a user