diff --git a/src/avian/classpath-common.h b/src/avian/classpath-common.h index e3f28605f1..0bb89ac715 100644 --- a/src/avian/classpath-common.h +++ b/src/avian/classpath-common.h @@ -343,7 +343,7 @@ translateInvokeResult(Thread* t, unsigned returnCode, object o) } GcClass* -resolveClassBySpec(Thread* t, object loader, const char* spec, +resolveClassBySpec(Thread* t, GcClassLoader* loader, const char* spec, unsigned specLength) { switch (*spec) { @@ -367,13 +367,13 @@ resolveClassBySpec(Thread* t, object loader, const char* spec, } GcJclass* -resolveJType(Thread* t, object loader, const char* spec, unsigned specLength) +resolveJType(Thread* t, GcClassLoader* loader, const char* spec, unsigned specLength) { return getJClass(t, resolveClassBySpec(t, loader, spec, specLength)); } object -resolveParameterTypes(Thread* t, object loader, object spec, +resolveParameterTypes(Thread* t, GcClassLoader* loader, GcByteArray* spec, unsigned* parameterCount, unsigned* returnTypeSpec) { PROTECT(t, loader); @@ -384,16 +384,16 @@ resolveParameterTypes(Thread* t, object loader, object spec, unsigned offset = 1; unsigned count = 0; - while (byteArrayBody(t, spec, offset) != ')') { - switch (byteArrayBody(t, spec, offset)) { + while (spec->body()[offset] != ')') { + switch (spec->body()[offset]) { case 'L': { unsigned start = offset; ++ offset; - while (byteArrayBody(t, spec, offset) != ';') ++ offset; + while (spec->body()[offset] != ';') ++ offset; ++ offset; GcClass* type = resolveClassBySpec - (t, loader, reinterpret_cast(&byteArrayBody(t, spec, start)), + (t, loader, reinterpret_cast(&spec->body()[start]), offset - start); list = reinterpret_cast(makePair(t, reinterpret_cast(type), list)); @@ -403,11 +403,11 @@ resolveParameterTypes(Thread* t, object loader, object spec, case '[': { unsigned start = offset; - while (byteArrayBody(t, spec, offset) == '[') ++ offset; - switch (byteArrayBody(t, spec, offset)) { + while (spec->body()[offset] == '[') ++ offset; + switch (spec->body()[offset]) { case 'L': ++ offset; - while (byteArrayBody(t, spec, offset) != ';') ++ offset; + while (spec->body()[offset] != ';') ++ offset; ++ offset; break; @@ -417,7 +417,7 @@ resolveParameterTypes(Thread* t, object loader, object spec, } GcClass* type = resolveClassBySpec - (t, loader, reinterpret_cast(&byteArrayBody(t, spec, start)), + (t, loader, reinterpret_cast(&spec->body()[start]), offset - start); list = reinterpret_cast(makePair(t, reinterpret_cast(type), list)); @@ -426,7 +426,7 @@ resolveParameterTypes(Thread* t, object loader, object spec, default: list = reinterpret_cast(makePair - (t, reinterpret_cast(primitiveClass(t, byteArrayBody(t, spec, offset))), list)); + (t, reinterpret_cast(primitiveClass(t, spec->body()[offset])), list)); ++ offset; ++ count; break; @@ -439,7 +439,7 @@ resolveParameterTypes(Thread* t, object loader, object spec, } object -resolveParameterJTypes(Thread* t, object loader, object spec, +resolveParameterJTypes(Thread* t, GcClassLoader* loader, GcByteArray* spec, unsigned* parameterCount, unsigned* returnTypeSpec) { object list = resolveParameterTypes @@ -461,9 +461,9 @@ resolveParameterJTypes(Thread* t, object loader, object spec, } object -resolveExceptionJTypes(Thread* t, object loader, object addendum) +resolveExceptionJTypes(Thread* t, GcClassLoader* loader, GcMethodAddendum* addendum) { - if (addendum == 0 or methodAddendumExceptionTable(t, addendum) == 0) { + if (addendum == 0 or addendum->exceptionTable() == 0) { return makeObjectArray(t, type(t, GcJclass::Type), 0); } @@ -472,21 +472,21 @@ resolveExceptionJTypes(Thread* t, object loader, object addendum) object array = makeObjectArray (t, type(t, GcJclass::Type), - shortArrayLength(t, methodAddendumExceptionTable(t, addendum))); + shortArrayLength(t, addendum->exceptionTable())); PROTECT(t, array); for (unsigned i = 0; i < shortArrayLength - (t, methodAddendumExceptionTable(t, addendum)); ++i) + (t, addendum->exceptionTable()); ++i) { uint16_t index = shortArrayBody - (t, methodAddendumExceptionTable(t, addendum), i) - 1; + (t, addendum->exceptionTable(), i) - 1; - object o = singletonObject(t, cast(t, addendumPool(t, addendum)), index); + object o = singletonObject(t, addendum->pool(), index); if (objectClass(t, o) == type(t, GcReference::Type)) { o = reinterpret_cast(resolveClass(t, loader, referenceName(t, o))); - set(t, addendumPool(t, addendum), SingletonBody + (index * BytesPerWord), + set(t, reinterpret_cast(addendum->pool()), SingletonBody + (index * BytesPerWord), o); } @@ -549,7 +549,7 @@ invoke(Thread* t, GcMethod* method, object instance, object args) memcpy(RUNTIME_ARRAY_BODY(name), p, nameLength - 1); RUNTIME_ARRAY_BODY(name)[nameLength - 1] = 0; type = resolveClass - (t, reinterpret_cast(method->class_()->loader()), + (t, method->class_()->loader(), RUNTIME_ARRAY_BODY(name)); } break; @@ -710,7 +710,7 @@ getDeclaredClasses(Thread* t, object c, bool publicOnly) t, resolveClass( t, - classLoader(t, c), + cast(t, classLoader(t, c)), innerClassReferenceInner(t, arrayBody(t, table, i))))); -- count; @@ -741,7 +741,7 @@ getDeclaringClass(Thread* t, object c) return getJClass( t, resolveClass(t, - classLoader(t, c), + cast(t, classLoader(t, c)), innerClassReferenceOuter(t, reference))); } } diff --git a/src/avian/machine.h b/src/avian/machine.h index 146a4caecf..fd0eeb2e87 100644 --- a/src/avian/machine.h +++ b/src/avian/machine.h @@ -2620,7 +2620,7 @@ scanMethodSpec(Thread* t, const char* s, bool static_, } GcClass* -findLoadedClass(Thread* t, object loader, object spec); +findLoadedClass(Thread* t, GcClassLoader* loader, object spec); inline bool emptyMethod(Thread* t UNUSED, GcMethod* method) @@ -2637,15 +2637,15 @@ object parseUtf8(Thread* t, object array); GcClass* -parseClass(Thread* t, object loader, const uint8_t* data, unsigned length, +parseClass(Thread* t, GcClassLoader* loader, const uint8_t* data, unsigned length, Gc::Type throwType = GcNoClassDefFoundError::Type); GcClass* -resolveClass(Thread* t, object loader, object name, bool throw_ = true, +resolveClass(Thread* t, GcClassLoader* loader, object name, bool throw_ = true, Gc::Type throwType = GcNoClassDefFoundError::Type); inline GcClass* -resolveClass(Thread* t, object loader, const char* name, bool throw_ = true, +resolveClass(Thread* t, GcClassLoader* loader, const char* name, bool throw_ = true, Gc::Type throwType = GcNoClassDefFoundError::Type) { PROTECT(t, loader); @@ -2655,24 +2655,24 @@ resolveClass(Thread* t, object loader, const char* name, bool throw_ = true, GcClass* resolveSystemClass -(Thread* t, object loader, object name, bool throw_ = true, +(Thread* t, GcClassLoader* loader, object name, bool throw_ = true, Gc::Type throwType = GcNoClassDefFoundError::Type); inline GcClass* -resolveSystemClass(Thread* t, object loader, const char* name) +resolveSystemClass(Thread* t, GcClassLoader* loader, const char* name) { return resolveSystemClass(t, loader, makeByteArray(t, "%s", name)); } void -linkClass(Thread* t, object loader, GcClass* class_); +linkClass(Thread* t, GcClassLoader* loader, GcClass* class_); GcMethod* resolveMethod(Thread* t, GcClass* class_, const char* methodName, const char* methodSpec); inline GcMethod* -resolveMethod(Thread* t, object loader, const char* className, +resolveMethod(Thread* t, GcClassLoader* loader, const char* className, const char* methodName, const char* methodSpec) { return resolveMethod @@ -2684,7 +2684,7 @@ resolveField(Thread* t, GcClass* class_, const char* fieldName, const char* fieldSpec); inline object -resolveField(Thread* t, object loader, const char* className, +resolveField(Thread* t, GcClassLoader* loader, const char* className, const char* fieldName, const char* fieldSpec) { return resolveField @@ -2704,7 +2704,7 @@ void initClass(Thread* t, GcClass* c); GcClass* -resolveObjectArrayClass(Thread* t, object loader, object elementClass); +resolveObjectArrayClass(Thread* t, GcClassLoader* loader, object elementClass); object makeObjectArray(Thread* t, GcClass* elementClass, unsigned count); @@ -3613,7 +3613,7 @@ poolSize(Thread* t, GcSingleton* pool) } inline GcClass* -resolveClassInObject(Thread* t, object loader, object container, +resolveClassInObject(Thread* t, GcClassLoader* loader, object container, unsigned classOffset, bool throw_ = true) { object o = fieldAtOffset(container, classOffset); @@ -3637,7 +3637,7 @@ resolveClassInObject(Thread* t, object loader, object container, } inline GcClass* -resolveClassInPool(Thread* t, object loader, GcMethod* method, unsigned index, +resolveClassInPool(Thread* t, GcClassLoader* loader, GcMethod* method, unsigned index, bool throw_ = true) { object o = singletonObject(t, method->code()->pool(), index); @@ -3664,12 +3664,12 @@ inline GcClass* resolveClassInPool(Thread* t, GcMethod* method, unsigned index, bool throw_ = true) { - return resolveClassInPool(t, reinterpret_cast(method->class_()->loader()), + return resolveClassInPool(t, method->class_()->loader(), method, index, throw_); } inline object -resolve(Thread* t, object loader, GcMethod* method, unsigned index, +resolve(Thread* t, GcClassLoader* loader, GcMethod* method, unsigned index, object (*find)(vm::Thread*, GcClass*, object, object), Gc::Type errorType, bool throw_ = true) { @@ -3705,7 +3705,7 @@ resolve(Thread* t, object loader, GcMethod* method, unsigned index, } inline object -resolveField(Thread* t, object loader, GcMethod* method, unsigned index, +resolveField(Thread* t, GcClassLoader* loader, GcMethod* method, unsigned index, bool throw_ = true) { return resolve(t, loader, method, index, findFieldInClass, @@ -3716,7 +3716,7 @@ inline object resolveField(Thread* t, GcMethod* method, unsigned index, bool throw_ = true) { return resolveField - (t, reinterpret_cast(method->class_()->loader()), method, index, throw_); + (t, method->class_()->loader(), method, index, throw_); } inline void @@ -3807,7 +3807,7 @@ class FieldWriteResource { }; inline GcMethod* -resolveMethod(Thread* t, object loader, GcMethod* method, unsigned index, +resolveMethod(Thread* t, GcClassLoader* loader, GcMethod* method, unsigned index, bool throw_ = true) { return cast(t, resolve(t, loader, method, index, findMethodInClass, @@ -3818,7 +3818,7 @@ inline GcMethod* resolveMethod(Thread* t, GcMethod* method, unsigned index, bool throw_ = true) { return resolveMethod - (t, reinterpret_cast(method->class_()->loader()), method, index, throw_); + (t, method->class_()->loader(), method, index, throw_); } GcVector* @@ -3969,7 +3969,7 @@ GcMethod* getCaller(Thread* t, unsigned target, bool skipMethodInvoke = false); object -defineClass(Thread* t, object loader, const uint8_t* buffer, unsigned length); +defineClass(Thread* t, GcClassLoader* loader, const uint8_t* buffer, unsigned length); inline GcMethod* methodClone(Thread* t, GcMethod* method) diff --git a/src/builtin.cpp b/src/builtin.cpp index e4bbbd6563..6c3be6af47 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -20,8 +20,8 @@ using namespace vm; namespace { int64_t -search(Thread* t, object loader, object name, - GcClass* (*op)(Thread*, object, object), bool replaceDots) +search(Thread* t, GcClassLoader* loader, object name, + GcClass* (*op)(Thread*, GcClassLoader*, object), bool replaceDots) { if (LIKELY(name)) { PROTECT(t, loader); @@ -42,7 +42,7 @@ search(Thread* t, object loader, object name, } GcClass* -resolveSystemClassThrow(Thread* t, object loader, object spec) +resolveSystemClassThrow(Thread* t, GcClassLoader* loader, object spec) { return resolveSystemClass (t, loader, spec, true, GcClassNotFoundException::Type); @@ -131,7 +131,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_avian_Classes_resolveVMClass (Thread* t, object, uintptr_t* arguments) { - object loader = reinterpret_cast(arguments[0]); + GcClassLoader* loader = cast(t, reinterpret_cast(arguments[0])); object spec = reinterpret_cast(arguments[1]); return reinterpret_cast @@ -142,7 +142,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_avian_Classes_defineVMClass (Thread* t, object, uintptr_t* arguments) { - object loader = reinterpret_cast(arguments[0]); + GcClassLoader* loader = cast(t, reinterpret_cast(arguments[0])); object b = reinterpret_cast(arguments[1]); int offset = arguments[2]; int length = arguments[3]; @@ -162,7 +162,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_avian_SystemClassLoader_findLoadedVMClass (Thread* t, object, uintptr_t* arguments) { - object loader = reinterpret_cast(arguments[0]); + GcClassLoader* loader = cast(t, reinterpret_cast(arguments[0])); object name = reinterpret_cast(arguments[1]); return search(t, loader, name, findLoadedClass, true); @@ -180,7 +180,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_avian_SystemClassLoader_findVMClass (Thread* t, object, uintptr_t* arguments) { - object loader = reinterpret_cast(arguments[0]); + GcClassLoader* loader = cast(t, reinterpret_cast(arguments[0])); object name = reinterpret_cast(arguments[1]); return search(t, loader, name, resolveSystemClassThrow, true); @@ -190,7 +190,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_avian_SystemClassLoader_resourceURLPrefix (Thread* t, object, uintptr_t* arguments) { - object loader = reinterpret_cast(arguments[0]); + GcClassLoader* loader = cast(t, reinterpret_cast(arguments[0])); object name = reinterpret_cast(arguments[1]); if (LIKELY(name)) { @@ -198,7 +198,7 @@ Avian_avian_SystemClassLoader_resourceURLPrefix stringChars(t, name, RUNTIME_ARRAY_BODY(n)); const char* name = static_cast - (systemClassLoaderFinder(t, loader))->urlPrefix(RUNTIME_ARRAY_BODY(n)); + (loader->as(t)->finder())->urlPrefix(RUNTIME_ARRAY_BODY(n)); return name ? reinterpret_cast(makeString(t, "%s", name)) : 0; } else { @@ -210,7 +210,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_avian_SystemClassLoader_00024ResourceEnumeration_nextResourceURLPrefix (Thread* t, object, uintptr_t* arguments) { - object loader = reinterpret_cast(arguments[1]); + GcClassLoader* loader = cast(t, reinterpret_cast(arguments[1])); object name = reinterpret_cast(arguments[2]); object finderElementPtrPtr = reinterpret_cast(arguments[3]); @@ -221,7 +221,7 @@ Avian_avian_SystemClassLoader_00024ResourceEnumeration_nextResourceURLPrefix void *&finderElementPtr = reinterpret_cast(longArrayBody(t, finderElementPtrPtr, 0)); const char* name = static_cast - (systemClassLoaderFinder(t, loader))->nextUrlPrefix(RUNTIME_ARRAY_BODY(n), + (loader->as(t)->finder())->nextUrlPrefix(RUNTIME_ARRAY_BODY(n), finderElementPtr); return name ? reinterpret_cast(makeString(t, "%s", name)) : 0; diff --git a/src/classpath-android.cpp b/src/classpath-android.cpp index e597ef70b6..371312d6f0 100644 --- a/src/classpath-android.cpp +++ b/src/classpath-android.cpp @@ -43,11 +43,11 @@ getDirectBufferAddress(Thread* t, object b) { PROTECT(t, b); - object field = resolveField - (t, objectClass(t, b), "effectiveDirectAddress", "J"); + GcField* field = cast(t, resolveField + (t, objectClass(t, b), "effectiveDirectAddress", "J")); return reinterpret_cast - (fieldAtOffset(b, fieldOffset(t, field))); + (fieldAtOffset(b, field->offset())); } void JNICALL @@ -111,35 +111,35 @@ makeMethodOrConstructor(Thread* t, GcJclass* c, unsigned index) { PROTECT(t, c); - object method = arrayBody - (t, classMethodTable(t, c->vmClass()), index); + GcMethod* method = cast(t, arrayBody + (t, classMethodTable(t, c->vmClass()), index)); PROTECT(t, method); unsigned parameterCount; unsigned returnTypeSpec; object parameterTypes = resolveParameterJTypes - (t, classLoader(t, methodClass(t, method)), methodSpec(t, method), + (t, method->class_()->loader(), method->spec(), ¶meterCount, &returnTypeSpec); PROTECT(t, parameterTypes); GcJclass* returnType = resolveJType - (t, classLoader(t, methodClass(t, method)), reinterpret_cast - (&byteArrayBody(t, methodSpec(t, method), returnTypeSpec)), - byteArrayLength(t, methodSpec(t, method)) - 1 - returnTypeSpec); + (t, method->class_()->loader(), reinterpret_cast + (&method->spec()->body()[returnTypeSpec]), + method->spec()->length() - 1 - returnTypeSpec); PROTECT(t, returnType); object exceptionTypes = resolveExceptionJTypes - (t, classLoader(t, methodClass(t, method)), methodAddendum(t, method)); + (t, method->class_()->loader(), method->addendum()); - if (byteArrayBody(t, methodName(t, method), 0) == '<') { + if (method->name()->body()[0] == '<') { return reinterpret_cast(makeJconstructor (t, 0, c, parameterTypes, exceptionTypes, 0, 0, 0, 0, index)); } else { PROTECT(t, exceptionTypes); GcString* name = cast(t, t->m->classpath->makeString - (t, methodName(t, method), 0, - byteArrayLength(t, methodName(t, method)) - 1)); + (t, reinterpret_cast(method->name()), 0, + method->name()->length() - 1)); return reinterpret_cast(makeJmethod (t, 0, index, c, name, parameterTypes, exceptionTypes, returnType, 0, 0, @@ -152,22 +152,22 @@ makeField(Thread* t, GcJclass* c, unsigned index) { PROTECT(t, c); - object field = arrayBody - (t, classFieldTable(t, c->vmClass()), index); + GcField* field = cast(t, arrayBody + (t, classFieldTable(t, c->vmClass()), index)); PROTECT(t, field); GcJclass* type = getJClass (t, resolveClassBySpec - (t, classLoader(t, fieldClass(t, field)), + (t, field->class_()->loader(), reinterpret_cast - (&byteArrayBody(t, fieldSpec(t, field), 0)), - byteArrayLength(t, fieldSpec(t, field)) - 1)); + (field->spec()->body().begin()), + field->spec()->length() - 1)); PROTECT(t, type); GcString* name = cast(t, t->m->classpath->makeString - (t, fieldName(t, field), 0, - byteArrayLength(t, fieldName(t, field)) - 1)); + (t, reinterpret_cast(field->name()), 0, + field->name()->length() - 1)); return reinterpret_cast(makeJfield(t, 0, c, type, 0, 0, name, index)); } @@ -178,7 +178,7 @@ void initVmThread(Thread* t, GcThread* thread, unsigned offset) if (fieldAtOffset(thread, offset) == 0) { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "java/lang/VMThread"); + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/VMThread"); PROTECT(t, c); object instance = makeNew(t, c); @@ -216,7 +216,7 @@ translateStackTrace(Thread* t, object raw) object array = makeObjectArray (t, resolveClass - (t, root(t, Machine::BootLoader), "java/lang/StackTraceElement"), + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/StackTraceElement"), objectArrayLength(t, raw)); PROTECT(t, array); @@ -279,7 +279,7 @@ class MyClasspath : public Classpath { group = threadGroup(t, parent->javaThread); } else { resolveSystemClass - (t, root(t, Machine::BootLoader), + (t, cast(t, root(t, Machine::BootLoader)), reinterpret_cast(type(t, GcThreadGroup::Type)->name()), false); group = makeNew(t, type(t, GcThreadGroup::Type)); @@ -291,7 +291,7 @@ class MyClasspath : public Classpath { } resolveSystemClass - (t, root(t, Machine::BootLoader), + (t, cast(t, root(t, Machine::BootLoader)), reinterpret_cast(type(t, GcThread::Type)->name()), false); GcThread* thread = cast(t, makeNew(t, type(t, GcThread::Type))); @@ -372,10 +372,10 @@ class MyClasspath : public Classpath { // later when we try to acquire it: objectMonitor(t, t->javaThread, true); - object field = resolveField( - t, objectClass(t, t->javaThread), "vmThread", "Ljava/lang/VMThread;"); + GcField* field = cast(t, resolveField( + t, objectClass(t, t->javaThread), "vmThread", "Ljava/lang/VMThread;")); - unsigned offset = fieldOffset(t, field); + unsigned offset = field->offset(); THREAD_RESOURCE(t, unsigned, offset, { object vmt = fieldAtOffset(t->javaThread, offset); @@ -396,7 +396,7 @@ class MyClasspath : public Classpath { initVmThread(t, cast(t, t->javaThread), offset); GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "java/lang/Thread", "run", "()V"); + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/Thread", "run", "()V"); t->m->processor->invoke(t, method, t->javaThread); } @@ -411,7 +411,7 @@ class MyClasspath : public Classpath { interceptMethods(Thread* t, bool updateRuntimeData) { { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "java/lang/Runtime", false); + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/Runtime", false); if (c) { PROTECT(t, c); @@ -423,7 +423,7 @@ class MyClasspath : public Classpath { } { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "java/lang/ref/FinalizerReference", + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/ref/FinalizerReference", false); if (c) { @@ -435,7 +435,7 @@ class MyClasspath : public Classpath { } { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "java/lang/ClassLoader", false); + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/ClassLoader", false); if (c) { PROTECT(t, c); @@ -450,7 +450,7 @@ class MyClasspath : public Classpath { } { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "libcore/util/ZoneInfoDB", false); + (t, cast(t, root(t, Machine::BootLoader)), "libcore/util/ZoneInfoDB", false); if (c) { PROTECT(t, c); @@ -461,7 +461,7 @@ class MyClasspath : public Classpath { } { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "libcore/io/MemoryMappedFile", + (t, cast(t, root(t, Machine::BootLoader)), "libcore/io/MemoryMappedFile", false); if (c) { @@ -508,7 +508,7 @@ class MyClasspath : public Classpath { boot(Thread* t) { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "java/lang/ClassLoader"); + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/ClassLoader"); PROTECT(t, c); GcMethod* constructor = resolveMethod @@ -533,7 +533,7 @@ class MyClasspath : public Classpath { makeDirectByteBuffer(Thread* t, void* p, jlong capacity) { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "java/nio/DirectByteBuffer"); + (t, cast(t, root(t, Machine::BootLoader)), "java/nio/DirectByteBuffer"); PROTECT(t, c); object instance = makeNew(t, c); @@ -559,10 +559,10 @@ class MyClasspath : public Classpath { { PROTECT(t, b); - object field = resolveField - (t, objectClass(t, b), "capacity", "I"); + GcField* field = cast(t, resolveField + (t, objectClass(t, b), "capacity", "I")); - return fieldAtOffset(b, fieldOffset(t, field)); + return fieldAtOffset(b, field->offset()); } virtual bool @@ -606,7 +606,7 @@ int64_t JNICALL mapData(Thread* t, object, uintptr_t*) { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "libcore/io/MemoryMappedFile"); + (t, cast(t, root(t, Machine::BootLoader)), "libcore/io/MemoryMappedFile"); PROTECT(t, c); object instance = makeNew(t, c); @@ -645,15 +645,15 @@ closeMemoryMappedFile(Thread* t, GcMethod* method, uintptr_t* arguments) MyClasspath* cp = static_cast(t->m->classpath); if (cp->tzdata) { - object field = resolveField(t, objectClass(t, file), "address", "J"); + GcField* field = cast(t, resolveField(t, objectClass(t, file), "address", "J")); - if (fieldAtOffset(file, fieldOffset(t, field)) + if (fieldAtOffset(file, field->offset()) == reinterpret_cast(cp->tzdata->start())) { cp->tzdata->dispose(); cp->tzdata = 0; - fieldAtOffset(file, fieldOffset(t, field)) = 0; + fieldAtOffset(file, field->offset()) = 0; return; } } @@ -665,9 +665,9 @@ closeMemoryMappedFile(Thread* t, GcMethod* method, uintptr_t* arguments) } bool -matchType(Thread* t, object field, object o) +matchType(Thread* t, GcField* field, object o) { - switch (fieldCode(t, field)) { + switch (field->code()) { case ByteField: return objectClass(t, o) == type(t, GcByte::Type); @@ -698,22 +698,21 @@ matchType(Thread* t, object field, object o) } else { PROTECT(t, o); - object spec; - if (byteArrayBody(t, fieldSpec(t, field), 0) == '[') { - spec = fieldSpec(t, field);; + GcByteArray* spec; + if (field->spec()->body()[0] == '[') { + spec = field->spec(); } else { - spec = reinterpret_cast(makeByteArray(t, byteArrayLength(t, fieldSpec(t, field)) - 2)); + spec = makeByteArray(t, field->spec()->length() - 2); - memcpy(&byteArrayBody(t, spec, 0), - &byteArrayBody(t, fieldSpec(t, field), 1), - byteArrayLength(t, fieldSpec(t, field)) - 3); + memcpy(spec->body().begin(), + &field->spec()->body()[1], + field->spec()->length() - 3); - byteArrayBody - (t, spec, byteArrayLength(t, fieldSpec(t, field)) - 3) = 0; + spec->body()[field->spec()->length() - 3] = 0; } return instanceOf - (t, resolveClass(t, classLoader(t, fieldClass(t, field)), spec), o); + (t, resolveClass(t, field->class_()->loader(), reinterpret_cast(spec)), o); } default: abort(t); @@ -721,24 +720,24 @@ matchType(Thread* t, object field, object o) } object -getField(Thread* t, object field, object instance) +getField(Thread* t, GcField* field, object instance) { PROTECT(t, field); PROTECT(t, instance); - initClass(t, cast(t, fieldClass(t, field))); + initClass(t, field->class_()); object target; - if (fieldFlags(t, field) & ACC_STATIC) { - target = classStaticTable(t, fieldClass(t, field)); - } else if (instanceOf(t, cast(t, fieldClass(t, field)), instance)){ + if (field->flags() & ACC_STATIC) { + target = reinterpret_cast(field->class_()->staticTable()); + } else if (instanceOf(t, field->class_(), instance)){ target = instance; } else { throwNew(t, GcIllegalArgumentException::Type); } - unsigned offset = fieldOffset(t, field); - switch (fieldCode(t, field)) { + unsigned offset = field->offset(); + switch (field->code()) { case ByteField: return reinterpret_cast(makeByte(t, fieldAtOffset(target, offset))); @@ -771,7 +770,7 @@ getField(Thread* t, object field, object instance) } void -setField(Thread* t, object field, object instance, object value) +setField(Thread* t, GcField* field, object instance, object value) { PROTECT(t, field); PROTECT(t, instance); @@ -782,19 +781,19 @@ setField(Thread* t, object field, object instance, object value) } object target; - if ((fieldFlags(t, field) & ACC_STATIC) != 0) { - target = classStaticTable(t, fieldClass(t, field)); - } else if (instanceOf(t, cast(t, fieldClass(t, field)), instance)){ + if ((field->flags() & ACC_STATIC) != 0) { + target = reinterpret_cast(field->class_()->staticTable()); + } else if (instanceOf(t, field->class_(), instance)){ target = instance; } else { throwNew(t, GcIllegalArgumentException::Type); } PROTECT(t, target); - initClass(t, cast(t, fieldClass(t, field))); + initClass(t, field->class_()); - unsigned offset = fieldOffset(t, field); - switch (fieldCode(t, field)) { + unsigned offset = field->offset(); + switch (field->code()) { case ByteField: fieldAtOffset(target, offset) = byteValue(t, value); break; @@ -1220,11 +1219,11 @@ Avian_java_lang_Class_classForName object name = reinterpret_cast(arguments[0]); PROTECT(t, name); - object loader = reinterpret_cast(arguments[2]); + GcClassLoader* loader = cast(t, reinterpret_cast(arguments[2])); PROTECT(t, loader); GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Classes", "forName", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;"); return reinterpret_cast @@ -1243,7 +1242,7 @@ Avian_java_lang_Class_getDeclaredField PROTECT(t, name); GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Classes", "findField", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "findField", "(Lavian/VMClass;Ljava/lang/String;)I"); int index = intValue @@ -1271,7 +1270,7 @@ Avian_java_lang_Class_getDeclaredConstructorOrMethod PROTECT(t, parameterTypes); GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Classes", "findMethod", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "findMethod", "(Lavian/VMClass;Ljava/lang/String;[Ljava/lang/Class;)I"); int index = intValue @@ -1420,12 +1419,12 @@ Avian_java_lang_VMThread_interrupt object vmThread = reinterpret_cast(arguments[0]); PROTECT(t, vmThread); - object field = resolveField - (t, objectClass(t, vmThread), "thread", "Ljava/lang/Thread;"); + GcField* field = cast(t, resolveField + (t, objectClass(t, vmThread), "thread", "Ljava/lang/Thread;")); interrupt (t, reinterpret_cast - (threadPeer(t, fieldAtOffset(vmThread, fieldOffset(t, field))))); + (threadPeer(t, fieldAtOffset(vmThread, field->offset())))); } extern "C" AVIAN_EXPORT int64_t JNICALL @@ -1442,11 +1441,11 @@ Avian_java_lang_VMThread_isInterrupted object vmThread = reinterpret_cast(arguments[0]); PROTECT(t, vmThread); - object field = resolveField - (t, objectClass(t, vmThread), "thread", "Ljava/lang/Thread;"); + GcField* field = cast(t, resolveField + (t, objectClass(t, vmThread), "thread", "Ljava/lang/Thread;")); return threadInterrupted - (t, fieldAtOffset(vmThread, fieldOffset(t, field))); + (t, fieldAtOffset(vmThread, field->offset())); } extern "C" AVIAN_EXPORT int64_t JNICALL @@ -1835,7 +1834,7 @@ Avian_java_lang_Class_getDeclaredMethods bool publicOnly = arguments[1]; GcMethod* get = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Classes", "getMethods", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "getMethods", "(Lavian/VMClass;Z)[Ljava/lang/reflect/Method;"); return reinterpret_cast @@ -1852,7 +1851,7 @@ Avian_java_lang_Class_getDeclaredFields bool publicOnly = arguments[1]; GcMethod* get = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Classes", "getFields", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "getFields", "(Lavian/VMClass;Z)[Ljava/lang/reflect/Field;"); return reinterpret_cast @@ -1931,7 +1930,7 @@ Avian_java_lang_reflect_Method_getAnnotation PROTECT(t, table); GcMethod* get = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Classes", "getAnnotation", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "getAnnotation", "(Ljava/lang/ClassLoader;[Ljava/lang/Object;)" "Ljava/lang/annotation/Annotation;"); @@ -1965,12 +1964,12 @@ Avian_java_lang_reflect_Method_getDeclaredAnnotations object array = makeObjectArray (t, resolveClass - (t, root(t, Machine::BootLoader), "java/lang/annotation/Annotation"), + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/annotation/Annotation"), objectArrayLength(t, table)); PROTECT(t, array); GcMethod* get = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Classes", "getAnnotation", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "getAnnotation", "(Ljava/lang/ClassLoader;[Ljava/lang/Object;)" "Ljava/lang/annotation/Annotation;"); PROTECT(t, get); @@ -1990,7 +1989,7 @@ Avian_java_lang_reflect_Method_getDeclaredAnnotations return reinterpret_cast (makeObjectArray (t, resolveClass - (t, root(t, Machine::BootLoader), "java/lang/annotation/Annotation"), + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/annotation/Annotation"), 0)); } @@ -1999,13 +1998,13 @@ extern "C" AVIAN_EXPORT int64_t JNICALL object, uintptr_t* arguments) { - object field = arrayBody( + GcField* field = cast(t, arrayBody( t, classFieldTable( t, jclassVmClass(t, reinterpret_cast(arguments[0]))), - arguments[1]); + arguments[1])); - object addendum = fieldAddendum(t, field); + object addendum = reinterpret_cast(field->addendum()); if (addendum) { object table = addendumAnnotationTable(t, addendum); if (table) { @@ -2015,13 +2014,13 @@ extern "C" AVIAN_EXPORT int64_t JNICALL object array = makeObjectArray(t, resolveClass(t, - root(t, Machine::BootLoader), + cast(t, root(t, Machine::BootLoader)), "java/lang/annotation/Annotation"), objectArrayLength(t, table)); PROTECT(t, array); GcMethod* get = resolveMethod(t, - root(t, Machine::BootLoader), + cast(t, root(t, Machine::BootLoader)), "avian/Classes", "getAnnotation", "(Ljava/lang/ClassLoader;[Ljava/lang/Object;)" @@ -2046,7 +2045,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL return reinterpret_cast(makeObjectArray( t, resolveClass( - t, root(t, Machine::BootLoader), "java/lang/annotation/Annotation"), + t, cast(t, root(t, Machine::BootLoader)), "java/lang/annotation/Annotation"), 0)); } @@ -2062,7 +2061,7 @@ Avian_java_lang_reflect_Method_getDefaultValue object addendum = methodAddendum(t, method); if (addendum) { GcMethod* get = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Classes", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "getAnnotationDefaultValue", "(Ljava/lang/ClassLoader;Lavian/MethodAddendum;)" "Ljava/lang/Object;"); @@ -2102,10 +2101,10 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Field_getField (Thread* t, object, uintptr_t* arguments) { - object field = arrayBody + GcField* field = cast(t, arrayBody (t, classFieldTable (t, jclassVmClass(t, reinterpret_cast(arguments[2]))), - arguments[4]); + arguments[4])); PROTECT(t, field); @@ -2119,10 +2118,10 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Field_getIField (Thread* t, object, uintptr_t* arguments) { - object field = arrayBody + GcField* field = cast(t, arrayBody (t, classFieldTable (t, jclassVmClass(t, reinterpret_cast(arguments[2]))), - arguments[4]); + arguments[4])); PROTECT(t, field); @@ -2136,10 +2135,10 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Field_getJField (Thread* t, object, uintptr_t* arguments) { - object field = arrayBody + GcField* field = cast(t, arrayBody (t, classFieldTable (t, jclassVmClass(t, reinterpret_cast(arguments[2]))), - arguments[4]); + arguments[4])); PROTECT(t, field); @@ -2153,10 +2152,10 @@ extern "C" AVIAN_EXPORT void JNICALL Avian_java_lang_reflect_Field_setField (Thread* t, object, uintptr_t* arguments) { - object field = arrayBody + GcField* field = cast(t, arrayBody (t, classFieldTable (t, jclassVmClass(t, reinterpret_cast(arguments[2]))), - arguments[4]); + arguments[4])); PROTECT(t, field); @@ -2173,10 +2172,10 @@ extern "C" AVIAN_EXPORT void JNICALL Avian_java_lang_reflect_Field_setIField (Thread* t, object, uintptr_t* arguments) { - object field = arrayBody + GcField* field = cast(t, arrayBody (t, classFieldTable (t, jclassVmClass(t, reinterpret_cast(arguments[2]))), - arguments[4]); + arguments[4])); object instance = reinterpret_cast(arguments[1]); PROTECT(t, instance); @@ -2201,12 +2200,12 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Field_getAnnotation (Thread* t, object, uintptr_t* arguments) { - object field = arrayBody + GcField* field = cast(t, arrayBody (t, classFieldTable (t, jclassVmClass(t, reinterpret_cast(arguments[0]))), - arguments[1]); + arguments[1])); - object addendum = fieldAddendum(t, field); + object addendum = reinterpret_cast(field->addendum()); if (addendum) { object table = addendumAnnotationTable(t, addendum); if (table) { @@ -2218,13 +2217,13 @@ Avian_java_lang_reflect_Field_getAnnotation PROTECT(t, table); GcMethod* get = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Classes", "getAnnotation", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "getAnnotation", "(Ljava/lang/ClassLoader;[Ljava/lang/Object;)" "Ljava/lang/annotation/Annotation;"); return reinterpret_cast (t->m->processor->invoke - (t, get, 0, classLoader(t, fieldClass(t, field)), + (t, get, 0, field->class_()->loader(), objectArrayBody(t, table, i))); } } @@ -2238,12 +2237,12 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Field_getSignatureAnnotation (Thread* t, object, uintptr_t* arguments) { - object field = arrayBody + GcField* field = cast(t, arrayBody (t, classFieldTable (t, jclassVmClass(t, reinterpret_cast(arguments[1]))), - arguments[2]); + arguments[2])); - object addendum = fieldAddendum(t, field); + object addendum = reinterpret_cast(field->addendum()); if (addendum) { object signature = addendumSignature(t, addendum); if (signature) { @@ -2460,14 +2459,14 @@ Avian_libcore_io_OsConstants_initConstants object table = classStaticTable(t, c); PROTECT(t, table); - object field = resolveField(t, c, "STDIN_FILENO", "I"); - fieldAtOffset(table, fieldOffset(t, field)) = 0; + GcField* field = cast(t, resolveField(t, c, "STDIN_FILENO", "I"); + fieldAtOffset(table, field->offset()) = 0; field = resolveField(t, c, "STDOUT_FILENO", "I"); - fieldAtOffset(table, fieldOffset(t, field)) = 1; + fieldAtOffset(table, field->offset()) = 1; field = resolveField(t, c, "STDERR_FILENO", "I"); - fieldAtOffset(table, fieldOffset(t, field)) = 2; + fieldAtOffset(table, field->offset()) = 2; } extern "C" AVIAN_EXPORT int64_t JNICALL diff --git a/src/classpath-avian.cpp b/src/classpath-avian.cpp index 16e6574801..8706deb578 100644 --- a/src/classpath-avian.cpp +++ b/src/classpath-avian.cpp @@ -97,7 +97,7 @@ class MyClasspath : public Classpath { runThread(Thread* t) { GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "java/lang/Thread", "run", + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/Thread", "run", "(Ljava/lang/Thread;)V"); t->m->processor->invoke(t, method, 0, t->javaThread); @@ -142,7 +142,7 @@ class MyClasspath : public Classpath { makeDirectByteBuffer(Thread* t, void* p, jlong capacity) { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "java/nio/DirectByteBuffer"); + (t, cast(t, root(t, Machine::BootLoader)), "java/nio/DirectByteBuffer"); PROTECT(t, c); object instance = makeNew(t, c); @@ -793,7 +793,7 @@ Avian_avian_Classes_makeMethod PROTECT(t, method); GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "java/lang/reflect/Method"); + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/reflect/Method"); PROTECT(t, c); object instance = makeNew(t, c); @@ -807,7 +807,7 @@ Avian_avian_Classes_makeMethod method = instance; c = resolveClass - (t, root(t, Machine::BootLoader), "java/lang/reflect/Constructor"); + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/reflect/Constructor"); object instance = makeNew(t, c); diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 26f5ff4e24..64ab3a3945 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -345,10 +345,10 @@ makeClassNameString(Thread* t, object name) } object -makeJmethod(Thread* t, object vmMethod, int index = -1); +makeJmethod(Thread* t, GcMethod* vmMethod, int index = -1); object -makeJconstructor(Thread* t, object vmMethod, int index = -1); +makeJconstructor(Thread* t, GcMethod* vmMethod, int index = -1); object makeJfield(Thread* t, object vmField, int index = -1); @@ -580,8 +580,8 @@ class MyClasspath : public Classpath { PROTECT(t, vmMethod); return vmMethod->name()->body()[0] == '<' - ? reinterpret_cast(makeJconstructor(t, reinterpret_cast(vmMethod))) - : reinterpret_cast(makeJmethod(t, reinterpret_cast(vmMethod))); + ? reinterpret_cast(makeJconstructor(t, vmMethod)) + : reinterpret_cast(makeJmethod(t, vmMethod)); } virtual object @@ -644,7 +644,7 @@ class MyClasspath : public Classpath { }); GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "java/lang/Thread", "run", "()V"); + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/Thread", "run", "()V"); t->m->processor->invoke(t, method, t->javaThread); } @@ -691,11 +691,11 @@ class MyClasspath : public Classpath { { globalMachine = t->m; - resolveSystemClass(t, root(t, Machine::BootLoader), + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), reinterpret_cast(type(t, GcClassLoader::Type)->name())); setRoot(t, Machine::ThreadTerminated, reinterpret_cast(resolveMethod - (t, root(t, Machine::BootLoader), "java/lang/ThreadGroup", + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/ThreadGroup", "threadTerminated", "(Ljava/lang/Thread;)V"))); #ifdef AVIAN_OPENJDK_SRC @@ -709,12 +709,12 @@ class MyClasspath : public Classpath { (t, type(t, GcClassLoader::Type), "assertionLock", "Ljava/lang/Object;"); - set(t, root(t, Machine::BootLoader), fieldOffset(t, assertionLock), - root(t, Machine::BootLoader)); + set(t, cast(t, root(t, Machine::BootLoader)), fieldOffset(t, assertionLock), + cast(t, root(t, Machine::BootLoader))); } { GcClass* class_ = resolveClass - (t, root(t, Machine::BootLoader), "java/util/Properties", true, + (t, cast(t, root(t, Machine::BootLoader)), "java/util/Properties", true, GcNoClassDefFoundError::Type); PROTECT(t, class_); @@ -742,7 +742,7 @@ class MyClasspath : public Classpath { t->m->processor->invoke (t, constructor, root(t, Machine::AppLoader), - root(t, Machine::BootLoader)); + cast(t, root(t, Machine::BootLoader))); } { object scl = resolveField @@ -783,7 +783,7 @@ class MyClasspath : public Classpath { makeDirectByteBuffer(Thread* t, void* p, jlong capacity) { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "java/nio/DirectByteBuffer"); + (t, cast(t, root(t, Machine::BootLoader)), "java/nio/DirectByteBuffer"); PROTECT(t, c); object instance = makeNew(t, c); @@ -872,7 +872,7 @@ class MyClasspath : public Classpath { shutDown(Thread* t) { GcClass* c = resolveClass - (t, root(t, Machine::BootLoader), "java/lang/Shutdown", false); + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/Shutdown", false); if (c) { GcMethod* m = findMethodOrNull(t, c, "shutdown", "()V"); @@ -1836,7 +1836,7 @@ getBootstrapResource(Thread* t, object, uintptr_t* arguments) if (m) { return reinterpret_cast - (t->m->processor->invoke(t, m, root(t, Machine::BootLoader), name)); + (t->m->processor->invoke(t, m, cast(t, root(t, Machine::BootLoader)), name)); } else { return 0; } @@ -1854,7 +1854,7 @@ getBootstrapResources(Thread* t, object, uintptr_t* arguments) if (m) { return reinterpret_cast - (t->m->processor->invoke(t, m, root(t, Machine::BootLoader), name)); + (t->m->processor->invoke(t, m, cast(t, root(t, Machine::BootLoader)), name)); } else { return 0; } @@ -1932,7 +1932,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData) MyClasspath* cp = static_cast(t->m->classpath); { object fileClass = resolveClass - (t, root(t, Machine::BootLoader), "java/io/File", false); + (t, cast(t, root(t, Machine::BootLoader)), "java/io/File", false); if (fileClass) { object filePathField = findFieldInClass2 @@ -1945,7 +1945,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData) } { object fileDescriptorClass = resolveClass - (t, root(t, Machine::BootLoader), "java/io/FileDescriptor", false); + (t, cast(t, root(t, Machine::BootLoader)), "java/io/FileDescriptor", false); if (fileDescriptorClass) { object fileDescriptorFdField = findFieldInClass2 @@ -1958,7 +1958,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData) } { object fileInputStreamClass = resolveClass - (t, root(t, Machine::BootLoader), "java/io/FileInputStream", false); + (t, cast(t, root(t, Machine::BootLoader)), "java/io/FileInputStream", false); if (fileInputStreamClass) { PROTECT(t, fileInputStreamClass); @@ -1996,7 +1996,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData) } { object zipFileClass = resolveClass - (t, root(t, Machine::BootLoader), "java/util/zip/ZipFile", false); + (t, cast(t, root(t, Machine::BootLoader)), "java/util/zip/ZipFile", false); if (zipFileClass) { PROTECT(t, zipFileClass); @@ -2049,7 +2049,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData) } { object jarFileClass = resolveClass - (t, root(t, Machine::BootLoader), "java/util/jar/JarFile", false); + (t, cast(t, root(t, Machine::BootLoader)), "java/util/jar/JarFile", false); if (jarFileClass) { intercept(t, jarFileClass, "getMetaInfEntryNames", @@ -2068,7 +2068,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData) #endif object fsClass = resolveClass - (t, root(t, Machine::BootLoader), fsClassName, false); + (t, cast(t, root(t, Machine::BootLoader)), fsClassName, false); if (fsClass) { PROTECT(t, fsClass); @@ -2118,9 +2118,9 @@ countMethods(Thread* t, object c, bool publicOnly) object table = classMethodTable(t, c); unsigned count = 0; for (unsigned i = 0, j = classDeclaredMethodCount(t, c); i < j; ++i) { - object vmMethod = arrayBody(t, table, i); - if (((not publicOnly) or (methodFlags(t, vmMethod) & ACC_PUBLIC)) - and byteArrayBody(t, methodName(t, vmMethod), 0) != '<') + GcMethod* vmMethod = cast(t, arrayBody(t, table, i)); + if (((not publicOnly) or (vmMethod->flags() & ACC_PUBLIC)) + and vmMethod->name()->body()[0] != '<') { ++ count; } @@ -2152,10 +2152,10 @@ countConstructors(Thread* t, object c, bool publicOnly) object table = classMethodTable(t, c); unsigned count = 0; for (unsigned i = 0, j = classDeclaredMethodCount(t, c); i < j; ++i) { - object vmMethod = arrayBody(t, table, i); - if (((not publicOnly) or (methodFlags(t, vmMethod) & ACC_PUBLIC)) + GcMethod* vmMethod = cast(t, arrayBody(t, table, i)); + if (((not publicOnly) or (vmMethod->flags() & ACC_PUBLIC)) and strcmp(reinterpret_cast - (&byteArrayBody(t, methodName(t, vmMethod), 0)), + (vmMethod->name()->body().begin()), "") == 0) { ++ count; @@ -2217,39 +2217,38 @@ makeJconstructor(Thread* t, #endif // HAVE_JexecutableHasRealParameterData object -makeJmethod(Thread* t, object vmMethod, int index) +makeJmethod(Thread* t, GcMethod* vmMethod, int index) { PROTECT(t, vmMethod); object name = intern (t, t->m->classpath->makeString - (t, methodName(t, vmMethod), 0, byteArrayLength - (t, methodName(t, vmMethod)) - 1)); + (t, reinterpret_cast(vmMethod->name()), 0, vmMethod->name()->length() - 1)); PROTECT(t, name); unsigned parameterCount; unsigned returnTypeSpec; object parameterTypes = resolveParameterJTypes - (t, classLoader(t, methodClass(t, vmMethod)), methodSpec(t, vmMethod), + (t, vmMethod->class_()->loader(), vmMethod->spec(), ¶meterCount, &returnTypeSpec); PROTECT(t, parameterTypes); GcJclass* returnType = resolveJType - (t, classLoader(t, methodClass(t, vmMethod)), reinterpret_cast - (&byteArrayBody(t, methodSpec(t, vmMethod), returnTypeSpec)), - byteArrayLength(t, methodSpec(t, vmMethod)) - 1 - returnTypeSpec); + (t, vmMethod->class_()->loader(), reinterpret_cast + (&vmMethod->spec()->body()[returnTypeSpec]), + vmMethod->spec()->length() - 1 - returnTypeSpec); PROTECT(t, returnType); object exceptionTypes = resolveExceptionJTypes - (t, classLoader(t, methodClass(t, vmMethod)), - methodAddendum(t, vmMethod)); + (t, vmMethod->class_()->loader(), + vmMethod->addendum()); PROTECT(t, exceptionTypes); object signature; object annotationTable; object parameterAnnotationTable; object annotationDefault; - object addendum = methodAddendum(t, vmMethod); + object addendum = reinterpret_cast(vmMethod->addendum()); if (addendum) { signature = addendumSignature(t, addendum); if (signature) { @@ -2278,16 +2277,16 @@ makeJmethod(Thread* t, object vmMethod, int index) PROTECT(t, annotationDefault); if (annotationTable or parameterAnnotationTable or annotationDefault) { - object runtimeData = getClassRuntimeData(t, cast(t, methodClass(t, vmMethod))); + object runtimeData = getClassRuntimeData(t, vmMethod->class_()); set(t, runtimeData, ClassRuntimeDataPool, - addendumPool(t, methodAddendum(t, vmMethod))); + reinterpret_cast(vmMethod->addendum()->pool())); } if (index == -1) { - object table = classMethodTable(t, methodClass(t, vmMethod)); + object table = vmMethod->class_()->methodTable(); for (unsigned i = 0; i < arrayLength(t, table); ++i) { - if (vmMethod == arrayBody(t, table, i)) { + if (reinterpret_cast(vmMethod) == arrayBody(t, table, i)) { index = i; break; } @@ -2296,35 +2295,35 @@ makeJmethod(Thread* t, object vmMethod, int index) expect(t, index != -1); - GcJclass* jclass = getJClass(t, cast(t, methodClass(t, vmMethod))); + GcJclass* jclass = getJClass(t, vmMethod->class_()); return reinterpret_cast(makeJmethod (t, true, 0, jclass, index, cast(t, name), returnType, parameterTypes, - exceptionTypes, methodFlags(t, vmMethod), cast(t, signature), 0, cast(t, annotationTable), + exceptionTypes, vmMethod->flags(), cast(t, signature), 0, cast(t, annotationTable), cast(t, parameterAnnotationTable), cast(t, annotationDefault), 0, 0, 0)); } object -makeJconstructor(Thread* t, object vmMethod, int index) +makeJconstructor(Thread* t, GcMethod* vmMethod, int index) { PROTECT(t, vmMethod); unsigned parameterCount; unsigned returnTypeSpec; object parameterTypes = resolveParameterJTypes - (t, classLoader(t, methodClass(t, vmMethod)), methodSpec(t, vmMethod), + (t, vmMethod->class_()->loader(), vmMethod->spec(), ¶meterCount, &returnTypeSpec); PROTECT(t, parameterTypes); object exceptionTypes = resolveExceptionJTypes - (t, classLoader(t, methodClass(t, vmMethod)), - methodAddendum(t, vmMethod)); + (t, vmMethod->class_()->loader(), + vmMethod->addendum()); PROTECT(t, exceptionTypes); object signature; object annotationTable; object parameterAnnotationTable; - object addendum = methodAddendum(t, vmMethod); + object addendum = reinterpret_cast(vmMethod->addendum()); if (addendum) { signature = addendumSignature(t, addendum); if (signature) { @@ -2348,16 +2347,16 @@ makeJconstructor(Thread* t, object vmMethod, int index) PROTECT(t, parameterAnnotationTable); if (annotationTable or parameterAnnotationTable) { - object runtimeData = getClassRuntimeData(t, cast(t, methodClass(t, vmMethod))); + object runtimeData = getClassRuntimeData(t, vmMethod->class_()); set(t, runtimeData, ClassRuntimeDataPool, - addendumPool(t, methodAddendum(t, vmMethod))); + reinterpret_cast(vmMethod->addendum()->pool())); } if (index == -1) { - object table = classMethodTable(t, methodClass(t, vmMethod)); + object table = vmMethod->class_()->methodTable(); for (unsigned i = 0; i < arrayLength(t, table); ++i) { - if (vmMethod == arrayBody(t, table, i)) { + if (reinterpret_cast(vmMethod) == arrayBody(t, table, i)) { index = i; break; } @@ -2366,12 +2365,24 @@ makeJconstructor(Thread* t, object vmMethod, int index) expect(t, index != -1); - GcJclass* jclass = getJClass(t, cast(t, methodClass(t, vmMethod))); + GcJclass* jclass = getJClass(t, vmMethod->class_()); - return reinterpret_cast(makeJconstructor - (t, true, 0, jclass, index, parameterTypes, exceptionTypes, methodFlags - (t, vmMethod), cast(t, signature), 0, cast(t, annotationTable), cast(t, parameterAnnotationTable), - 0, 0, 0)); + return reinterpret_cast( + makeJconstructor(t, + true, + 0, + jclass, + index, + parameterTypes, + exceptionTypes, + vmMethod->flags(), + cast(t, signature), + 0, + cast(t, annotationTable), + cast(t, parameterAnnotationTable), + 0, + 0, + 0)); } object @@ -2386,7 +2397,7 @@ makeJfield(Thread* t, object vmField, int index) PROTECT(t, name); GcClass* type = resolveClassBySpec - (t, classLoader(t, fieldClass(t, vmField)), + (t, cast(t, classLoader(t, fieldClass(t, vmField))), reinterpret_cast (&byteArrayBody(t, fieldSpec(t, vmField), 0)), byteArrayLength(t, fieldSpec(t, vmField)) - 1); @@ -2531,7 +2542,7 @@ Avian_sun_misc_Perf_createLong return reinterpret_cast (t->m->processor->invoke (t, resolveMethod - (t, root(t, Machine::BootLoader), "java/nio/ByteBuffer", "allocate", + (t, cast(t, root(t, Machine::BootLoader)), "java/nio/ByteBuffer", "allocate", "(I)Ljava/nio/ByteBuffer;"), 0, 8)); } @@ -2550,7 +2561,7 @@ Avian_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoade object data = reinterpret_cast(arguments[2]); int32_t offset = arguments[3]; int32_t length = arguments[4]; - object loader = reinterpret_cast(arguments[5]); + GcClassLoader* loader = cast(t, reinterpret_cast(arguments[5])); //object domain = reinterpret_cast(arguments[6]); uint8_t* buffer = static_cast(t->m->heap->allocate(length)); @@ -2941,7 +2952,7 @@ jvmInitProperties(Thread* t, uintptr_t* arguments) jobject properties = reinterpret_cast(arguments[0]); GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "java/util/Properties", "setProperty", + (t, cast(t, root(t, Machine::BootLoader)), "java/util/Properties", "setProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;"); PROTECT(t, method); @@ -3009,7 +3020,7 @@ jvmInitProperties(Thread* t, uintptr_t* arguments) local::setProperty (t, method, *properties, "sun.boot.class.path", static_cast - (systemClassLoaderFinder(t, root(t, Machine::BootLoader)))->path()); + (cast(t, root(t, Machine::BootLoader))->finder())->path()); local::setProperty(t, method, *properties, "file.encoding", "UTF-8"); #ifdef ARCH_x86_32 @@ -3412,7 +3423,7 @@ jvmDumpThreads(Thread* t, uintptr_t* arguments) unsigned threadsLength = objectArrayLength(t, *threads); GcClass* arrayClass = resolveObjectArrayClass - (t, reinterpret_cast(type(t, GcStackTraceElement::Type)->loader()), + (t, type(t, GcStackTraceElement::Type)->loader(), reinterpret_cast(type(t, GcStackTraceElement::Type))); object result = makeObjectArray(t, arrayClass, threadsLength); PROTECT(t, result); @@ -3542,7 +3553,7 @@ jvmGetSystemPackages(Thread* t, uintptr_t*) makeObjectArray( t, resolveClass( - t, root(t, Machine::BootLoader), "java/lang/Package"), + t, cast(t, root(t, Machine::BootLoader)), "java/lang/Package"), 0))); } @@ -3572,9 +3583,9 @@ EXPORT(JVM_LatestUserDefinedLoader)(Thread* t) { } virtual bool visit(Processor::StackWalker* walker) { - object loader = reinterpret_cast(walker->method()->class_()->loader()); + GcClassLoader* loader = walker->method()->class_()->loader(); if (loader - and loader != root(t, Machine::BootLoader) + and loader != cast(t, root(t, Machine::BootLoader)) and strcmp (objectClass(t, loader)->name()->body().begin(), reinterpret_cast @@ -3588,12 +3599,12 @@ EXPORT(JVM_LatestUserDefinedLoader)(Thread* t) } Thread* t; - object loader; + GcClassLoader* loader; } v(t); t->m->processor->walkStack(t, &v); - return makeLocalReference(t, v.loader); + return makeLocalReference(t, reinterpret_cast(v.loader)); } extern "C" AVIAN_EXPORT jclass JNICALL @@ -3853,7 +3864,7 @@ jvmResolveClass(Thread* t, uintptr_t* arguments) jclass c = reinterpret_cast(arguments[0]); GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Classes", "link", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "link", "(Lavian/VMClass;)V"); t->m->processor->invoke(t, method, 0, jclassVmClass(t, *c)); @@ -3878,7 +3889,7 @@ jvmFindClassFromClassLoader(Thread* t, uintptr_t* arguments) jboolean throwError = arguments[3]; GcClass* c = resolveClass - (t, loader ? *loader : root(t, Machine::BootLoader), name, true, + (t, cast(t, loader ? *loader : root(t, Machine::BootLoader)), name, true, throwError ? static_cast(GcNoClassDefFoundError::Type) : static_cast(GcClassNotFoundException::Type)); @@ -3893,7 +3904,7 @@ jvmFindClassFromClassLoader(Thread* t, uintptr_t* arguments) extern "C" AVIAN_EXPORT jclass JNICALL EXPORT(JVM_FindClassFromClassLoader)(Thread* t, const char* name, - jboolean init, jobject loader, + jboolean init, jobject* loader, jboolean throwError) { uintptr_t arguments[] = { reinterpret_cast(name), @@ -3928,14 +3939,14 @@ jvmFindLoadedClass(Thread* t, uintptr_t* arguments) replace('.', '/', s); } - GcClass* c = findLoadedClass(t, *loader, spec); + GcClass* c = findLoadedClass(t, cast(t, *loader), spec); return reinterpret_cast (c ? makeLocalReference(t, reinterpret_cast(getJClass(t, c))) : 0); } extern "C" AVIAN_EXPORT jclass JNICALL -EXPORT(JVM_FindLoadedClass)(Thread* t, jobject loader, jstring name) +EXPORT(JVM_FindLoadedClass)(Thread* t, jobject* loader, jstring name) { uintptr_t arguments[] = { reinterpret_cast(loader), reinterpret_cast(name) }; @@ -3952,11 +3963,11 @@ jvmDefineClass(Thread* t, uintptr_t* arguments) return reinterpret_cast (makeLocalReference - (t, reinterpret_cast(getJClass(t, cast(t, defineClass(t, *loader, data, length)))))); + (t, reinterpret_cast(getJClass(t, cast(t, defineClass(t, cast(t, *loader), data, length)))))); } extern "C" AVIAN_EXPORT jclass JNICALL -EXPORT(JVM_DefineClass)(Thread* t, const char*, jobject loader, +EXPORT(JVM_DefineClass)(Thread* t, const char*, jobject* loader, const uint8_t* data, jsize length, jobject) { uintptr_t arguments[] = { reinterpret_cast(loader), @@ -3967,7 +3978,7 @@ EXPORT(JVM_DefineClass)(Thread* t, const char*, jobject loader, } extern "C" AVIAN_EXPORT jclass JNICALL -EXPORT(JVM_DefineClassWithSource)(Thread* t, const char*, jobject loader, +EXPORT(JVM_DefineClassWithSource)(Thread* t, const char*, jobject* loader, const uint8_t* data, jsize length, jobject, const char*) { @@ -3975,7 +3986,7 @@ EXPORT(JVM_DefineClassWithSource)(Thread* t, const char*, jobject loader, } extern "C" AVIAN_EXPORT jclass JNICALL -EXPORT(JVM_DefineClassWithSourceCond)(Thread* t, const char*, jobject loader, +EXPORT(JVM_DefineClassWithSourceCond)(Thread* t, const char*, jobject* loader, const uint8_t* data, jsize length, jobject, const char*, jboolean) { @@ -4032,9 +4043,9 @@ EXPORT(JVM_GetClassLoader)(Thread* t, jclass c) { ENTER(t, Thread::ActiveState); - object loader = classLoader(t, jclassVmClass(t, *c)); + GcClassLoader* loader = cast(t, classLoader(t, jclassVmClass(t, *c))); - if (loader == root(t, Machine::BootLoader)) { + if (loader == cast(t, root(t, Machine::BootLoader))) { // sun.misc.Unsafe.getUnsafe expects a null result if the class // loader is the boot classloader and will throw a // SecurityException otherwise. @@ -4049,7 +4060,7 @@ EXPORT(JVM_GetClassLoader)(Thread* t, jclass c) return makeLocalReference(t, root(t, Machine::BootLoader)); } } else { - return makeLocalReference(t, loader); + return makeLocalReference(t, reinterpret_cast(loader)); } } @@ -4106,7 +4117,7 @@ jvmGetProtectionDomain(Thread* t, uintptr_t* arguments) jclass c = reinterpret_cast(arguments[0]); GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Classes", "getProtectionDomain", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "getProtectionDomain", "(Lavian/VMClass;)Ljava/security/ProtectionDomain;"); return reinterpret_cast @@ -4273,11 +4284,11 @@ jvmGetClassDeclaredMethods(Thread* t, uintptr_t* arguments) for (unsigned i = 0, j = classDeclaredMethodCount(t, jclassVmClass(t, *c)); i < j; ++i) { - object vmMethod = arrayBody(t, table, i); + GcMethod* vmMethod = cast(t, arrayBody(t, table, i)); PROTECT(t, vmMethod); - if (((not publicOnly) or (methodFlags(t, vmMethod) & ACC_PUBLIC)) - and byteArrayBody(t, methodName(t, vmMethod), 0) != '<') + if (((not publicOnly) or (vmMethod->flags() & ACC_PUBLIC)) + and vmMethod->name()->body()[0] != '<') { object method = makeJmethod(t, vmMethod, i); @@ -4369,12 +4380,12 @@ jvmGetClassDeclaredConstructors(Thread* t, uintptr_t* arguments) for (unsigned i = 0, j = classDeclaredMethodCount(t, jclassVmClass(t, *c)); i < j; ++i) { - object vmMethod = arrayBody(t, table, i); + GcMethod* vmMethod = cast(t, arrayBody(t, table, i)); PROTECT(t, vmMethod); - if (((not publicOnly) or (methodFlags(t, vmMethod) & ACC_PUBLIC)) + if (((not publicOnly) or (vmMethod->flags() & ACC_PUBLIC)) and strcmp(reinterpret_cast - (&byteArrayBody(t, methodName(t, vmMethod), 0)), + (vmMethod->name()->body().begin()), "") == 0) { object method = makeJconstructor(t, vmMethod, i); @@ -4621,7 +4632,7 @@ maybeWrap(Thread* t, bool wrapException) PROTECT(t, exception); GcClass* paeClass = resolveClass - (t, root(t, Machine::BootLoader), + (t, cast(t, root(t, Machine::BootLoader)), "java/security/PrivilegedActionException"); PROTECT(t, paeClass); @@ -4648,7 +4659,7 @@ jvmDoPrivileged(Thread* t, uintptr_t* arguments) // object: GcClass* privilegedAction = resolveClass - (t, root(t, Machine::BootLoader), "java/security/PrivilegedAction"); + (t, cast(t, root(t, Machine::BootLoader)), "java/security/PrivilegedAction"); GcMethod* method; if (instanceOf(t, privilegedAction, *action)) { @@ -4656,7 +4667,7 @@ jvmDoPrivileged(Thread* t, uintptr_t* arguments) (t, privilegedAction, "run", "()Ljava/lang/Object;"); } else { GcClass* privilegedExceptionAction = resolveClass - (t, root(t, Machine::BootLoader), + (t, cast(t, root(t, Machine::BootLoader)), "java/security/PrivilegedExceptionAction"); method = resolveMethod @@ -5186,7 +5197,7 @@ getMemoryManagers(Thread* t, uintptr_t*) t, makeObjectArray(t, resolveClass(t, - root(t, Machine::BootLoader), + cast(t, root(t, Machine::BootLoader)), "java/lang/management/MemoryManagerMXBean"), 0))); } @@ -5204,7 +5215,7 @@ getMemoryPools(Thread* t, uintptr_t*) t, makeObjectArray(t, resolveClass(t, - root(t, Machine::BootLoader), + cast(t, root(t, Machine::BootLoader)), "java/lang/management/MemoryPoolMXBean"), 0))); } @@ -5259,7 +5270,7 @@ getEnclosingMethodInfo(Thread* t, uintptr_t* arguments) PROTECT(t, array); enclosingClass = reinterpret_cast(getJClass - (t, resolveClass(t, classLoader(t, class_), enclosingClass))); + (t, resolveClass(t, cast(t, classLoader(t, class_)), enclosingClass))); set(t, array, ArrayBody, enclosingClass); diff --git a/src/compile.cpp b/src/compile.cpp index 84f780b267..8270b0b5a0 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -336,7 +336,7 @@ resolveTarget(MyThread* t, void* stack, GcMethod* method) PROTECT(t, method); PROTECT(t, class_); - resolveSystemClass(t, root(t, Machine::BootLoader), reinterpret_cast(class_->name())); + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), reinterpret_cast(class_->name())); } if (method->class_()->flags() & ACC_INTERFACE) { @@ -352,7 +352,7 @@ resolveTarget(MyThread* t, GcClass* class_, unsigned index) if (class_->vmFlags() & BootstrapFlag) { PROTECT(t, class_); - resolveSystemClass(t, root(t, Machine::BootLoader), reinterpret_cast(class_->name())); + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), reinterpret_cast(class_->name())); } return cast(t, arrayBody(t, class_->virtualTable(), index)); @@ -2281,7 +2281,7 @@ resolveMethod(Thread* t, object pair) PROTECT(t, reference); GcClass* class_ = resolveClassInObject - (t, classLoader(t, methodClass(t, pairFirst(t, pair))), reference, + (t, cast(t, cast(t, pair)->first())->class_()->loader(), reference, ReferenceClass); return cast(t, findInHierarchy @@ -2419,7 +2419,7 @@ getJClassFromReference(MyThread* t, object pair) return reinterpret_cast(getJClass( t, resolveClass(t, - classLoader(t, methodClass(t, pairFirst(t, pair))), + cast(t, cast(t, pair)->first())->class_()->loader(), referenceName(t, pairSecond(t, pair))))); } @@ -2512,7 +2512,7 @@ makeBlankObjectArrayFromReference(MyThread* t, object pair, return makeBlankObjectArray( t, resolveClass(t, - classLoader(t, methodClass(t, pairFirst(t, pair))), + cast(t, cast(t, pair)->first())->class_()->loader(), referenceName(t, pairSecond(t, pair))), length); } @@ -2651,7 +2651,7 @@ makeMultidimensionalArrayFromReference(MyThread* t, object pair, { return makeMultidimensionalArray (t, resolveClass - (t, classLoader(t, methodClass(t, pairFirst(t, pair))), + (t, cast(t, cast(t, pair)->first())->class_()->loader(), referenceName(t, pairSecond(t, pair))), dimensions, offset); } @@ -2710,7 +2710,7 @@ checkCastFromReference(MyThread* t, object pair, object o) PROTECT(t, o); GcClass* c = resolveClass - (t, classLoader(t, methodClass(t, pairFirst(t, pair))), + (t, cast(t, cast(t, pair)->first())->class_()->loader(), referenceName(t, pairSecond(t, pair))); checkCast(t, c, o); @@ -2723,7 +2723,7 @@ resolveField(Thread* t, object pair) PROTECT(t, reference); GcClass* class_ = resolveClassInObject - (t, classLoader(t, methodClass(t, pairFirst(t, pair))), reference, + (t, cast(t, cast(t, pair)->first())->class_()->loader(), reference, ReferenceClass); return findInHierarchy @@ -2906,7 +2906,7 @@ instanceOfFromReference(Thread* t, object pair, object o) PROTECT(t, o); GcClass* c = resolveClass - (t, classLoader(t, methodClass(t, pairFirst(t, pair))), + (t, cast(t, cast(t, pair)->first())->class_()->loader(), referenceName(t, pairSecond(t, pair))); return instanceOf64(t, c, o); @@ -2936,7 +2936,7 @@ uint64_t makeNewFromReference(Thread* t, object pair) { GcClass* class_ = resolveClass - (t, classLoader(t, methodClass(t, pairFirst(t, pair))), + (t, cast(t, cast(t, pair)->first())->class_()->loader(), referenceName(t, pairSecond(t, pair))); PROTECT(t, class_); @@ -7593,7 +7593,7 @@ returnClass(MyThread* t, GcMethod* method) memcpy(&byteArrayBody(t, name, 0), spec + 1, length - 2); } - return resolveClass(t, reinterpret_cast(method->class_()->loader()), name); + return resolveClass(t, method->class_()->loader(), name); } bool @@ -7717,7 +7717,7 @@ callContinuation(MyThread* t, object continuation, object result, PROTECT(t, nextContinuation); GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Continuations", "rewind", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Continuations", "rewind", "(Ljava/lang/Runnable;Lavian/Callback;Ljava/lang/Object;" "Ljava/lang/Throwable;)V"); @@ -7777,7 +7777,7 @@ callWithCurrentContinuation(MyThread* t, object receiver) if (root(t, ReceiveMethod) == 0) { GcMethod* m = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Function", "call", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Function", "call", "(Ljava/lang/Object;)Ljava/lang/Object;"); if (m) { @@ -7787,7 +7787,7 @@ callWithCurrentContinuation(MyThread* t, object receiver) if (classVmFlags(t, continuationClass) & BootstrapFlag) { resolveSystemClass - (t, root(t, Machine::BootLoader), + (t, cast(t, root(t, Machine::BootLoader)), vm::className(t, continuationClass)); } } @@ -7817,7 +7817,7 @@ dynamicWind(MyThread* t, object before, object thunk, object after) if (root(t, WindMethod) == 0) { GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Continuations", "wind", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Continuations", "wind", "(Ljava/lang/Runnable;Ljava/util/concurrent/Callable;" "Ljava/lang/Runnable;)Lavian/Continuations$UnwindResult;"); @@ -8024,7 +8024,7 @@ invoke(Thread* thread, GcMethod* method, ArgumentList* arguments) compile(t, local::codeAllocator(static_cast(t)), 0, resolveMethod - (t, root(t, Machine::AppLoader), + (t, cast(t, root(t, Machine::AppLoader)), "foo/ClassName", "methodName", "()V")); @@ -8664,7 +8664,7 @@ class MyProcessor: public Processor { this_, methodSpec, false, arguments); GcMethod* method = resolveMethod - (t, reinterpret_cast(loader), className, methodName, methodSpec); + (t, loader, className, methodName, methodSpec); assertT(t, ((method->flags() & ACC_STATIC) == 0) xor (this_ == 0)); diff --git a/src/interpret.cpp b/src/interpret.cpp index e0acedcabf..7a70228081 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -2665,7 +2665,7 @@ interpret3(Thread* t, const int base) GcClass* class_ = objectClass(t, peekObject(t, sp - parameterFootprint)); assertT(t, class_->vmFlags() & BootstrapFlag); - resolveClass(t, reinterpret_cast(frameMethod(t, frame)->class_()->loader()), + resolveClass(t, frameMethod(t, frame)->class_()->loader(), reinterpret_cast(class_->name())); ip -= 3; @@ -2891,7 +2891,7 @@ invoke(Thread* t, GcMethod* method) class_ = objectClass(t, peekObject(t, t->sp - parameterFootprint)); if (class_->vmFlags() & BootstrapFlag) { - resolveClass(t, root(t, Machine::BootLoader), reinterpret_cast(class_->name())); + resolveClass(t, cast(t, root(t, Machine::BootLoader)), reinterpret_cast(class_->name())); } if (method->class_()->flags() & ACC_INTERFACE) { @@ -3219,7 +3219,7 @@ class MyProcessor: public Processor { pushArguments(t, this_, methodSpec, false, arguments); GcMethod* method = resolveMethod - (t, reinterpret_cast(loader), className, methodName, methodSpec); + (t, loader, className, methodName, methodSpec); assertT(t, ((method->flags() & ACC_STATIC) == 0) xor (this_ == 0)); diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 5f75b1a97a..db7c654dc0 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -325,7 +325,7 @@ defineClass(Thread* t, uintptr_t* arguments) t, reinterpret_cast(getJClass(t, cast(t, defineClass(t, - loader ? *loader : root(t, Machine::BootLoader), + cast(t, loader ? *loader : root(t, Machine::BootLoader)), buffer, length)))))); } @@ -353,9 +353,8 @@ findClass(Thread* t, uintptr_t* arguments) GcClass* c = resolveClass( t, - caller ? reinterpret_cast - (t->m->classpath->libraryClassLoader(t, caller)) - : root(t, Machine::AppLoader), + caller ? t->m->classpath->libraryClassLoader(t, caller) : cast + (t, root(t, Machine::AppLoader)), n); if (t->m->classpath->mayInitClasses()) { @@ -3564,7 +3563,7 @@ boot(Thread* t, uintptr_t*) PROTECT(t, host); GcMethod* method = resolveMethod - (t, root(t, Machine::BootLoader), "avian/Traces", "startTraceListener", + (t, cast(t, root(t, Machine::BootLoader)), "avian/Traces", "startTraceListener", "(Ljava/lang/String;I)V"); t->m->processor->invoke(t, method, 0, host, atoi(port)); diff --git a/src/machine.cpp b/src/machine.cpp index 3f01a6ce7c..6ba3cacd6e 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1253,7 +1253,7 @@ parseInterfaceTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool, PROTECT(t, name); GcClass* interface = resolveClass - (t, reinterpret_cast(class_->loader()), name, true, throwType); + (t, class_->loader(), name, true, throwType); PROTECT(t, interface); @@ -2523,7 +2523,7 @@ updateBootstrapClass(Thread* t, GcClass* bootstrapClass, GcClass* class_) } GcClass* -makeArrayClass(Thread* t, object loader, unsigned dimensions, object spec, +makeArrayClass(Thread* t, GcClassLoader* loader, unsigned dimensions, object spec, object elementClass) { if (type(t, GcJobject::Type)->vmFlags() & BootstrapFlag) { @@ -2536,7 +2536,7 @@ makeArrayClass(Thread* t, object loader, unsigned dimensions, object spec, // avoid infinite recursion due to trying to create an array to // make a stack trace for a ClassNotFoundException. resolveSystemClass - (t, root(t, Machine::BootLoader), + (t, cast(t, root(t, Machine::BootLoader)), reinterpret_cast(type(t, GcJobject::Type)->name()), false); } @@ -2560,7 +2560,7 @@ makeArrayClass(Thread* t, object loader, unsigned dimensions, object spec, 0, 0, 0, - cast(t, loader), + loader, arrayLength(t, vtable)); PROTECT(t, c); @@ -2571,27 +2571,27 @@ makeArrayClass(Thread* t, object loader, unsigned dimensions, object spec, } void -saveLoadedClass(Thread* t, object loader, GcClass* c) +saveLoadedClass(Thread* t, GcClassLoader* loader, GcClass* c) { PROTECT(t, loader); PROTECT(t, c); ACQUIRE(t, t->m->classLock); - if (classLoaderMap(t, loader) == 0) { + if (loader->map() == 0) { GcHashMap* map = makeHashMap(t, 0, 0); - set(t, loader, ClassLoaderMap, reinterpret_cast(map)); + set(t, reinterpret_cast(loader), ClassLoaderMap, reinterpret_cast(map)); } hashMapInsert(t, - cast(t, classLoaderMap(t, loader)), + cast(t, loader->map()), reinterpret_cast(c->name()), reinterpret_cast(c), byteArrayHash); } GcClass* -makeArrayClass(Thread* t, object loader, object spec, bool throw_, +makeArrayClass(Thread* t, GcClassLoader* loader, object spec, bool throw_, Gc::Type throwType) { PROTECT(t, loader); @@ -2649,23 +2649,23 @@ makeArrayClass(Thread* t, object loader, object spec, bool throw_, ACQUIRE(t, t->m->classLock); - GcClass* class_ = findLoadedClass(t, reinterpret_cast(elementClass->loader()), spec); + GcClass* class_ = findLoadedClass(t, elementClass->loader(), spec); if (class_) { return class_; } class_ = makeArrayClass - (t, reinterpret_cast(elementClass->loader()), dimensions, spec, reinterpret_cast(elementClass)); + (t, elementClass->loader(), dimensions, spec, reinterpret_cast(elementClass)); PROTECT(t, class_); - saveLoadedClass(t, reinterpret_cast(elementClass->loader()), class_); + saveLoadedClass(t, elementClass->loader(), class_); return class_; } GcClass* -resolveArrayClass(Thread* t, object loader, object spec, bool throw_, +resolveArrayClass(Thread* t, GcClassLoader* loader, object spec, bool throw_, Gc::Type throwType) { GcClass* c = cast(t, @@ -2684,7 +2684,7 @@ resolveArrayClass(Thread* t, object loader, object spec, bool throw_, PROTECT(t, loader); PROTECT(t, spec); - c = findLoadedClass(t, root(t, Machine::BootLoader), spec); + c = findLoadedClass(t, cast(t, root(t, Machine::BootLoader)), spec); if (c) { return c; @@ -2899,13 +2899,13 @@ boot(Thread* t) set(t, root(t, Machine::BootLoader), ClassLoaderMap, reinterpret_cast(map)); } - systemClassLoaderFinder(t, root(t, Machine::BootLoader)) = m->bootFinder; + cast(t, root(t, Machine::BootLoader))->finder() = m->bootFinder; { GcHashMap* map = makeHashMap(t, 0, 0); set(t, root(t, Machine::AppLoader), ClassLoaderMap, reinterpret_cast(map)); } - systemClassLoaderFinder(t, root(t, Machine::AppLoader)) = m->appFinder; + cast(t, root(t, Machine::AppLoader))->finder() = m->appFinder; set(t, root(t, Machine::AppLoader), ClassLoaderParent, root(t, Machine::BootLoader)); @@ -4081,7 +4081,7 @@ resolveBootstrap(Thread* t, uintptr_t* arguments) { object name = reinterpret_cast(arguments[0]); - resolveSystemClass(t, root(t, Machine::BootLoader), name); + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), name); return 1; } @@ -4238,7 +4238,7 @@ primitiveSize(Thread* t, unsigned code) } GcClass* -parseClass(Thread* t, object loader, const uint8_t* data, unsigned size, +parseClass(Thread* t, GcClassLoader* loader, const uint8_t* data, unsigned size, Gc::Type throwType) { PROTECT(t, loader); @@ -4289,7 +4289,7 @@ parseClass(Thread* t, object loader, const uint8_t* data, unsigned size, 0, // methods 0, // addendum 0, // static table - cast(t, loader), + loader, 0, // source 0);// vtable length PROTECT(t, class_); @@ -4369,7 +4369,7 @@ parseClass(Thread* t, object loader, const uint8_t* data, unsigned size, uint64_t runParseClass(Thread* t, uintptr_t* arguments) { - object loader = reinterpret_cast(arguments[0]); + GcClassLoader* loader = cast(t, reinterpret_cast(arguments[0])); System::Region* region = reinterpret_cast(arguments[1]); Gc::Type throwType = static_cast(arguments[2]); @@ -4378,7 +4378,7 @@ runParseClass(Thread* t, uintptr_t* arguments) } GcClass* -resolveSystemClass(Thread* t, object loader, object spec, bool throw_, +resolveSystemClass(Thread* t, GcClassLoader* loader, object spec, bool throw_, Gc::Type throwType) { PROTECT(t, loader); @@ -4387,14 +4387,14 @@ resolveSystemClass(Thread* t, object loader, object spec, bool throw_, ACQUIRE(t, t->m->classLock); GcClass* class_ = cast(t, hashMapFind - (t, cast(t, classLoaderMap(t, loader)), spec, byteArrayHash, byteArrayEqual)); + (t, cast(t, loader->map()), spec, byteArrayHash, byteArrayEqual)); if (class_ == 0) { PROTECT(t, class_); - if (classLoaderParent(t, loader)) { + if (loader->parent()) { class_ = resolveSystemClass - (t, classLoaderParent(t, loader), spec, false); + (t, loader->parent(), spec, false); if (class_) { return class_; } @@ -4412,7 +4412,7 @@ resolveSystemClass(Thread* t, object loader, object spec, bool throw_, 7); System::Region* region = static_cast - (systemClassLoaderFinder(t, loader))->find + (loader->as(t)->finder())->find (RUNTIME_ARRAY_BODY(file)); if (region) { @@ -4449,7 +4449,7 @@ resolveSystemClass(Thread* t, object loader, object spec, bool throw_, } { const char* source = static_cast - (systemClassLoaderFinder(t, loader))->sourceUrl + (loader->as(t)->finder())->sourceUrl (RUNTIME_ARRAY_BODY(file)); if (source) { @@ -4476,7 +4476,7 @@ resolveSystemClass(Thread* t, object loader, object spec, bool throw_, } if (class_) { - hashMapInsert(t, cast(t, classLoaderMap(t, loader)), spec, reinterpret_cast(class_), byteArrayHash); + hashMapInsert(t, cast(t, loader->map()), spec, reinterpret_cast(class_), byteArrayHash); updatePackageMap(t, class_); } else if (throw_) { @@ -4488,19 +4488,19 @@ resolveSystemClass(Thread* t, object loader, object spec, bool throw_, } GcClass* -findLoadedClass(Thread* t, object loader, object spec) +findLoadedClass(Thread* t, GcClassLoader* loader, object spec) { PROTECT(t, loader); PROTECT(t, spec); ACQUIRE(t, t->m->classLock); - return classLoaderMap(t, loader) ? cast(t, hashMapFind - (t, cast(t, classLoaderMap(t, loader)), spec, byteArrayHash, byteArrayEqual)) : 0; + return loader->map() ? cast(t, hashMapFind + (t, cast(t, loader->map()), spec, byteArrayHash, byteArrayEqual)) : 0; } GcClass* -resolveClass(Thread* t, object loader, object spec, bool throw_, +resolveClass(Thread* t, GcClassLoader* loader, object spec, bool throw_, Gc::Type throwType) { if (objectClass(t, loader) == type(t, GcSystemClassLoader::Type)) { @@ -4519,7 +4519,7 @@ resolveClass(Thread* t, object loader, object spec, bool throw_, } else { if (root(t, Machine::LoadClassMethod) == 0) { GcMethod* m = resolveMethod - (t, root(t, Machine::BootLoader), "java/lang/ClassLoader", + (t, cast(t, root(t, Machine::BootLoader)), "java/lang/ClassLoader", "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"); if (m) { @@ -4529,7 +4529,7 @@ resolveClass(Thread* t, object loader, object spec, bool throw_, if (classLoaderClass->vmFlags() & BootstrapFlag) { resolveSystemClass - (t, root(t, Machine::BootLoader), + (t, cast(t, root(t, Machine::BootLoader)), reinterpret_cast(classLoaderClass->name())); } } @@ -4740,7 +4740,7 @@ initClass(Thread* t, GcClass* c) } GcClass* -resolveObjectArrayClass(Thread* t, object loader, object elementClass) +resolveObjectArrayClass(Thread* t, GcClassLoader* loader, object elementClass) { PROTECT(t, loader); PROTECT(t, elementClass); @@ -4785,7 +4785,7 @@ object makeObjectArray(Thread* t, GcClass* elementClass, unsigned count) { GcClass* arrayClass = resolveObjectArrayClass - (t, reinterpret_cast(elementClass->loader()), reinterpret_cast(elementClass)); + (t, elementClass->loader(), reinterpret_cast(elementClass)); PROTECT(t, arrayClass); @@ -5315,7 +5315,7 @@ getCaller(Thread* t, unsigned target, bool skipMethodInvoke) } object -defineClass(Thread* t, object loader, const uint8_t* buffer, unsigned length) +defineClass(Thread* t, GcClassLoader* loader, const uint8_t* buffer, unsigned length) { PROTECT(t, loader); @@ -5362,7 +5362,7 @@ populateMultiArray(Thread* t, object array, int32_t* counts, byteArrayLength(t, spec) - 1); GcClass* class_ = resolveClass - (t, reinterpret_cast(objectClass(t, array)->loader()), elementSpec); + (t, objectClass(t, array)->loader(), elementSpec); PROTECT(t, class_); for (int32_t i = 0; i < counts[index]; ++i) { diff --git a/src/tools/bootimage-generator/main.cpp b/src/tools/bootimage-generator/main.cpp index 49796d11a2..eeb69ef920 100644 --- a/src/tools/bootimage-generator/main.cpp +++ b/src/tools/bootimage-generator/main.cpp @@ -311,7 +311,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, } resolver(&typeMaps); Finder* finder = static_cast - (systemClassLoaderFinder(t, root(t, Machine::BootLoader))); + (cast(t, root(t, Machine::BootLoader))->finder()); for (Finder::Iterator it(finder); it.hasMore();) { unsigned nameSize = 0; @@ -322,7 +322,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, { // fprintf(stderr, "pass 1 %.*s\n", nameSize - 6, name); object c = reinterpret_cast(resolveSystemClass - (t, root(t, Machine::BootLoader), + (t, cast(t, root(t, Machine::BootLoader)), makeByteArray(t, "%.*s", nameSize - 6, name), true)); PROTECT(t, c); @@ -607,7 +607,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, { // fprintf(stderr, "pass 2 %.*s\n", nameSize - 6, name); object c = reinterpret_cast(resolveSystemClass - (t, root(t, Machine::BootLoader), + (t, cast(t, root(t, Machine::BootLoader)), makeByteArray(t, "%.*s", nameSize - 6, name), true)); PROTECT(t, c); @@ -655,7 +655,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, if (objectClass(t, o) == type(t, GcReference::Type)) { o = reinterpret_cast(resolveClass - (t, root(t, Machine::BootLoader), referenceName(t, o))); + (t, cast(t, root(t, Machine::BootLoader)), referenceName(t, o))); set(t, reinterpret_cast(addendum->pool()), SingletonBody + (index * BytesPerWord), o); @@ -704,7 +704,7 @@ visitRoots(Thread* t, BootImage* image, HeapWalker* w, object constants) { Machine* m = t->m; - for (HashMapIterator it(t, cast(t, classLoaderMap(t, root(t, Machine::BootLoader)))); + for (HashMapIterator it(t, cast(t, cast(t, root(t, Machine::BootLoader))->map())); it.hasMore();) { w->visitRoot(it.next()->second()); @@ -1523,28 +1523,28 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp // resolve primitive array classes in case they are needed at // runtime: { object name = reinterpret_cast(makeByteArray(t, "[B")); - resolveSystemClass(t, root(t, Machine::BootLoader), name, true); + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), name, true); name = reinterpret_cast(makeByteArray(t, "[Z")); - resolveSystemClass(t, root(t, Machine::BootLoader), name, true); + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), name, true); name = reinterpret_cast(makeByteArray(t, "[S")); - resolveSystemClass(t, root(t, Machine::BootLoader), name, true); + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), name, true); name = reinterpret_cast(makeByteArray(t, "[C")); - resolveSystemClass(t, root(t, Machine::BootLoader), name, true); + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), name, true); name = reinterpret_cast(makeByteArray(t, "[I")); - resolveSystemClass(t, root(t, Machine::BootLoader), name, true); + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), name, true); name = reinterpret_cast(makeByteArray(t, "[J")); - resolveSystemClass(t, root(t, Machine::BootLoader), name, true); + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), name, true); name = reinterpret_cast(makeByteArray(t, "[F")); - resolveSystemClass(t, root(t, Machine::BootLoader), name, true); + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), name, true); name = reinterpret_cast(makeByteArray(t, "[D")); - resolveSystemClass(t, root(t, Machine::BootLoader), name, true); + resolveSystemClass(t, cast(t, root(t, Machine::BootLoader)), name, true); } } @@ -1561,14 +1561,14 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp updateConstants(t, constants, heapWalker->map()); image->bootClassCount = hashMapSize - (t, classLoaderMap(t, root(t, Machine::BootLoader))); + (t, cast(t, root(t, Machine::BootLoader))->map()); unsigned* bootClassTable = static_cast (t->m->heap->allocate(image->bootClassCount * sizeof(unsigned))); { unsigned i = 0; for (HashMapIterator it - (t, cast(t, classLoaderMap(t, root(t, Machine::BootLoader)))); + (t, cast(t, cast(t, root(t, Machine::BootLoader))->map())); it.hasMore();) { bootClassTable[i++] = targetVW