diff options
author | Hans Boehm <Hans_Boehm@hp.com> | 2004-08-28 00:45:56 +0000 |
---|---|---|
committer | Hans Boehm <hboehm@gcc.gnu.org> | 2004-08-28 00:45:56 +0000 |
commit | ed3479983db246f3126c12c441659ef6b8ed027e (patch) | |
tree | 3ffbf3d3e391be4b78a46bc6acfcb0fbb12af641 /libjava | |
parent | 3c1cbf58a609a29362ed15c322d588797f3f4cc5 (diff) | |
download | gcc-ed3479983db246f3126c12c441659ef6b8ed027e.zip gcc-ed3479983db246f3126c12c441659ef6b8ed027e.tar.gz gcc-ed3479983db246f3126c12c441659ef6b8ed027e.tar.bz2 |
configure.ac: Handle --enable-gc-debug.
* configure.ac: Handle --enable-gc-debug.
* configure: Regenerate.
* include/config.h.in (LIBGCJ_GC_DEBUG): Add.
* boehm.cc: Include gc_mark.h, javaxfc.h, but no GC private files.
Rearrange include file order.
(GC_DEBUG): Set if LIBGCJ_GC_DEBUG is set.
(GC_finalize_all, GC_debug_generic_malloc): Don't declare.
(disable_gc_mutex): Delete along with all references.
(_Jv_MarkObj, _Jv_MarkArray): Use public types,
adjust for debug header size.
(_Jv_AllocObj, _Jv_allocPtrFreeObj): Define out of line for
debug case.
(_Jv_AllocArray): Declare min_heap_addr only if needed.
(gcj_describe_type_fn): New.
(_Jv_InitGC): Use GC_new_free_list, GC_new_proc, and GC_new_kind.
Register gcj_describe_type_fn.
* include/boehm-gc.h:
(_Jv_AllocObj, _Jv_allocPtrFreeObj):
Don't define, but declare, for debug case.
* java/lang/natObject.cc:
(GC_DEBUG): Define if LIBGCJ_GC_DEBUG is set.
From-SVN: r86686
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 24 | ||||
-rw-r--r-- | libjava/boehm.cc | 230 | ||||
-rwxr-xr-x | libjava/configure | 17 | ||||
-rw-r--r-- | libjava/configure.ac | 7 | ||||
-rw-r--r-- | libjava/include/boehm-gc.h | 12 | ||||
-rw-r--r-- | libjava/include/config.h.in | 3 | ||||
-rw-r--r-- | libjava/java/lang/natObject.cc | 3 |
7 files changed, 197 insertions, 99 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index fb6d555..fb67852 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,27 @@ +2004-08-27 Hans Boehm <Hans.Boehm@hp.com> + + * configure.ac: Handle --enable-gc-debug. + * configure: Regenerate. + * include/config.h.in (LIBGCJ_GC_DEBUG): Add. + * boehm.cc: Include gc_mark.h, javaxfc.h, but no GC private files. + Rearrange include file order. + (GC_DEBUG): Set if LIBGCJ_GC_DEBUG is set. + (GC_finalize_all, GC_debug_generic_malloc): Don't declare. + (disable_gc_mutex): Delete along with all references. + (_Jv_MarkObj, _Jv_MarkArray): Use public types, + adjust for debug header size. + (_Jv_AllocObj, _Jv_allocPtrFreeObj): Define out of line for + debug case. + (_Jv_AllocArray): Declare min_heap_addr only if needed. + (gcj_describe_type_fn): New. + (_Jv_InitGC): Use GC_new_free_list, GC_new_proc, and GC_new_kind. + Register gcj_describe_type_fn. + * include/boehm-gc.h: + (_Jv_AllocObj, _Jv_allocPtrFreeObj): + Don't define, but declare, for debug case. + * java/lang/natObject.cc: + (GC_DEBUG): Define if LIBGCJ_GC_DEBUG is set. + 2004-08-26 Mark Wielaard <mark@klomp.org> Fixes PR libgcj/17002: diff --git a/libjava/boehm.cc b/libjava/boehm.cc index cf84918..c2a93a5 100644 --- a/libjava/boehm.cc +++ b/libjava/boehm.cc @@ -10,36 +10,35 @@ details. */ #include <config.h> -#include <stdio.h> -#include <limits.h> - -#include <jvm.h> -#include <gcj/cni.h> - -#include <java/lang/Class.h> -#include <java/lang/reflect/Modifier.h> -#include <java-interp.h> - -// More nastiness: the GC wants to define TRUE and FALSE. We don't -// need the Java definitions (themselves a hack), so we undefine them. -#undef TRUE -#undef FALSE - extern "C" { -#include <private/gc_pmark.h> +#include <gc_config.h> + +// Set GC_DEBUG before including gc.h! +#ifdef LIBGCJ_GC_DEBUG +# define GC_DEBUG +#endif + +#include <gc_mark.h> #include <gc_gcj.h> +#include <javaxfc.h> // GC_finalize_all declaration. #ifdef THREAD_LOCAL_ALLOC # define GC_REDIRECT_TO_LOCAL # include <gc_local_alloc.h> #endif - - // These aren't declared in any Boehm GC header. - void GC_finalize_all (void); - ptr_t GC_debug_generic_malloc (size_t size, int k, GC_EXTRA_PARAMS); }; +#include <stdio.h> +#include <limits.h> + +#include <jvm.h> +#include <gcj/cni.h> + +#include <java/lang/Class.h> +#include <java/lang/reflect/Modifier.h> +#include <java-interp.h> + #define MAYBE_MARK(Obj, Top, Limit, Source, Exit) \ Top=GC_MARK_AND_PUSH((GC_PTR)Obj, Top, Limit, (GC_PTR *)Source) @@ -47,10 +46,7 @@ extern "C" static int array_kind_x; // Freelist used for Java arrays. -static ptr_t *array_free_list; - -// Lock used to protect access to Boehm's GC_enable/GC_disable functions. -static _Jv_Mutex_t disable_gc_mutex; +static void * *array_free_list; @@ -58,15 +54,14 @@ static _Jv_Mutex_t disable_gc_mutex; // object. We use `void *' arguments and return, and not what the // Boehm GC wants, to avoid pollution in our headers. void * -_Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) +_Jv_MarkObj (void *addr, void *msp, void *msl, void * env) { - mse *mark_stack_ptr = (mse *) msp; - mse *mark_stack_limit = (mse *) msl; - jobject obj = (jobject) addr; + struct GC_ms_entry *mark_stack_ptr = (struct GC_ms_entry *)msp; + struct GC_ms_entry *mark_stack_limit = (struct GC_ms_entry *)msl; - // FIXME: if env is 1, this object was allocated through the debug - // interface, and addr points to the beginning of the debug header. - // In that case, we should really add the size of the header to addr. + if (env == (void *)1) /* Object allocated with debug allocator. */ + addr = (GC_PTR)GC_USR_PTR_FROM_BASE(addr); + jobject obj = (jobject) addr; _Jv_VTable *dt = *(_Jv_VTable **) addr; // The object might not yet have its vtable set, or it might @@ -78,15 +73,15 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) if (__builtin_expect (! dt || !(dt -> get_finalizer()), false)) return mark_stack_ptr; jclass klass = dt->clas; - ptr_t p; + GC_PTR p; # ifndef JV_HASH_SYNCHRONIZATION // Every object has a sync_info pointer. - p = (ptr_t) obj->sync_info; + p = (GC_PTR) obj->sync_info; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, obj, o1label); # endif // Mark the object's class. - p = (ptr_t) klass; + p = (GC_PTR) klass; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, obj, o2label); if (__builtin_expect (klass == &java::lang::Class::class$, false)) @@ -105,25 +100,25 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) // of our root set. - HB jclass c = (jclass) addr; - p = (ptr_t) c->name; + p = (GC_PTR) c->name; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c3label); - p = (ptr_t) c->superclass; + p = (GC_PTR) c->superclass; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c4label); for (int i = 0; i < c->constants.size; ++i) { /* FIXME: We could make this more precise by using the tags -KKT */ - p = (ptr_t) c->constants.data[i].p; + p = (GC_PTR) c->constants.data[i].p; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c5label); } #ifdef INTERPRETER if (_Jv_IsInterpretedClass (c)) { - p = (ptr_t) c->constants.tags; + p = (GC_PTR) c->constants.tags; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c5alabel); - p = (ptr_t) c->constants.data; + p = (GC_PTR) c->constants.data; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c5blabel); - p = (ptr_t) c->vtable; + p = (GC_PTR) c->vtable; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c5clabel); } #endif @@ -131,7 +126,7 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) // If the class is an array, then the methods field holds a // pointer to the element class. If the class is primitive, // then the methods field holds a pointer to the array class. - p = (ptr_t) c->methods; + p = (GC_PTR) c->methods; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c6label); // The vtable might have been set, but the rest of the class @@ -147,34 +142,34 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) // points to a methods structure. for (int i = 0; i < c->method_count; ++i) { - p = (ptr_t) c->methods[i].name; + p = (GC_PTR) c->methods[i].name; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cm1label); - p = (ptr_t) c->methods[i].signature; + p = (GC_PTR) c->methods[i].signature; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cm2label); } } // Mark all the fields. - p = (ptr_t) c->fields; + p = (GC_PTR) c->fields; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c8label); for (int i = 0; i < c->field_count; ++i) { _Jv_Field* field = &c->fields[i]; #ifndef COMPACT_FIELDS - p = (ptr_t) field->name; + p = (GC_PTR) field->name; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c8alabel); #endif - p = (ptr_t) field->type; + p = (GC_PTR) field->type; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c8blabel); // For the interpreter, we also need to mark the memory // containing static members if ((field->flags & java::lang::reflect::Modifier::STATIC)) { - p = (ptr_t) field->u.addr; + p = (GC_PTR) field->u.addr; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c8clabel); // also, if the static member is a reference, @@ -184,31 +179,31 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) if (JvFieldIsRef (field) && field->isResolved()) { jobject val = *(jobject*) field->u.addr; - p = (ptr_t) val; + p = (GC_PTR) val; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c8elabel); } } } - p = (ptr_t) c->vtable; + p = (GC_PTR) c->vtable; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, c9label); - p = (ptr_t) c->interfaces; + p = (GC_PTR) c->interfaces; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cAlabel); for (int i = 0; i < c->interface_count; ++i) { - p = (ptr_t) c->interfaces[i]; + p = (GC_PTR) c->interfaces[i]; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cClabel); } - p = (ptr_t) c->loader; + p = (GC_PTR) c->loader; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cBlabel); - p = (ptr_t) c->arrayclass; + p = (GC_PTR) c->arrayclass; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cDlabel); - p = (ptr_t) c->protectionDomain; + p = (GC_PTR) c->protectionDomain; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cPlabel); - p = (ptr_t) c->hack_signers; + p = (GC_PTR) c->hack_signers; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cSlabel); - p = (ptr_t) c->aux_info; + p = (GC_PTR) c->aux_info; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cTlabel); #ifdef INTERPRETER @@ -216,12 +211,12 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) { _Jv_InterpClass* ic = (_Jv_InterpClass*) c->aux_info; - p = (ptr_t) ic->interpreted_methods; + p = (GC_PTR) ic->interpreted_methods; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, cElabel); for (int i = 0; i < c->method_count; i++) { - p = (ptr_t) ic->interpreted_methods[i]; + p = (GC_PTR) ic->interpreted_methods[i]; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, \ cFlabel); @@ -233,7 +228,7 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) = (_Jv_InterpMethod *) ic->interpreted_methods[i]; if (im) { - p = (ptr_t) im->prepared; + p = (GC_PTR) im->prepared; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, \ cFlabel); } @@ -241,12 +236,12 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) // The interpreter installs a heap-allocated trampoline // here, so we'll mark it. - p = (ptr_t) c->methods[i].ncode; + p = (GC_PTR) c->methods[i].ncode; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cm3label); } - p = (ptr_t) ic->field_initializers; + p = (GC_PTR) ic->field_initializers; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, cGlabel); } @@ -273,7 +268,7 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) if (JvFieldIsRef (field)) { jobject val = JvGetObjectField (obj, field); - p = (ptr_t) val; + p = (GC_PTR) val; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, obj, elabel); } @@ -290,10 +285,13 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) // array (of objects). We use `void *' arguments and return, and not // what the Boehm GC wants, to avoid pollution in our headers. void * -_Jv_MarkArray (void *addr, void *msp, void *msl, void * /*env*/) +_Jv_MarkArray (void *addr, void *msp, void *msl, void * env) { - mse *mark_stack_ptr = (mse *) msp; - mse *mark_stack_limit = (mse *) msl; + struct GC_ms_entry *mark_stack_ptr = (struct GC_ms_entry *)msp; + struct GC_ms_entry *mark_stack_limit = (struct GC_ms_entry *)msl; + + if (env == (void *)1) /* Object allocated with debug allocator. */ + addr = (void *)GC_USR_PTR_FROM_BASE(addr); jobjectArray array = (jobjectArray) addr; _Jv_VTable *dt = *(_Jv_VTable **) addr; @@ -303,21 +301,21 @@ _Jv_MarkArray (void *addr, void *msp, void *msl, void * /*env*/) if (__builtin_expect (! dt || !(dt -> get_finalizer()), false)) return mark_stack_ptr; jclass klass = dt->clas; - ptr_t p; + GC_PTR p; # ifndef JV_HASH_SYNCHRONIZATION // Every object has a sync_info pointer. - p = (ptr_t) array->sync_info; + p = (GC_PTR) array->sync_info; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, array, e1label); # endif // Mark the object's class. - p = (ptr_t) klass; + p = (GC_PTR) klass; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, &(dt -> clas), o2label); for (int i = 0; i < JvGetArrayLength (array); ++i) { jobject obj = elements (array)[i]; - p = (ptr_t) obj; + p = (GC_PTR) obj; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, array, e2label); } @@ -366,7 +364,7 @@ _Jv_BuildGCDescr(jclass self) // If we find a field outside the range of our bitmap, // fall back to procedure marker. The bottom 2 bits are // reserved. - if (off >= bits_per_word - 2) + if (off >= (unsigned)bits_per_word - 2) return (void *) (GCJ_DEFAULT_DESCR); desc |= 1ULL << (bits_per_word - off - 1); } @@ -394,12 +392,44 @@ _Jv_AllocBytes (jsize size) return r; } +#ifdef LIBGCJ_GC_DEBUG + +void * +_Jv_AllocObj (jsize size, jclass klass) +{ + return GC_GCJ_MALLOC (size, klass->vtable); +} + +void * +_Jv_AllocPtrFreeObj (jsize size, jclass klass) +{ +#ifdef JV_HASH_SYNCHRONIZATION + void * obj = GC_MALLOC_ATOMIC(size); + *((_Jv_VTable **) obj) = klass->vtable; +#else + void * obj = GC_GCJ_MALLOC(size, klass->vtable); +#endif + return obj; +} + +#endif /* LIBGCJ_GC_DEBUG */ +// In the non-debug case, the above two functions are defined +// as inline functions in boehm-gc.h. In the debug case we +// really want to take advantage of the definitions in gc_gcj.h. + // Allocate space for a new Java array. // Used only for arrays of objects. void * _Jv_AllocArray (jsize size, jclass klass) { void *obj; + +#ifdef LIBGCJ_GC_DEBUG + // There isn't much to lose by scanning this conservatively. + // If we didn't, the mark proc would have to understand that + // it needed to skip the header. + obj = GC_MALLOC(size); +#else const jsize min_heap_addr = 16*1024; // A heuristic. If size is less than this value, the size // stored in the array can't possibly be misinterpreted as @@ -407,12 +437,6 @@ _Jv_AllocArray (jsize size, jclass klass) // completely conservatively, since no misidentification can // take place. -#ifdef GC_DEBUG - // There isn't much to lose by scanning this conservatively. - // If we didn't, the mark proc would have to understand that - // it needed to skip the header. - obj = GC_MALLOC(size); -#else if (size < min_heap_addr) obj = GC_MALLOC(size); else @@ -497,17 +521,13 @@ extern "C" void GC_disable(); void _Jv_DisableGC (void) { - _Jv_MutexLock (&disable_gc_mutex); GC_disable(); - _Jv_MutexUnlock (&disable_gc_mutex); } void _Jv_EnableGC (void) { - _Jv_MutexLock (&disable_gc_mutex); GC_enable(); - _Jv_MutexUnlock (&disable_gc_mutex); } static void * handle_out_of_memory(size_t) @@ -515,6 +535,29 @@ static void * handle_out_of_memory(size_t) _Jv_ThrowNoMemory(); } +static void +gcj_describe_type_fn(void *obj, char *out_buf) +{ + _Jv_VTable *dt = *(_Jv_VTable **) obj; + + if (! dt /* Shouldn't happen */) + { + strcpy(out_buf, "GCJ (bad)"); + return; + } + jclass klass = dt->clas; + if (!klass /* shouldn't happen */) + { + strcpy(out_buf, "GCJ (bad)"); + return; + } + jstring name = klass -> getName(); + size_t len = name -> length(); + if (len >= GC_TYPE_DESCR_LEN) len = GC_TYPE_DESCR_LEN - 1; + JvGetStringUTFRegion (name, 0, len, out_buf); + out_buf[len] = '\0'; +} + void _Jv_InitGC (void) { @@ -525,6 +568,8 @@ _Jv_InitGC (void) // Configure the collector to use the bitmap marking descriptors that we // stash in the class vtable. + // We always use mark proc descriptor 0, since the compiler knows + // about it. GC_init_gcj_malloc (0, (void *) _Jv_MarkObj); // Cause an out of memory error to be thrown from the allocators, @@ -535,23 +580,14 @@ _Jv_InitGC (void) // We use a different mark procedure for object arrays. This code // configures a different object `kind' for object array allocation and - // marking. FIXME: see above. - array_free_list = (ptr_t *) GC_generic_malloc_inner ((MAXOBJSZ + 1) - * sizeof (ptr_t), - PTRFREE); - memset (array_free_list, 0, (MAXOBJSZ + 1) * sizeof (ptr_t)); - - proc = GC_n_mark_procs++; - GC_mark_procs[proc] = (GC_mark_proc) _Jv_MarkArray; - - array_kind_x = GC_n_kinds++; - GC_obj_kinds[array_kind_x].ok_freelist = array_free_list; - GC_obj_kinds[array_kind_x].ok_reclaim_list = 0; - GC_obj_kinds[array_kind_x].ok_descriptor = GC_MAKE_PROC (proc, 0); - GC_obj_kinds[array_kind_x].ok_relocate_descr = FALSE; - GC_obj_kinds[array_kind_x].ok_init = TRUE; - - _Jv_MutexInit (&disable_gc_mutex); + // marking. + array_free_list = GC_new_free_list(); + proc = GC_new_proc((GC_mark_proc)_Jv_MarkArray); + array_kind_x = GC_new_kind(array_free_list, GC_MAKE_PROC (proc, 0), 0, 1); + + /* Arrange to have the GC print Java class names in backtraces, etc. */ + GC_register_describe_type_fn(GC_gcj_kind, gcj_describe_type_fn); + GC_register_describe_type_fn(GC_gcj_debug_kind, gcj_describe_type_fn); } #ifdef JV_HASH_SYNCHRONIZATION diff --git a/libjava/configure b/libjava/configure index 19b8d8d..cd6dc28 100755 --- a/libjava/configure +++ b/libjava/configure @@ -869,6 +869,7 @@ Optional Features: allow compilation of several files at once --enable-libgcj-debug enable runtime debugging code + --enable-gc-debug include full support for pointer backtracing etc. --enable-interpreter enable interpreter --enable-sjlj-exceptions force use of builtin_setjmp for exceptions @@ -4735,7 +4736,7 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic" case $host in *-*-irix6*) # Find out which ABI we are using. - echo '#line 4738 "configure"' > conftest.$ac_ext + echo '#line 4739 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -5716,6 +5717,18 @@ _ACEOF fi fi; +# Check for gc debugging. This option is handled both here and in the GC. +# Check whether --enable-gc-debug or --disable-gc-debug was given. +if test "${enable_gc_debug+set}" = set; then + enableval="$enable_gc_debug" + if test "$enable_gc_debug" = "yes"; then + cat >>confdefs.h <<\_ACEOF +#define LIBGCJ_GC_DEBUG 1 +_ACEOF + + fi +fi; + # See if the user has the interpreter included. # Check whether --enable-interpreter or --disable-interpreter was given. if test "${enable_interpreter+set}" = set; then @@ -5752,7 +5765,7 @@ if test "${enable_sjlj_exceptions+set}" = set; then : else cat > conftest.$ac_ext << EOF -#line 5755 "configure" +#line 5768 "configure" struct S { ~S(); }; void bar(); void foo() diff --git a/libjava/configure.ac b/libjava/configure.ac index 0085b47..72f2549 100644 --- a/libjava/configure.ac +++ b/libjava/configure.ac @@ -253,6 +253,13 @@ AC_ARG_ENABLE(libgcj-debug, LIBGCJDEBUG="true" fi]) +# Check for gc debugging. This option is handled both here and in the GC. +AC_ARG_ENABLE(gc-debug, +[ --enable-gc-debug include full support for pointer backtracing etc.], +[ if test "$enable_gc_debug" = "yes"; then + AC_DEFINE(LIBGCJ_GC_DEBUG) + fi]) + # See if the user has the interpreter included. AC_ARG_ENABLE(interpreter, AS_HELP_STRING([--enable-interpreter], diff --git a/libjava/include/boehm-gc.h b/libjava/include/boehm-gc.h index 4e0065f..fa2623b 100644 --- a/libjava/include/boehm-gc.h +++ b/libjava/include/boehm-gc.h @@ -35,6 +35,8 @@ extern "C" void * GC_local_gcj_malloc(size_t, void *); extern "C" void * GC_local_malloc_atomic(size_t); #endif +#ifndef LIBGCJ_GC_DEBUG + inline void * _Jv_AllocObj (jsize size, jclass klass) { @@ -67,6 +69,16 @@ _Jv_AllocPtrFreeObj (jsize size, jclass klass) return obj; } +#else /* LIBGCJ_GC_DEBUG */ + +void * +_Jv_AllocObj (jsize size, jclass klass); + +void * +_Jv_AllocPtrFreeObj (jsize size, jclass klass); + +#endif /* LIBGCJ_GC_DEBUG */ + // _Jv_AllocBytes (jsize size) should go here, too. But clients don't // usually include this header. diff --git a/libjava/include/config.h.in b/libjava/include/config.h.in index bb52dbc..0429517 100644 --- a/libjava/include/config.h.in +++ b/libjava/include/config.h.in @@ -366,6 +366,9 @@ /* Indicate that linker is not able to 8-byte align static data */ #undef JV_LINKER_CANNOT_8BYTE_ALIGN_STATICS +/* Define if we want to use debug calls into the garbage collector. */ +#undef LIBGCJ_GC_DEBUG + /* Define if using POSIX threads on Linux. */ #undef LINUX_THREADS diff --git a/libjava/java/lang/natObject.cc b/libjava/java/lang/natObject.cc index cb03db9..7dff626 100644 --- a/libjava/java/lang/natObject.cc +++ b/libjava/java/lang/natObject.cc @@ -286,6 +286,9 @@ _Jv_ObjectCheckMonitor (jobject obj) // operations is already ridiculous, and would become worse if we // went through the proper intermediaries. #else +# ifdef LIBGCJ_GC_DEBUG +# define GC_DEBUG +# endif # include "gc.h" #endif |