diff options
author | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-09-30 09:56:58 +0000 |
---|---|---|
committer | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-09-30 09:56:58 +0000 |
commit | 2629d8057817e7327f63d151692a5562895df341 (patch) | |
tree | 546907bd61de305c953b5ae99d05489fc543bc16 /libjava/prims.cc | |
parent | 1a5c0c2c669c244f17e5b3b1d78868fd5f61373b (diff) | |
download | gcc-2629d8057817e7327f63d151692a5562895df341.tar.gz |
2000-09-30 Hans Boehm <boehm@acm.org>
Bryce McKinlay <bryce@albatross.co.nz>
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36679 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/prims.cc')
-rw-r--r-- | libjava/prims.cc | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/libjava/prims.cc b/libjava/prims.cc index 92e449645df..ff48b9724d7 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -335,18 +335,17 @@ _Jv_AllocBytesChecked (jsize size) return r; } -// Allocate a new object of class C. SIZE is the size of the object +// Allocate a new object of class KLASS. SIZE is the size of the object // to allocate. You might think this is redundant, but it isn't; some // classes, such as String, aren't of fixed size. jobject -_Jv_AllocObject (jclass c, jint size) +_Jv_AllocObject (jclass klass, jint size) { - _Jv_InitClass (c); + _Jv_InitClass (klass); - jobject obj = (jobject) _Jv_AllocObj (size); + jobject obj = (jobject) _Jv_AllocObj (size, klass); if (__builtin_expect (! obj, false)) JvThrow (no_memory); - *((_Jv_VTable **) obj) = c->vtable; // If this class has inherited finalize from Object, then don't // bother registering a finalizer. We know that finalize() is the @@ -355,7 +354,7 @@ _Jv_AllocObject (jclass c, jint size) // implementation would look for Object.finalize in Object's method // table at startup, and then use that information to find the // appropriate index in the method vector. - if (c->vtable->method[1] != ObjectClass.vtable->method[1]) + if (klass->vtable->get_finalizer() != ObjectClass.vtable->get_finalizer()) _Jv_RegisterFinalizer (obj, _Jv_FinalizeObject); #ifdef ENABLE_JVMPI @@ -368,7 +367,7 @@ _Jv_AllocObject (jclass c, jint size) event.event_type = JVMPI_EVENT_OBJECT_ALLOC; event.env_id = NULL; event.u.obj_alloc.arena_id = 0; - event.u.obj_alloc.class_id = (jobjectID) c; + event.u.obj_alloc.class_id = (jobjectID) klass; event.u.obj_alloc.is_array = 0; event.u.obj_alloc.size = size; event.u.obj_alloc.obj_id = (jobjectID) obj; @@ -405,9 +404,9 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) size += count * sizeof (jobject); // FIXME: second argument should be "current loader" // - jclass clas = _Jv_FindArrayClass (elementClass, 0); + jclass klass = _Jv_FindArrayClass (elementClass, 0); - obj = (jobjectArray) _Jv_AllocArray (size); + obj = (jobjectArray) _Jv_AllocArray (size, klass); if (__builtin_expect (! obj, false)) JvThrow (no_memory); obj->length = count; @@ -419,10 +418,6 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) while (--count >= 0) *ptr++ = init; } - // Set the vtbl last to avoid problems if the GC happens during the - // window in this function between the allocation and this - // assignment. - *((_Jv_VTable **) obj) = clas->vtable; return obj; } @@ -444,17 +439,14 @@ _Jv_NewPrimArray (jclass eltype, jint count) (SIZE_T_MAX - size) / elsize, false)) JvThrow (no_memory); - __JArray *arr = (__JArray*) _Jv_AllocObj (size + elsize * count); + jclass klass = _Jv_FindArrayClass (eltype, 0); + + __JArray *arr = (__JArray*) _Jv_AllocObj (size + elsize * count, klass); if (__builtin_expect (! arr, false)) JvThrow (no_memory); arr->length = count; // Note that we assume we are given zeroed memory by the allocator. - jclass klass = _Jv_FindArrayClass (eltype, 0); - // Set the vtbl last to avoid problems if the GC happens during the - // window in this function between the allocation and this - // assignment. - *((_Jv_VTable **) arr) = klass->vtable; return arr; } |