Commit 5bb11b2e by Bryce McKinlay Committed by Bryce McKinlay

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
parent 5bab9296
2001-01-05 Bryce McKinlay <bryce@albatross.co.nz> 2001-01-05 Bryce McKinlay <bryce@albatross.co.nz>
* class.c (make_class_data): Push initial value for "arrayclass".
* decl.c (init_decl_processing): Add new class field "arrayclass".
2001-01-05 Bryce McKinlay <bryce@albatross.co.nz>
From patha@softlab.ericsson.se: From patha@softlab.ericsson.se:
* parse.y (switch_label): Use build, not build1, to construct * parse.y (switch_label): Use build, not build1, to construct
DEFAULT_EXPR. DEFAULT_EXPR.
......
...@@ -1441,6 +1441,7 @@ make_class_data (type) ...@@ -1441,6 +1441,7 @@ make_class_data (type)
PUSH_FIELD_VALUE (cons, "depth", integer_zero_node); PUSH_FIELD_VALUE (cons, "depth", integer_zero_node);
PUSH_FIELD_VALUE (cons, "ancestors", null_pointer_node); PUSH_FIELD_VALUE (cons, "ancestors", null_pointer_node);
PUSH_FIELD_VALUE (cons, "idt", null_pointer_node); PUSH_FIELD_VALUE (cons, "idt", null_pointer_node);
PUSH_FIELD_VALUE (cons, "arrayclass", null_pointer_node);
FINISH_RECORD_CONSTRUCTOR (cons); FINISH_RECORD_CONSTRUCTOR (cons);
......
...@@ -672,6 +672,7 @@ init_decl_processing () ...@@ -672,6 +672,7 @@ init_decl_processing ()
PUSH_FIELD (class_type_node, field, "depth", short_type_node); PUSH_FIELD (class_type_node, field, "depth", short_type_node);
PUSH_FIELD (class_type_node, field, "ancestors", ptr_type_node); PUSH_FIELD (class_type_node, field, "ancestors", ptr_type_node);
PUSH_FIELD (class_type_node, field, "idt", ptr_type_node); PUSH_FIELD (class_type_node, field, "idt", ptr_type_node);
PUSH_FIELD (class_type_node, field, "arrayclass", ptr_type_node);
for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = TREE_CHAIN (t)) for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
FIELD_PRIVATE (t) = 1; FIELD_PRIVATE (t) = 1;
push_super_field (class_type_node, object_type_node); push_super_field (class_type_node, object_type_node);
......
2001-01-08 Bryce McKinlay <bryce@albatross.co.nz>
* 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.
2001-01-08 Tom Tromey <tromey@redhat.com> 2001-01-08 Tom Tromey <tromey@redhat.com>
Fix for PR java/1586: Fix for PR java/1586:
......
...@@ -225,6 +225,8 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) ...@@ -225,6 +225,8 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */)
} }
p = (ptr_t) c->loader; p = (ptr_t) c->loader;
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cBlabel); MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cBlabel);
p = (ptr_t) c->arrayclass;
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cDlabel);
#ifdef INTERPRETER #ifdef INTERPRETER
if (_Jv_IsInterpretedClass (c)) if (_Jv_IsInterpretedClass (c))
......
...@@ -210,7 +210,7 @@ private: ...@@ -210,7 +210,7 @@ private:
inline friend void inline friend void
_Jv_InitClass (jclass klass) _Jv_InitClass (jclass klass)
{ {
if (klass->state == JV_STATE_DONE) if (__builtin_expect (klass->state == JV_STATE_DONE, true))
return; return;
klass->initializeClass (); klass->initializeClass ();
} }
...@@ -254,9 +254,9 @@ private: ...@@ -254,9 +254,9 @@ private:
java::lang::ClassLoader *loader); java::lang::ClassLoader *loader);
friend jclass _Jv_FindClassInCache (_Jv_Utf8Const *name, friend jclass _Jv_FindClassInCache (_Jv_Utf8Const *name,
java::lang::ClassLoader *loader); java::lang::ClassLoader *loader);
friend jclass _Jv_FindArrayClass (jclass element, friend void _Jv_NewArrayClass (jclass element,
java::lang::ClassLoader *loader, java::lang::ClassLoader *loader,
_Jv_VTable *array_vtable = 0); _Jv_VTable *array_vtable = 0);
friend jclass _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass, friend jclass _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
java::lang::ClassLoader *loader); java::lang::ClassLoader *loader);
...@@ -268,6 +268,16 @@ private: ...@@ -268,6 +268,16 @@ private:
friend jshort _Jv_AppendPartialITable (jclass, jclass, void **, jshort); friend jshort _Jv_AppendPartialITable (jclass, jclass, void **, jshort);
friend jshort _Jv_FindIIndex (jclass *, jshort *, jshort); friend jshort _Jv_FindIIndex (jclass *, jshort *, jshort);
// Return array class corresponding to element type KLASS, creating it if
// neccessary.
inline friend jclass
_Jv_GetArrayClass (jclass klass, java::lang::ClassLoader *loader)
{
if (__builtin_expect (!klass->arrayclass, false))
_Jv_NewArrayClass (klass, loader);
return klass->arrayclass;
}
#ifdef INTERPRETER #ifdef INTERPRETER
friend jboolean _Jv_IsInterpretedClass (jclass); friend jboolean _Jv_IsInterpretedClass (jclass);
friend void _Jv_InitField (jobject, jclass, _Jv_Field*); friend void _Jv_InitField (jobject, jclass, _Jv_Field*);
...@@ -302,8 +312,7 @@ private: ...@@ -302,8 +312,7 @@ private:
// Class constants. // Class constants.
_Jv_Constants constants; _Jv_Constants constants;
// Methods. If this is an array class, then this field holds a // Methods. If this is an array class, then this field holds a
// pointer to the element type. If this is a primitive class, this // pointer to the element type.
// is used to cache a pointer to the appropriate array type.
_Jv_Method *methods; _Jv_Method *methods;
// Number of methods. If this class is primitive, this holds the // Number of methods. If this class is primitive, this holds the
// character used to represent this type in a signature. // character used to represent this type in a signature.
...@@ -337,6 +346,8 @@ private: ...@@ -337,6 +346,8 @@ private:
jclass *ancestors; jclass *ancestors;
// Interface Dispatch Table. // Interface Dispatch Table.
_Jv_IDispatchTable *idt; _Jv_IDispatchTable *idt;
// Pointer to the class that represents an array of this class.
jclass arrayclass;
}; };
#endif /* __JAVA_LANG_CLASS_H__ */ #endif /* __JAVA_LANG_CLASS_H__ */
...@@ -421,7 +421,7 @@ java::lang::Class::_getFields (JArray<java::lang::reflect::Field *> *result, ...@@ -421,7 +421,7 @@ java::lang::Class::_getFields (JArray<java::lang::reflect::Field *> *result,
rfield->offset = (char *) field - (char *) fields; rfield->offset = (char *) field - (char *) fields;
rfield->declaringClass = this; rfield->declaringClass = this;
rfield->name = _Jv_NewStringUtf8Const (field->name); rfield->name = _Jv_NewStringUtf8Const (field->name);
(elements (result))[offset + i] = rfield; (elements (result))[offset++] = rfield;
} }
} }
jclass superclass = getSuperclass(); jclass superclass = getSuperclass();
...@@ -929,8 +929,7 @@ _Jv_IsAssignableFrom (jclass target, jclass source) ...@@ -929,8 +929,7 @@ _Jv_IsAssignableFrom (jclass target, jclass source)
// Abstract classes have no IDT, and IDTs provide no way to check // Abstract classes have no IDT, and IDTs provide no way to check
// two interfaces for assignability. // two interfaces for assignability.
if (__builtin_expect if (__builtin_expect
(java::lang::reflect::Modifier::isAbstract (source->accflags) (source->idt == NULL || source->isInterface(), false))
|| source->isInterface(), false))
return _Jv_InterfaceAssignableFrom (target, source); return _Jv_InterfaceAssignableFrom (target, source);
_Jv_IDispatchTable *cl_idt = source->idt; _Jv_IDispatchTable *cl_idt = source->idt;
...@@ -1007,6 +1006,8 @@ _Jv_CheckArrayStore (jobject arr, jobject obj) ...@@ -1007,6 +1006,8 @@ _Jv_CheckArrayStore (jobject arr, jobject obj)
#define INITIAL_IOFFSETS_LEN 4 #define INITIAL_IOFFSETS_LEN 4
#define INITIAL_IFACES_LEN 4 #define INITIAL_IFACES_LEN 4
static _Jv_IDispatchTable null_idt = { {SHRT_MAX, 0, NULL} };
// Generate tables for constant-time assignment testing and interface // Generate tables for constant-time assignment testing and interface
// method lookup. This implements the technique described by Per Bothner // method lookup. This implements the technique described by Per Bothner
// <per@bothner.com> on the java-discuss mailing list on 1999-09-02: // <per@bothner.com> on the java-discuss mailing list on 1999-09-02:
...@@ -1028,8 +1029,10 @@ _Jv_PrepareConstantTimeTables (jclass klass) ...@@ -1028,8 +1029,10 @@ _Jv_PrepareConstantTimeTables (jclass klass)
// interfaces or primitive types. // interfaces or primitive types.
jclass klass0 = klass; jclass klass0 = klass;
jboolean has_interfaces = 0;
while (klass0 != &ObjectClass) while (klass0 != &ObjectClass)
{ {
has_interfaces += klass0->interface_count;
klass0 = klass0->superclass; klass0 = klass0->superclass;
klass->depth++; klass->depth++;
} }
...@@ -1051,6 +1054,14 @@ _Jv_PrepareConstantTimeTables (jclass klass) ...@@ -1051,6 +1054,14 @@ _Jv_PrepareConstantTimeTables (jclass klass)
if (java::lang::reflect::Modifier::isAbstract (klass->accflags)) if (java::lang::reflect::Modifier::isAbstract (klass->accflags))
return; return;
// Optimization: If class implements no interfaces, use a common
// predefined interface table.
if (!has_interfaces)
{
klass->idt = &null_idt;
return;
}
klass->idt = klass->idt =
(_Jv_IDispatchTable *) _Jv_Malloc (sizeof (_Jv_IDispatchTable)); (_Jv_IDispatchTable *) _Jv_Malloc (sizeof (_Jv_IDispatchTable));
...@@ -1095,7 +1106,7 @@ _Jv_PrepareConstantTimeTables (jclass klass) ...@@ -1095,7 +1106,7 @@ _Jv_PrepareConstantTimeTables (jclass klass)
} }
// Return index of item in list, or -1 if item is not present. // Return index of item in list, or -1 if item is not present.
jshort inline jshort
_Jv_IndexOf (void *item, void **list, jshort list_len) _Jv_IndexOf (void *item, void **list, jshort list_len)
{ {
for (int i=0; i < list_len; i++) for (int i=0; i < list_len; i++)
......
...@@ -530,26 +530,35 @@ _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass, ...@@ -530,26 +530,35 @@ _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
ret->depth = 0; ret->depth = 0;
ret->ancestors = NULL; ret->ancestors = NULL;
ret->idt = NULL; ret->idt = NULL;
ret->arrayclass = NULL;
_Jv_RegisterClass (ret); _Jv_RegisterClass (ret);
return ret; return ret;
} }
jclass static _Jv_IDispatchTable *array_idt = NULL;
_Jv_FindArrayClass (jclass element, java::lang::ClassLoader *loader, static jshort array_depth = 0;
_Jv_VTable *array_vtable) static jclass *array_ancestors = NULL;
// Create a class representing an array of ELEMENT and store a pointer to it
// in element->arrayclass. LOADER is the ClassLoader which _initiated_ the
// instantiation of this array. ARRAY_VTABLE is the vtable to use for the new
// array class. This parameter is optional.
void
_Jv_NewArrayClass (jclass element, java::lang::ClassLoader *loader,
_Jv_VTable *array_vtable)
{ {
JvSynchronize sync (element);
_Jv_Utf8Const *array_name; _Jv_Utf8Const *array_name;
int len; int len;
if (element->arrayclass)
return;
if (element->isPrimitive()) if (element->isPrimitive())
{ len = 3;
// For primitive types the array is cached in the class.
jclass ret = (jclass) element->methods;
if (ret)
return ret;
len = 3;
}
else else
len = element->name->length + 5; len = element->name->length + 5;
...@@ -557,7 +566,7 @@ _Jv_FindArrayClass (jclass element, java::lang::ClassLoader *loader, ...@@ -557,7 +566,7 @@ _Jv_FindArrayClass (jclass element, java::lang::ClassLoader *loader,
char signature[len]; char signature[len];
int index = 0; int index = 0;
signature[index++] = '['; signature[index++] = '[';
// Compute name of array class to see if we've already cached it. // Compute name of array class.
if (element->isPrimitive()) if (element->isPrimitive())
{ {
signature[index++] = (char) element->method_count; signature[index++] = (char) element->method_count;
...@@ -576,65 +585,76 @@ _Jv_FindArrayClass (jclass element, java::lang::ClassLoader *loader, ...@@ -576,65 +585,76 @@ _Jv_FindArrayClass (jclass element, java::lang::ClassLoader *loader,
array_name = _Jv_makeUtf8Const (signature, index); array_name = _Jv_makeUtf8Const (signature, index);
} }
jclass array_class = _Jv_FindClassInCache (array_name, element->loader); // Create new array class.
jclass array_class = _Jv_NewClass (array_name, &ObjectClass,
if (! array_class) element->loader);
// Note that `vtable_method_count' doesn't include the initial
// gc_descr slot.
JvAssert (ObjectClass.vtable_method_count == NUM_OBJECT_METHODS);
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 *)));
_Jv_VTable *vtable;
if (array_vtable)
vtable = array_vtable;
else
vtable = (_Jv_VTable *) _Jv_AllocBytes (size);
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;
// Stash the pointer to the element type.
array_class->methods = (_Jv_Method *) element;
// Register our interfaces.
static jclass interfaces[] = { &CloneableClass, &SerializableClass };
array_class->interfaces = interfaces;
array_class->interface_count = sizeof interfaces / sizeof interfaces[0];
// Since all array classes have the same interface dispatch table, we can
// cache one and reuse it. It is not neccessary to synchronize this.
if (!array_idt)
{ {
// Create new array class.
array_class = _Jv_NewClass (array_name, &ObjectClass, element->loader);
// Note that `vtable_method_count' doesn't include the initial
// gc_descr slot.
JvAssert (ObjectClass.vtable_method_count == NUM_OBJECT_METHODS);
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 *)));
_Jv_VTable *vtable;
if (array_vtable)
vtable = array_vtable;
else
vtable = (_Jv_VTable *) _Jv_AllocBytes (size);
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;
// Stash the pointer to the element type.
array_class->methods = (_Jv_Method *) element;
// Register our interfaces.
static jclass interfaces[] = { &CloneableClass, &SerializableClass };
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); _Jv_PrepareConstantTimeTables (array_class);
array_idt = array_class->idt;
array_depth = array_class->depth;
array_ancestors = array_class->ancestors;
}
else
{
array_class->idt = array_idt;
array_class->depth = array_depth;
array_class->ancestors = array_ancestors;
}
// as per vmspec 5.3.3.2 using namespace java::lang::reflect;
array_class->accflags = element->accflags; {
// Array classes are "abstract final"...
// FIXME: initialize other Class instance variables, _Jv_ushort accflags = Modifier::FINAL | Modifier::ABSTRACT;
// e.g. `fields'. // ... and inherit accessibility from element type, per vmspec 5.3.3.2
accflags |= (element->accflags & Modifier::PUBLIC);
accflags |= (element->accflags & Modifier::PROTECTED);
accflags |= (element->accflags & Modifier::PRIVATE);
array_class->accflags = accflags;
}
// say this class is initialized and ready to go! // An array class has no visible instance fields. "length" is invisible to
array_class->state = JV_STATE_DONE; // reflection.
// vmspec, section 5.3.3 describes this // say this class is initialized and ready to go!
if (element->loader != loader) array_class->state = JV_STATE_DONE;
_Jv_RegisterInitiatingLoader (array_class, loader);
}
// For primitive types, point back at this array. // vmspec, section 5.3.3 describes this
if (element->isPrimitive()) if (element->loader != loader)
element->methods = (_Jv_Method *) array_class; _Jv_RegisterInitiatingLoader (array_class, loader);
return array_class; element->arrayclass = array_class;
} }
...@@ -54,7 +54,7 @@ java::lang::reflect::Array::newInstance (jclass componentType, jintArray dimensi ...@@ -54,7 +54,7 @@ java::lang::reflect::Array::newInstance (jclass componentType, jintArray dimensi
jclass arrayType = componentType; jclass arrayType = componentType;
for (int i = 0; i < ndims; i++) // FIXME 2nd arg should for (int i = 0; i < ndims; i++) // FIXME 2nd arg should
// be "current" loader // be "current" loader
arrayType = _Jv_FindArrayClass (arrayType, 0); arrayType = _Jv_GetArrayClass (arrayType, 0);
return _Jv_NewMultiArray (arrayType, ndims, dims); return _Jv_NewMultiArray (arrayType, ndims, dims);
} }
......
...@@ -286,7 +286,7 @@ _Jv_GetTypesFromSignature (jmethodID method, ...@@ -286,7 +286,7 @@ _Jv_GetTypesFromSignature (jmethodID method,
// FIXME: 2'nd argument should be "current loader" // FIXME: 2'nd argument should be "current loader"
while (--num_arrays >= 0) while (--num_arrays >= 0)
type = _Jv_FindArrayClass (type, 0); type = _Jv_GetArrayClass (type, 0);
// ARGPTR can be NULL if we are processing the return value of a // ARGPTR can be NULL if we are processing the return value of a
// call from Constructor. // call from Constructor.
if (argPtr) if (argPtr)
......
...@@ -394,19 +394,13 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) ...@@ -394,19 +394,13 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init)
JvAssert (! elementClass->isPrimitive ()); JvAssert (! elementClass->isPrimitive ());
// Ensure that elements pointer is properly aligned.
jobjectArray obj = NULL; jobjectArray obj = NULL;
size_t size = (size_t) _Jv_GetArrayElementFromElementType (obj, size_t size = (size_t) elements (obj);
elementClass);
// Check for overflow.
if (__builtin_expect ((size_t) count >
(SIZE_T_MAX - size) / sizeof (jobject), false))
JvThrow (no_memory);
size += count * sizeof (jobject); size += count * sizeof (jobject);
// FIXME: second argument should be "current loader" // // FIXME: second argument should be "current loader"
jclass klass = _Jv_FindArrayClass (elementClass, 0); jclass klass = _Jv_GetArrayClass (elementClass, 0);
obj = (jobjectArray) _Jv_AllocArray (size, klass); obj = (jobjectArray) _Jv_AllocArray (size, klass);
if (__builtin_expect (! obj, false)) if (__builtin_expect (! obj, false))
...@@ -414,11 +408,11 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) ...@@ -414,11 +408,11 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init)
// Cast away const. // Cast away const.
jsize *lp = const_cast<jsize *> (&obj->length); jsize *lp = const_cast<jsize *> (&obj->length);
*lp = count; *lp = count;
jobject *ptr = elements(obj);
// We know the allocator returns zeroed memory. So don't bother // We know the allocator returns zeroed memory. So don't bother
// zeroing it again. // zeroing it again.
if (init) if (init)
{ {
jobject *ptr = elements(obj);
while (--count >= 0) while (--count >= 0)
*ptr++ = init; *ptr++ = init;
} }
...@@ -443,7 +437,7 @@ _Jv_NewPrimArray (jclass eltype, jint count) ...@@ -443,7 +437,7 @@ _Jv_NewPrimArray (jclass eltype, jint count)
(SIZE_T_MAX - size) / elsize, false)) (SIZE_T_MAX - size) / elsize, false))
JvThrow (no_memory); JvThrow (no_memory);
jclass klass = _Jv_FindArrayClass (eltype, 0); jclass klass = _Jv_GetArrayClass (eltype, 0);
__JArray *arr = (__JArray*) _Jv_AllocObj (size + elsize * count, klass); __JArray *arr = (__JArray*) _Jv_AllocObj (size + elsize * count, klass);
if (__builtin_expect (! arr, false)) if (__builtin_expect (! arr, false))
...@@ -529,7 +523,7 @@ public: ...@@ -529,7 +523,7 @@ public:
// the same order they are declared in Class.h. // the same order they are declared in Class.h.
next = NULL; next = NULL;
name = _Jv_makeUtf8Const ((char *) cname, -1); name = _Jv_makeUtf8Const ((char *) cname, -1);
accflags = Modifier::PUBLIC | Modifier::FINAL; accflags = Modifier::PUBLIC | Modifier::FINAL | Modifier::ABSTRACT;
superclass = NULL; superclass = NULL;
constants.size = 0; constants.size = 0;
constants.tags = NULL; constants.tags = NULL;
...@@ -547,10 +541,15 @@ public: ...@@ -547,10 +541,15 @@ public:
interface_count = 0; interface_count = 0;
state = JV_STATE_DONE; state = JV_STATE_DONE;
thread = NULL; thread = NULL;
depth = -1;
ancestors = NULL;
idt = NULL;
// Note that we have to set `methods' to NULL. // Note that we have to set `methods' to NULL.
if (sig != 'V') 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) ...@@ -606,8 +605,8 @@ _Jv_FindClassFromSignature (char *sig, java::lang::ClassLoader *loader)
} }
case '[': case '[':
return _Jv_FindArrayClass (_Jv_FindClassFromSignature (&sig[1], loader), return _Jv_GetArrayClass (_Jv_FindClassFromSignature (&sig[1], loader),
loader); loader);
} }
JvFail ("couldn't understand class signature"); JvFail ("couldn't understand class signature");
return NULL; // Placate compiler. return NULL; // Placate compiler.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment