Index: allchblk.c =================================================================== RCS file: /cvs/gcc/gcc/boehm-gc/allchblk.c,v retrieving revision 1.12 diff -u -r1.12 allchblk.c --- allchblk.c 13 Aug 2004 23:05:29 -0000 1.12 +++ allchblk.c 7 Feb 2005 19:23:03 -0000 @@ -590,8 +590,9 @@ GET_HDR(hbp, hhdr); size_avail = hhdr->hb_sz; if (size_avail < size_needed) continue; - if (!GC_use_entire_heap - && size_avail != size_needed + if (size_avail != size_needed + && !GC_use_entire_heap + && !GC_dont_gc && USED_HEAP_SIZE >= GC_requested_heapsize && !TRUE_INCREMENTAL && GC_should_collect()) { # ifdef USE_MUNMAP @@ -608,7 +609,8 @@ /* If we are deallocating lots of memory from */ /* finalizers, fail and collect sooner rather */ /* than later. */ - if (GC_finalizer_mem_freed > (GC_heapsize >> 4)) { + if (WORDS_TO_BYTES(GC_finalizer_mem_freed) + > (GC_heapsize >> 4)) { continue; } # endif /* !USE_MUNMAP */ @@ -698,7 +700,7 @@ struct hblk * h; struct hblk * prev = hhdr -> hb_prev; - GC_words_wasted += total_size; + GC_words_wasted += BYTES_TO_WORDS(total_size); GC_large_free_bytes -= total_size; GC_remove_from_fl(hhdr, n); for (h = hbp; h < limit; h++) { Index: dyn_load.c =================================================================== RCS file: /cvs/gcc/gcc/boehm-gc/dyn_load.c,v retrieving revision 1.22 diff -u -r1.22 dyn_load.c --- dyn_load.c 13 Aug 2004 23:05:29 -0000 1.22 +++ dyn_load.c 7 Feb 2005 19:23:03 -0000 @@ -735,6 +735,10 @@ # define HAVE_REGISTER_MAIN_STATIC_DATA + /* The frame buffer testing code is dead in this version. */ + /* We leave it here temporarily in case the switch to just */ + /* testing for MEM_IMAGE sections causes un expected */ + /* problems. */ GC_bool GC_warn_fb = TRUE; /* Warn about traced likely */ /* graphics memory. */ GC_bool GC_disallow_ignore_fb = FALSE; @@ -856,7 +860,11 @@ && (protect == PAGE_EXECUTE_READWRITE || protect == PAGE_READWRITE) && !GC_is_heap_base(buf.AllocationBase) - && !is_frame_buffer(p, buf.RegionSize)) { + /* This used to check for + * !is_frame_buffer(p, buf.RegionSize, buf.Type) + * instead of just checking for MEM_IMAGE. + * If something breaks, change it back. */ + && buf.Type == MEM_IMAGE) { # ifdef DEBUG_VIRTUALQUERY GC_dump_meminfo(&buf); # endif Index: mach_dep.c =================================================================== RCS file: /cvs/gcc/gcc/boehm-gc/mach_dep.c,v retrieving revision 1.16 diff -u -r1.16 mach_dep.c --- mach_dep.c 13 Aug 2004 23:05:30 -0000 1.16 +++ mach_dep.c 7 Feb 2005 19:23:03 -0000 @@ -400,64 +400,79 @@ } #endif /* !USE_GENERIC_PUSH_REGS && !USE_ASM_PUSH_REGS */ +void GC_with_callee_saves_pushed(fn, arg) +void (*fn)(); +ptr_t arg; +{ + word dummy; + +# if defined(USE_GENERIC_PUSH_REGS) +# ifdef HAVE_BUILTIN_UNWIND_INIT + /* This was suggested by Richard Henderson as the way to */ + /* force callee-save registers and register windows onto */ + /* the stack. */ + __builtin_unwind_init(); +# else /* !HAVE_BUILTIN_UNWIND_INIT */ + /* Generic code */ + /* The idea is due to Parag Patel at HP. */ + /* We're not sure whether he would like */ + /* to be he acknowledged for it or not. */ + jmp_buf regs; + register word * i = (word *) regs; + register ptr_t lim = (ptr_t)(regs) + (sizeof regs); + + /* Setjmp doesn't always clear all of the buffer. */ + /* That tends to preserve garbage. Clear it. */ + for (; (char *)i < lim; i++) { + *i = 0; + } +# if defined(POWERPC) || defined(MSWIN32) || defined(MSWINCE) \ + || defined(UTS4) || defined(LINUX) || defined(EWS4800) + (void) setjmp(regs); +# else + (void) _setjmp(regs); + /* We don't want to mess with signals. According to */ + /* SUSV3, setjmp() may or may not save signal mask. */ + /* _setjmp won't, but is less portable. */ +# endif +# endif /* !HAVE_BUILTIN_UNWIND_INIT */ +# elif defined(PTHREADS) && !defined(MSWIN32) /* !USE_GENERIC_PUSH_REGS */ + /* We may still need this to save thread contexts. */ + /* This should probably be used in all Posix/non-gcc */ + /* settings. We defer that change to minimize risk. */ + ucontext_t ctxt; + getcontext(&ctxt); +# else /* Shouldn't be needed */ + ABORT("Unexpected call to GC_with_callee_saves_pushed"); +# endif +# if (defined(SPARC) && !defined(HAVE_BUILTIN_UNWIND_INIT)) \ + || defined(IA64) + /* On a register window machine, we need to save register */ + /* contents on the stack for this to work. The setjmp */ + /* is probably not needed on SPARC, since pointers are */ + /* only stored in windowed or scratch registers. It is */ + /* needed on IA64, since some non-windowed registers are */ + /* preserved. */ + { + GC_save_regs_ret_val = GC_save_regs_in_stack(); + /* On IA64 gcc, could use __builtin_ia64_flushrs() and */ + /* __builtin_ia64_flushrs(). The latter will be done */ + /* implicitly by __builtin_unwind_init() for gcc3.0.1 */ + /* and later. */ + } +# endif + fn(arg); + /* Strongly discourage the compiler from treating the above */ + /* as a tail-call, since that would pop the register */ + /* contents before we get a chance to look at them. */ + GC_noop1((word)(&dummy)); +} + #if defined(USE_GENERIC_PUSH_REGS) void GC_generic_push_regs(cold_gc_frame) ptr_t cold_gc_frame; { - { - word dummy; - -# ifdef HAVE_BUILTIN_UNWIND_INIT - /* This was suggested by Richard Henderson as the way to */ - /* force callee-save registers and register windows onto */ - /* the stack. */ - __builtin_unwind_init(); -# else /* !HAVE_BUILTIN_UNWIND_INIT */ - /* Generic code */ - /* The idea is due to Parag Patel at HP. */ - /* We're not sure whether he would like */ - /* to be he acknowledged for it or not. */ - jmp_buf regs; - register word * i = (word *) regs; - register ptr_t lim = (ptr_t)(regs) + (sizeof regs); - - /* Setjmp doesn't always clear all of the buffer. */ - /* That tends to preserve garbage. Clear it. */ - for (; (char *)i < lim; i++) { - *i = 0; - } -# if defined(POWERPC) || defined(MSWIN32) || defined(MSWINCE) \ - || defined(UTS4) || defined(LINUX) || defined(EWS4800) - (void) setjmp(regs); -# else - (void) _setjmp(regs); - /* We don't want to mess with signals. According to */ - /* SUSV3, setjmp() may or may not save signal mask. */ - /* _setjmp won't, but is less portable. */ -# endif -# endif /* !HAVE_BUILTIN_UNWIND_INIT */ -# if (defined(SPARC) && !defined(HAVE_BUILTIN_UNWIND_INIT)) \ - || defined(IA64) - /* On a register window machine, we need to save register */ - /* contents on the stack for this to work. The setjmp */ - /* is probably not needed on SPARC, since pointers are */ - /* only stored in windowed or scratch registers. It is */ - /* needed on IA64, since some non-windowed registers are */ - /* preserved. */ - { - GC_save_regs_ret_val = GC_save_regs_in_stack(); - /* On IA64 gcc, could use __builtin_ia64_flushrs() and */ - /* __builtin_ia64_flushrs(). The latter will be done */ - /* implicitly by __builtin_unwind_init() for gcc3.0.1 */ - /* and later. */ - } -# endif - GC_push_current_stack(cold_gc_frame); - /* Strongly discourage the compiler from treating the above */ - /* as a tail-call, since that would pop the register */ - /* contents before we get a chance to look at them. */ - GC_noop1((word)(&dummy)); - } + GC_with_callee_saves_pushed(GC_push_current_stack, cold_gc_frame); } #endif /* USE_GENERIC_PUSH_REGS */ Index: mark_rts.c =================================================================== RCS file: /cvs/gcc/gcc/boehm-gc/mark_rts.c,v retrieving revision 1.11 diff -u -r1.11 mark_rts.c --- mark_rts.c 28 Jul 2003 04:18:20 -0000 1.11 +++ mark_rts.c 7 Feb 2005 19:23:03 -0000 @@ -368,8 +368,11 @@ ptr_t GC_approx_sp() { - word dummy; + VOLATILE word dummy; + dummy = 42; /* Force stack to grow if necessary. Otherwise the */ + /* later accesses might cause the kernel to think we're */ + /* doing something wrong. */ # ifdef _MSC_VER # pragma warning(disable:4172) # endif Index: pthread_stop_world.c =================================================================== RCS file: /cvs/gcc/gcc/boehm-gc/pthread_stop_world.c,v retrieving revision 1.2 diff -u -r1.2 pthread_stop_world.c --- pthread_stop_world.c 13 Aug 2004 23:05:30 -0000 1.2 +++ pthread_stop_world.c 7 Feb 2005 19:23:03 -0000 @@ -101,8 +101,28 @@ sem_t GC_suspend_ack_sem; +void GC_suspend_handler_inner(ptr_t sig_arg); + +#if defined(IA64) || defined(HP_PA) +extern void GC_with_callee_saves_pushed(); + +void GC_suspend_handler(int sig) +{ + GC_with_callee_saves_pushed(GC_suspend_handler_inner, (ptr_t)(word)sig); +} + +#else +/* We believe that in all other cases the full context is already */ +/* in the signal handler frame. */ void GC_suspend_handler(int sig) { + GC_suspend_handler_inner((ptr_t)(word)sig); +} +#endif + +void GC_suspend_handler_inner(ptr_t sig_arg) +{ + int sig = (int)(word)sig_arg; int dummy; pthread_t my_thread = pthread_self(); GC_thread me; @@ -369,9 +389,11 @@ } } for (i = 0; i < n_live_threads; i++) { - if (0 != (code = sem_wait(&GC_suspend_ack_sem))) { + while (0 != (code = sem_wait(&GC_suspend_ack_sem))) { + if (errno != EINTR) { GC_err_printf1("Sem_wait returned %ld\n", (unsigned long)code); ABORT("sem_wait for handler failed"); + } } } # ifdef PARALLEL_MARK