diff --git a/classpath/avian/VMClass.java b/classpath/avian/VMClass.java index b95726f42b..338808a83f 100644 --- a/classpath/avian/VMClass.java +++ b/classpath/avian/VMClass.java @@ -16,6 +16,7 @@ public class VMClass { public short fixedSize; public byte arrayElementSize; public byte arrayDimensions; + public VMClass arrayElementClass; public int runtimeDataIndex; public int[] objectMask; public byte[] name; @@ -35,7 +36,7 @@ public class VMClass { */ public VMMethod[] methodTable; public ClassAddendum addendum; - public Object staticTable; + public Singleton staticTable; public ClassLoader loader; public byte[] source; } diff --git a/classpath/java/lang/Class.java b/classpath/java/lang/Class.java index 0999831a1b..53879ccf7e 100644 --- a/classpath/java/lang/Class.java +++ b/classpath/java/lang/Class.java @@ -171,8 +171,8 @@ public final class Class implements Type, AnnotatedElement { return SystemClassLoader.getClass(Classes.primitiveClass('D')); } - if (vmClass.staticTable == null) throw new AssertionError(); - return SystemClassLoader.getClass((VMClass) vmClass.staticTable); + if (vmClass.arrayElementClass == null) throw new AssertionError(); + return SystemClassLoader.getClass((VMClass) vmClass.arrayElementClass); } else { return null; } diff --git a/src/avian/processor.h b/src/avian/processor.h index effbafd5fc..ccbbf3b740 100644 --- a/src/avian/processor.h +++ b/src/avian/processor.h @@ -36,6 +36,7 @@ class GcByteArray; class GcCode; class GcClass; class GcMethod; +class GcClassAddendum; class Processor { public: @@ -88,6 +89,7 @@ class Processor { uint16_t fixedSize, uint8_t arrayElementSize, uint8_t arrayDimensions, + GcClass* arrayElementClass, object objectMask, object name, object sourceFile, @@ -96,7 +98,7 @@ class Processor { object virtualTable, object fieldTable, object methodTable, - object addendum, + GcClassAddendum* addendum, object staticTable, object loader, unsigned vtableLength) = 0; diff --git a/src/avian/target.h b/src/avian/target.h index f9e77291a7..c796855ddc 100644 --- a/src/avian/target.h +++ b/src/avian/target.h @@ -116,7 +116,7 @@ typedef int64_t target_intptr_t; const unsigned TargetClassFixedSize = 12; const unsigned TargetClassArrayElementSize = 14; -const unsigned TargetClassVtable = 128; +const unsigned TargetClassVtable = 136; const unsigned TargetFieldOffset = 12; @@ -134,7 +134,7 @@ typedef int32_t target_intptr_t; const unsigned TargetClassFixedSize = 8; const unsigned TargetClassArrayElementSize = 10; -const unsigned TargetClassVtable = 68; +const unsigned TargetClassVtable = 72; const unsigned TargetFieldOffset = 8; diff --git a/src/classpath-android.cpp b/src/classpath-android.cpp index 667e289da7..5e67d54bc2 100644 --- a/src/classpath-android.cpp +++ b/src/classpath-android.cpp @@ -1206,7 +1206,7 @@ Avian_java_lang_Class_getComponentType (getJClass(t, primitiveClass(t, n))); } else { return reinterpret_cast - (getJClass(t, cast(t, classStaticTable(t, c->vmClass())))); + (getJClass(t, cast(t, classArrayElementClass(t, c->vmClass())))); } } else { return 0; diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index e1284cc8f6..bb46c155e5 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -4154,7 +4154,7 @@ jvmGetComponentType(Thread* t, uintptr_t* arguments) } else { return reinterpret_cast (makeLocalReference - (t, reinterpret_cast(getJClass(t, cast(t, classStaticTable(t, jclassVmClass(t, *c))))))); + (t, reinterpret_cast(getJClass(t, cast(t, classArrayElementClass(t, jclassVmClass(t, *c))))))); } } else { return 0; diff --git a/src/compile.cpp b/src/compile.cpp index e5559c5925..d6177bffff 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -8420,6 +8420,10 @@ class MyProcessor: public Processor { abort(t); } + expect(t, TargetClassArrayElementSize == ClassArrayElementSize); + expect(t, TargetClassFixedSize == ClassFixedSize); + expect(t, TargetClassVtable == ClassVtable); + #endif t->init(); @@ -8468,6 +8472,7 @@ class MyProcessor: public Processor { uint16_t fixedSize, uint8_t arrayElementSize, uint8_t arrayDimensions, + GcClass* arrayElementClass, object objectMask, object name, object sourceFile, @@ -8476,8 +8481,8 @@ class MyProcessor: public Processor { object virtualTable, object fieldTable, object methodTable, + GcClassAddendum* addendum, object staticTable, - object addendum, object loader, unsigned vtableLength) { @@ -8487,6 +8492,7 @@ class MyProcessor: public Processor { fixedSize, arrayElementSize, arrayDimensions, + arrayElementClass, 0, cast(t, objectMask), cast(t, name), @@ -8496,8 +8502,8 @@ class MyProcessor: public Processor { virtualTable, fieldTable, methodTable, - reinterpret_cast(staticTable), // DANGER DANGER DANGER!!!!!!!!! addendum, + staticTable, cast(t, loader), 0, vtableLength); diff --git a/src/interpret.cpp b/src/interpret.cpp index 2b5c539bef..b6c6283884 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -559,7 +559,7 @@ invokeNativeSlow(Thread* t, GcMethod* method, void* function) RUNTIME_ARRAY_BODY(args)[argOffset++] = reinterpret_cast(t); RUNTIME_ARRAY_BODY(types)[typeOffset++] = POINTER_TYPE; - object jclass = 0; + GcJclass* jclass = 0; PROTECT(t, jclass); unsigned sp; @@ -2114,9 +2114,9 @@ interpret3(Thread* t, const int base) GcClass* class_ = resolveClassInPool (t, frameMethod(t, frame), index - 1); - pushObject(t, getJClass(t, class_)); + pushObject(t, reinterpret_cast(getJClass(t, class_))); } else if (objectClass(t, v) == type(t, GcClass::Type)) { - pushObject(t, getJClass(t, cast(t, v))); + pushObject(t, reinterpret_cast(getJClass(t, cast(t, v)))); } else { pushObject(t, v); } @@ -3010,6 +3010,7 @@ class MyProcessor: public Processor { uint16_t fixedSize, uint8_t arrayElementSize, uint8_t arrayDimensions, + GcClass* arrayElementClass, object objectMask, object name, object sourceFile, @@ -3018,7 +3019,7 @@ class MyProcessor: public Processor { object virtualTable, object fieldTable, object methodTable, - object addendum, + GcClassAddendum* addendum, object staticTable, object loader, unsigned vtableLength UNUSED) @@ -3029,6 +3030,7 @@ class MyProcessor: public Processor { fixedSize, arrayElementSize, arrayDimensions, + arrayElementClass, 0, cast(t, objectMask), cast(t, name), @@ -3038,7 +3040,7 @@ class MyProcessor: public Processor { virtualTable, fieldTable, methodTable, - cast(t, addendum), + addendum, staticTable, cast(t, loader), 0, diff --git a/src/machine.cpp b/src/machine.cpp index 28a8b696c4..e43afda5e5 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2510,6 +2510,7 @@ updateBootstrapClass(Thread* t, GcClass* bootstrapClass, GcClass* class_) bootstrapClass->vmFlags() |= class_->vmFlags(); bootstrapClass->flags() |= class_->flags(); + set(t, reinterpret_cast(bootstrapClass), ClassArrayElementClass, reinterpret_cast(class_->arrayElementClass())); set(t, reinterpret_cast(bootstrapClass), ClassSuper, reinterpret_cast(class_->super())); set(t, reinterpret_cast(bootstrapClass), ClassInterfaceTable, reinterpret_cast(class_->interfaceTable())); set(t, reinterpret_cast(bootstrapClass), ClassVirtualTable, reinterpret_cast(class_->virtualTable())); @@ -2548,6 +2549,7 @@ makeArrayClass(Thread* t, object loader, unsigned dimensions, object spec, 2 * BytesPerWord, BytesPerWord, dimensions, + cast(t, elementClass), reinterpret_cast(type(t, GcArray::Type)->objectMask()), spec, 0, @@ -2557,7 +2559,7 @@ makeArrayClass(Thread* t, object loader, unsigned dimensions, object spec, 0, 0, 0, - elementClass, + 0, loader, arrayLength(t, vtable)); @@ -2742,7 +2744,7 @@ bootClass(Thread* t, Gc::Type type, int superType, uint32_t objectMask, GcClass* class_ = t->m->processor->makeClass (t, 0, BootstrapFlag, fixedSize, arrayElementSize, - arrayElementSize ? 1 : 0, mask, 0, 0, reinterpret_cast(super), 0, 0, 0, 0, 0, 0, + arrayElementSize ? 1 : 0, 0, mask, 0, 0, reinterpret_cast(super), 0, 0, 0, 0, 0, 0, root(t, Machine::BootLoader), vtableLength); setType(t, type, class_); @@ -2876,21 +2878,21 @@ boot(Thread* t) type(t, GcJvoid::Type)->vmFlags() |= PrimitiveFlag; - set(t, reinterpret_cast(type(t, GcBooleanArray::Type)), ClassStaticTable, + set(t, reinterpret_cast(type(t, GcBooleanArray::Type)), ClassArrayElementClass, reinterpret_cast(type(t, GcJboolean::Type))); - set(t, reinterpret_cast(type(t, GcByteArray::Type)), ClassStaticTable, + set(t, reinterpret_cast(type(t, GcByteArray::Type)), ClassArrayElementClass, reinterpret_cast(type(t, GcJbyte::Type))); - set(t, reinterpret_cast(type(t, GcCharArray::Type)), ClassStaticTable, + set(t, reinterpret_cast(type(t, GcCharArray::Type)), ClassArrayElementClass, reinterpret_cast(type(t, GcJchar::Type))); - set(t, reinterpret_cast(type(t, GcShortArray::Type)), ClassStaticTable, + set(t, reinterpret_cast(type(t, GcShortArray::Type)), ClassArrayElementClass, reinterpret_cast(type(t, GcJshort::Type))); - set(t, reinterpret_cast(type(t, GcIntArray::Type)), ClassStaticTable, + set(t, reinterpret_cast(type(t, GcIntArray::Type)), ClassArrayElementClass, reinterpret_cast(type(t, GcJint::Type))); - set(t, reinterpret_cast(type(t, GcLongArray::Type)), ClassStaticTable, + set(t, reinterpret_cast(type(t, GcLongArray::Type)), ClassArrayElementClass, reinterpret_cast(type(t, GcJlong::Type))); - set(t, reinterpret_cast(type(t, GcFloatArray::Type)), ClassStaticTable, + set(t, reinterpret_cast(type(t, GcFloatArray::Type)), ClassArrayElementClass, reinterpret_cast(type(t, GcJfloat::Type))); - set(t, reinterpret_cast(type(t, GcDoubleArray::Type)), ClassStaticTable, + set(t, reinterpret_cast(type(t, GcDoubleArray::Type)), ClassArrayElementClass, reinterpret_cast(type(t, GcJdouble::Type))); { GcHashMap* map = makeHashMap(t, 0, 0); @@ -4114,7 +4116,7 @@ isAssignableFrom(Thread* t, GcClass* a, GcClass* b) } else if (a->arrayDimensions()) { if (b->arrayDimensions()) { return isAssignableFrom - (t, cast(t, a->staticTable()), cast(t, b->staticTable())); + (t, a->arrayElementClass(), b->arrayElementClass()); } } else if ((a->vmFlags() & PrimitiveFlag) == (b->vmFlags() & PrimitiveFlag)) @@ -4275,6 +4277,7 @@ parseClass(Thread* t, object loader, const uint8_t* data, unsigned size, 0, // fixed size 0, // array size 0, // array dimensions + 0, // array element class 0, // runtime data index 0, // object mask cast(t, referenceName(t, singletonObject(t, pool, name - 1))), @@ -4327,6 +4330,7 @@ parseClass(Thread* t, object loader, const uint8_t* data, unsigned size, class_->fixedSize(), class_->arrayElementSize(), class_->arrayDimensions(), + class_->arrayElementClass(), reinterpret_cast(class_->objectMask()), reinterpret_cast(class_->name()), reinterpret_cast(class_->sourceFile()), @@ -4335,7 +4339,7 @@ parseClass(Thread* t, object loader, const uint8_t* data, unsigned size, reinterpret_cast(class_->virtualTable()), reinterpret_cast(class_->fieldTable()), reinterpret_cast(class_->methodTable()), - reinterpret_cast(class_->addendum()), + class_->addendum(), reinterpret_cast(class_->staticTable()), reinterpret_cast(class_->loader()), vtableLength);