X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fpurify.c;h=642dea9361b175b1646270b312a2f151a7de9f2e;hb=2d4a0df3457bcd50916b33d374da592d8776db0a;hp=331f03bf585decaaf35ae32564ae1754cf95b1a5;hpb=040e4e707e4f7bc9bda2ab78774fd9205c44ee1f;p=sbcl.git diff --git a/src/runtime/purify.c b/src/runtime/purify.c index 331f03b..642dea9 100644 --- a/src/runtime/purify.c +++ b/src/runtime/purify.c @@ -17,8 +17,10 @@ #include #include #include +#if (defined(LISP_FEATURE_SB_THREAD) && defined(LISP_FEATURE_LINUX)) #include #include +#endif #include #include "runtime.h" @@ -43,6 +45,7 @@ */ static lispobj *dynamic_space_free_pointer; #endif +extern unsigned long bytes_consed_between_gcs; #define gc_abort() \ lose("GC invariant lost, file \"%s\", line %d", __FILE__, __LINE__) @@ -130,17 +133,11 @@ dynamic_pointer_p(lispobj ptr) static unsigned pointer_filter_verbose = 0; -/* FIXME: This is substantially the same code as in gencgc.c. (There - * are some differences, at least (1) the gencgc.c code needs to worry - * about return addresses on the stack pinning code objects, (2) the - * gencgc.c code needs to worry about the GC maybe happening in an - * interrupt service routine when the main thread of control was - * interrupted just as it had allocated memory and before it - * initialized it, while PURIFY needn't worry about that, and (3) the - * gencgc.c code has mutated more under maintenance since the fork - * from CMU CL than the code here has.) The two versions should be - * made to explicitly share common code, instead of just two different - * cut-and-pasted versions. */ +/* FIXME: This is substantially the same code as + * possibly_valid_dynamic_space_pointer in gencgc.c. The only + * relevant difference seems to be that the gencgc code also checks + * for raw pointers into Code objects */ + static int valid_dynamic_space_pointer(lispobj *pointer, lispobj *start_addr) { @@ -1061,7 +1058,7 @@ pscav_code(struct code*code) gc_assert(!dynamic_pointer_p(func)); #ifdef __i386__ - /* Temporarly convert the self pointer to a real function + /* Temporarily convert the self pointer to a real function * pointer. */ ((struct simple_fun *)native_pointer(func))->self -= FUN_RAW_ADDR_OFFSET; @@ -1339,11 +1336,12 @@ purify(lispobj static_roots, lispobj read_only_roots) fflush(stdout); #endif +#if (defined(LISP_FEATURE_GENCGC) && defined(LISP_FEATURE_X86)) #if 0 - /* can't do this unless the threads in question are suspended with - * ptrace + /* This is what we should do, but can't unless the threads in + * question are suspended with ptrace. That's right, purify is not + * threadsafe */ -#if (defined(LISP_FEATURE_GENCGC) && defined(LISP_FEATURE_X86)) for_each_thread(thread) { void **ptr; struct user_regs_struct regs; @@ -1354,11 +1352,11 @@ purify(lispobj static_roots, lispobj read_only_roots) setup_i386_stack_scav(regs.ebp, ((void *)thread->control_stack_end)); } -#endif -#endif +#endif /* 0 */ + /* stopgap until we can set things up as in preceding comment */ setup_i386_stack_scav(((&static_roots)-2), ((void *)all_threads->control_stack_end)); - +#endif pscav(&static_roots, 1, 0); pscav(&read_only_roots, 1, 1); @@ -1377,8 +1375,9 @@ purify(lispobj static_roots, lispobj read_only_roots) fflush(stdout); #endif #ifndef __i386__ - pscav((lispobj *)CONTROL_STACK_START, - current_control_stack_pointer - (lispobj *)CONTROL_STACK_START, + pscav((lispobj *)all_threads->control_stack_start, + current_control_stack_pointer - + all_threads->control_stack_start, 0); #else #ifdef LISP_FEATURE_GENCGC @@ -1391,8 +1390,9 @@ purify(lispobj static_roots, lispobj read_only_roots) fflush(stdout); #endif #if !defined(__i386__) - pscav( (lispobj *)BINDING_STACK_START, - (lispobj *)current_binding_stack_pointer - (lispobj *)BINDING_STACK_START, + pscav( (lispobj *)all_threads->binding_stack_start, + (lispobj *)current_binding_stack_pointer - + all_threads->binding_stack_start, 0); #else for_each_thread(thread) { @@ -1471,10 +1471,9 @@ purify(lispobj static_roots, lispobj read_only_roots) * calling SCRUB-CONTROL-STACK - this zeros the stack on the x86. */ #ifndef __i386__ os_zero((os_vm_address_t) current_control_stack_pointer, - (os_vm_size_t) (CONTROL_STACK_SIZE - - ((current_control_stack_pointer - - (lispobj *)CONTROL_STACK_START) * - sizeof(lispobj)))); + (os_vm_size_t) + ((all_threads->control_stack_end - + current_control_stack_pointer) * sizeof(lispobj))); #endif /* It helps to update the heap free pointers so that free_heap can @@ -1484,6 +1483,7 @@ purify(lispobj static_roots, lispobj read_only_roots) #if !defined(__i386__) dynamic_space_free_pointer = current_dynamic_space; + set_auto_gc_trigger(bytes_consed_between_gcs); #else #if defined LISP_FEATURE_GENCGC gc_free_heap(); @@ -1496,6 +1496,5 @@ purify(lispobj static_roots, lispobj read_only_roots) printf(" done]\n"); fflush(stdout); #endif - return 0; }