add VMClass changes

This commit is contained in:
Joshua Warner 2014-06-27 18:32:20 -06:00 committed by Joshua Warner
parent 9b36dca846
commit 194e3b2701
9 changed files with 42 additions and 27 deletions

View File

@ -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;
}

View File

@ -171,8 +171,8 @@ public final class Class <T> 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;
}

View File

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

View File

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

View File

@ -1206,7 +1206,7 @@ Avian_java_lang_Class_getComponentType
(getJClass(t, primitiveClass(t, n)));
} else {
return reinterpret_cast<uintptr_t>
(getJClass(t, cast<GcClass>(t, classStaticTable(t, c->vmClass()))));
(getJClass(t, cast<GcClass>(t, classArrayElementClass(t, c->vmClass()))));
}
} else {
return 0;

View File

@ -4154,7 +4154,7 @@ jvmGetComponentType(Thread* t, uintptr_t* arguments)
} else {
return reinterpret_cast<uintptr_t>
(makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, classStaticTable(t, jclassVmClass(t, *c)))))));
(t, reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, classArrayElementClass(t, jclassVmClass(t, *c)))))));
}
} else {
return 0;

View File

@ -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<GcIntArray>(t, objectMask),
cast<GcByteArray>(t, name),
@ -8496,8 +8502,8 @@ class MyProcessor: public Processor {
virtualTable,
fieldTable,
methodTable,
reinterpret_cast<GcClassAddendum*>(staticTable), // DANGER DANGER DANGER!!!!!!!!!
addendum,
staticTable,
cast<GcClassLoader>(t, loader),
0,
vtableLength);

View File

@ -559,7 +559,7 @@ invokeNativeSlow(Thread* t, GcMethod* method, void* function)
RUNTIME_ARRAY_BODY(args)[argOffset++] = reinterpret_cast<uintptr_t>(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<object>(getJClass(t, class_)));
} else if (objectClass(t, v) == type(t, GcClass::Type)) {
pushObject(t, getJClass(t, cast<GcClass>(t, v)));
pushObject(t, reinterpret_cast<object>(getJClass(t, cast<GcClass>(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<GcIntArray>(t, objectMask),
cast<GcByteArray>(t, name),
@ -3038,7 +3040,7 @@ class MyProcessor: public Processor {
virtualTable,
fieldTable,
methodTable,
cast<GcClassAddendum>(t, addendum),
addendum,
staticTable,
cast<GcClassLoader>(t, loader),
0,

View File

@ -2510,6 +2510,7 @@ updateBootstrapClass(Thread* t, GcClass* bootstrapClass, GcClass* class_)
bootstrapClass->vmFlags() |= class_->vmFlags();
bootstrapClass->flags() |= class_->flags();
set(t, reinterpret_cast<object>(bootstrapClass), ClassArrayElementClass, reinterpret_cast<object>(class_->arrayElementClass()));
set(t, reinterpret_cast<object>(bootstrapClass), ClassSuper, reinterpret_cast<object>(class_->super()));
set(t, reinterpret_cast<object>(bootstrapClass), ClassInterfaceTable, reinterpret_cast<object>(class_->interfaceTable()));
set(t, reinterpret_cast<object>(bootstrapClass), ClassVirtualTable, reinterpret_cast<object>(class_->virtualTable()));
@ -2548,6 +2549,7 @@ makeArrayClass(Thread* t, object loader, unsigned dimensions, object spec,
2 * BytesPerWord,
BytesPerWord,
dimensions,
cast<GcClass>(t, elementClass),
reinterpret_cast<object>(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<object>(super), 0, 0, 0, 0, 0, 0,
arrayElementSize ? 1 : 0, 0, mask, 0, 0, reinterpret_cast<object>(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<object>(type(t, GcBooleanArray::Type)), ClassStaticTable,
set(t, reinterpret_cast<object>(type(t, GcBooleanArray::Type)), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJboolean::Type)));
set(t, reinterpret_cast<object>(type(t, GcByteArray::Type)), ClassStaticTable,
set(t, reinterpret_cast<object>(type(t, GcByteArray::Type)), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJbyte::Type)));
set(t, reinterpret_cast<object>(type(t, GcCharArray::Type)), ClassStaticTable,
set(t, reinterpret_cast<object>(type(t, GcCharArray::Type)), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJchar::Type)));
set(t, reinterpret_cast<object>(type(t, GcShortArray::Type)), ClassStaticTable,
set(t, reinterpret_cast<object>(type(t, GcShortArray::Type)), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJshort::Type)));
set(t, reinterpret_cast<object>(type(t, GcIntArray::Type)), ClassStaticTable,
set(t, reinterpret_cast<object>(type(t, GcIntArray::Type)), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJint::Type)));
set(t, reinterpret_cast<object>(type(t, GcLongArray::Type)), ClassStaticTable,
set(t, reinterpret_cast<object>(type(t, GcLongArray::Type)), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJlong::Type)));
set(t, reinterpret_cast<object>(type(t, GcFloatArray::Type)), ClassStaticTable,
set(t, reinterpret_cast<object>(type(t, GcFloatArray::Type)), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJfloat::Type)));
set(t, reinterpret_cast<object>(type(t, GcDoubleArray::Type)), ClassStaticTable,
set(t, reinterpret_cast<object>(type(t, GcDoubleArray::Type)), ClassArrayElementClass,
reinterpret_cast<object>(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<GcClass>(t, a->staticTable()), cast<GcClass>(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<GcByteArray>(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<object>(class_->objectMask()),
reinterpret_cast<object>(class_->name()),
reinterpret_cast<object>(class_->sourceFile()),
@ -4335,7 +4339,7 @@ parseClass(Thread* t, object loader, const uint8_t* data, unsigned size,
reinterpret_cast<object>(class_->virtualTable()),
reinterpret_cast<object>(class_->fieldTable()),
reinterpret_cast<object>(class_->methodTable()),
reinterpret_cast<object>(class_->addendum()),
class_->addendum(),
reinterpret_cast<object>(class_->staticTable()),
reinterpret_cast<object>(class_->loader()),
vtableLength);