From bf3b8e42e291aeaeae178f6be1a49deebcd4e527 Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Sat, 30 Sep 2000 09:56:58 +0000 Subject: Implement bitmap descriptor based marking for Boehm GC. 2000-09-30 Hans Boehm Bryce McKinlay Implement bitmap descriptor based marking for Boehm GC. * configure.in: Define JC1GCSPEC. Set it if boehm-gc is used. * configure: Rebuilt. * libgcj.spec.in: Pass JC1GCSPEC to jc1. * include/jvm.h (struct _Jv_VTable): New field `gc_descr'. New inline method get_finalizer(). (struct _Jv_ArrayVTable): Ditto. Declare method array with NUM_OBJECT_METHODS elements instead of NUM_OBJECT_METHODS + 1. (_Jv_AllocObj): Add new jclass parameter. (_Jv_AllocArray): Ditto. (_Jv_BuildGCDescr): New prototype. * prims.cc (_Jv_AllocObject): Rename parameter `c' to `klass'. Pass `klass' to _Jv_AllocObj. Don't set the new object's vtable. Use get_finalizer() instead of direct finalizer vtable offset. (_Jv_NewObjectArray): Rename parameter `clas' to `klass'. Pass `klass' to _Jv_AllocArray. Don't set the new array's vtable. (_Jv_NewPrimArray): Call _Jv_FindArrayClass before _Jv_AllocObj. Pass `klass' to _Jv_AllocObj. Don't set the new array's vtable. * resolve.cc (METHOD_NOT_THERE, METHOD_INACCESSIBLE): New #defines. (_Jv_ResolvePoolEntry): Use METHOD_NOT_THERE and METHOD_INACCESSIBLE. (_Jv_DetermineVTableIndex): Ditto. (_Jv_PrepareClass): Ditto. Remove offset-by-one adjustments from vtable calculations to account for new gc_descr field. * boehm.cc: #include gc_gcj.h. (obj_kind_x, obj_free_list): `#if 0'-ed away. (_Jv_MarkObj): Check that vtable doesn't point to a cleared object. New commentary from HB. Mark the classes vtable. (_Jv_MarkArray): Check that vtable doesn't point to a cleared object. (GC_DEFAULT_DESCR): New #define. (_Jv_BuildGCDescr): New function. Use GC_DEFAULT_DESCR, for now. (_Jv_AllocObj): New parameter `klass'. Use GC_GCJ_MALLOC (). (_Jv_AllocArray): New parameter `klass'. Allocate with GC_MALLOC and scan conservativly if size is less than min_heap_addr. Set vtable pointer of new object before returning. (_Jv_AllocBytes): Use GC_MALLOC_ATOMIC, not GC_GENERIC_MALLOC. (_Jv_InitGC): Call GC_init_gcj_malloc(). Don't set up marking and allocation for obj_kind_x. * nogc.cc (_Jv_BuildGCDescr): New function. Return 0. (_Jv_AllocObj): Set vtable on returned object. (_Jv_AllocArray): Ditto. * java/lang/Class.h (_Jv_NewObjectArray): No longer a friend. (_Jv_NewPrimArray): Ditto. (_Jv_AllocObj): Declare as a friend. (_Jv_AllocArray): Ditto. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Copy gc_descr from &ObjectClass into new array class. Remove offset-by-one adjustments from `method' size calculations to account for gc_descr field. Co-Authored-By: Bryce McKinlay From-SVN: r36679 --- libjava/java/lang/Class.h | 4 ++-- libjava/java/lang/natClassLoader.cc | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'libjava/java/lang') diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h index 0f60274..0300a59 100644 --- a/libjava/java/lang/Class.h +++ b/libjava/java/lang/Class.h @@ -220,8 +220,8 @@ private: friend jint JvNumStaticFields (jclass); friend jobject _Jv_AllocObject (jclass, jint); - friend jobjectArray _Jv_NewObjectArray (jsize, jclass, jobject); - friend jobject _Jv_NewPrimArray (jclass, jint); + friend void *_Jv_AllocObj (jint, jclass); + friend void *_Jv_AllocArray (jint, jclass); friend jobject _Jv_JNI_ToReflectedField (_Jv_JNIEnv *, jclass, jfieldID, jboolean); diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc index 54ffc42..b03b8c2 100644 --- a/libjava/java/lang/natClassLoader.cc +++ b/libjava/java/lang/natClassLoader.cc @@ -586,16 +586,15 @@ _Jv_FindArrayClass (jclass element, java::lang::ClassLoader *loader, array_class = _Jv_NewClass (array_name, &ObjectClass, element->loader); // Note that `vtable_method_count' doesn't include the initial - // NULL slot. + // gc_descr slot. JvAssert (ObjectClass.vtable_method_count == NUM_OBJECT_METHODS); - int dm_count = ObjectClass.vtable_method_count + 1; + int dm_count = ObjectClass.vtable_method_count; // Create a new vtable by copying Object's vtable (except the // class pointer, of course). Note that we allocate this as // unscanned memory -- the vtables are handled specially by the // GC. - int size = (sizeof (_Jv_VTable) + - ((dm_count - 1) * sizeof (void *))); + int size = (sizeof (_Jv_VTable) + ((dm_count - 1) * sizeof (void *))); _Jv_VTable *vtable; if (array_vtable) vtable = array_vtable; @@ -604,6 +603,7 @@ _Jv_FindArrayClass (jclass element, java::lang::ClassLoader *loader, vtable->clas = array_class; memcpy (vtable->method, ObjectClass.vtable->method, dm_count * sizeof (void *)); + vtable->gc_descr = ObjectClass.vtable->gc_descr; array_class->vtable = vtable; array_class->vtable_method_count = ObjectClass.vtable_method_count; @@ -615,6 +615,8 @@ _Jv_FindArrayClass (jclass element, java::lang::ClassLoader *loader, array_class->interfaces = interfaces; array_class->interface_count = sizeof interfaces / sizeof interfaces[0]; + // FIXME: Shouldn't this be synchronized? _Jv_PrepareConstantTimeTables + // needs to be called with the mutex for array_class held. // Generate the interface dispatch table. _Jv_PrepareConstantTimeTables (array_class); -- cgit v1.1