X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fcheneygc.c;h=2ba625077e16a06eeadc7ed1a8f878615970ee5f;hb=29a168e2bf7a6d509dea282cc5c781aba734d87c;hp=6679f111fcb866f7faeb833b8d3aebe468901e09;hpb=481348f2f96f364374f669786f9fc61348decabc;p=sbcl.git diff --git a/src/runtime/cheneygc.c b/src/runtime/cheneygc.c index 6679f11..2ba6250 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 @@ -47,9 +48,6 @@ lispobj *new_space; lispobj *new_space_free_pointer; static void scavenge_newspace(void); -static void scavenge_interrupt_contexts(void); - -extern unsigned long bytes_consed_between_gcs; /* collecting garbage */ @@ -89,7 +87,7 @@ zero_stack(void) void * -gc_general_alloc(long bytes, int unboxed_p, int quick_p) { +gc_general_alloc(long bytes, int page_type_flag, int quick_p) { lispobj *new=new_space_free_pointer; new_space_free_pointer+=(bytes/N_WORD_BYTES); return new; @@ -109,7 +107,7 @@ lispobj copy_large_object(lispobj object, long nwords) { * last_generation argument. That's meaningless for us, since we're * not a generational GC. So we ignore it. */ void -collect_garbage(unsigned ignore) +collect_garbage(generation_index_t ignore) { #ifdef PRINTNOISE struct timeval start_tv, stop_tv; @@ -124,8 +122,6 @@ collect_garbage(unsigned ignore) unsigned long control_stack_size, binding_stack_size; sigset_t tmp, old; struct thread *th=arch_os_get_current_thread(); - struct interrupt_data *data=th->interrupt_data; - #ifdef PRINTNOISE printf("[Collecting garbage ... \n"); @@ -177,8 +173,8 @@ collect_garbage(unsigned ignore) printf("Scavenging interrupt handlers (%d bytes) ...\n", (int)sizeof(interrupt_handlers)); #endif - scavenge((lispobj *) data->interrupt_handlers, - sizeof(data->interrupt_handlers) / sizeof(lispobj)); + scavenge((lispobj *) interrupt_handlers, + sizeof(interrupt_handlers) / sizeof(lispobj)); /* _size quantities are in units of sizeof(lispobj) - i.e. 4 */ control_stack_size = @@ -225,11 +221,16 @@ collect_garbage(unsigned ignore) /* Scan the weak pointers. */ #ifdef PRINTNOISE + printf("Scanning weak hash tables ...\n"); +#endif + scan_weak_hash_tables(); + + /* Scan the weak pointers. */ +#ifdef PRINTNOISE printf("Scanning weak pointers ...\n"); #endif scan_weak_pointers(); - /* Flip spaces. */ #ifdef PRINTNOISE printf("Flipping spaces ...\n"); @@ -238,8 +239,12 @@ collect_garbage(unsigned ignore) /* Maybe FIXME: it's possible that we could significantly reduce * RSS by zeroing the from_space or madvise(MADV_DONTNEED) or * similar os-dependent tricks here */ +#ifdef LISP_FEATURE_HPUX + /* hpux cant handle unmapping areas that are not 100% mapped */ + clear_auto_gc_trigger(); +#endif os_zero((os_vm_address_t) from_space, - (os_vm_size_t) DYNAMIC_SPACE_SIZE); + (os_vm_size_t) dynamic_space_size); current_dynamic_space = new_space; dynamic_space_free_pointer = new_space_free_pointer; @@ -299,6 +304,7 @@ scavenge_newspace(void) here,new_space_free_pointer); */ next = new_space_free_pointer; scavenge(here, next - here); + scav_weak_hash_tables(); here = next; } /* printf("done with newspace\n"); */ @@ -335,9 +341,9 @@ scavenge_interrupt_context(os_context_t *context) 0x7FFFFFFFFFFFFFFF on 64-bit platforms */ lip_offset = (((unsigned long)1) << (N_WORD_BITS - 1)) - 1; lip_register_pair = -1; - for (i = 0; i < (sizeof(boxed_registers) / sizeof(int)); i++) { + for (i = 0; i < (int)(sizeof(boxed_registers) / sizeof(int)); i++) { unsigned long reg; - long offset; + unsigned long offset; int index; index = boxed_registers[i]; @@ -370,7 +376,7 @@ scavenge_interrupt_context(os_context_t *context) #endif /* Scavenge all boxed registers in the context. */ - for (i = 0; i < (sizeof(boxed_registers) / sizeof(int)); i++) { + for (i = 0; i < (int)(sizeof(boxed_registers) / sizeof(int)); i++) { int index; lispobj foo; @@ -492,20 +498,6 @@ print_garbage(lispobj *from_space, lispobj *from_space_free_pointer) } -/* vector-like objects */ - -static long -scav_vector(lispobj *where, lispobj object) -{ - if (HeaderValue(object) == subtype_VectorValidHashing) { - *where = - (subtype_VectorMustRehash<= (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; }