X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fgencgc.c;h=c8defa31d4f2bfc55ed48328e158a2c2c93a26e3;hb=ed1910efb36f71b5ebe33b5ffffd7195e15644de;hp=c53d57436b0aa3c8d3496583316754f6be5a4ac3;hpb=1d06300e09f767a38bbe6d5b38232ca334ab1913;p=sbcl.git diff --git a/src/runtime/gencgc.c b/src/runtime/gencgc.c index c53d574..c8defa3 100644 --- a/src/runtime/gencgc.c +++ b/src/runtime/gencgc.c @@ -26,10 +26,14 @@ #include #include -#include #include #include #include "sbcl.h" +#if defined(LISP_FEATURE_WIN32) && defined(LISP_FEATURE_SB_THREAD) +#include "pthreads_win32.h" +#else +#include +#endif #include "runtime.h" #include "os.h" #include "interr.h" @@ -1255,10 +1259,12 @@ gc_heap_exhausted_error_or_lose (long available, long requested) else { /* FIXME: assert free_pages_lock held */ (void)thread_mutex_unlock(&free_pages_lock); +#if !(defined(LISP_FEATURE_WIN32) && defined(LISP_FEATURE_SB_THREAD)) gc_assert(get_pseudo_atomic_atomic(thread)); clear_pseudo_atomic_atomic(thread); if (get_pseudo_atomic_interrupted(thread)) do_pending_interrupt(); +#endif /* Another issue is that signalling HEAP-EXHAUSTED error leads * to running user code at arbitrary places, even in a * WITHOUT-INTERRUPTS which may lead to a deadlock without @@ -3319,7 +3325,7 @@ preserve_context_registers (os_context_t *c) /* On Darwin the signal context isn't a contiguous block of memory, * so just preserve_pointering its contents won't be sufficient. */ -#if defined(LISP_FEATURE_DARWIN) +#if defined(LISP_FEATURE_DARWIN)||defined(LISP_FEATURE_WIN32) #if defined LISP_FEATURE_X86 preserve_pointer((void*)*os_context_register_addr(c,reg_EAX)); preserve_pointer((void*)*os_context_register_addr(c,reg_ECX)); @@ -3348,9 +3354,11 @@ preserve_context_registers (os_context_t *c) #error "preserve_context_registers needs to be tweaked for non-x86 Darwin" #endif #endif +#if !defined(LISP_FEATURE_WIN32) for(ptr = ((void **)(c+1))-1; ptr>=(void **)c; ptr--) { preserve_pointer(*ptr); } +#endif } #endif @@ -3535,10 +3543,18 @@ garbage_collect_generation(generation_index_t generation, int raise) scavenge_control_stack(th); } +# ifdef LISP_FEATURE_SB_SAFEPOINT + /* In this case, scrub all stacks right here from the GCing thread + * instead of doing what the comment below says. Suboptimal, but + * easier. */ + for_each_thread(th) + scrub_thread_control_stack(th); +# else /* Scrub the unscavenged control stack space, so that we can't run * into any stale pointers in a later GC (this is done by the * stop-for-gc handler in the other threads). */ scrub_control_stack(); +# endif } #endif @@ -4011,6 +4027,10 @@ gc_init(void) { page_index_t i; +#if defined(LISP_FEATURE_SB_SAFEPOINT) + alloc_gc_page(); +#endif + /* Compute the number of pages needed for the dynamic space. * Dynamic space size should be aligned on page size. */ page_table_pages = dynamic_space_size/GENCGC_CARD_BYTES; @@ -4181,8 +4201,10 @@ general_alloc_internal(long nbytes, int page_type_flag, struct alloc_region *reg gc_assert((((unsigned long)region->free_pointer & LOWTAG_MASK) == 0) && ((nbytes & LOWTAG_MASK) == 0)); +#if !(defined(LISP_FEATURE_WIN32) && defined(LISP_FEATURE_SB_THREAD)) /* Must be inside a PA section. */ gc_assert(get_pseudo_atomic_atomic(thread)); +#endif if (nbytes > large_allocation) large_allocation = nbytes; @@ -4284,7 +4306,9 @@ general_alloc(long nbytes, int page_type_flag) lispobj * alloc(long nbytes) { +#if !(defined(LISP_FEATURE_WIN32) && defined(LISP_FEATURE_SB_THREAD)) gc_assert(get_pseudo_atomic_atomic(arch_os_get_current_thread())); +#endif return general_alloc(nbytes, BOXED_PAGE_FLAG); }