summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhboehm <hboehm>2009-06-13 02:00:06 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:45 +0200
commit4faed82e614d119f649a5e1dcfac2174f06d59a8 (patch)
treeeb0580dc2d507b1cf5b79f3f1ec757bee0556390
parentf9c7d77d0cff9d52082a422052cab1480fda858d (diff)
2009-06-12 Hans Boehm <Hans.Boehm@hp.com> (Really mostly Ivan Maidanski)
diff98_cvs(resembling diff3, diff27, diff59, diff61, diff66, diff73 partly) * dbg_mlc.c (GC_print_smashed_obj): Convert a group of printf() calls into a single one (for output atomicity). * typd_mlc.c (GC_calloc_explicitly_typed): Don't declare and use GC_finalization_failures variable; check the result of GC_general_register_disappearing_link() (for lack of memory) instead. * finalize.c (GC_finalization_failures): Remove unused global variable. * finalize.c (GC_general_register_disappearing_link, GC_general_register_disappearing_link): Don't update the value of GC_finalization_failures (since unused). * include/private/gc_pmark.h (PUSH_ONE_CHECKED_STACK, GC_PUSH_ONE_STACK, GC_PUSH_ONE_HEAP): The first parameter is of word type now (as FIXUP_POINTER requires numeric argument). * finalize.c (GC_ignore_self_finalize_mark_proc): GC_PUSH_ONE_HEAP requires the first parameter of word type. * mark.c (PUSH_GRANULE): Ditto. * mark.c (GC_push_one, GC_push_all_eager): Ditto (for GC_PUSH_ONE_STACK). * finalize.c (GC_finalize_all): Call GC_invoke_finalizers() or GC_finalizer_notifier directly, instead of GC_INVOKE_FINALIZERS() to prevent infinite looping. * include/javaxfc.h: Clarify GC_finalize_all comment. * gcj_mlc.c: Include gc_pmark.h before "ifdef GC_GCJ_SUPPORT" (not after) for configuration information. * gcj_mlc.c (GC_gcj_malloc_ignore_off_page): Add comment. * gcj_mlc.c (GC_gcj_malloc_ignore_off_page): Check "op" local variable for NULL before dereferencing it, return GC_oom_fn() in this case. * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page): Transform the code to suppress compiler warning (for uninitialized "lg" variable).
-rw-r--r--ChangeLog39
-rw-r--r--dbg_mlc.c23
-rw-r--r--finalize.c20
-rw-r--r--gcj_mlc.c19
-rw-r--r--include/javaxfc.h3
-rw-r--r--include/private/gc_pmark.h16
-rw-r--r--mark.c22
-rw-r--r--typd_mlc.c24
8 files changed, 104 insertions, 62 deletions
diff --git a/ChangeLog b/ChangeLog
index 3100cda..5429803 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,48 @@
+2009-06-12 Hans Boehm <Hans.Boehm@hp.com> (Really mostly Ivan Maidanski)
+ diff98_cvs(resembling diff3, diff27, diff59, diff61, diff66,
+ diff73 partly)
+
+ * dbg_mlc.c (GC_print_smashed_obj): Convert a group of printf()
+ calls into a single one (for output atomicity).
+ * typd_mlc.c (GC_calloc_explicitly_typed): Don't declare and use
+ GC_finalization_failures variable; check the result of
+ GC_general_register_disappearing_link() (for lack of memory)
+ instead.
+ * finalize.c (GC_finalization_failures): Remove unused global
+ variable.
+ * finalize.c (GC_general_register_disappearing_link,
+ GC_general_register_disappearing_link): Don't update the value of
+ GC_finalization_failures (since unused).
+ * include/private/gc_pmark.h (PUSH_ONE_CHECKED_STACK,
+ GC_PUSH_ONE_STACK, GC_PUSH_ONE_HEAP): The first parameter is of
+ word type now (as FIXUP_POINTER requires numeric argument).
+ * finalize.c (GC_ignore_self_finalize_mark_proc): GC_PUSH_ONE_HEAP
+ requires the first parameter of word type.
+ * mark.c (PUSH_GRANULE): Ditto.
+ * mark.c (GC_push_one, GC_push_all_eager): Ditto (for
+ GC_PUSH_ONE_STACK).
+ * finalize.c (GC_finalize_all): Call GC_invoke_finalizers() or
+ GC_finalizer_notifier directly, instead
+ of GC_INVOKE_FINALIZERS() to prevent infinite looping.
+ * include/javaxfc.h: Clarify GC_finalize_all comment.
+ * gcj_mlc.c: Include gc_pmark.h before "ifdef GC_GCJ_SUPPORT" (not
+ after) for configuration information.
+ * gcj_mlc.c (GC_gcj_malloc_ignore_off_page): Add comment.
+ * gcj_mlc.c (GC_gcj_malloc_ignore_off_page): Check "op" local
+ variable for NULL before dereferencing it, return GC_oom_fn() in
+ this case.
+ * typd_mlc.c (GC_malloc_explicitly_typed,
+ GC_malloc_explicitly_typed_ignore_off_page): Transform the code to
+ suppress compiler warning (for uninitialized "lg" variable).
+
2009-06-12 Hans Boehm <Hans.Boehm@hp.com>
* win32_threads.c (GC_unregister_my_thread): add false assertion
in unreachable code.
2009-06-12 Hans Boehm <Hans.Boehm@hp.com> (Really Ivan Maidanski)
+ diff97_cvs (resembling diff43, diff51, diff67, diff76, diff83 partly)
- diff97 (resembling diff43, diff51, diff67, diff76, diff83 partly)
* pthread_support.c (GC_inner_start_routine): Don't release the
GC lock between GC_register_my_thread_inner() and
GC_init_thread_local() calls (post the "registered" even after
diff --git a/dbg_mlc.c b/dbg_mlc.c
index dfc13b9..85d82b8 100644
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -407,21 +407,20 @@ STATIC void GC_print_smashed_obj(ptr_t p, ptr_t clobbered_addr)
register oh * ohdr = (oh *)GC_base(p);
GC_ASSERT(I_DONT_HOLD_LOCK());
- GC_err_printf("%p in or near object at %p(", clobbered_addr, p);
if (clobbered_addr <= (ptr_t)(&(ohdr -> oh_sz))
|| ohdr -> oh_string == 0) {
- GC_err_printf("<smashed>, appr. sz = %lu)\n",
- (unsigned long)(GC_size((ptr_t)ohdr) - DEBUG_BYTES));
+ GC_err_printf(
+ "%p in or near object at %p(<smashed>, appr. sz = %lu)\n",
+ clobbered_addr, p,
+ (unsigned long)(GC_size((ptr_t)ohdr) - DEBUG_BYTES));
} else {
- if ((word)(ohdr -> oh_string) < HBLKSIZE) {
- GC_err_puts("(smashed string)");
- } else if (ohdr -> oh_string[0] == '\0') {
- GC_err_puts("EMPTY(smashed?)");
- } else {
- GC_err_puts(ohdr -> oh_string);
- }
- GC_err_printf(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int),
- (unsigned long)(ohdr -> oh_sz));
+ GC_err_printf("%p in or near object at %p(%s:%lu, sz=%lu)\n",
+ clobbered_addr, p,
+ (word)(ohdr -> oh_string) < HBLKSIZE ? "(smashed string)" :
+ ohdr -> oh_string[0] == '\0' ? "EMPTY(smashed?)" :
+ ohdr -> oh_string,
+ (unsigned long)(ohdr -> oh_int),
+ (unsigned long)(ohdr -> oh_sz));
PRINT_CALL_CHAIN(ohdr);
}
}
diff --git a/finalize.c b/finalize.c
index 4780c0e..b77f5fd 100644
--- a/finalize.c
+++ b/finalize.c
@@ -44,9 +44,6 @@ struct hash_chain_entry {
struct hash_chain_entry * next;
};
-unsigned GC_finalization_failures = 0;
- /* Number of finalization requests that failed for lack of memory. */
-
static struct disappearing_link {
struct hash_chain_entry prolog;
# define dl_hidden_link prolog.hidden_key
@@ -189,7 +186,6 @@ GC_API int GC_CALL GC_general_register_disappearing_link(void * * link,
new_dl = (struct disappearing_link *)
GC_oom_fn(sizeof(struct disappearing_link));
if (0 == new_dl) {
- GC_finalization_failures++;
return(2);
}
/* It's not likely we'll make it here, but ... */
@@ -259,7 +255,8 @@ STATIC void GC_ignore_self_finalize_mark_proc(ptr_t p)
{
hdr * hhdr = HDR(p);
word descr = hhdr -> hb_descr;
- ptr_t q, r;
+ ptr_t q;
+ word r;
ptr_t scan_limit;
ptr_t target_limit = p + hhdr -> hb_sz - 1;
@@ -269,8 +266,8 @@ STATIC void GC_ignore_self_finalize_mark_proc(ptr_t p)
scan_limit = target_limit + 1 - sizeof(word);
}
for (q = p; q <= scan_limit; q += ALIGNMENT) {
- r = *(ptr_t *)q;
- if (r < p || r > target_limit) {
+ r = *(word *)q;
+ if ((ptr_t)r < p || (ptr_t)r > target_limit) {
GC_PUSH_ONE_HEAP(r, q);
}
}
@@ -397,7 +394,6 @@ STATIC void GC_register_finalizer_inner(void * obj,
new_fo = (struct finalizable_object *)
GC_oom_fn(sizeof(struct finalizable_object));
if (0 == new_fo) {
- GC_finalization_failures++;
return;
}
/* It's not likely we'll make it here, but ... */
@@ -719,7 +715,13 @@ GC_API void GC_CALL GC_finalize_all(void)
while (GC_fo_entries > 0) {
GC_enqueue_all_finalizers();
UNLOCK();
- GC_INVOKE_FINALIZERS();
+ GC_invoke_finalizers();
+ if (GC_finalize_on_demand &&
+ GC_finalizer_notifier != (GC_finalizer_notifier_proc)0) {
+ GC_finalizer_notifier();
+ } else {
+ GC_invoke_finalizers();
+ }
LOCK();
}
UNLOCK();
diff --git a/gcj_mlc.c b/gcj_mlc.c
index 9035f21..6441ca2 100644
--- a/gcj_mlc.c
+++ b/gcj_mlc.c
@@ -14,6 +14,8 @@
*/
/* Boehm, July 31, 1995 5:02 pm PDT */
+#include "private/gc_pmark.h" /* includes gc_priv.h */
+
#ifdef GC_GCJ_SUPPORT
/*
@@ -35,7 +37,6 @@
* 2) FASTLOCK is not a significant win.
*/
-#include "private/gc_pmark.h" /* includes gc_priv.h */
#include "gc_gcj.h"
#include "private/dbg_mlc.h"
@@ -208,6 +209,7 @@ GC_API void * GC_CALL GC_debug_gcj_malloc(size_t lb,
return (GC_store_debug_info(result, (word)lb, s, (word)i));
}
+/* There is no THREAD_LOCAL_ALLOC for GC_gcj_malloc_ignore_off_page(). */
GC_API void * GC_CALL GC_gcj_malloc_ignore_off_page(size_t lb,
void * ptr_to_struct_containing_descr)
{
@@ -223,22 +225,25 @@ GC_API void * GC_CALL GC_gcj_malloc_ignore_off_page(size_t lb,
if( (op = *opp) == 0 ) {
maybe_finalize();
op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_gcj_kind);
- /* lg = GC_size_map[lb]; */ /* May have been uninitialized. */
+ if (0 == op) {
+ UNLOCK();
+ return(GC_oom_fn(lb));
+ }
} else {
*opp = obj_link(op);
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
}
- *(void **)op = ptr_to_struct_containing_descr;
- UNLOCK();
} else {
LOCK();
maybe_finalize();
op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_gcj_kind);
- if (0 != op) {
- *(void **)op = ptr_to_struct_containing_descr;
+ if (0 == op) {
+ UNLOCK();
+ return(GC_oom_fn(lb));
}
- UNLOCK();
}
+ *(void **)op = ptr_to_struct_containing_descr;
+ UNLOCK();
return((void *) op);
}
diff --git a/include/javaxfc.h b/include/javaxfc.h
index 46643e9..43f3bac 100644
--- a/include/javaxfc.h
+++ b/include/javaxfc.h
@@ -7,7 +7,8 @@
# endif
/*
- * Invoke all remaining finalizers that haven't yet been run.
+ * Invoke all remaining finalizers that haven't yet been run, or
+ * repeatedly notify that there are finalizers to be run.
* This is needed for strict compliance with the Java standard,
* which can make the runtime guarantee that all finalizers are run.
* This is problematic for several reasons:
diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h
index b7d72b5..cbc799b 100644
--- a/include/private/gc_pmark.h
+++ b/include/private/gc_pmark.h
@@ -365,10 +365,10 @@ exit_label: ; \
#if defined(PRINT_BLACK_LIST) || defined(KEEP_BACK_PTRS)
# define PUSH_ONE_CHECKED_STACK(p, source) \
- GC_mark_and_push_stack(p, (ptr_t)(source))
+ GC_mark_and_push_stack((ptr_t)(p), (ptr_t)(source))
#else
# define PUSH_ONE_CHECKED_STACK(p, source) \
- GC_mark_and_push_stack(p)
+ GC_mark_and_push_stack((ptr_t)(p))
#endif
/*
@@ -382,13 +382,13 @@ exit_label: ; \
# if NEED_FIXUP_POINTER
/* Try both the raw version and the fixed up one. */
# define GC_PUSH_ONE_STACK(p, source) \
- if ((p) >= (ptr_t)GC_least_plausible_heap_addr \
- && (p) < (ptr_t)GC_greatest_plausible_heap_addr) { \
+ if ((ptr_t)(p) >= (ptr_t)GC_least_plausible_heap_addr \
+ && (ptr_t)(p) < (ptr_t)GC_greatest_plausible_heap_addr) { \
PUSH_ONE_CHECKED_STACK(p, source); \
} \
FIXUP_POINTER(p); \
- if ((p) >= (ptr_t)GC_least_plausible_heap_addr \
- && (p) < (ptr_t)GC_greatest_plausible_heap_addr) { \
+ if ((ptr_t)(p) >= (ptr_t)GC_least_plausible_heap_addr \
+ && (ptr_t)(p) < (ptr_t)GC_greatest_plausible_heap_addr) { \
PUSH_ONE_CHECKED_STACK(p, source); \
}
# else /* !NEED_FIXUP_POINTER */
@@ -406,8 +406,8 @@ exit_label: ; \
*/
# define GC_PUSH_ONE_HEAP(p,source) \
FIXUP_POINTER(p); \
- if ((p) >= (ptr_t)GC_least_plausible_heap_addr \
- && (p) < (ptr_t)GC_greatest_plausible_heap_addr) { \
+ if ((ptr_t)(p) >= (ptr_t)GC_least_plausible_heap_addr \
+ && (ptr_t)(p) < (ptr_t)GC_greatest_plausible_heap_addr) { \
GC_mark_stack_top = GC_mark_and_push( \
(void *)(p), GC_mark_stack_top, \
GC_mark_stack_limit, (void * *)(source)); \
diff --git a/mark.c b/mark.c
index 72c5566..da9dc1c 100644
--- a/mark.c
+++ b/mark.c
@@ -1352,7 +1352,7 @@ void GC_push_conditional(ptr_t bottom, ptr_t top, GC_bool all)
void GC_push_one(word p)
# endif
{
- GC_PUSH_ONE_STACK((ptr_t)p, MARKED_FROM_REGISTER);
+ GC_PUSH_ONE_STACK(p, MARKED_FROM_REGISTER);
}
/*ARGSUSED*/
@@ -1491,7 +1491,7 @@ void GC_push_all_eager(ptr_t bottom, ptr_t top)
word * b = (word *)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
word * t = (word *)(((word) top) & ~(ALIGNMENT-1));
register word *p;
- register ptr_t q;
+ register word q;
register word *lim;
register ptr_t greatest_ha = GC_greatest_plausible_heap_addr;
register ptr_t least_ha = GC_least_plausible_heap_addr;
@@ -1503,8 +1503,8 @@ void GC_push_all_eager(ptr_t bottom, ptr_t top)
/* to be valid. */
lim = t - 1 /* longword */;
for (p = b; p <= lim; p = (word *)(((ptr_t)p) + ALIGNMENT)) {
- q = (ptr_t)(*p);
- GC_PUSH_ONE_STACK((ptr_t)q, p);
+ q = *p;
+ GC_PUSH_ONE_STACK(q, p);
}
# undef GC_greatest_plausible_heap_addr
# undef GC_least_plausible_heap_addr
@@ -1568,25 +1568,25 @@ void GC_push_all_stack(ptr_t bottom, ptr_t top)
# if GC_GRANULE_WORDS == 1
# define USE_PUSH_MARKED_ACCELERATORS
# define PUSH_GRANULE(q) \
- { ptr_t qcontents = (ptr_t)((q)[0]); \
+ { word qcontents = (q)[0]; \
GC_PUSH_ONE_HEAP(qcontents, (q)); }
# elif GC_GRANULE_WORDS == 2
# define USE_PUSH_MARKED_ACCELERATORS
# define PUSH_GRANULE(q) \
- { ptr_t qcontents = (ptr_t)((q)[0]); \
+ { word qcontents = (q)[0]; \
GC_PUSH_ONE_HEAP(qcontents, (q)); \
- qcontents = (ptr_t)((q)[1]); \
+ qcontents = (q)[1]; \
GC_PUSH_ONE_HEAP(qcontents, (q)+1); }
# elif GC_GRANULE_WORDS == 4
# define USE_PUSH_MARKED_ACCELERATORS
# define PUSH_GRANULE(q) \
- { ptr_t qcontents = (ptr_t)((q)[0]); \
+ { word qcontents = (q)[0]; \
GC_PUSH_ONE_HEAP(qcontents, (q)); \
- qcontents = (ptr_t)((q)[1]); \
+ qcontents = (q)[1]; \
GC_PUSH_ONE_HEAP(qcontents, (q)+1); \
- qcontents = (ptr_t)((q)[2]); \
+ qcontents = (q)[2]; \
GC_PUSH_ONE_HEAP(qcontents, (q)+2); \
- qcontents = (ptr_t)((q)[3]); \
+ qcontents = (q)[3]; \
GC_PUSH_ONE_HEAP(qcontents, (q)+3); }
# endif
#endif
diff --git a/typd_mlc.c b/typd_mlc.c
index 2c79098..ded8b2d 100644
--- a/typd_mlc.c
+++ b/typd_mlc.c
@@ -609,13 +609,14 @@ GC_API void * GC_CALL GC_malloc_explicitly_typed(size_t lb, GC_descr d)
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
UNLOCK();
}
+ ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
} else {
op = (ptr_t)GENERAL_MALLOC((word)lb, GC_explicit_kind);
- if (op != NULL)
+ if (op != NULL) {
lg = BYTES_TO_GRANULES(GC_size(op));
+ ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
+ }
}
- if (op != NULL)
- ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
return((void *) op);
}
@@ -635,6 +636,7 @@ DCL_LOCK_STATE;
if( (op = *opp) == 0 ) {
UNLOCK();
op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind);
+ if (0 == op) return 0;
lg = GC_size_map[lb]; /* May have been uninitialized. */
} else {
*opp = obj_link(op);
@@ -642,13 +644,14 @@ DCL_LOCK_STATE;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
UNLOCK();
}
+ ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
} else {
op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind);
- if (op != NULL)
+ if (op != NULL) {
lg = BYTES_TO_WORDS(GC_size(op));
+ ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
+ }
}
- if (op != NULL)
- ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
return((void *) op);
}
@@ -712,18 +715,13 @@ DCL_LOCK_STATE;
lp -> ld_descriptor = leaf.ld_descriptor;
((volatile word *)op)[GRANULES_TO_WORDS(lg) - 1] = (word)lp;
} else {
- extern unsigned GC_finalization_failures;
- unsigned ff = GC_finalization_failures;
size_t lw = GRANULES_TO_WORDS(lg);
((word *)op)[lw - 1] = (word)complex_descr;
/* Make sure the descriptor is cleared once there is any danger */
/* it may have been collected. */
- (void)
- GC_general_register_disappearing_link((void * *)
- ((word *)op+lw-1),
- (void *) op);
- if (ff != GC_finalization_failures) {
+ if (GC_general_register_disappearing_link((void * *)((word *)op+lw-1),
+ op) == 2) {
/* Couldn't register it due to lack of memory. Punt. */
/* This will probably fail too, but gives the recovery code */
/* a chance. */