+2009-06-04 Hans Boehm <Hans.Boehm@hp.com> (Really Ivan Maidanski)
+ (diff89_cvs, resembling diff3, diff27, diff34, diff38, diff47, diff49,
+ diff59, diff60, diff66, diff67, diff68, diff69a, diff70, diff81
+ partly)
+ * dbg_mlc.c (GC_store_debug_info, GC_store_debug_info_inner): Remove
+ outdated comment about disabling signals.
+ * mallocx.c (GC_malloc_uncollectable,
+ GC_malloc_atomic_uncollectable): Ditto.
+ * os_dep.c: Ditto.
+ * dbg_mlc.c (GC_debug_change_stubborn, GC_debug_end_stubborn_change):
+ Add ARGSUSED tag.
+ * pthread_stop_world.c (GC_suspend_handler,
+ GC_suspend_handler_inner): Ditto.
+ * dbg_mlc.c (GC_debug_free, GC_debug_realloc): Fix printf message.
+ * dbg_mlc.c (GC_debug_realloc): Set "result" to NULL in the default
+ switch branch to suppress compiler warning.
+ * dyn_load.c (GC_init_dyld): Use ABORT() instead of GC_abort().
+ * include/private/darwin_semaphore.h (sem_init): Ditto.
+ * include/javaxfc.h: Replace "GC_H" with "_GC_H".
+ * include/private/dbg_mlc.h (GC_has_other_debug_info,
+ GC_store_debug_info): Replace K&R-style function prototypes with ANSI
+ C one.
+ * include/private/gcconfig.h (GC_FreeBSDGetDataStart, real_malloc,
+ GC_win32_get_mem, GC_wince_get_mem, GC_unix_get_mem): Ditto.
+ * include/private/pthread_support.h (GC_stop_init): Ditto.
+ * include/private/gcconfig.h: Refine comment about setting
+ GC_stackbottom.
+ * include/private/gcconfig.h (FIXUP_POINTER): Put parentheses in the
+ "right" places.
+ * include/private/pthread_support.h (GC_Thread_Rep): Refine comment
+ for "stack_end" field.
+ * mallocx.c (GC_malloc_uncollectable,
+ GC_malloc_atomic_uncollectable): Remove cast to undefined "hbklk".
+ * os_dep.c (GC_USE_MEM_TOP_DOWN): New macro (for setting
+ GC_mem_top_down to MEM_TOP_DOWN for debug purposes).
+ * os_dep.c (GC_gww_read_dirty, catch_exception_raise): Fix WARN()
+ format specifier (should be word-compliant, "%p" is used w/o "0x").
+ * pthread_stop_world.c (GC_suspend_handler_inner): Ditto.
+ * os_dep.c (GC_dirty_init): Append new-line to printf messages.
+ * os_dep.c (GC_mprotect_thread): Fix GC_err_printf message.
+ * os_dep.c (GC_save_callers): Change GC_ASSERT to GC_STATIC_ASSERT.
+ * pthread_stop_world.c (GC_retry_signals, GC_suspend_ack_sem): Define
+ as STATIC.
+ * pthread_stop_world.c (GC_push_all_stacks): Add assertion for that
+ "thread_blocked" is not set for the current thread.
+ * real_malloc.c: Add "extern GC_quiet" to suppress compiler warning.
+ * reclaim.c (GC_reclaim_all): Initialize "start_time" (to 0) to
+ suppress compiler warning.
+
2009-06-02 Hans Boehm <Hans.Boehm@hp.com> (Really Ivan Maidanski)
(adding last bit of diff86_cvs)
* tests/test.c (check_heap_stats): Avoid unbalanced brackets in ifdef.
register word * result = (word *)((oh *)p + 1);
DCL_LOCK_STATE;
- /* There is some argument that we should dissble signals here. */
- /* But that's expensive. And this way things should only appear */
- /* inconsistent while we're in the handler. */
LOCK();
GC_ASSERT(GC_size(p) >= sizeof(oh) + sz);
GC_ASSERT(!(SMALL_OBJ(sz) && CROSSES_HBLK(p, sz)));
{
register word * result = (word *)((oh *)p + 1);
- /* There is some argument that we should disable signals here. */
- /* But that's expensive. And this way things should only appear */
- /* inconsistent while we're in the handler. */
GC_ASSERT(GC_size(p) >= sizeof(oh) + sz);
GC_ASSERT(!(SMALL_OBJ(sz) && CROSSES_HBLK(p, sz)));
# ifdef KEEP_BACK_PTRS
return GC_debug_malloc(lb, OPT_RA s, i);
}
+/*ARGSUSED*/
GC_API void GC_CALL GC_debug_change_stubborn(void *p)
{
}
+/*ARGSUSED*/
GC_API void GC_CALL GC_debug_end_stubborn_change(void *p)
{
}
}
if ((ptr_t)p - (ptr_t)base != sizeof(oh)) {
GC_err_printf(
- "GC_debug_free called on pointer %p wo debugging info\n", p);
+ "GC_debug_free called on pointer %p w/o debugging info\n", p);
} else {
# ifndef SHORT_DBG_HDRS
clobbered = GC_check_annotated_obj((oh *)base);
}
if ((ptr_t)p - (ptr_t)base != sizeof(oh)) {
GC_err_printf(
- "GC_debug_realloc called on pointer %p wo debugging info\n", p);
+ "GC_debug_realloc called on pointer %p w/o debugging info\n", p);
return(GC_realloc(p, lb));
}
hhdr = HDR(base);
break;
# endif
default:
+ result = NULL; /* initialized to prevent warning. */
GC_err_printf("GC_debug_realloc: encountered bad kind\n");
ABORT("bad kind");
}
# endif
if(!_dyld_bind_fully_image_containing_address((unsigned long*)GC_malloc))
- GC_abort("_dyld_bind_fully_image_containing_address failed");
+ ABORT("_dyld_bind_fully_image_containing_address failed");
}
}
-# ifndef GC_H
+# ifndef _GC_H
# include "gc.h"
# endif
static int sem_init(sem_t *sem, int pshared, int value) {
int ret;
if(pshared)
- GC_abort("sem_init with pshared set");
+ ABORT("sem_init with pshared set");
sem->value = value;
ret = pthread_mutex_init(&sem->mutex,NULL);
#ifdef SHORT_DBG_HDRS
# define GC_has_other_debug_info(p) TRUE
#else
- GC_bool GC_has_other_debug_info(/* p */);
+ GC_bool GC_has_other_debug_info(ptr_t p);
#endif
#if defined(KEEP_BACK_PTRS) || defined(MAKE_BACK_GRAPH)
/* Store debugging info into p. Return displaced pointer. */
/* Assumes we don't hold allocation lock. */
-ptr_t GC_store_debug_info(/* p, sz, string, integer */);
+ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str, word integer);
#endif /* _DBG_MLC_H */
* easily accomplished by introducing a new main program, setting
* GC_stackbottom to the address of a local variable, and then calling
* the original main program. The new main program would read something
- * like:
+ * like (provided real_main() is not inlined by the compiler):
*
* # include "gc_private.h"
*
# define DYNAMIC_LOADING
# endif
extern char etext[];
- extern char * GC_FreeBSDGetDataStart();
+ ptr_t GC_FreeBSDGetDataStart(size_t max_page_size, ptr_t etext_addr);
# define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
# endif
# ifdef NETBSD
# define DYNAMIC_LOADING
# endif
extern char etext[];
- extern char * GC_FreeBSDGetDataStart();
+ ptr_t GC_FreeBSDGetDataStart(size_t max_page_size, ptr_t etext_addr);
# define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
# endif
# ifdef NETBSD
# endif
# if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
-# define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
+# define FIXUP_POINTER(p) (p = ((p) & POINTER_MASK) << POINTER_SHIFT)
# endif
# if defined(FIXUP_POINTER)
/* does. */
struct hblk; /* See gc_priv.h. */
# if defined(PCR)
- char * real_malloc();
+ char * real_malloc(size_t bytes);
# define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
+ GC_page_size-1)
# elif defined(OS2)
# define GET_MEM(bytes) HBLKPTR((size_t) calloc(1, (size_t)bytes + GC_page_size) \
+ GC_page_size-1)
# elif defined(MSWIN32)
- extern ptr_t GC_win32_get_mem();
+ ptr_t GC_win32_get_mem(GC_word bytes);
# define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
# elif defined(MACOS)
# if defined(USE_TEMPORARY_MEMORY)
NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
# endif
# elif defined(MSWINCE)
- extern ptr_t GC_wince_get_mem();
+ ptr_t GC_wince_get_mem(GC_word bytes);
# define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
# elif defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
extern void *GC_amiga_get_mem(size_t size);
GC_amiga_get_mem((size_t)bytes + GC_page_size) \
+ GC_page_size-1)
# else
- extern ptr_t GC_unix_get_mem();
+ ptr_t GC_unix_get_mem(GC_word bytes);
# define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
# endif
/* has set its sp value. Thus it does */
/* not need to be sent a signal to stop */
/* it. */
- ptr_t stack_end; /* Cold end of the stack. */
+ ptr_t stack_end; /* Cold end of the stack (except for */
+ /* main thread). */
# ifdef IA64
ptr_t backing_store_end;
ptr_t backing_store_ptr;
GC_thread GC_lookup_thread(pthread_t id);
-void GC_stop_init();
+void GC_stop_init(void);
extern GC_bool GC_in_thread_creation;
/* We may currently be in thread creation or destruction. */
opp = &(GC_uobjfreelist[lg]);
LOCK();
if( (op = *opp) != 0 ) {
- /* See above comment on signals. */
*opp = obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
if (0 == op) return(0);
GC_ASSERT(((word)op & (HBLKSIZE - 1)) == 0); /* large block */
- hhdr = HDR((struct hbklk *)op);
+ hhdr = HDR(op);
/* We don't need the lock here, since we have an undisguised */
/* pointer. We do need to hold the lock while we adjust */
/* mark bits. */
opp = &(GC_auobjfreelist[lg]);
LOCK();
if( (op = *opp) != 0 ) {
- /* See above comment on signals. */
*opp = obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
if (0 == op) return(0);
GC_ASSERT(((word)op & (HBLKSIZE - 1)) == 0);
- hhdr = HDR((struct hbklk *)op);
+ hhdr = HDR(op);
LOCK();
set_mark_bit_from_hdr(hhdr, 0); /* Only object. */
word GC_n_heap_bases = 0;
-DWORD GC_mem_top_down = 0; /* Change to MEM_TOP_DOWN for better 64-bit */
+#ifdef GC_USE_MEM_TOP_DOWN
+ STATIC DWORD GC_mem_top_down = MEM_TOP_DOWN;
+ /* Use GC_USE_MEM_TOP_DOWN for better 64-bit */
/* testing. Otherwise all addresses tend to */
/* end up in first 4GB, hiding bugs. */
+#else
+ STATIC DWORD GC_mem_top_down = 0;
+#endif
ptr_t GC_win32_get_mem(word bytes)
{
if ( i != 0 && last_warned != start && warn_count++ < 5) {
last_warned = start;
WARN(
- "GC_gww_read_dirty unexpectedly failed at %ld: "
+ "GC_gww_read_dirty unexpectedly failed at %p: "
"Falling back to marking all pages dirty\n", start);
}
for (j = 0; j < nblocks; ++j) {
# ifdef DEFAULT_VDB
-/* All of the following assume the allocation lock is held, and */
-/* signals are disabled. */
+/* All of the following assume the allocation lock is held. */
/* The client asserts that unallocated pages in the heap are never */
/* written. */
GC_old_segv_handler_used_si = FALSE;
}
if (GC_old_segv_handler == (SIG_HNDLR_PTR)SIG_IGN) {
- GC_err_printf("Previously ignored segmentation violation!?");
+ GC_err_printf("Previously ignored segmentation violation!?\n");
GC_old_segv_handler = (SIG_HNDLR_PTR)SIG_DFL;
}
if (GC_old_segv_handler != (SIG_HNDLR_PTR)SIG_DFL) {
GC_old_bus_handler_used_si = FALSE;
}
if (GC_old_bus_handler == (SIG_HNDLR_PTR)SIG_IGN) {
- GC_err_printf("Previously ignored bus error!?");
+ GC_err_printf("Previously ignored bus error!?\n");
GC_old_bus_handler = (SIG_HNDLR_PTR)SIG_DFL;
}
if (GC_old_bus_handler != (SIG_HNDLR_PTR)SIG_DFL) {
/* This will fail if the thread dies, but the thread */
/* shouldn't die... */
# ifdef BROKEN_EXCEPTION_HANDLING
- GC_err_printf("mach_msg failed with %d %s while sending"
+ GC_err_printf("mach_msg failed with %d %s while sending "
"exc reply\n", (int)r,mach_error_string(r));
# else
ABORT("mach_msg failed while sending exception reply");
}
if(++last_fault_count < 32) {
if(last_fault_count == 1)
- WARN("Ignoring KERN_PROTECTION_FAILURE at %lx\n", (GC_word)addr);
+ WARN("Ignoring KERN_PROTECTION_FAILURE at %p\n", addr);
return KERN_SUCCESS;
}
}
GC_in_save_callers = TRUE;
# endif
- GC_ASSERT(sizeof(struct callinfo) == sizeof(void *));
+ GC_STATIC_ASSERT(sizeof(struct callinfo) == sizeof(void *));
npcs = backtrace((void **)tmp_info, NFRAMES + IGNORE_FRAMES);
BCOPY(tmp_info+IGNORE_FRAMES, info, (npcs - IGNORE_FRAMES) * sizeof(void *));
for (i = npcs - IGNORE_FRAMES; i < NFRAMES; ++i) info[i].ci_pc = 0;
/* stopped). */
#ifdef GC_OSF1_THREADS
- GC_bool GC_retry_signals = TRUE;
+ STATIC GC_bool GC_retry_signals = TRUE;
#else
- GC_bool GC_retry_signals = FALSE;
+ STATIC GC_bool GC_retry_signals = FALSE;
#endif
/*
# endif
#endif
-sem_t GC_suspend_ack_sem;
+STATIC sem_t GC_suspend_ack_sem;
#ifdef GC_NETBSD_THREADS
# define GC_NETBSD_THREADS_WORKAROUND
/* It seems to be necessary to wait until threads have restarted. */
/* But it is unclear why that is the case. */
- sem_t GC_restart_ack_sem;
+ STATIC sem_t GC_restart_ack_sem;
#endif
STATIC void GC_suspend_handler_inner(ptr_t sig_arg, void *context);
#if defined(IA64) || defined(HP_PA) || defined(M68K)
#ifdef SA_SIGINFO
+/*ARGSUSED*/
STATIC void GC_suspend_handler(int sig, siginfo_t *info, void *context)
#else
STATIC void GC_suspend_handler(int sig)
}
#endif
+/*ARGSUSED*/
STATIC void GC_suspend_handler_inner(ptr_t sig_arg, void *context)
{
int sig = (int)(word)sig_arg;
if (me -> stop_info.last_stop_count == my_stop_count) {
/* Duplicate signal. OK if we are retrying. */
if (!GC_retry_signals) {
- WARN("Duplicate suspend signal in thread %lx\n",
- pthread_self());
+ WARN("Duplicate suspend signal in thread %p\n",
+ (word)pthread_self());
}
return;
}
if (p -> flags & FINISHED) continue;
++nthreads;
if (THREAD_EQUAL(p -> id, me)) {
+ GC_ASSERT(!p->thread_blocked);
# ifdef SPARC
lo = (ptr_t)GC_save_regs_in_stack();
# else
{
return(malloc(size));
}
+
+# else
+
+extern int GC_quiet;
+ /* ANSI C doesn't allow translation units to be empty. */
+ /* So we guarantee this one is nonempty. */
+
#endif /* PCR */
struct hblk ** rlp;
struct hblk ** rlh;
# ifndef SMALL_CONFIG
- CLOCK_TYPE start_time;
+ CLOCK_TYPE start_time = 0; /* initialized to prevent warning. */
CLOCK_TYPE done_time;
if (GC_print_stats == VERBOSE)