diff options
author | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-01-08 23:28:56 +0000 |
---|---|---|
committer | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-01-08 23:28:56 +0000 |
commit | 9007522bf97494be0eb119dc7a5daa5207755acf (patch) | |
tree | be919e8f9daa4b9caa6045e085c18aa82e8c4a09 /libjava/prims.cc | |
parent | 1ca75808120df5bb57e654e0dd4c5c097468b56e (diff) | |
download | gcc-9007522bf97494be0eb119dc7a5daa5207755acf.tar.gz |
In gcc/java:
* class.c (make_class_data): Push initial value for "arrayclass".
* decl.c (init_decl_processing): Add new class field "arrayclass".
In libjava:
* java/lang/Class.h (_Jv_InitClass): Use __builtin_expect.
(_Jv_NewArrayClass): Renamed from _Jv_FindArrayClass.
(_Jv_GetArrayClass): New inline function.
(arrayclass): New field.
* prims.cc (_Jv_NewObjectArray): Use _Jv_GetArrayClass. Don't use
_Jv_GetArrayElementFromElementType.
(_Jv_NewPrimArray): Ditto.
(_Jv_PrimClass constructor): Initialize "depth", "ancestors", and
"idt" for completeness. Initialze "arrayclass" using _Jv_NewArrayClass.
Set Modifier::ABSTRACT.
* java/lang/natClassLoader.cc (_Jv_NewClass): Initialize "arrayclass".
(_Jv_NewArrayClass): Renamed from _Jv_FindArrayClass. Now void.
Now synchronized. Array classes are now referenced from
elementClass->arrayclass. Don't use _Jv_FindClassInCache.
Set array classes' accessibility flags correctly. Optimize so that
all array classes share the same IDT.
* java/lang/reflect/natArray.cc (newInstance): Use _Jv_GetArrayClass.
* java/lang/reflect/natMethod.cc (_Jv_GetTypesFromSignature): Ditto.
* java/lang/natClass.cc (_getFields): Increment offset. Prevent fields
in superclasses from overwriting classes own fields.
(_Jv_IsAssignableFrom): Check for NULL source idt instead of calling
Modifier::isAbstract().
(null_idt): New static field.
(_Jv_PrepareConstantTimeTables): Optimize case where class implements
no interfaces.
(_Jv_IndexOf): Made inline.
* boehm.cc (_Jv_MarkObj): Mark "arrayclass" field.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38808 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/prims.cc')
-rw-r--r-- | libjava/prims.cc | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/libjava/prims.cc b/libjava/prims.cc index 06585749c5f..c4c7316dfce 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -394,19 +394,13 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) JvAssert (! elementClass->isPrimitive ()); + // Ensure that elements pointer is properly aligned. jobjectArray obj = NULL; - size_t size = (size_t) _Jv_GetArrayElementFromElementType (obj, - elementClass); - - // Check for overflow. - if (__builtin_expect ((size_t) count > - (SIZE_T_MAX - size) / sizeof (jobject), false)) - JvThrow (no_memory); - + size_t size = (size_t) elements (obj); size += count * sizeof (jobject); - // FIXME: second argument should be "current loader" // - jclass klass = _Jv_FindArrayClass (elementClass, 0); + // FIXME: second argument should be "current loader" + jclass klass = _Jv_GetArrayClass (elementClass, 0); obj = (jobjectArray) _Jv_AllocArray (size, klass); if (__builtin_expect (! obj, false)) @@ -414,11 +408,11 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) // Cast away const. jsize *lp = const_cast<jsize *> (&obj->length); *lp = count; - jobject *ptr = elements(obj); // We know the allocator returns zeroed memory. So don't bother // zeroing it again. if (init) { + jobject *ptr = elements(obj); while (--count >= 0) *ptr++ = init; } @@ -443,7 +437,7 @@ _Jv_NewPrimArray (jclass eltype, jint count) (SIZE_T_MAX - size) / elsize, false)) JvThrow (no_memory); - jclass klass = _Jv_FindArrayClass (eltype, 0); + jclass klass = _Jv_GetArrayClass (eltype, 0); __JArray *arr = (__JArray*) _Jv_AllocObj (size + elsize * count, klass); if (__builtin_expect (! arr, false)) @@ -529,7 +523,7 @@ public: // the same order they are declared in Class.h. next = NULL; name = _Jv_makeUtf8Const ((char *) cname, -1); - accflags = Modifier::PUBLIC | Modifier::FINAL; + accflags = Modifier::PUBLIC | Modifier::FINAL | Modifier::ABSTRACT; superclass = NULL; constants.size = 0; constants.tags = NULL; @@ -547,10 +541,15 @@ public: interface_count = 0; state = JV_STATE_DONE; thread = NULL; + depth = -1; + ancestors = NULL; + idt = NULL; // Note that we have to set `methods' to NULL. if (sig != 'V') - _Jv_FindArrayClass (this, NULL, (_Jv_VTable *) array_vtable); + _Jv_NewArrayClass (this, NULL, (_Jv_VTable *) array_vtable); + else + arrayclass = NULL; } }; @@ -606,8 +605,8 @@ _Jv_FindClassFromSignature (char *sig, java::lang::ClassLoader *loader) } case '[': - return _Jv_FindArrayClass (_Jv_FindClassFromSignature (&sig[1], loader), - loader); + return _Jv_GetArrayClass (_Jv_FindClassFromSignature (&sig[1], loader), + loader); } JvFail ("couldn't understand class signature"); return NULL; // Placate compiler. |