Save off and restore all THREAD_LOCALS when switching GCs

svn: r12805
This commit is contained in:
Kevin Tew 2008-12-12 19:35:24 +00:00
parent 4cc0633218
commit 1af924d8de
2 changed files with 23 additions and 3 deletions

View File

@ -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();

View File

@ -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);