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.

From-SVN: r38808
This commit is contained in:
Bryce McKinlay 2001-01-08 23:28:56 +00:00 committed by Bryce McKinlay
parent 5bab9296f5
commit 5bb11b2e20
11 changed files with 174 additions and 94 deletions

View file

@ -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.