diff --git a/src/avian/classpath-common.h b/src/avian/classpath-common.h index 4b396d5672..802c6526da 100644 --- a/src/avian/classpath-common.h +++ b/src/avian/classpath-common.h @@ -489,7 +489,7 @@ resolveExceptionJTypes(Thread* t, GcClassLoader* loader, GcMethodAddendum* adden object o = singletonObject(t, addendum->pool()->as(t), index); if (objectClass(t, o) == type(t, GcReference::Type)) { - o = reinterpret_cast(resolveClass(t, loader, cast(t, cast(t, o)->name()))); + o = reinterpret_cast(resolveClass(t, loader, cast(t, o)->name())); set(t, reinterpret_cast(addendum->pool()), SingletonBody + (index * BytesPerWord), o); diff --git a/src/avian/machine.h b/src/avian/machine.h index 9f74e07450..430a85c3da 100644 --- a/src/avian/machine.h +++ b/src/avian/machine.h @@ -3667,7 +3667,7 @@ resolveClassInPool(Thread* t, GcClassLoader* loader, GcMethod* method, unsigned if (objectClass(t, o) == type(t, GcReference::Type)) { PROTECT(t, method); - GcClass* c = resolveClass(t, loader, cast(t, cast(t, o)->name()), throw_); + GcClass* c = resolveClass(t, loader, cast(t, o)->name(), throw_); if (c) { storeStoreMemoryBarrier(); @@ -3707,7 +3707,7 @@ resolve(Thread* t, GcClassLoader* loader, GcMethod* method, unsigned index, if (class_) { o = findInHierarchy - (t, class_, cast(t, reference->name()), cast(t, reference->spec()), + (t, class_, reference->name(), reference->spec(), find, errorType, throw_); if (o) { diff --git a/src/compile.cpp b/src/compile.cpp index 743002400d..d656e910b7 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -1321,7 +1321,7 @@ unsigned methodReferenceParameterFootprint(Thread* t, return parameterFootprint( t, reinterpret_cast( - &byteArrayBody(t, referenceSpec(t, reference), 0)), + referenceSpec(t, reference)->body().begin()), isStatic); } @@ -1332,7 +1332,7 @@ int methodReferenceReturnCode(Thread* t, object reference) unsigned returnCode; scanMethodSpec(t, reinterpret_cast( - &byteArrayBody(t, referenceSpec(t, reference), 0)), + referenceSpec(t, reference)->body().begin()), true, ¶meterCount, ¶meterFootprint, @@ -2285,7 +2285,7 @@ resolveMethod(Thread* t, object pair) ReferenceClass); return cast(t, findInHierarchy - (t, class_, cast(t, referenceName(t, reference)), cast(t, referenceSpec(t, reference)), + (t, class_, referenceName(t, reference), referenceSpec(t, reference), findMethodInClass, GcNoSuchMethodError::Type)); } @@ -2420,7 +2420,7 @@ getJClassFromReference(MyThread* t, object pair) t, resolveClass(t, cast(t, cast(t, pair)->first())->class_()->loader(), - cast(t, referenceName(t, pairSecond(t, pair)))))); + referenceName(t, pairSecond(t, pair))))); } unsigned @@ -2513,7 +2513,7 @@ makeBlankObjectArrayFromReference(MyThread* t, object pair, t, resolveClass(t, cast(t, cast(t, pair)->first())->class_()->loader(), - cast(t, referenceName(t, pairSecond(t, pair)))), + referenceName(t, pairSecond(t, pair))), length); } @@ -2652,7 +2652,7 @@ makeMultidimensionalArrayFromReference(MyThread* t, object pair, return makeMultidimensionalArray (t, resolveClass (t, cast(t, cast(t, pair)->first())->class_()->loader(), - cast(t, referenceName(t, pairSecond(t, pair)))), dimensions, offset); + referenceName(t, pairSecond(t, pair))), dimensions, offset); } void NO_RETURN @@ -2711,7 +2711,7 @@ checkCastFromReference(MyThread* t, object pair, object o) GcClass* c = resolveClass (t, cast(t, cast(t, pair)->first())->class_()->loader(), - cast(t, referenceName(t, pairSecond(t, pair)))); + referenceName(t, pairSecond(t, pair))); checkCast(t, c, o); } @@ -2727,7 +2727,7 @@ resolveField(Thread* t, object pair) ReferenceClass); return findInHierarchy - (t, class_, cast(t, referenceName(t, reference)), cast(t, referenceSpec(t, reference)), + (t, class_, referenceName(t, reference), referenceSpec(t, reference), findFieldInClass, GcNoSuchFieldError::Type); } @@ -2907,7 +2907,7 @@ instanceOfFromReference(Thread* t, object pair, object o) GcClass* c = resolveClass (t, cast(t, cast(t, pair)->first())->class_()->loader(), - cast(t, referenceName(t, pairSecond(t, pair)))); + referenceName(t, pairSecond(t, pair))); return instanceOf64(t, c, o); } @@ -2937,7 +2937,7 @@ makeNewFromReference(Thread* t, object pair) { GcClass* class_ = resolveClass (t, cast(t, cast(t, pair)->first())->class_()->loader(), - cast(t, referenceName(t, pairSecond(t, pair)))); + referenceName(t, pairSecond(t, pair))); PROTECT(t, class_); @@ -3362,14 +3362,9 @@ bool isReferenceTailCall(MyThread* t, object code, unsigned ip, GcMethod* caller, object calleeReference) { - object c = referenceClass(t, calleeReference); - if (objectClass(t, c) == type(t, GcClass::Type)) { - c = className(t, c); - } - return isTailCall (t, code, ip, caller, methodReferenceReturnCode(t, calleeReference), - cast(t, c), cast(t, referenceName(t, calleeReference)), cast(t, referenceSpec(t, calleeReference))); + referenceClass(t, calleeReference), referenceName(t, calleeReference), referenceSpec(t, calleeReference)); } lir::TernaryOperation toCompilerJumpOp(MyThread* t, unsigned instruction) { @@ -4572,7 +4567,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, } } else { int fieldCode = vm::fieldCode - (t, byteArrayBody(t, referenceSpec(t, reference), 0)); + (t, referenceSpec(t, reference)->body()[0]); object pair = reinterpret_cast(makePair(t, reinterpret_cast(context->method), reference)); @@ -5784,7 +5779,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, } } else { int fieldCode = vm::fieldCode - (t, byteArrayBody(t, referenceSpec(t, reference), 0)); + (t, referenceSpec(t, reference)->body()[0]); ir::Value* value = popField(t, frame, fieldCode); ir::Type rType = operandTypeForFieldCode(t, fieldCode); diff --git a/src/machine.cpp b/src/machine.cpp index 6cb9ae9fb1..e132c1d095 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -948,7 +948,7 @@ parsePoolEntry(Thread* t, Stream& s, uint32_t* index, GcSingleton* pool, unsigne unsigned si = s.read2() - 1; parsePoolEntry(t, s, index, pool, si); - object value = reinterpret_cast(makeReference(t, 0, 0, singletonObject(t, pool, si), 0)); + object value = reinterpret_cast(makeReference(t, 0, 0, cast(t, singletonObject(t, pool, si)), 0)); set(t, reinterpret_cast(pool), SingletonBody + (i * BytesPerWord), value); if(DebugClassReader) { @@ -1003,15 +1003,15 @@ parsePoolEntry(Thread* t, Stream& s, uint32_t* index, GcSingleton* pool, unsigne parsePoolEntry(t, s, index, pool, ci); parsePoolEntry(t, s, index, pool, nti); - object className = referenceName(t, singletonObject(t, pool, ci)); + GcByteArray* className = referenceName(t, singletonObject(t, pool, ci)); object nameAndType = singletonObject(t, pool, nti); object value = reinterpret_cast(makeReference - (t, 0, className, pairFirst(t, nameAndType), pairSecond(t, nameAndType))); + (t, 0, className, cast(t, pairFirst(t, nameAndType)), cast(t, pairSecond(t, nameAndType)))); set(t, reinterpret_cast(pool), SingletonBody + (i * BytesPerWord), value); if(DebugClassReader) { - fprintf(stderr, " consts[%d] = method %s.%s%s\n", i, &byteArrayBody(t, className, 0), &byteArrayBody(t, pairFirst(t, nameAndType), 0), &byteArrayBody(t, pairSecond(t, nameAndType), 0)); + fprintf(stderr, " consts[%d] = method %s.%s%s\n", i, className->body().begin(), &byteArrayBody(t, pairFirst(t, nameAndType), 0), &byteArrayBody(t, pairSecond(t, nameAndType), 0)); } } } return 1; @@ -1027,9 +1027,9 @@ parsePoolEntry(Thread* t, Stream& s, uint32_t* index, GcSingleton* pool, unsigne if (DebugClassReader) { fprintf(stderr, " consts[%d] = method handle %d %s.%s%s\n", i, kind, - &byteArrayBody(t, referenceClass(t, value), 0), - &byteArrayBody(t, referenceName(t, value), 0), - &byteArrayBody(t, referenceSpec(t, value), 0)); + referenceClass(t, value)->body().begin(), + referenceName(t, value)->body().begin(), + referenceSpec(t, value)->body().begin()); } value = reinterpret_cast(makeReference @@ -1249,7 +1249,7 @@ parseInterfaceTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool, } for (unsigned i = 0; i < count; ++i) { - GcByteArray* name = cast(t, referenceName(t, singletonObject(t, pool, s.read2() - 1))); + GcByteArray* name = referenceName(t, singletonObject(t, pool, s.read2() - 1)); PROTECT(t, name); GcClass* interface = resolveClass @@ -2415,8 +2415,8 @@ parseAttributeTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool) object reference = reinterpret_cast(makeInnerClassReference (t, - cast(t, inner ? referenceName(t, singletonObject(t, pool, inner - 1)) : 0), - cast(t, outer ? referenceName(t, singletonObject(t, pool, outer - 1)) : 0), + inner ? referenceName(t, singletonObject(t, pool, inner - 1)) : 0, + outer ? referenceName(t, singletonObject(t, pool, outer - 1)) : 0, cast(t, name ? singletonObject(t, pool, name - 1) : 0), flags)); @@ -2444,7 +2444,7 @@ parseAttributeTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool) GcClassAddendum* addendum = getClassAddendum(t, class_, pool); - set(t, reinterpret_cast(addendum), ClassAddendumEnclosingClass, + set(t, addendum, ClassAddendumEnclosingClass, referenceName(t, singletonObject(t, pool, enclosingClass - 1))); set(t, reinterpret_cast(addendum), ClassAddendumEnclosingMethod, enclosingMethod @@ -4280,7 +4280,7 @@ parseClass(Thread* t, GcClassLoader* loader, const uint8_t* data, unsigned size, 0, // array element class 0, // runtime data index 0, // object mask - cast(t, referenceName(t, singletonObject(t, pool, name - 1))), + referenceName(t, singletonObject(t, pool, name - 1)), 0, // source file 0, // super 0, // interfaces @@ -4297,7 +4297,7 @@ parseClass(Thread* t, GcClassLoader* loader, const uint8_t* data, unsigned size, unsigned super = s.read2(); if (super) { GcClass* sc = resolveClass - (t, loader, cast(t, referenceName(t, singletonObject(t, pool, super - 1))), + (t, loader, referenceName(t, singletonObject(t, pool, super - 1)), true, throwType); set(t, reinterpret_cast(class_), ClassSuper, reinterpret_cast(sc)); diff --git a/src/types.def b/src/types.def index 588bdc857c..c90de9e5d8 100644 --- a/src/types.def +++ b/src/types.def @@ -73,13 +73,6 @@ (type lineNumberTable (array uint64_t body)) - -(type reference - (uint8_t kind) - (object class) - (object name) - (object spec)) - (type invocation (uint16_t bootstrap) (int32_t index) @@ -307,6 +300,12 @@ (extends jobject) (array int8_t body)) +(type reference + (uint8_t kind) + (byteArray class) + (byteArray name) + (byteArray spec)) + (type finder (void* finder) (byteArray name)