From 75f2dd013cac877c602318328e68351539819737 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Thu, 26 Jun 2014 18:17:46 -0600 Subject: [PATCH] remove old function-based accessors --- src/avian/machine.h | 24 +-- src/classpath-android.cpp | 272 +++++++++++++++--------------- src/classpath-avian.cpp | 4 +- src/classpath-openjdk.cpp | 250 ++++++++++++++------------- src/jnienv.cpp | 2 +- src/tools/type-generator/main.cpp | 67 +------- 6 files changed, 283 insertions(+), 336 deletions(-) diff --git a/src/avian/machine.h b/src/avian/machine.h index d1e242e0e2..641cae0a4e 100644 --- a/src/avian/machine.h +++ b/src/avian/machine.h @@ -1317,9 +1317,6 @@ class Machine { void printTrace(Thread* t, GcThrowable* exception); -uint8_t& -threadInterrupted(Thread* t, object thread); - void enterActiveState(Thread* t); @@ -1579,6 +1576,8 @@ class Thread { unsigned flags; }; +class GcJfield; + class Classpath { public: virtual object @@ -1600,7 +1599,7 @@ class Classpath { makeJField(Thread* t, GcField* vmField) = 0; virtual GcField* - getVMField(Thread* t, object jfield) = 0; + getVMField(Thread* t, GcJfield* jfield) = 0; virtual void clearInterrupted(Thread* t) = 0; @@ -2321,19 +2320,20 @@ makeString(Thread* t, object data, int32_t hash, int32_t) # endif // not HAVE_StringHash32 inline GcString* -makeString(Thread* t, object data, unsigned offset, unsigned length, unsigned) +makeString(Thread* t, object odata, unsigned offset, unsigned length, unsigned) { - if (offset == 0 and length == charArrayLength(t, data)) { - return makeString(t, data, 0, 0); + GcCharArray* data = cast(t, odata); + if (offset == 0 and length == data->length()) { + return makeString(t, reinterpret_cast(data), 0, 0); } else { PROTECT(t, data); - object array = reinterpret_cast(makeCharArray(t, length)); + GcCharArray* array = makeCharArray(t, length); - memcpy(&charArrayBody(t, array, 0), &charArrayBody(t, data, offset), + memcpy(array->body().begin(), &data->body()[offset], length * 2); - return makeString(t, array, 0, 0); + return makeString(t, reinterpret_cast(array), 0, 0); } } @@ -3843,11 +3843,11 @@ resolveMethod(Thread* t, GcMethod* method, unsigned index, bool throw_ = true) GcVector* vectorAppend(Thread*, GcVector*, object); -inline object +inline GcClassRuntimeData* getClassRuntimeDataIfExists(Thread* t, GcClass* c) { if (c->runtimeDataIndex()) { - return cast(t, root(t, Machine::ClassRuntimeDataTable))->body()[c->runtimeDataIndex() - 1]; + return cast(t, cast(t, root(t, Machine::ClassRuntimeDataTable))->body()[c->runtimeDataIndex() - 1]); } else { return 0; } diff --git a/src/classpath-android.cpp b/src/classpath-android.cpp index c4ec77fc4b..4a726391f1 100644 --- a/src/classpath-android.cpp +++ b/src/classpath-android.cpp @@ -111,8 +111,7 @@ makeMethodOrConstructor(Thread* t, GcJclass* c, unsigned index) { PROTECT(t, c); - GcMethod* method = cast(t, arrayBody - (t, c->vmClass()->methodTable(), index)); + GcMethod* method = cast(t, cast(t, c->vmClass()->methodTable())->body()[index]); PROTECT(t, method); unsigned parameterCount; @@ -152,8 +151,8 @@ makeField(Thread* t, GcJclass* c, unsigned index) { PROTECT(t, c); - GcField* field = cast(t, arrayBody - (t, c->vmClass()->fieldTable(), index)); + GcField* field = cast(t, cast + (t, c->vmClass()->fieldTable())->body()[index]); PROTECT(t, field); @@ -249,16 +248,18 @@ class MyClasspath : public Classpath { makeString(Thread* t, object array, int32_t offset, int32_t length) { if (objectClass(t, array) == type(t, GcByteArray::Type)) { + GcByteArray* byteArray = cast(t, array); PROTECT(t, array); + PROTECT(t, byteArray); - object charArray = reinterpret_cast(makeCharArray(t, length)); + GcCharArray* charArray = makeCharArray(t, length); for (int i = 0; i < length; ++i) { - expect(t, (byteArrayBody(t, array, offset + i) & 0x80) == 0); + expect(t, (byteArray->body()[offset + i] & 0x80) == 0); - charArrayBody(t, charArray, i) = byteArrayBody(t, array, offset + i); + charArray->body()[i] = byteArray->body()[offset + i]; } - array = charArray; + array = reinterpret_cast(charArray); } else { expect(t, objectClass(t, array) == type(t, GcCharArray::Type)); } @@ -312,9 +313,9 @@ class MyClasspath : public Classpath { virtual object makeJMethod(Thread* t, GcMethod* vmMethod) { - object table = vmMethod->class_()->methodTable(); - for (unsigned i = 0; i < arrayLength(t, table); ++i) { - if (reinterpret_cast(vmMethod) == arrayBody(t, table, i)) { + GcArray* table = cast(t, vmMethod->class_()->methodTable()); + for (unsigned i = 0; i < table->length(); ++i) { + if (reinterpret_cast(vmMethod) == table->body()[i]) { return makeMethodOrConstructor (t, getJClass(t, vmMethod->class_()), i); } @@ -326,20 +327,20 @@ class MyClasspath : public Classpath { getVMMethod(Thread* t, object jmethod) { return cast(t, objectClass(t, jmethod) == type(t, GcJmethod::Type) - ? arrayBody - (t, jmethodDeclaringClass(t, jmethod)->vmClass()->methodTable(), - jmethodSlot(t, jmethod)) - : arrayBody - (t, jconstructorDeclaringClass(t, jmethod)->vmClass()->methodTable(), - jconstructorSlot(t, jmethod))); + ? cast + (t, cast(t, jmethod)->declaringClass()->vmClass()->methodTable()) + ->body()[cast(t, jmethod)->slot()] + : cast + (t, cast(t, jmethod)->declaringClass()->vmClass()->methodTable()) + ->body()[cast(t, jmethod)->slot()]); } virtual object makeJField(Thread* t, GcField* vmField) { - object table = vmField->class_()->fieldTable(); - for (unsigned i = 0; i < arrayLength(t, table); ++i) { - if (reinterpret_cast(vmField) == arrayBody(t, table, i)) { + GcArray* table = cast(t, vmField->class_()->fieldTable()); + for (unsigned i = 0; i < table->length(); ++i) { + if (reinterpret_cast(vmField) == table->body()[i]) { return makeField(t, getJClass(t, vmField->class_()), i); } } @@ -347,11 +348,11 @@ class MyClasspath : public Classpath { } virtual GcField* - getVMField(Thread* t, object jfield) + getVMField(Thread* t, GcJfield* jfield) { - return cast(t, arrayBody - (t, jfieldDeclaringClass(t, jfield)->vmClass()->fieldTable(), - jfieldSlot(t, jfield))); + return cast(t, cast + (t, jfield->declaringClass()->vmClass()->fieldTable())->body() + [jfield->slot()]); } virtual void @@ -790,35 +791,35 @@ setField(Thread* t, GcField* field, object instance, object value) unsigned offset = field->offset(); switch (field->code()) { case ByteField: - fieldAtOffset(target, offset) = byteValue(t, value); + fieldAtOffset(target, offset) = cast(t, value)->value(); break; case BooleanField: - fieldAtOffset(target, offset) = booleanValue(t, value); + fieldAtOffset(target, offset) = cast(t, value)->value(); break; case CharField: - fieldAtOffset(target, offset) = charValue(t, value); + fieldAtOffset(target, offset) = cast(t, value)->value(); break; case ShortField: - fieldAtOffset(target, offset) = shortValue(t, value); + fieldAtOffset(target, offset) = cast(t, value)->value(); break; case IntField: - fieldAtOffset(target, offset) = intValue(t, value); + fieldAtOffset(target, offset) = cast(t, value)->value(); break; case LongField: - fieldAtOffset(target, offset) = longValue(t, value); + fieldAtOffset(target, offset) = cast(t, value)->value(); break; case FloatField: - fieldAtOffset(target, offset) = floatValue(t, value); + fieldAtOffset(target, offset) = cast(t, value)->value(); break; case DoubleField: - fieldAtOffset(target, offset) = doubleValue(t, value); + fieldAtOffset(target, offset) = cast(t, value)->value(); break; case ObjectField: @@ -1028,14 +1029,14 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_String_isEmpty (Thread* t, object, uintptr_t* arguments) { - return stringLength(t, reinterpret_cast(arguments[0])) == 0; + return cast(t, reinterpret_cast(arguments[0]))->length(t) == 0; } extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_String_length (Thread* t, object, uintptr_t* arguments) { - return stringLength(t, reinterpret_cast(arguments[0])); + return cast(t, reinterpret_cast(arguments[0]))->length(t); } extern "C" AVIAN_EXPORT int64_t JNICALL @@ -1087,15 +1088,15 @@ Avian_java_lang_Class_getInterfaces GcClassAddendum* addendum = c->vmClass()->addendum(); if (addendum) { - object table = addendum->interfaceTable(); + GcArray* table = cast(t, addendum->interfaceTable()); if (table) { PROTECT(t, table); - object array = makeObjectArray(t, arrayLength(t, table)); + object array = makeObjectArray(t, table->length()); PROTECT(t, array); - for (unsigned i = 0; i < arrayLength(t, table); ++i) { - GcJclass* c = getJClass(t, cast(t, arrayBody(t, table, i))); + for (unsigned i = 0; i < table->length(); ++i) { + GcJclass* c = getJClass(t, cast(t, table->body()[i])); set(t, array, ArrayBody + (i * BytesPerWord), reinterpret_cast(c)); } @@ -1113,7 +1114,7 @@ Avian_java_lang_Class_getDeclaredClasses { return reinterpret_cast (getDeclaredClasses - (t, jclassVmClass(t, reinterpret_cast(arguments[0])), + (t, cast(t, reinterpret_cast(arguments[0]))->vmClass(), arguments[1])); } @@ -1123,14 +1124,14 @@ Avian_java_lang_Class_getDeclaringClass { return reinterpret_cast (getDeclaringClass - (t, jclassVmClass(t, reinterpret_cast(arguments[0])))); + (t, cast(t, reinterpret_cast(arguments[0]))->vmClass())); } extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_Class_getEnclosingMethod (Thread* t, object, uintptr_t* arguments) { - GcClass* c = jclassVmClass(t, reinterpret_cast(arguments[0])); + GcClass* c = cast(t, reinterpret_cast(arguments[0]))->vmClass(); PROTECT(t, c); GcClassAddendum* addendum = c->addendum(); @@ -1174,7 +1175,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_Class_newInstanceImpl (Thread* t, object, uintptr_t* arguments) { - GcClass* c = jclassVmClass(t, reinterpret_cast(arguments[0])); + GcClass* c = cast(t, reinterpret_cast(arguments[0]))->vmClass(); GcMethod* method = resolveMethod(t, c, "", "()V"); PROTECT(t, method); @@ -1240,9 +1241,9 @@ Avian_java_lang_Class_getDeclaredField (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "findField", "(Lavian/VMClass;Ljava/lang/String;)I"); - int index = intValue + int index = cast (t, t->m->processor->invoke - (t, method, 0, c->vmClass(), name)); + (t, method, 0, c->vmClass(), name))->value(); if (index >= 0) { return reinterpret_cast(local::makeField(t, c, index)); @@ -1268,9 +1269,9 @@ Avian_java_lang_Class_getDeclaredConstructorOrMethod (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", "findMethod", "(Lavian/VMClass;Ljava/lang/String;[Ljava/lang/Class;)I"); - int index = intValue + int index = cast (t, t->m->processor->invoke - (t, method, 0, c->vmClass(), name, parameterTypes)); + (t, method, 0, c->vmClass(), name, parameterTypes))->value(); if (index >= 0) { return reinterpret_cast @@ -1399,11 +1400,11 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_sun_misc_Unsafe_objectFieldOffset (Thread* t, object, uintptr_t* arguments) { - object jfield = reinterpret_cast(arguments[1]); - return fieldOffset - (t, arrayBody - (t, jfieldDeclaringClass(t, jfield)->vmClass()->fieldTable(), - jfieldSlot(t, jfield))); + GcJfield* jfield = cast(t, reinterpret_cast(arguments[1])); + return cast + (t, cast + (t, jfield->declaringClass()->vmClass()->fieldTable()) + ->body()[jfield->slot()])->offset(); } extern "C" AVIAN_EXPORT void JNICALL @@ -1418,7 +1419,7 @@ Avian_java_lang_VMThread_interrupt interrupt (t, reinterpret_cast - (threadPeer(t, fieldAtOffset(vmThread, field->offset())))); + (cast(t, fieldAtOffset(vmThread, field->offset()))->peer())); } extern "C" AVIAN_EXPORT int64_t JNICALL @@ -1438,8 +1439,7 @@ Avian_java_lang_VMThread_isInterrupted GcField* field = resolveField (t, objectClass(t, vmThread), "thread", "Ljava/lang/Thread;"); - return threadInterrupted - (t, fieldAtOffset(vmThread, field->offset())); + return cast(t, fieldAtOffset(vmThread, field->offset()))->interrupted(); } extern "C" AVIAN_EXPORT int64_t JNICALL @@ -1491,7 +1491,7 @@ Avian_dalvik_system_VMStack_getThreadStackTrace (Thread* t, object, uintptr_t* arguments) { Thread* p = reinterpret_cast - (threadPeer(t, reinterpret_cast(arguments[0]))); + (cast(t, reinterpret_cast(arguments[0]))->peer()); return reinterpret_cast (local::translateStackTrace @@ -1707,14 +1707,14 @@ Avian_java_lang_Class_getModifiers (Thread* t, object, uintptr_t* arguments) { return classModifiers - (t, jclassVmClass(t, reinterpret_cast(arguments[0]))); + (t, cast(t, reinterpret_cast(arguments[0]))->vmClass()); } extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_Class_getSuperclass (Thread* t, object, uintptr_t* arguments) { - GcClass* c = jclassVmClass(t, reinterpret_cast(arguments[0])); + GcClass* c = cast(t, reinterpret_cast(arguments[0]))->vmClass(); if (c->flags() & ACC_INTERFACE) { return 0; } else { @@ -1734,7 +1734,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_Class_getNameNative (Thread* t, object, uintptr_t* arguments) { - GcByteArray* name = jclassVmClass(t, reinterpret_cast(arguments[0]))->name(); + GcByteArray* name = cast(t, reinterpret_cast(arguments[0]))->vmClass()->name(); THREAD_RUNTIME_ARRAY(t, char, s, name->length()); replace('/', '.', RUNTIME_ARRAY_BODY(s), @@ -1748,7 +1748,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_Class_isInterface (Thread* t, object, uintptr_t* arguments) { - return (jclassVmClass(t, reinterpret_cast(arguments[0]))->flags() + return (cast(t, reinterpret_cast(arguments[0]))->vmClass()->flags() & ACC_INTERFACE) != 0; } @@ -1756,7 +1756,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_Class_isPrimitive (Thread* t, object, uintptr_t* arguments) { - return (jclassVmClass(t, reinterpret_cast(arguments[0]))->vmFlags() + return (cast(t, reinterpret_cast(arguments[0]))->vmClass()->vmFlags() & PrimitiveFlag) != 0; } @@ -1764,7 +1764,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_Class_isAnonymousClass (Thread* t, object, uintptr_t* arguments) { - GcByteArray* name = jclassVmClass(t, reinterpret_cast(arguments[0]))->name(); + GcByteArray* name = cast(t, reinterpret_cast(arguments[0]))->vmClass()->name(); for (unsigned i = 0; i < name->length() - 1; ++i) { int c = name->body()[i]; @@ -1781,19 +1781,19 @@ Avian_java_lang_Class_getClassLoader (Thread* t, object, uintptr_t* arguments) { return reinterpret_cast - (jclassVmClass(t, reinterpret_cast(arguments[0]))->loader()); + (cast(t, reinterpret_cast(arguments[0]))->vmClass()->loader()); } extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_Class_isAssignableFrom (Thread* t, object, uintptr_t* arguments) { - object this_ = reinterpret_cast(arguments[0]); - object that = reinterpret_cast(arguments[1]); + GcJclass* this_ = cast(t, reinterpret_cast(arguments[0])); + GcJclass* that = cast(t, reinterpret_cast(arguments[1])); if (LIKELY(that)) { return isAssignableFrom - (t, jclassVmClass(t, this_), jclassVmClass(t, that)); + (t, this_->vmClass(), that->vmClass()); } else { throwNew(t, GcNullPointerException::Type); } @@ -1803,11 +1803,11 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_Class_isInstance (Thread* t, object, uintptr_t* arguments) { - object this_ = reinterpret_cast(arguments[0]); + GcJclass* this_ = cast(t, reinterpret_cast(arguments[0])); object o = reinterpret_cast(arguments[1]); if (o) { - return instanceOf(t, jclassVmClass(t, this_), o); + return instanceOf(t, this_->vmClass(), o); } else { return 0; } @@ -1853,9 +1853,9 @@ Avian_java_lang_reflect_Method_invokeNative { object instance = reinterpret_cast(arguments[1]); object args = reinterpret_cast(arguments[2]); - GcMethod* method = cast(t, arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[3]))->methodTable(), - arguments[6])); + GcMethod* method = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[3]))->vmClass()->methodTable()) + ->body()[arguments[6]]); return reinterpret_cast(invoke(t, method, instance, args)); } @@ -1864,21 +1864,21 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Method_getMethodModifiers (Thread* t, object, uintptr_t* arguments) { - return methodFlags - (t, arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[0]))->methodTable(), - arguments[1])); + return cast + (t, cast + (t, cast(t, reinterpret_cast(arguments[0]))->vmClass()->methodTable()) + ->body()[arguments[1]])->flags(); } extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Method_isAnnotationPresent (Thread* t, object, uintptr_t* arguments) { - object method = arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[0]))->methodTable(), - arguments[1]); + GcMethod* method = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[0]))->vmClass()->methodTable()) + ->body()[arguments[1]]); - GcMethodAddendum* addendum = methodAddendum(t, method); + GcMethodAddendum* addendum = method->addendum(); if (addendum) { object table = addendum->annotationTable(); if (table) { @@ -1899,11 +1899,11 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Method_getAnnotation (Thread* t, object, uintptr_t* arguments) { - object method = arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[0]))->methodTable(), - arguments[1]); + GcMethod* method = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[0]))->vmClass()->methodTable()) + ->body()[arguments[1]]); - GcMethodAddendum* addendum = methodAddendum(t, method); + GcMethodAddendum* addendum = method->addendum(); if (addendum) { object table = addendum->annotationTable(); if (table) { @@ -1921,7 +1921,7 @@ Avian_java_lang_reflect_Method_getAnnotation return reinterpret_cast (t->m->processor->invoke - (t, get, 0, methodClass(t, method)->loader(), + (t, get, 0, method->class_()->loader(), objectArrayBody(t, table, i))); } } @@ -1935,11 +1935,11 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Method_getDeclaredAnnotations (Thread* t, object, uintptr_t* arguments) { - object method = arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[0]))->methodTable(), - arguments[1]); + GcMethod* method = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[0]))->vmClass()->methodTable()) + ->body()[arguments[1]]); - GcMethodAddendum* addendum = methodAddendum(t, method); + GcMethodAddendum* addendum = method->addendum(); if (addendum) { object table = addendum->annotationTable(); if (table) { @@ -1960,7 +1960,7 @@ Avian_java_lang_reflect_Method_getDeclaredAnnotations for (unsigned i = 0; i < objectArrayLength(t, table); ++i) { object a = t->m->processor->invoke - (t, get, 0, methodClass(t, method)->loader(), + (t, get, 0, method->class_()->loader(), objectArrayBody(t, table, i)); set(t, array, ArrayBody + (i * BytesPerWord), a); @@ -1982,10 +1982,10 @@ extern "C" AVIAN_EXPORT int64_t JNICALL object, uintptr_t* arguments) { - GcField* field = cast(t, arrayBody( + GcField* field = cast(t, cast( t, - jclassVmClass(t, reinterpret_cast(arguments[0]))->fieldTable(), - arguments[1])); + cast(t, reinterpret_cast(arguments[0]))->vmClass()->fieldTable()) + ->body()[arguments[1]]); GcFieldAddendum* addendum = field->addendum(); if (addendum) { @@ -2015,7 +2015,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL = t->m->processor->invoke(t, get, 0, - classLoader(t, reinterpret_cast(arguments[0])), + cast(t, reinterpret_cast(arguments[0]))->loader(), objectArrayBody(t, table, i)); set(t, array, ArrayBody + (i * BytesPerWord), a); @@ -2036,11 +2036,11 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Method_getDefaultValue (Thread* t, object, uintptr_t* arguments) { - object method = arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[1]))->methodTable(), - arguments[2]); + GcMethod* method = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[1]))->vmClass()->methodTable()) + ->body()[arguments[2]]); - GcMethodAddendum* addendum = methodAddendum(t, method); + GcMethodAddendum* addendum = method->addendum(); if (addendum) { GcMethod* get = resolveMethod (t, cast(t, root(t, Machine::BootLoader)), "avian/Classes", @@ -2050,7 +2050,7 @@ Avian_java_lang_reflect_Method_getDefaultValue return reinterpret_cast (t->m->processor->invoke - (t, get, 0, methodClass(t, method)->loader(), addendum)); + (t, get, 0, method->class_()->loader(), addendum)); } return 0; @@ -2063,12 +2063,12 @@ Avian_java_lang_reflect_Constructor_constructNative object args = reinterpret_cast(arguments[1]); PROTECT(t, args); - GcClass* c = jclassVmClass(t, reinterpret_cast(arguments[2])); + GcClass* c = cast(t, reinterpret_cast(arguments[2]))->vmClass(); PROTECT(t, c); initClass(t, c); - GcMethod* method = cast(t, arrayBody(t, c->methodTable(), arguments[4])); + GcMethod* method = cast(t, cast(t, c->methodTable())->body()[arguments[4]]); PROTECT(t, method); object instance = makeNew(t, c); @@ -2083,9 +2083,9 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Field_getField (Thread* t, object, uintptr_t* arguments) { - GcField* field = cast(t, arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[2]))->fieldTable(), - arguments[4])); + GcField* field = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[2]))->vmClass()->fieldTable()) + ->body()[arguments[4]]); PROTECT(t, field); @@ -2099,41 +2099,41 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Field_getIField (Thread* t, object, uintptr_t* arguments) { - GcField* field = cast(t, arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[2]))->fieldTable(), - arguments[4])); + GcField* field = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[2]))->vmClass()->fieldTable()) + ->body()[arguments[4]]); PROTECT(t, field); object instance = reinterpret_cast(arguments[1]); PROTECT(t, instance); - return intValue(t, local::getField(t, field, instance)); + return cast(t, local::getField(t, field, instance))->value(); } extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Field_getJField (Thread* t, object, uintptr_t* arguments) { - GcField* field = cast(t, arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[2]))->fieldTable(), - arguments[4])); + GcField* field = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[2]))->vmClass()->fieldTable()) + ->body()[arguments[4]]); PROTECT(t, field); object instance = reinterpret_cast(arguments[1]); PROTECT(t, instance); - return longValue(t, local::getField(t, field, instance)); + return cast(t, local::getField(t, field, instance))->value(); } extern "C" AVIAN_EXPORT void JNICALL Avian_java_lang_reflect_Field_setField (Thread* t, object, uintptr_t* arguments) { - GcField* field = cast(t, arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[2]))->fieldTable(), - arguments[4])); + GcField* field = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[2]))->vmClass()->fieldTable()) + ->body()[arguments[4]]); PROTECT(t, field); @@ -2150,9 +2150,9 @@ extern "C" AVIAN_EXPORT void JNICALL Avian_java_lang_reflect_Field_setIField (Thread* t, object, uintptr_t* arguments) { - GcField* field = cast(t, arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[2]))->fieldTable(), - arguments[4])); + GcField* field = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[2]))->vmClass()->fieldTable()) + ->body()[arguments[4]]); object instance = reinterpret_cast(arguments[1]); PROTECT(t, instance); @@ -2166,19 +2166,19 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Field_getFieldModifiers (Thread* t, object, uintptr_t* arguments) { - return fieldFlags - (t, arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[1]))->fieldTable(), - arguments[2])); + return cast + (t, cast + (t, cast(t, reinterpret_cast(arguments[1]))->vmClass()->fieldTable()) + ->body()[arguments[2]])->flags(); } extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Field_getAnnotation (Thread* t, object, uintptr_t* arguments) { - GcField* field = cast(t, arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[0]))->fieldTable(), - arguments[1])); + GcField* field = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[0]))->vmClass()->fieldTable()) + ->body()[arguments[1]]); GcFieldAddendum* addendum = field->addendum(); if (addendum) { @@ -2212,19 +2212,19 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_reflect_Field_getSignatureAnnotation (Thread* t, object, uintptr_t* arguments) { - GcField* field = cast(t, arrayBody - (t, jclassVmClass(t, reinterpret_cast(arguments[1]))->fieldTable(), - arguments[2])); + GcField* field = cast(t, cast + (t, cast(t, reinterpret_cast(arguments[1]))->vmClass()->fieldTable()) + ->body()[arguments[2]]); - object addendum = reinterpret_cast(field->addendum()); + GcFieldAddendum* addendum = field->addendum(); if (addendum) { - object signature = addendumSignature(t, addendum); + GcByteArray* signature = cast(t, addendum->signature()); if (signature) { object array = makeObjectArray(t, 1); PROTECT(t, array); GcString* string = t->m->classpath->makeString - (t, signature, 0, byteArrayLength(t, signature) - 1); + (t, reinterpret_cast(signature), 0, signature->length() - 1); set(t, array, ArrayBody, reinterpret_cast(string)); @@ -2274,7 +2274,7 @@ Avian_java_lang_reflect_Array_createObjectArray { return reinterpret_cast (makeObjectArray - (t, jclassVmClass(t, reinterpret_cast(arguments[0])), + (t, cast(t, reinterpret_cast(arguments[0]))->vmClass(), arguments[1])); } @@ -2289,15 +2289,15 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_dalvik_system_VMRuntime_newNonMovableArray (Thread* t, object, uintptr_t* arguments) { - if (jclassVmClass(t, reinterpret_cast(arguments[1])) + if (cast(t, reinterpret_cast(arguments[1]))->vmClass() == type(t, GcJbyte::Type)) { - object array = allocate3 + GcByteArray* array = reinterpret_cast(allocate3 (t, t->m->heap, Machine::FixedAllocation, - ArrayBody + arguments[2], false); + ArrayBody + arguments[2], false)); - setObjectClass(t, array, type(t, GcByteArray::Type)); - byteArrayLength(t, array) = arguments[2]; + setObjectClass(t, reinterpret_cast(array), type(t, GcByteArray::Type)); + array->length() = arguments[2]; return reinterpret_cast(array); } else { @@ -2427,7 +2427,7 @@ extern "C" AVIAN_EXPORT void JNICALL Avian_libcore_io_OsConstants_initConstants (Thread* t, object method, uintptr_t*) { - object c = methodClass(t, method); + object c = method->class_(); PROTECT(t, c); object table = classStaticTable(t, c); diff --git a/src/classpath-avian.cpp b/src/classpath-avian.cpp index b34ff2cc78..985d6107a8 100644 --- a/src/classpath-avian.cpp +++ b/src/classpath-avian.cpp @@ -82,9 +82,9 @@ class MyClasspath : public Classpath { } virtual GcField* - getVMField(Thread* t, object jfield) + getVMField(Thread* t UNUSED, GcJfield* jfield) { - return cast(t, jfield)->vmField(); + return jfield->vmField(); } virtual void diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 889c4e1827..dcec53bf83 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -316,7 +316,7 @@ primitiveName(Thread* t, GcClass* c) } } -object +GcByteArray* getClassName(Thread* t, GcClass* c) { if (c->name() == 0) { @@ -331,15 +331,15 @@ getClassName(Thread* t, GcClass* c) } } - return reinterpret_cast(c->name()); + return c->name(); } GcString* -makeClassNameString(Thread* t, object name) +makeClassNameString(Thread* t, GcByteArray* name) { - THREAD_RUNTIME_ARRAY(t, char, s, byteArrayLength(t, name)); + THREAD_RUNTIME_ARRAY(t, char, s, name->length()); replace('/', '.', RUNTIME_ARRAY_BODY(s), - reinterpret_cast(&byteArrayBody(t, name, 0))); + reinterpret_cast(name->body().begin())); return makeString(t, "%s", RUNTIME_ARRAY_BODY(s)); } @@ -498,14 +498,15 @@ class MyClasspath : public Classpath { } virtual GcString* - makeString(Thread* t, object array, int32_t offset, int32_t length) + makeString(Thread* t, object oarray, int32_t offset, int32_t length) { - if (objectClass(t, array) == type(t, GcByteArray::Type)) { + if (objectClass(t, oarray) == type(t, GcByteArray::Type)) { + GcByteArray* array = cast(t, oarray); PROTECT(t, array); GcCharArray* charArray = makeCharArray(t, length); for (int i = 0; i < length; ++i) { - if (byteArrayBody(t, array, offset + i) & 0x80) { + if (array->body()[offset + i] & 0x80) { GcMethod* constructor = resolveMethod (t, type(t, GcString::Type), "", "([BIILjava/lang/String;)V"); @@ -523,15 +524,15 @@ class MyClasspath : public Classpath { return cast(t, s); } - charArrayBody(t, reinterpret_cast(charArray), i) = byteArrayBody(t, array, offset + i); + charArray->body()[i] = array->body()[offset + i]; } - array = reinterpret_cast(charArray); + oarray = reinterpret_cast(charArray); } else { - expect(t, objectClass(t, array) == type(t, GcCharArray::Type)); + expect(t, objectClass(t, oarray) == type(t, GcCharArray::Type)); } - return vm::makeString(t, array, offset, length, 0); + return vm::makeString(t, oarray, offset, length, 0); } virtual GcThread* @@ -591,13 +592,21 @@ class MyClasspath : public Classpath { virtual GcMethod* getVMMethod(Thread* t, object jmethod) { - return cast(t, objectClass(t, jmethod) == type(t, GcJmethod::Type) - ? arrayBody - (t, jmethodClazz(t, jmethod)->vmClass()->methodTable(), - jmethodSlot(t, jmethod)) - : arrayBody - (t, jconstructorClazz(t, jmethod)->vmClass()->methodTable(), - jconstructorSlot(t, jmethod))); + return cast( + t, + objectClass(t, jmethod) == type(t, GcJmethod::Type) + ? cast(t, + cast(t, jmethod) + ->clazz() + ->vmClass() + ->methodTable()) + ->body()[cast(t, jmethod)->slot()] + : cast(t, + cast(t, jmethod) + ->clazz() + ->vmClass() + ->methodTable()) + ->body()[cast(t, jmethod)->slot()]); } virtual object @@ -607,10 +616,12 @@ class MyClasspath : public Classpath { } virtual GcField* - getVMField(Thread* t, object jfield) + getVMField(Thread* t, GcJfield* jfield) { - return cast(t, arrayBody - (t, jfieldClazz(t, jfield)->vmClass()->fieldTable(), jfieldSlot(t, jfield))); + return cast + (t, + cast(t, jfield->clazz()->vmClass()->fieldTable()) + ->body()[jfield->slot()]); } virtual void @@ -2109,17 +2120,17 @@ classDeclaredMethodCount(Thread* t, GcClass* c) return count; } } - object table = c->methodTable(); - return table == 0 ? 0 : arrayLength(t, table); + GcArray* table = cast(t, c->methodTable()); + return table == 0 ? 0 : table->length(); } unsigned countMethods(Thread* t, GcClass* c, bool publicOnly) { - object table = c->methodTable(); + GcArray* table = cast(t, c->methodTable()); unsigned count = 0; for (unsigned i = 0, j = classDeclaredMethodCount(t, c); i < j; ++i) { - GcMethod* vmMethod = cast(t, arrayBody(t, table, i)); + GcMethod* vmMethod = cast(t, table->body()[i]); if (((not publicOnly) or (vmMethod->flags() & ACC_PUBLIC)) and vmMethod->name()->body()[0] != '<') { @@ -2132,28 +2143,28 @@ countMethods(Thread* t, GcClass* c, bool publicOnly) unsigned countFields(Thread* t, GcClass* c, bool publicOnly) { - object table = c->fieldTable(); + GcArray* table = cast(t, c->fieldTable()); if (publicOnly) { unsigned count = 0; - for (unsigned i = 0; i < arrayLength(t, table); ++i) { - GcField* vmField = cast(t, arrayBody(t, table, i)); + for (unsigned i = 0; i < table->length(); ++i) { + GcField* vmField = cast(t, table->body()[i]); if (vmField->flags() & ACC_PUBLIC) { ++ count; } } return count; } else { - return objectArrayLength(t, table); + return objectArrayLength(t, reinterpret_cast(table)); } } unsigned countConstructors(Thread* t, GcClass* c, bool publicOnly) { - object table = c->methodTable(); + GcArray* table = cast(t, c->methodTable()); unsigned count = 0; for (unsigned i = 0, j = classDeclaredMethodCount(t, c); i < j; ++i) { - GcMethod* vmMethod = cast(t, arrayBody(t, table, i)); + GcMethod* vmMethod = cast(t, table->body()[i]); if (((not publicOnly) or (vmMethod->flags() & ACC_PUBLIC)) and strcmp(reinterpret_cast (vmMethod->name()->body().begin()), @@ -2249,22 +2260,21 @@ makeJmethod(Thread* t, GcMethod* vmMethod, int index) object annotationTable; object parameterAnnotationTable; object annotationDefault; - object addendum = reinterpret_cast(vmMethod->addendum()); + GcMethodAddendum* addendum = vmMethod->addendum(); if (addendum) { - signature = addendumSignature(t, addendum); + signature = addendum->signature(); if (signature) { PROTECT(t, addendum); signature = reinterpret_cast(t->m->classpath->makeString - (t, signature, 0, byteArrayLength(t, signature) - 1)); + (t, signature, 0, cast(t, signature)->length() - 1)); } - annotationTable = addendumAnnotationTable(t, addendum); + annotationTable = addendum->annotationTable(); - parameterAnnotationTable = methodAddendumParameterAnnotationTable - (t, addendum); + parameterAnnotationTable = addendum->parameterAnnotationTable(); - annotationDefault = methodAddendumAnnotationDefault(t, addendum); + annotationDefault = addendum->annotationDefault(); } else { signature = 0; annotationTable = 0; @@ -2285,9 +2295,9 @@ makeJmethod(Thread* t, GcMethod* vmMethod, int index) } if (index == -1) { - object table = vmMethod->class_()->methodTable(); - for (unsigned i = 0; i < arrayLength(t, table); ++i) { - if (reinterpret_cast(vmMethod) == arrayBody(t, table, i)) { + GcArray* table = cast(t, vmMethod->class_()->methodTable()); + for (unsigned i = 0; i < table->length(); ++i) { + if (reinterpret_cast(vmMethod) == table->body()[i]) { index = i; break; } @@ -2324,19 +2334,18 @@ makeJconstructor(Thread* t, GcMethod* vmMethod, int index) object signature; object annotationTable; object parameterAnnotationTable; - object addendum = reinterpret_cast(vmMethod->addendum()); + GcMethodAddendum* addendum = vmMethod->addendum(); if (addendum) { - signature = addendumSignature(t, addendum); + signature = addendum->signature(); if (signature) { PROTECT(t, addendum); signature = reinterpret_cast(t->m->classpath->makeString - (t, signature, 0, byteArrayLength(t, signature) - 1)); + (t, signature, 0, cast(t, signature)->length() - 1)); } - annotationTable = addendumAnnotationTable(t, addendum); - parameterAnnotationTable = methodAddendumParameterAnnotationTable - (t, addendum); + annotationTable = addendum->annotationTable(); + parameterAnnotationTable = addendum->parameterAnnotationTable(); } else { signature = 0; annotationTable = 0; @@ -2355,9 +2364,9 @@ makeJconstructor(Thread* t, GcMethod* vmMethod, int index) } if (index == -1) { - object table = vmMethod->class_()->methodTable(); - for (unsigned i = 0; i < arrayLength(t, table); ++i) { - if (reinterpret_cast(vmMethod) == arrayBody(t, table, i)) { + GcArray* table = cast(t, vmMethod->class_()->methodTable()); + for (unsigned i = 0; i < table->length(); ++i) { + if (reinterpret_cast(vmMethod) == table->body()[i]) { index = i; break; } @@ -2414,7 +2423,7 @@ makeJfield(Thread* t, GcField* vmField, int index) PROTECT(t, addendum); signature = reinterpret_cast(t->m->classpath->makeString - (t, signature, 0, byteArrayLength(t, signature) - 1)); + (t, signature, 0, cast(t, signature)->length() - 1)); } annotationTable = addendum->annotationTable(); @@ -2434,9 +2443,9 @@ makeJfield(Thread* t, GcField* vmField, int index) } if (index == -1) { - object table = vmField->class_()->fieldTable(); - for (unsigned i = 0; i < arrayLength(t, table); ++i) { - if (reinterpret_cast(vmField) == arrayBody(t, table, i)) { + GcArray* table = cast(t, vmField->class_()->fieldTable()); + for (unsigned i = 0; i < table->length(); ++i) { + if (reinterpret_cast(vmField) == table->body()[i]) { index = i; break; } @@ -2511,7 +2520,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_lang_Class_getSuperclass (Thread* t, object, uintptr_t* arguments) { - GcClass* class_ = jclassVmClass(t, reinterpret_cast(arguments[0])); + GcClass* class_ = cast(t, reinterpret_cast(arguments[0]))->vmClass(); if (class_->flags() & ACC_INTERFACE) { return 0; } else { @@ -2557,7 +2566,7 @@ Avian_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoade (Thread* t, object, uintptr_t* arguments) { //object name = reinterpret_cast(arguments[1]); - object data = reinterpret_cast(arguments[2]); + GcByteArray* data = cast(t, reinterpret_cast(arguments[2])); int32_t offset = arguments[3]; int32_t length = arguments[4]; GcClassLoader* loader = cast(t, reinterpret_cast(arguments[5])); @@ -2568,7 +2577,7 @@ Avian_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoade THREAD_RESOURCE2(t, uint8_t*, buffer, int, length, t->m->heap->free(buffer, length)); - memcpy(buffer, &byteArrayBody(t, data, offset), length); + memcpy(buffer, &data->body()[offset], length); return reinterpret_cast (getJClass(t, cast(t, defineClass(t, loader, buffer, length)))); @@ -2578,7 +2587,7 @@ extern "C" AVIAN_EXPORT int64_t Avian_sun_misc_Unsafe_allocateInstance (Thread* t, object, uintptr_t* arguments) { - GcClass* c = jclassVmClass(t, reinterpret_cast(arguments[1])); + GcClass* c = cast(t, reinterpret_cast(arguments[1]))->vmClass(); PROTECT(t, c); initClass(t, c); @@ -2590,10 +2599,10 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_sun_misc_Unsafe_staticFieldOffset (Thread* t, object, uintptr_t* arguments) { - object jfield = reinterpret_cast(arguments[1]); - return fieldOffset - (t, arrayBody - (t, jfieldClazz(t, jfield)->vmClass()->fieldTable(), jfieldSlot(t, jfield))); + GcJfield* jfield = cast(t, reinterpret_cast(arguments[1])); + return cast + (t, cast + (t, jfield->clazz()->vmClass()->fieldTable())->body()[jfield->slot()])->offset(); } extern "C" AVIAN_EXPORT int64_t JNICALL @@ -2601,17 +2610,17 @@ Avian_sun_misc_Unsafe_staticFieldBase (Thread* t, object, uintptr_t* arguments) { return reinterpret_cast - (jfieldClazz(t, reinterpret_cast(arguments[1]))->vmClass()->staticTable()); + (cast(t, reinterpret_cast(arguments[1]))->clazz()->vmClass()->staticTable()); } extern "C" AVIAN_EXPORT int64_t JNICALL Avian_sun_misc_Unsafe_objectFieldOffset (Thread* t, object, uintptr_t* arguments) { - object jfield = reinterpret_cast(arguments[1]); - return fieldOffset - (t, arrayBody - (t, jfieldClazz(t, jfield)->vmClass()->fieldTable(), jfieldSlot(t, jfield))); + GcJfield* jfield = cast(t, reinterpret_cast(arguments[1])); + return cast + (t, cast + (t, jfield->clazz()->vmClass()->fieldTable())->body()[jfield->slot()])->offset(); } extern "C" AVIAN_EXPORT int64_t JNICALL @@ -2778,7 +2787,7 @@ extern "C" AVIAN_EXPORT void JNICALL Avian_sun_misc_Unsafe_ensureClassInitialized (Thread* t, object, uintptr_t* arguments) { - initClass(t, jclassVmClass(t, reinterpret_cast(arguments[1]))); + initClass(t, cast(t, reinterpret_cast(arguments[1]))->vmClass()); } extern "C" AVIAN_EXPORT void JNICALL @@ -3212,7 +3221,7 @@ EXPORT(JVM_GetStackTraceDepth)(Thread* t, jobject throwable) { ENTER(t, Thread::ActiveState); - return objectArrayLength(t, throwableTrace(t, *throwable)); + return objectArrayLength(t, cast(t, *throwable)->trace()); } uint64_t @@ -3224,7 +3233,7 @@ jvmGetStackTraceElement(Thread* t, uintptr_t* arguments) return reinterpret_cast (makeLocalReference (t, reinterpret_cast(makeStackTraceElement - (t, cast(t, objectArrayBody(t, throwableTrace(t, *throwable), index)))))); + (t, cast(t, objectArrayBody(t, cast(t, *throwable)->trace(), index)))))); } extern "C" AVIAN_EXPORT jobject JNICALL @@ -3293,7 +3302,7 @@ EXPORT(JVM_IsThreadAlive)(Thread* t, jobject thread) { ENTER(t, Thread::ActiveState); - Thread* p = reinterpret_cast(threadPeer(t, *thread)); + Thread* p = reinterpret_cast(cast(t, *thread)->peer()); return p and (p->flags & Thread::ActiveFlag) != 0; } @@ -3484,8 +3493,7 @@ jvmGetClassContext(Thread* t, uintptr_t*) for (unsigned i = 0; i < objectArrayLength(t, trace); ++i) { object c = reinterpret_cast(getJClass( t, - methodClass(t, - traceElementMethod(t, objectArrayBody(t, trace, i))))); + cast(t, cast(t, objectArrayBody(t, trace, i))->method())->class_())); set(t, context, ArrayBody + (i * BytesPerWord), c); } @@ -3517,14 +3525,14 @@ jvmGetSystemPackage(Thread* t, uintptr_t* arguments) object key = reinterpret_cast(makeByteArray(t, RUNTIME_ARRAY_BODY(chars))); - object array = hashMapFind - (t, cast(t, root(t, Machine::PackageMap)), key, byteArrayHash, byteArrayEqual); + GcByteArray* array = cast(t, hashMapFind + (t, cast(t, root(t, Machine::PackageMap)), key, byteArrayHash, byteArrayEqual)); if (array) { return reinterpret_cast (makeLocalReference (t, reinterpret_cast(t->m->classpath->makeString - (t, array, 0, byteArrayLength(t, array))))); + (t, reinterpret_cast(array), 0, array->length())))); } else { return 0; } @@ -3681,28 +3689,28 @@ EXPORT(JVM_SetArrayElement)(Thread* t, jobject array, jint index, switch (objectClass(t, *array)->name()->body()[1]) { case 'Z': - fieldAtOffset(*array, ArrayBody + index) = booleanValue(t, *value); + fieldAtOffset(*array, ArrayBody + index) = cast(t, *value)->value(); break; case 'B': - fieldAtOffset(*array, ArrayBody + index) = byteValue(t, *value); + fieldAtOffset(*array, ArrayBody + index) = cast(t, *value)->value(); break; case 'C': - fieldAtOffset(*array, ArrayBody + (index * 2)) = charValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 2)) = cast(t, *value)->value(); break; case 'S': - fieldAtOffset(*array, ArrayBody + (index * 2)) = shortValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 2)) = cast(t, *value)->value(); break; case 'I': - fieldAtOffset(*array, ArrayBody + (index * 4)) = intValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 4)) = cast(t, *value)->value(); break; case 'F': - fieldAtOffset(*array, ArrayBody + (index * 4)) = floatValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 4)) = cast(t, *value)->value(); break; case 'J': - fieldAtOffset(*array, ArrayBody + (index * 8)) = longValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 8)) = cast(t, *value)->value(); break; case 'D': - fieldAtOffset(*array, ArrayBody + (index * 8)) = doubleValue(t, *value); + fieldAtOffset(*array, ArrayBody + (index * 8)) = cast(t, *value)->value(); break; case 'L': case '[': @@ -3718,11 +3726,11 @@ EXPORT(JVM_SetPrimitiveArrayElement)(Thread*, jobject, jint, jvalue, unsigned char) { abort(); } object -makeNewArray(Thread* t, object c, unsigned length) +makeNewArray(Thread* t, GcClass* c, unsigned length) { - if (classVmFlags(t, c) & PrimitiveFlag) { + if (c->vmFlags() & PrimitiveFlag) { const char* name = reinterpret_cast - (&byteArrayBody(t, local::getClassName(t, cast(t, c)), 0)); + (local::getClassName(t, c)->body().begin()); switch (*name) { case 'b': @@ -3740,7 +3748,7 @@ makeNewArray(Thread* t, object c, unsigned length) default: abort(t); } } else { - return reinterpret_cast(makeObjectArray(t, cast(t, c), length)); + return reinterpret_cast(makeObjectArray(t, c, length)); } } @@ -3752,7 +3760,7 @@ jvmNewArray(Thread* t, uintptr_t* arguments) return reinterpret_cast (makeLocalReference - (t, makeNewArray(t, reinterpret_cast((*elementClass)->vmClass()), length))); + (t, makeNewArray(t, (*elementClass)->vmClass(), length))); } extern "C" AVIAN_EXPORT jobject JNICALL @@ -3781,7 +3789,7 @@ jvmNewMultiArray(Thread* t, uintptr_t* arguments) } object array = makeNewArray - (t, reinterpret_cast((*elementClass)->vmClass()), RUNTIME_ARRAY_BODY(counts)[0]); + (t, (*elementClass)->vmClass(), RUNTIME_ARRAY_BODY(counts)[0]); PROTECT(t, array); populateMultiArray(t, array, RUNTIME_ARRAY_BODY(counts), 0, @@ -4001,16 +4009,16 @@ jvmGetClassInterfaces(Thread* t, uintptr_t* arguments) GcClassAddendum* addendum = (*c)->vmClass()->addendum(); if (addendum) { - object table = addendum->interfaceTable(); + GcArray* table = cast(t, addendum->interfaceTable()); if (table) { PROTECT(t, table); object array = makeObjectArray - (t, type(t, GcJclass::Type), arrayLength(t, table)); + (t, type(t, GcJclass::Type), table->length()); PROTECT(t, array); - for (unsigned i = 0; i < arrayLength(t, table); ++i) { - object c = reinterpret_cast(getJClass(t, cast(t, arrayBody(t, table, i)))); + for (unsigned i = 0; i < table->length(); ++i) { + object c = reinterpret_cast(getJClass(t, cast(t, table->body()[i]))); set(t, array, ArrayBody + (i * BytesPerWord), c); } @@ -4070,10 +4078,10 @@ EXPORT(JVM_GetClassSigners)(Thread* t, jclass c) { ENTER(t, Thread::ActiveState); - object runtimeData = getClassRuntimeDataIfExists(t, (*c)->vmClass()); + GcClassRuntimeData* runtimeData = getClassRuntimeDataIfExists(t, (*c)->vmClass()); return runtimeData ? reinterpret_cast(makeLocalReference - (t, classRuntimeDataSigners(t, runtimeData))) : 0; + (t, runtimeData->signers())) : 0; } extern "C" AVIAN_EXPORT jbyteArray JNICALL @@ -4177,7 +4185,7 @@ uint64_t jvmGetClassModifiers(Thread* t, uintptr_t* arguments) { return classModifiers - (t, jclassVmClass(t, *reinterpret_cast(arguments[0]))); + (t, cast(t, *reinterpret_cast(arguments[0]))->vmClass()); } extern "C" AVIAN_EXPORT jint JNICALL @@ -4194,7 +4202,7 @@ jvmGetDeclaredClasses(Thread* t, uintptr_t* arguments) return reinterpret_cast (makeLocalReference (t, getDeclaredClasses - (t, jclassVmClass(t, *reinterpret_cast(arguments[0])), false))); + (t, cast(t, *reinterpret_cast(arguments[0]))->vmClass(), false))); } extern "C" AVIAN_EXPORT jobjectArray JNICALL @@ -4211,7 +4219,7 @@ jvmGetDeclaringClass(Thread* t, uintptr_t* arguments) return reinterpret_cast (makeLocalReference (t, reinterpret_cast(getDeclaringClass - (t, jclassVmClass(t, *reinterpret_cast(arguments[0])))))); + (t, cast(t, *reinterpret_cast(arguments[0]))->vmClass())))); } extern "C" AVIAN_EXPORT jclass JNICALL @@ -4229,12 +4237,12 @@ jvmGetClassSignature(Thread* t, uintptr_t* arguments) GcClassAddendum* addendum = (*c)->vmClass()->addendum(); if (addendum) { - object signature = addendum->signature(); + GcByteArray* signature = cast(t, addendum->signature()); if (signature) { return reinterpret_cast (makeLocalReference (t, reinterpret_cast(t->m->classpath->makeString - (t, signature, 0, byteArrayLength(t, signature) - 1)))); + (t, reinterpret_cast(signature), 0, signature->length() - 1)))); } } return 0; @@ -4264,7 +4272,7 @@ jvmGetClassDeclaredMethods(Thread* t, uintptr_t* arguments) jclass c = reinterpret_cast(arguments[0]); jboolean publicOnly = arguments[1]; - object table = (*c)->vmClass()->methodTable(); + GcArray* table = cast(t, (*c)->vmClass()->methodTable()); if (table) { PROTECT(t, table); @@ -4277,7 +4285,7 @@ jvmGetClassDeclaredMethods(Thread* t, uintptr_t* arguments) for (unsigned i = 0, j = classDeclaredMethodCount(t, (*c)->vmClass()); i < j; ++i) { - GcMethod* vmMethod = cast(t, arrayBody(t, table, i)); + GcMethod* vmMethod = cast(t, table->body()[i]); PROTECT(t, vmMethod); if (((not publicOnly) or (vmMethod->flags() & ACC_PUBLIC)) @@ -4313,7 +4321,7 @@ jvmGetClassDeclaredFields(Thread* t, uintptr_t* arguments) { jclass c = reinterpret_cast(arguments[0]); jboolean publicOnly = arguments[1]; - object table = (*c)->vmClass()->fieldTable(); + GcArray* table = cast(t, (*c)->vmClass()->fieldTable()); if (table) { PROTECT(t, table); @@ -4323,8 +4331,8 @@ jvmGetClassDeclaredFields(Thread* t, uintptr_t* arguments) PROTECT(t, array); unsigned ai = 0; - for (unsigned i = 0; i < arrayLength(t, table); ++i) { - GcField* vmField = cast(t, arrayBody(t, table, i)); + for (unsigned i = 0; i < table->length(); ++i) { + GcField* vmField = cast(t, table->body()[i]); PROTECT(t, vmField); if ((not publicOnly) or (vmField->flags() & ACC_PUBLIC)) { @@ -4360,7 +4368,7 @@ jvmGetClassDeclaredConstructors(Thread* t, uintptr_t* arguments) jclass c = reinterpret_cast(arguments[0]); jboolean publicOnly = arguments[1]; - object table = (*c)->vmClass()->methodTable(); + GcArray* table = cast(t, (*c)->vmClass()->methodTable()); if (table) { PROTECT(t, table); @@ -4373,7 +4381,7 @@ jvmGetClassDeclaredConstructors(Thread* t, uintptr_t* arguments) for (unsigned i = 0, j = classDeclaredMethodCount(t, (*c)->vmClass()); i < j; ++i) { - GcMethod* vmMethod = cast(t, arrayBody(t, table, i)); + GcMethod* vmMethod = cast(t, table->body()[i]); PROTECT(t, vmMethod); if (((not publicOnly) or (vmMethod->flags() & ACC_PUBLIC)) @@ -4422,9 +4430,9 @@ jvmInvokeMethod(Thread* t, uintptr_t* arguments) jobject instance = reinterpret_cast(arguments[1]); jobjectArray args = reinterpret_cast(arguments[2]); - GcMethod* vmMethod = cast(t, arrayBody - (t, jmethodClazz(t, *method)->vmClass()->methodTable(), - jmethodSlot(t, *method))); + GcMethod* vmMethod = cast(t, cast + (t, cast(t, *method)->clazz()->vmClass()->methodTable())->body()[ + cast(t, *method)->slot()]); if (vmMethod->flags() & ACC_STATIC) { instance = 0; @@ -4458,12 +4466,12 @@ jvmNewInstanceFromConstructor(Thread* t, uintptr_t* arguments) jobjectArray args = reinterpret_cast(arguments[1]); object instance = make - (t, jconstructorClazz(t, *constructor)->vmClass()); + (t, cast(t, *constructor)->clazz()->vmClass()); PROTECT(t, instance); - GcMethod* method = cast(t, arrayBody - (t, jconstructorClazz(t, *constructor)->vmClass()->methodTable(), - jconstructorSlot(t, *constructor))); + GcMethod* method = cast(t, cast + (t, cast(t, *constructor)->clazz()->vmClass()->methodTable())->body()[ + cast(t, *constructor)->slot()]); invoke(t, method, reinterpret_cast(instance), args ? reinterpret_cast(*args) : 0); @@ -5265,20 +5273,20 @@ getEnclosingMethodInfo(Thread* t, uintptr_t* arguments) set(t, array, ArrayBody, enclosingClass); - object enclosingMethod = addendum->enclosingMethod(); + GcPair* enclosingMethod = cast(t, addendum->enclosingMethod()); if (enclosingMethod) { PROTECT(t, enclosingMethod); GcString* name = t->m->classpath->makeString - (t, pairFirst(t, enclosingMethod), 0, - byteArrayLength(t, pairFirst(t, enclosingMethod)) - 1); + (t, enclosingMethod->first(), 0, + cast(t, enclosingMethod->first())->length() - 1); set(t, array, ArrayBody + BytesPerWord, reinterpret_cast(name)); GcString* spec = t->m->classpath->makeString - (t, pairSecond(t, enclosingMethod), 0, - byteArrayLength(t, pairSecond(t, enclosingMethod)) - 1); + (t, enclosingMethod->second(), 0, + cast(t, enclosingMethod->second())->length() - 1); set(t, array, ArrayBody + (2 * BytesPerWord), reinterpret_cast(spec)); } diff --git a/src/jnienv.cpp b/src/jnienv.cpp index ca0a8f2be3..acb7024348 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -3241,7 +3241,7 @@ fromReflectedField(Thread* t, uintptr_t* arguments) { jobject f = reinterpret_cast(arguments[0]); - return fieldID(t, t->m->classpath->getVMField(t, *f)); + return fieldID(t, t->m->classpath->getVMField(t, cast(t, *f))); } jfieldID JNICALL diff --git a/src/tools/type-generator/main.cpp b/src/tools/type-generator/main.cpp index f90b763acb..8f13544e8b 100644 --- a/src/tools/type-generator/main.cpp +++ b/src/tools/type-generator/main.cpp @@ -875,14 +875,8 @@ std::string cppFieldType(Module& module, Field& f) { } } -void writeAccessorName(Output* out, Class* cl, Field& field) -{ - out->write(cl->name); - out->write(capitalize(field.name)); -} - void -writeAccessor(Output* out, Module& module, Class* cl, Field& field, bool isArray) +writeAccessor(Output* out, Class* cl, Field& field) { std::string typeName = field.typeName; @@ -897,61 +891,6 @@ writeAccessor(Output* out, Module& module, Class* cl, Field& field, bool isArray out->write(capitalize(cl->name)); out->write(capitalize(field.name)); out->write(" 1\n\n"); - - out->write("inline "); - - // if (endsWith("[0]", typeName)) { - // out->write(take(strlen(typeName) - 3, typeName)); - // out->write("*"); - // } else { - out->write(cppFieldType(module, field)); - out->write("&"); - // } - - out->write("\n"); - writeAccessorName(out, cl, field); - out->write("(Thread* t UNUSED, object"); - out->write(" o"); - if (isArray) { - out->write(", unsigned i"); - } - out->write(") {\n"); - - out->write(" assertT(t, t->m->unsafe or "); - out->write("instanceOf(t, reinterpret_cast(arrayBodyUnsafe"); - out->write("(t, t->m->types, Gc::"); - out->write(capitalize(cl->name)); - out->write("Type))"); - out->write(", o));\n"); - - if (isArray) { - out->write(" assertT(t, i < "); - out->write(cl->name); - out->write("Length(t, o));\n"); - } - - out->write(" return *reinterpret_cast<"); - - // if (endsWith("[0]", typeName)) { - // out->write(take(strlen(typeName) - 3, typeName)); - // out->write("*"); - // } else { - out->write(cppFieldType(module, field)); - out->write("*"); - // } - - out->write(">(reinterpret_cast(o) + "); - - out->write(capitalize(cl->name)); - out->write(capitalize(field.name)); - - if (isArray) { - out->write(" + (i * "); - unsigned elementSize = sizeOf(module, field.typeName); - out->write(elementSize); - out->write(")"); - } - out->write(");\n}\n\n"); } void @@ -963,11 +902,11 @@ writeAccessors(Output* out, Module& module) Field& f = **it; if(!f.polyfill) { - writeAccessor(out, module, cl, f, false); + writeAccessor(out, cl, f); } } if(cl->arrayField) { - writeAccessor(out, module, cl, *cl->arrayField, true); + writeAccessor(out, cl, *cl->arrayField); } } }