X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fcheneygc.c;h=db74f54e621a8a1c084eebaec6eaa6a366e91d97;hb=c75cf4e142aaf9a72433ea6db778d8111a0b1c83;hp=0f7d38b75b011d793e8e205dd23b7977bf877ab5;hpb=1de12891f900d156ed035a097561ecd7755a256a;p=sbcl.git diff --git a/src/runtime/cheneygc.c b/src/runtime/cheneygc.c index 0f7d38b..db74f54 100644 --- a/src/runtime/cheneygc.c +++ b/src/runtime/cheneygc.c @@ -30,6 +30,7 @@ #include "genesis/static-symbols.h" #include "genesis/primitive-objects.h" #include "thread.h" +#include "arch.h" /* So you need to debug? */ #if 0 @@ -48,8 +49,6 @@ lispobj *new_space_free_pointer; static void scavenge_newspace(void); -extern unsigned long bytes_consed_between_gcs; - /* collecting garbage */ @@ -623,3 +622,42 @@ void clear_auto_gc_trigger(void) current_auto_gc_trigger = NULL; } + +static boolean +gc_trigger_hit(void *addr) +{ + if (current_auto_gc_trigger == NULL) + return 0; + else{ + return (addr >= (void *)current_auto_gc_trigger && + addr <((void *)current_dynamic_space + dynamic_space_size)); + } +} + +boolean +cheneygc_handle_wp_violation(os_context_t *context, void *addr) +{ + if(!foreign_function_call_active && gc_trigger_hit(addr)){ + struct thread *thread=arch_os_get_current_thread(); + clear_auto_gc_trigger(); + /* Don't flood the system with interrupts if the need to gc is + * already noted. This can happen for example when SUB-GC + * allocates or after a gc triggered in a WITHOUT-GCING. */ + if (SymbolValue(GC_PENDING,thread) == NIL) { + if (SymbolValue(GC_INHIBIT,thread) == NIL) { + if (arch_pseudo_atomic_atomic(context)) { + /* set things up so that GC happens when we finish + * the PA section */ + SetSymbolValue(GC_PENDING,T,thread); + arch_set_pseudo_atomic_interrupted(context); + } else { + maybe_gc(context); + } + } else { + SetSymbolValue(GC_PENDING,T,thread); + } + } + return 1; + } + return 0; +}