Make GC callbacks members of NewGC
svn: r12549
This commit is contained in:
parent
e27ae4d457
commit
bea2297421
|
@ -162,10 +162,8 @@ void wxsScheme_setup(Scheme_Env *env)
|
||||||
get_ps_setup_from_user = scheme_false;
|
get_ps_setup_from_user = scheme_false;
|
||||||
message_box = scheme_false;
|
message_box = scheme_false;
|
||||||
|
|
||||||
orig_collect_start_callback = GC_collect_start_callback;
|
orig_collect_start_callback = GC_set_collect_start_callback(collect_start_callback);
|
||||||
GC_collect_start_callback = (GC_START_END_PTR)collect_start_callback;
|
orig_collect_end_callback = GC_set_collect_end_callback(collect_end_callback);
|
||||||
orig_collect_end_callback = GC_collect_end_callback;
|
|
||||||
GC_collect_end_callback = (GC_START_END_PTR)collect_end_callback;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -320,8 +320,20 @@ void GC_maybe_gc()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PLTSCHEME: notification callback for starting/ending a GC */
|
/* PLTSCHEME: notification callback for starting/ending a GC */
|
||||||
void (*GC_collect_start_callback)(void) = NULL;
|
GC_collect_start_callback_Proc GC_collect_start_callback = NULL;
|
||||||
void (*GC_collect_end_callback)(void) = NULL;
|
GC_collect_end_callback_Proc GC_collect_end_callback = NULL;
|
||||||
|
GC_collect_start_callback_Proc GC_set_collect_start_callback(GC_collect_start_callback_Proc func) {
|
||||||
|
GC_collect_start_callback_Proc old;
|
||||||
|
old = GC_collect_start_callback;
|
||||||
|
GC_collect_start_callback = func;
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
GC_collect_end_callback_Proc GC_set_collect_end_callback(GC_collect_end_callback_Proc func) {
|
||||||
|
GC_collect_end_callback_Proc old;
|
||||||
|
old = GC_collect_end_callback;
|
||||||
|
GC_collect_end_callback = func;
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stop the world garbage collection. Assumes lock held, signals disabled.
|
* Stop the world garbage collection. Assumes lock held, signals disabled.
|
||||||
|
|
|
@ -1017,13 +1017,15 @@ extern void GC_thr_init GC_PROTO((void));/* Needed for Solaris/X86 */
|
||||||
#if defined(GC_REDIRECT_TO_LOCAL) && !defined(GC_LOCAL_ALLOC_H)
|
#if defined(GC_REDIRECT_TO_LOCAL) && !defined(GC_LOCAL_ALLOC_H)
|
||||||
# include "gc_local_alloc.h"
|
# include "gc_local_alloc.h"
|
||||||
#endif
|
#endif
|
||||||
|
typedef void (*GC_collect_start_callback_Proc)(void);
|
||||||
|
typedef void (*GC_collect_end_callback_Proc)(void);
|
||||||
|
|
||||||
/* PLTSCHEME: */
|
/* PLTSCHEME: */
|
||||||
GC_API void (*GC_custom_finalize)(void);
|
GC_API void (*GC_custom_finalize)(void);
|
||||||
GC_API void (*GC_push_last_roots)(void);
|
GC_API void (*GC_push_last_roots)(void);
|
||||||
GC_API void (*GC_push_last_roots_again)(void);
|
GC_API void (*GC_push_last_roots_again)(void);
|
||||||
GC_API void (*GC_collect_start_callback)(void);
|
GC_API GC_collect_start_callback_Proc GC_set_collect_start_callback(GC_collect_start_callback_Proc);
|
||||||
GC_API void (*GC_collect_end_callback)(void);
|
GC_API GC_collect_end_callback_Proc GC_set_collect_end_callback(GC_collect_end_callback_Proc);
|
||||||
GC_API void (*GC_out_of_memory)(void);
|
GC_API void (*GC_out_of_memory)(void);
|
||||||
GC_API int GC_did_mark_stack_overflow(void);
|
GC_API int GC_did_mark_stack_overflow(void);
|
||||||
GC_API void GC_mark_from_mark_stack(void);
|
GC_API void GC_mark_from_mark_stack(void);
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
typedef int (*Size_Proc)(void *obj);
|
typedef int (*Size_Proc)(void *obj);
|
||||||
typedef int (*Mark_Proc)(void *obj);
|
typedef int (*Mark_Proc)(void *obj);
|
||||||
typedef int (*Fixup_Proc)(void *obj);
|
typedef int (*Fixup_Proc)(void *obj);
|
||||||
|
typedef void (*GC_collect_start_callback_Proc)(void);
|
||||||
|
typedef void (*GC_collect_end_callback_Proc)(void);
|
||||||
|
typedef void (*GC_collect_inform_callback_Proc)(int major_gc, long pre_used, long post_used);
|
||||||
|
typedef unsigned long (*GC_get_thread_stack_base_Proc)(void);
|
||||||
/*
|
/*
|
||||||
Types of the traversal procs (supplied by MzScheme); see overview in README
|
Types of the traversal procs (supplied by MzScheme); see overview in README
|
||||||
for information about traversals. The return value is the size of
|
for information about traversals. The return value is the size of
|
||||||
|
@ -56,9 +60,9 @@ extern "C" {
|
||||||
/* Administration */
|
/* Administration */
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
||||||
GC2_EXTERN unsigned long (*GC_get_thread_stack_base)(void);
|
GC2_EXTERN void GC_set_get_thread_stack_base(unsigned long (*)(void));
|
||||||
/*
|
/*
|
||||||
Called by GC to get the base for stack traversal in the current
|
Sets callback called by GC to get the base for stack traversal in the current
|
||||||
thread (see README). The returned address must not be in the middle
|
thread (see README). The returned address must not be in the middle
|
||||||
of a variable-stack record. */
|
of a variable-stack record. */
|
||||||
|
|
||||||
|
@ -96,11 +100,11 @@ GC2_EXTERN void GC_register_thread(void *, void *);
|
||||||
/*
|
/*
|
||||||
Indicates that a a thread record is owned by a particular custodian. */
|
Indicates that a a thread record is owned by a particular custodian. */
|
||||||
|
|
||||||
GC2_EXTERN void (*GC_collect_start_callback)(void);
|
GC2_EXTERN GC_collect_start_callback_Proc GC_set_collect_start_callback(GC_collect_start_callback_Proc);
|
||||||
GC2_EXTERN void (*GC_collect_end_callback)(void);
|
GC2_EXTERN GC_collect_end_callback_Proc GC_set_collect_end_callback(GC_collect_end_callback_Proc);
|
||||||
GC2_EXTERN void (*GC_collect_inform_callback)(int major_gc, long pre_used, long post_used);
|
GC2_EXTERN void GC_set_collect_inform_callback(GC_collect_inform_callback_Proc);
|
||||||
/*
|
/*
|
||||||
Called by GC before/after performing a collection. Used by MzScheme
|
Sets callbacks called by GC before/after performing a collection. Used by MzScheme
|
||||||
to zero out some data and record collection times. The end
|
to zero out some data and record collection times. The end
|
||||||
procedure should be called before finalizations are performed. */
|
procedure should be called before finalizations are performed. */
|
||||||
|
|
||||||
|
|
|
@ -130,15 +130,31 @@ static THREAD_LOCAL NewGC *GC;
|
||||||
#define GENERATIONS 1
|
#define GENERATIONS 1
|
||||||
|
|
||||||
/* the externals */
|
/* the externals */
|
||||||
void (*GC_collect_start_callback)(void);
|
|
||||||
void (*GC_collect_end_callback)(void);
|
|
||||||
void (*GC_collect_inform_callback)(int major_gc, long pre_used, long post_used);
|
|
||||||
void (*GC_out_of_memory)(void);
|
void (*GC_out_of_memory)(void);
|
||||||
void (*GC_report_out_of_memory)(void);
|
void (*GC_report_out_of_memory)(void);
|
||||||
unsigned long (*GC_get_thread_stack_base)(void);
|
|
||||||
void (*GC_mark_xtagged)(void *obj);
|
void (*GC_mark_xtagged)(void *obj);
|
||||||
void (*GC_fixup_xtagged)(void *obj);
|
void (*GC_fixup_xtagged)(void *obj);
|
||||||
|
|
||||||
|
GC_collect_start_callback_Proc GC_set_collect_start_callback(GC_collect_start_callback_Proc func) {
|
||||||
|
NewGC *gc = GC_get_GC();
|
||||||
|
GC_collect_start_callback_Proc old;
|
||||||
|
old = gc->GC_collect_start_callback;
|
||||||
|
gc->GC_collect_start_callback = func;
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
GC_collect_end_callback_Proc GC_set_collect_end_callback(GC_collect_end_callback_Proc func) {
|
||||||
|
NewGC *gc = GC_get_GC();
|
||||||
|
GC_collect_end_callback_Proc old;
|
||||||
|
old = gc->GC_collect_end_callback;
|
||||||
|
gc->GC_collect_end_callback = func;
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
void GC_set_collect_inform_callback(void (*func)(int major_gc, long pre_used, long post_used)) {
|
||||||
|
NewGC *gc = GC_get_GC();
|
||||||
|
gc->GC_collect_inform_callback = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "my_qsort.c"
|
#include "my_qsort.c"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -982,8 +998,13 @@ unsigned long GC_get_stack_base()
|
||||||
return gc->stack_base;
|
return gc->stack_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GC_set_get_thread_stack_base(unsigned long (*func)(void)) {
|
||||||
|
NewGC *gc = GC_get_GC();
|
||||||
|
gc->GC_get_thread_stack_base = func;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void *get_stack_base(NewGC *gc) {
|
static inline void *get_stack_base(NewGC *gc) {
|
||||||
if (GC_get_thread_stack_base) return (void*) GC_get_thread_stack_base();
|
if (gc->GC_get_thread_stack_base) return (void*) gc->GC_get_thread_stack_base();
|
||||||
return (void*) gc->stack_base;
|
return (void*) gc->stack_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2409,8 +2430,8 @@ static void garbage_collect(NewGC *gc, int force_full)
|
||||||
TIME_INIT();
|
TIME_INIT();
|
||||||
|
|
||||||
/* inform the system (if it wants us to) that we're starting collection */
|
/* inform the system (if it wants us to) that we're starting collection */
|
||||||
if(GC_collect_start_callback)
|
if(gc->GC_collect_start_callback)
|
||||||
GC_collect_start_callback();
|
gc->GC_collect_start_callback();
|
||||||
|
|
||||||
TIME_STEP("started");
|
TIME_STEP("started");
|
||||||
|
|
||||||
|
@ -2530,10 +2551,10 @@ static void garbage_collect(NewGC *gc, int force_full)
|
||||||
gc->last_full_mem_use = gc->memory_in_use;
|
gc->last_full_mem_use = gc->memory_in_use;
|
||||||
|
|
||||||
/* inform the system (if it wants us to) that we're done with collection */
|
/* inform the system (if it wants us to) that we're done with collection */
|
||||||
if (GC_collect_start_callback)
|
if (gc->GC_collect_start_callback)
|
||||||
GC_collect_end_callback();
|
gc->GC_collect_end_callback();
|
||||||
if (GC_collect_inform_callback)
|
if (gc->GC_collect_inform_callback)
|
||||||
GC_collect_inform_callback(gc->gc_full, old_mem_use + old_gen0, gc->memory_in_use);
|
gc->GC_collect_inform_callback(gc->gc_full, old_mem_use + old_gen0, gc->memory_in_use);
|
||||||
|
|
||||||
TIME_STEP("ended");
|
TIME_STEP("ended");
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,12 @@ typedef struct NewGC {
|
||||||
unsigned long num_minor_collects;
|
unsigned long num_minor_collects;
|
||||||
unsigned long num_major_collects;
|
unsigned long num_major_collects;
|
||||||
|
|
||||||
|
/* Callbacks */
|
||||||
|
void (*GC_collect_start_callback)(void);
|
||||||
|
void (*GC_collect_end_callback)(void);
|
||||||
|
void (*GC_collect_inform_callback)(int major_gc, long pre_used, long post_used);
|
||||||
|
unsigned long (*GC_get_thread_stack_base)(void);
|
||||||
|
|
||||||
GC_Immobile_Box *immobile_boxes;
|
GC_Immobile_Box *immobile_boxes;
|
||||||
|
|
||||||
/* Common with CompactGC */
|
/* Common with CompactGC */
|
||||||
|
|
|
@ -776,10 +776,25 @@ static long mem_traced;
|
||||||
static long num_chunks;
|
static long num_chunks;
|
||||||
static long num_blocks;
|
static long num_blocks;
|
||||||
|
|
||||||
void (*GC_collect_start_callback)(void);
|
typedef void (*GC_collect_start_callback_Proc)(void);
|
||||||
void (*GC_collect_end_callback)(void);
|
typedef void (*GC_collect_end_callback_Proc)(void);
|
||||||
|
GC_collect_start_callback_Proc GC_collect_start_callback;
|
||||||
|
GC_collect_end_callback_Proc GC_collect_end_callback;
|
||||||
void (*GC_custom_finalize)(void);
|
void (*GC_custom_finalize)(void);
|
||||||
|
|
||||||
|
GC_collect_start_callback_Proc GC_set_collect_start_callback(GC_collect_start_callback_Proc) {
|
||||||
|
GC_collect_start_callback_Proc old;
|
||||||
|
old = GC_collect_start_callback;
|
||||||
|
GC_collect_start_callback = func;
|
||||||
|
return old
|
||||||
|
}
|
||||||
|
GC_collect_end_callback_Proc GC_set_collect_end_callback(GC_collect_end_callback_Proc) {
|
||||||
|
GC_collect_end_callback_Proc old
|
||||||
|
old = GC_collect_end_callback;
|
||||||
|
GC_collect_end_callback = func;
|
||||||
|
return old
|
||||||
|
}
|
||||||
|
|
||||||
static long roots_count;
|
static long roots_count;
|
||||||
static long roots_size;
|
static long roots_size;
|
||||||
static unsigned long *roots;
|
static unsigned long *roots;
|
||||||
|
|
|
@ -892,9 +892,6 @@ typedef struct Scheme_Thread_Memory {
|
||||||
|
|
||||||
Scheme_Thread_Memory *tm_start, *tm_next;
|
Scheme_Thread_Memory *tm_start, *tm_next;
|
||||||
|
|
||||||
extern MZ_DLLIMPORT void (*GC_collect_start_callback)(void);
|
|
||||||
extern MZ_DLLIMPORT void (*GC_collect_end_callback)(void);
|
|
||||||
|
|
||||||
void scheme_init_thread_memory()
|
void scheme_init_thread_memory()
|
||||||
{
|
{
|
||||||
#ifndef MZ_PRECISE_GC
|
#ifndef MZ_PRECISE_GC
|
||||||
|
@ -915,8 +912,8 @@ void scheme_init_thread_memory()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* scheme_init_thread() will replace these: */
|
/* scheme_init_thread() will replace these: */
|
||||||
GC_collect_start_callback = scheme_suspend_remembered_threads;
|
GC_set_collect_start_callback(scheme_suspend_remembered_threads);
|
||||||
GC_collect_end_callback = scheme_resume_remembered_threads;
|
GC_set_collect_end_callback(scheme_resume_remembered_threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scheme_Thread_Memory *scheme_remember_thread(void *t, int autoclose)
|
Scheme_Thread_Memory *scheme_remember_thread(void *t, int autoclose)
|
||||||
|
|
|
@ -2053,7 +2053,7 @@ Scheme_Object *scheme_dump_gc_stats(int c, Scheme_Object *p[])
|
||||||
scheme_console_printf(" swapped in\n");
|
scheme_console_printf(" swapped in\n");
|
||||||
var_stack = GC_variable_stack;
|
var_stack = GC_variable_stack;
|
||||||
delta = 0;
|
delta = 0;
|
||||||
limit = (void *)GC_get_thread_stack_base();
|
limit = (void *)scheme_get_current_thread_stack_start();
|
||||||
} else {
|
} else {
|
||||||
scheme_console_printf(" swapped out\n");
|
scheme_console_printf(" swapped out\n");
|
||||||
var_stack = (void **)t->jmpup_buf.gc_var_stack;
|
var_stack = (void **)t->jmpup_buf.gc_var_stack;
|
||||||
|
|
|
@ -200,10 +200,6 @@ Scheme_Object *scheme_break_enabled_key;
|
||||||
|
|
||||||
long scheme_total_gc_time;
|
long scheme_total_gc_time;
|
||||||
static long start_this_gc_time, end_this_gc_time;
|
static long start_this_gc_time, end_this_gc_time;
|
||||||
#ifndef MZ_PRECISE_GC
|
|
||||||
extern MZ_DLLIMPORT void (*GC_collect_start_callback)(void);
|
|
||||||
extern MZ_DLLIMPORT void (*GC_collect_end_callback)(void);
|
|
||||||
#endif
|
|
||||||
static void get_ready_for_GC(void);
|
static void get_ready_for_GC(void);
|
||||||
static void done_with_GC(void);
|
static void done_with_GC(void);
|
||||||
#ifdef MZ_PRECISE_GC
|
#ifdef MZ_PRECISE_GC
|
||||||
|
@ -437,7 +433,7 @@ extern BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MZ_PRECISE_GC
|
#ifdef MZ_PRECISE_GC
|
||||||
static unsigned long get_current_stack_start(void);
|
unsigned long scheme_get_current_thread_stack_start(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
|
@ -2106,10 +2102,10 @@ static Scheme_Thread *make_thread(Scheme_Config *config,
|
||||||
thread_swap_callbacks = scheme_null;
|
thread_swap_callbacks = scheme_null;
|
||||||
thread_swap_out_callbacks = scheme_null;
|
thread_swap_out_callbacks = scheme_null;
|
||||||
|
|
||||||
GC_collect_start_callback = get_ready_for_GC;
|
GC_set_collect_start_callback(get_ready_for_GC);
|
||||||
GC_collect_end_callback = done_with_GC;
|
GC_set_collect_end_callback(done_with_GC);
|
||||||
#ifdef MZ_PRECISE_GC
|
#ifdef MZ_PRECISE_GC
|
||||||
GC_collect_inform_callback = inform_GC;
|
GC_set_collect_inform_callback(inform_GC);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LINK_EXTENSIONS_BY_TABLE
|
#ifdef LINK_EXTENSIONS_BY_TABLE
|
||||||
|
@ -2118,7 +2114,7 @@ static Scheme_Thread *make_thread(Scheme_Config *config,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MZ_PRECISE_GC) || defined(USE_SENORA_GC)
|
#if defined(MZ_PRECISE_GC) || defined(USE_SENORA_GC)
|
||||||
GC_get_thread_stack_base = get_current_stack_start;
|
GC_set_get_thread_stack_base(scheme_get_current_thread_stack_start);
|
||||||
#endif
|
#endif
|
||||||
process->stack_start = stack_base;
|
process->stack_start = stack_base;
|
||||||
|
|
||||||
|
@ -7448,7 +7444,7 @@ Scheme_Jumpup_Buf_Holder *scheme_new_jmpupbuf_holder(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MZ_PRECISE_GC
|
#ifdef MZ_PRECISE_GC
|
||||||
static unsigned long get_current_stack_start(void)
|
unsigned long scheme_get_current_thread_stack_start(void)
|
||||||
{
|
{
|
||||||
Scheme_Thread *p;
|
Scheme_Thread *p;
|
||||||
p = scheme_current_thread;
|
p = scheme_current_thread;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user