mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
remove old function-based accessors
This commit is contained in:
parent
a1583f1ecc
commit
75f2dd013c
@ -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<GcCharArray>(t, odata);
|
||||
if (offset == 0 and length == data->length()) {
|
||||
return makeString(t, reinterpret_cast<object>(data), 0, 0);
|
||||
} else {
|
||||
PROTECT(t, data);
|
||||
|
||||
object array = reinterpret_cast<object>(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<object>(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<GcVector>(t, root(t, Machine::ClassRuntimeDataTable))->body()[c->runtimeDataIndex() - 1];
|
||||
return cast<GcClassRuntimeData>(t, cast<GcVector>(t, root(t, Machine::ClassRuntimeDataTable))->body()[c->runtimeDataIndex() - 1]);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -111,8 +111,7 @@ makeMethodOrConstructor(Thread* t, GcJclass* c, unsigned index)
|
||||
{
|
||||
PROTECT(t, c);
|
||||
|
||||
GcMethod* method = cast<GcMethod>(t, arrayBody
|
||||
(t, c->vmClass()->methodTable(), index));
|
||||
GcMethod* method = cast<GcMethod>(t, cast<GcArray>(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<GcField>(t, arrayBody
|
||||
(t, c->vmClass()->fieldTable(), index));
|
||||
GcField* field = cast<GcField>(t, cast<GcArray>
|
||||
(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<GcByteArray>(t, array);
|
||||
PROTECT(t, array);
|
||||
PROTECT(t, byteArray);
|
||||
|
||||
object charArray = reinterpret_cast<object>(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<object>(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<object>(vmMethod) == arrayBody(t, table, i)) {
|
||||
GcArray* table = cast<GcArray>(t, vmMethod->class_()->methodTable());
|
||||
for (unsigned i = 0; i < table->length(); ++i) {
|
||||
if (reinterpret_cast<object>(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<GcMethod>(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<GcArray>
|
||||
(t, cast<GcJmethod>(t, jmethod)->declaringClass()->vmClass()->methodTable())
|
||||
->body()[cast<GcJmethod>(t, jmethod)->slot()]
|
||||
: cast<GcArray>
|
||||
(t, cast<GcJconstructor>(t, jmethod)->declaringClass()->vmClass()->methodTable())
|
||||
->body()[cast<GcJconstructor>(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<object>(vmField) == arrayBody(t, table, i)) {
|
||||
GcArray* table = cast<GcArray>(t, vmField->class_()->fieldTable());
|
||||
for (unsigned i = 0; i < table->length(); ++i) {
|
||||
if (reinterpret_cast<object>(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<GcField>(t, arrayBody
|
||||
(t, jfieldDeclaringClass(t, jfield)->vmClass()->fieldTable(),
|
||||
jfieldSlot(t, jfield)));
|
||||
return cast<GcField>(t, cast<GcArray>
|
||||
(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<int8_t>(target, offset) = byteValue(t, value);
|
||||
fieldAtOffset<int8_t>(target, offset) = cast<GcByte>(t, value)->value();
|
||||
break;
|
||||
|
||||
case BooleanField:
|
||||
fieldAtOffset<int8_t>(target, offset) = booleanValue(t, value);
|
||||
fieldAtOffset<int8_t>(target, offset) = cast<GcBoolean>(t, value)->value();
|
||||
break;
|
||||
|
||||
case CharField:
|
||||
fieldAtOffset<int16_t>(target, offset) = charValue(t, value);
|
||||
fieldAtOffset<int16_t>(target, offset) = cast<GcChar>(t, value)->value();
|
||||
break;
|
||||
|
||||
case ShortField:
|
||||
fieldAtOffset<int16_t>(target, offset) = shortValue(t, value);
|
||||
fieldAtOffset<int16_t>(target, offset) = cast<GcShort>(t, value)->value();
|
||||
break;
|
||||
|
||||
case IntField:
|
||||
fieldAtOffset<int32_t>(target, offset) = intValue(t, value);
|
||||
fieldAtOffset<int32_t>(target, offset) = cast<GcInt>(t, value)->value();
|
||||
break;
|
||||
|
||||
case LongField:
|
||||
fieldAtOffset<int64_t>(target, offset) = longValue(t, value);
|
||||
fieldAtOffset<int64_t>(target, offset) = cast<GcLong>(t, value)->value();
|
||||
break;
|
||||
|
||||
case FloatField:
|
||||
fieldAtOffset<int32_t>(target, offset) = floatValue(t, value);
|
||||
fieldAtOffset<int32_t>(target, offset) = cast<GcFloat>(t, value)->value();
|
||||
break;
|
||||
|
||||
case DoubleField:
|
||||
fieldAtOffset<int64_t>(target, offset) = doubleValue(t, value);
|
||||
fieldAtOffset<int64_t>(target, offset) = cast<GcDouble>(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<object>(arguments[0])) == 0;
|
||||
return cast<GcString>(t, reinterpret_cast<object>(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<object>(arguments[0]));
|
||||
return cast<GcString>(t, reinterpret_cast<object>(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<GcArray>(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<GcClass>(t, arrayBody(t, table, i)));
|
||||
for (unsigned i = 0; i < table->length(); ++i) {
|
||||
GcJclass* c = getJClass(t, cast<GcClass>(t, table->body()[i]));
|
||||
set(t, array, ArrayBody + (i * BytesPerWord), reinterpret_cast<object>(c));
|
||||
}
|
||||
|
||||
@ -1113,7 +1114,7 @@ Avian_java_lang_Class_getDeclaredClasses
|
||||
{
|
||||
return reinterpret_cast<intptr_t>
|
||||
(getDeclaredClasses
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[0])),
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]))->vmClass(),
|
||||
arguments[1]));
|
||||
}
|
||||
|
||||
@ -1123,14 +1124,14 @@ Avian_java_lang_Class_getDeclaringClass
|
||||
{
|
||||
return reinterpret_cast<intptr_t>
|
||||
(getDeclaringClass
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[0]))));
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0]));
|
||||
GcClass* c = cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0]));
|
||||
GcClass* c = cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]))->vmClass();
|
||||
|
||||
GcMethod* method = resolveMethod(t, c, "<init>", "()V");
|
||||
PROTECT(t, method);
|
||||
@ -1240,9 +1241,9 @@ Avian_java_lang_Class_getDeclaredField
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "findField",
|
||||
"(Lavian/VMClass;Ljava/lang/String;)I");
|
||||
|
||||
int index = intValue
|
||||
int index = cast<GcInt>
|
||||
(t, t->m->processor->invoke
|
||||
(t, method, 0, c->vmClass(), name));
|
||||
(t, method, 0, c->vmClass(), name))->value();
|
||||
|
||||
if (index >= 0) {
|
||||
return reinterpret_cast<uintptr_t>(local::makeField(t, c, index));
|
||||
@ -1268,9 +1269,9 @@ Avian_java_lang_Class_getDeclaredConstructorOrMethod
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "findMethod",
|
||||
"(Lavian/VMClass;Ljava/lang/String;[Ljava/lang/Class;)I");
|
||||
|
||||
int index = intValue
|
||||
int index = cast<GcInt>
|
||||
(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<uintptr_t>
|
||||
@ -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<object>(arguments[1]);
|
||||
return fieldOffset
|
||||
(t, arrayBody
|
||||
(t, jfieldDeclaringClass(t, jfield)->vmClass()->fieldTable(),
|
||||
jfieldSlot(t, jfield)));
|
||||
GcJfield* jfield = cast<GcJfield>(t, reinterpret_cast<object>(arguments[1]));
|
||||
return cast<GcField>
|
||||
(t, cast<GcArray>
|
||||
(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<Thread*>
|
||||
(threadPeer(t, fieldAtOffset<object>(vmThread, field->offset()))));
|
||||
(cast<GcThread>(t, fieldAtOffset<object>(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<object>(vmThread, field->offset()));
|
||||
return cast<GcThread>(t, fieldAtOffset<object>(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<Thread*>
|
||||
(threadPeer(t, reinterpret_cast<object>(arguments[0])));
|
||||
(cast<GcThread>(t, reinterpret_cast<object>(arguments[0]))->peer());
|
||||
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(local::translateStackTrace
|
||||
@ -1707,14 +1707,14 @@ Avian_java_lang_Class_getModifiers
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
return classModifiers
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[0])));
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0]));
|
||||
GcClass* c = cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0]))->name();
|
||||
GcByteArray* name = cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0]))->flags()
|
||||
return (cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0]))->vmFlags()
|
||||
return (cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0]))->name();
|
||||
GcByteArray* name = cast<GcJclass>(t, reinterpret_cast<object>(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<uintptr_t>
|
||||
(jclassVmClass(t, reinterpret_cast<object>(arguments[0]))->loader());
|
||||
(cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0]);
|
||||
object that = reinterpret_cast<object>(arguments[1]);
|
||||
GcJclass* this_ = cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]));
|
||||
GcJclass* that = cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0]);
|
||||
GcJclass* this_ = cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]));
|
||||
object o = reinterpret_cast<object>(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<object>(arguments[1]);
|
||||
object args = reinterpret_cast<object>(arguments[2]);
|
||||
GcMethod* method = cast<GcMethod>(t, arrayBody
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[3]))->methodTable(),
|
||||
arguments[6]));
|
||||
GcMethod* method = cast<GcMethod>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(arguments[3]))->vmClass()->methodTable())
|
||||
->body()[arguments[6]]);
|
||||
|
||||
return reinterpret_cast<uintptr_t>(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<object>(arguments[0]))->methodTable(),
|
||||
arguments[1]));
|
||||
return cast<GcMethod>
|
||||
(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0]))->methodTable(),
|
||||
arguments[1]);
|
||||
GcMethod* method = cast<GcMethod>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0]))->methodTable(),
|
||||
arguments[1]);
|
||||
GcMethod* method = cast<GcMethod>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(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<uintptr_t>
|
||||
(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<object>(arguments[0]))->methodTable(),
|
||||
arguments[1]);
|
||||
GcMethod* method = cast<GcMethod>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(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<GcField>(t, arrayBody(
|
||||
GcField* field = cast<GcField>(t, cast<GcArray>(
|
||||
t,
|
||||
jclassVmClass(t, reinterpret_cast<object>(arguments[0]))->fieldTable(),
|
||||
arguments[1]));
|
||||
cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[0])),
|
||||
cast<GcClass>(t, reinterpret_cast<object>(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<object>(arguments[1]))->methodTable(),
|
||||
arguments[2]);
|
||||
GcMethod* method = cast<GcMethod>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(arguments[1]))->vmClass()->methodTable())
|
||||
->body()[arguments[2]]);
|
||||
|
||||
GcMethodAddendum* addendum = methodAddendum(t, method);
|
||||
GcMethodAddendum* addendum = method->addendum();
|
||||
if (addendum) {
|
||||
GcMethod* get = resolveMethod
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes",
|
||||
@ -2050,7 +2050,7 @@ Avian_java_lang_reflect_Method_getDefaultValue
|
||||
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(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<object>(arguments[1]);
|
||||
PROTECT(t, args);
|
||||
|
||||
GcClass* c = jclassVmClass(t, reinterpret_cast<object>(arguments[2]));
|
||||
GcClass* c = cast<GcJclass>(t, reinterpret_cast<object>(arguments[2]))->vmClass();
|
||||
PROTECT(t, c);
|
||||
|
||||
initClass(t, c);
|
||||
|
||||
GcMethod* method = cast<GcMethod>(t, arrayBody(t, c->methodTable(), arguments[4]));
|
||||
GcMethod* method = cast<GcMethod>(t, cast<GcArray>(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<GcField>(t, arrayBody
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[2]))->fieldTable(),
|
||||
arguments[4]));
|
||||
GcField* field = cast<GcField>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(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<GcField>(t, arrayBody
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[2]))->fieldTable(),
|
||||
arguments[4]));
|
||||
GcField* field = cast<GcField>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(arguments[2]))->vmClass()->fieldTable())
|
||||
->body()[arguments[4]]);
|
||||
|
||||
PROTECT(t, field);
|
||||
|
||||
object instance = reinterpret_cast<object>(arguments[1]);
|
||||
PROTECT(t, instance);
|
||||
|
||||
return intValue(t, local::getField(t, field, instance));
|
||||
return cast<GcInt>(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<GcField>(t, arrayBody
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[2]))->fieldTable(),
|
||||
arguments[4]));
|
||||
GcField* field = cast<GcField>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(arguments[2]))->vmClass()->fieldTable())
|
||||
->body()[arguments[4]]);
|
||||
|
||||
PROTECT(t, field);
|
||||
|
||||
object instance = reinterpret_cast<object>(arguments[1]);
|
||||
PROTECT(t, instance);
|
||||
|
||||
return longValue(t, local::getField(t, field, instance));
|
||||
return cast<GcLong>(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<GcField>(t, arrayBody
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[2]))->fieldTable(),
|
||||
arguments[4]));
|
||||
GcField* field = cast<GcField>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(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<GcField>(t, arrayBody
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[2]))->fieldTable(),
|
||||
arguments[4]));
|
||||
GcField* field = cast<GcField>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(arguments[2]))->vmClass()->fieldTable())
|
||||
->body()[arguments[4]]);
|
||||
|
||||
object instance = reinterpret_cast<object>(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<object>(arguments[1]))->fieldTable(),
|
||||
arguments[2]));
|
||||
return cast<GcField>
|
||||
(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(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<GcField>(t, arrayBody
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[0]))->fieldTable(),
|
||||
arguments[1]));
|
||||
GcField* field = cast<GcField>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(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<GcField>(t, arrayBody
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[1]))->fieldTable(),
|
||||
arguments[2]));
|
||||
GcField* field = cast<GcField>(t, cast<GcArray>
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(arguments[1]))->vmClass()->fieldTable())
|
||||
->body()[arguments[2]]);
|
||||
|
||||
object addendum = reinterpret_cast<object>(field->addendum());
|
||||
GcFieldAddendum* addendum = field->addendum();
|
||||
if (addendum) {
|
||||
object signature = addendumSignature(t, addendum);
|
||||
GcByteArray* signature = cast<GcByteArray>(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<object>(signature), 0, signature->length() - 1);
|
||||
|
||||
set(t, array, ArrayBody, reinterpret_cast<object>(string));
|
||||
|
||||
@ -2274,7 +2274,7 @@ Avian_java_lang_reflect_Array_createObjectArray
|
||||
{
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(makeObjectArray
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[0])),
|
||||
(t, cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[1]))
|
||||
if (cast<GcJclass>(t, reinterpret_cast<object>(arguments[1]))->vmClass()
|
||||
== type(t, GcJbyte::Type))
|
||||
{
|
||||
object array = allocate3
|
||||
GcByteArray* array = reinterpret_cast<GcByteArray*>(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<object>(array), type(t, GcByteArray::Type));
|
||||
array->length() = arguments[2];
|
||||
|
||||
return reinterpret_cast<intptr_t>(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);
|
||||
|
@ -82,9 +82,9 @@ class MyClasspath : public Classpath {
|
||||
}
|
||||
|
||||
virtual GcField*
|
||||
getVMField(Thread* t, object jfield)
|
||||
getVMField(Thread* t UNUSED, GcJfield* jfield)
|
||||
{
|
||||
return cast<GcJfield>(t, jfield)->vmField();
|
||||
return jfield->vmField();
|
||||
}
|
||||
|
||||
virtual void
|
||||
|
@ -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<object>(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<char*>(&byteArrayBody(t, name, 0)));
|
||||
reinterpret_cast<char*>(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<GcByteArray>(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), "<init>",
|
||||
"([BIILjava/lang/String;)V");
|
||||
@ -523,15 +524,15 @@ class MyClasspath : public Classpath {
|
||||
return cast<GcString>(t, s);
|
||||
}
|
||||
|
||||
charArrayBody(t, reinterpret_cast<object>(charArray), i) = byteArrayBody(t, array, offset + i);
|
||||
charArray->body()[i] = array->body()[offset + i];
|
||||
}
|
||||
|
||||
array = reinterpret_cast<object>(charArray);
|
||||
oarray = reinterpret_cast<object>(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<GcMethod>(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<GcMethod>(
|
||||
t,
|
||||
objectClass(t, jmethod) == type(t, GcJmethod::Type)
|
||||
? cast<GcArray>(t,
|
||||
cast<GcJmethod>(t, jmethod)
|
||||
->clazz()
|
||||
->vmClass()
|
||||
->methodTable())
|
||||
->body()[cast<GcJmethod>(t, jmethod)->slot()]
|
||||
: cast<GcArray>(t,
|
||||
cast<GcJconstructor>(t, jmethod)
|
||||
->clazz()
|
||||
->vmClass()
|
||||
->methodTable())
|
||||
->body()[cast<GcJconstructor>(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<GcField>(t, arrayBody
|
||||
(t, jfieldClazz(t, jfield)->vmClass()->fieldTable(), jfieldSlot(t, jfield)));
|
||||
return cast
|
||||
<GcField>(t,
|
||||
cast<GcArray>(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<GcArray>(t, c->methodTable());
|
||||
return table == 0 ? 0 : table->length();
|
||||
}
|
||||
|
||||
unsigned
|
||||
countMethods(Thread* t, GcClass* c, bool publicOnly)
|
||||
{
|
||||
object table = c->methodTable();
|
||||
GcArray* table = cast<GcArray>(t, c->methodTable());
|
||||
unsigned count = 0;
|
||||
for (unsigned i = 0, j = classDeclaredMethodCount(t, c); i < j; ++i) {
|
||||
GcMethod* vmMethod = cast<GcMethod>(t, arrayBody(t, table, i));
|
||||
GcMethod* vmMethod = cast<GcMethod>(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<GcArray>(t, c->fieldTable());
|
||||
if (publicOnly) {
|
||||
unsigned count = 0;
|
||||
for (unsigned i = 0; i < arrayLength(t, table); ++i) {
|
||||
GcField* vmField = cast<GcField>(t, arrayBody(t, table, i));
|
||||
for (unsigned i = 0; i < table->length(); ++i) {
|
||||
GcField* vmField = cast<GcField>(t, table->body()[i]);
|
||||
if (vmField->flags() & ACC_PUBLIC) {
|
||||
++ count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
} else {
|
||||
return objectArrayLength(t, table);
|
||||
return objectArrayLength(t, reinterpret_cast<object>(table));
|
||||
}
|
||||
}
|
||||
|
||||
unsigned
|
||||
countConstructors(Thread* t, GcClass* c, bool publicOnly)
|
||||
{
|
||||
object table = c->methodTable();
|
||||
GcArray* table = cast<GcArray>(t, c->methodTable());
|
||||
unsigned count = 0;
|
||||
for (unsigned i = 0, j = classDeclaredMethodCount(t, c); i < j; ++i) {
|
||||
GcMethod* vmMethod = cast<GcMethod>(t, arrayBody(t, table, i));
|
||||
GcMethod* vmMethod = cast<GcMethod>(t, table->body()[i]);
|
||||
if (((not publicOnly) or (vmMethod->flags() & ACC_PUBLIC))
|
||||
and strcmp(reinterpret_cast<char*>
|
||||
(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<object>(vmMethod->addendum());
|
||||
GcMethodAddendum* addendum = vmMethod->addendum();
|
||||
if (addendum) {
|
||||
signature = addendumSignature(t, addendum);
|
||||
signature = addendum->signature();
|
||||
if (signature) {
|
||||
PROTECT(t, addendum);
|
||||
|
||||
signature = reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1));
|
||||
(t, signature, 0, cast<GcByteArray>(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<object>(vmMethod) == arrayBody(t, table, i)) {
|
||||
GcArray* table = cast<GcArray>(t, vmMethod->class_()->methodTable());
|
||||
for (unsigned i = 0; i < table->length(); ++i) {
|
||||
if (reinterpret_cast<object>(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<object>(vmMethod->addendum());
|
||||
GcMethodAddendum* addendum = vmMethod->addendum();
|
||||
if (addendum) {
|
||||
signature = addendumSignature(t, addendum);
|
||||
signature = addendum->signature();
|
||||
if (signature) {
|
||||
PROTECT(t, addendum);
|
||||
|
||||
signature = reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1));
|
||||
(t, signature, 0, cast<GcByteArray>(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<object>(vmMethod) == arrayBody(t, table, i)) {
|
||||
GcArray* table = cast<GcArray>(t, vmMethod->class_()->methodTable());
|
||||
for (unsigned i = 0; i < table->length(); ++i) {
|
||||
if (reinterpret_cast<object>(vmMethod) == table->body()[i]) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
@ -2414,7 +2423,7 @@ makeJfield(Thread* t, GcField* vmField, int index)
|
||||
PROTECT(t, addendum);
|
||||
|
||||
signature = reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1));
|
||||
(t, signature, 0, cast<GcByteArray>(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<object>(vmField) == arrayBody(t, table, i)) {
|
||||
GcArray* table = cast<GcArray>(t, vmField->class_()->fieldTable());
|
||||
for (unsigned i = 0; i < table->length(); ++i) {
|
||||
if (reinterpret_cast<object>(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<object>(arguments[0]));
|
||||
GcClass* class_ = cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[1]);
|
||||
object data = reinterpret_cast<object>(arguments[2]);
|
||||
GcByteArray* data = cast<GcByteArray>(t, reinterpret_cast<object>(arguments[2]));
|
||||
int32_t offset = arguments[3];
|
||||
int32_t length = arguments[4];
|
||||
GcClassLoader* loader = cast<GcClassLoader>(t, reinterpret_cast<object>(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<int64_t>
|
||||
(getJClass(t, cast<GcClass>(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<object>(arguments[1]));
|
||||
GcClass* c = cast<GcJclass>(t, reinterpret_cast<object>(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<object>(arguments[1]);
|
||||
return fieldOffset
|
||||
(t, arrayBody
|
||||
(t, jfieldClazz(t, jfield)->vmClass()->fieldTable(), jfieldSlot(t, jfield)));
|
||||
GcJfield* jfield = cast<GcJfield>(t, reinterpret_cast<object>(arguments[1]));
|
||||
return cast<GcField>
|
||||
(t, cast<GcArray>
|
||||
(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<int64_t>
|
||||
(jfieldClazz(t, reinterpret_cast<object>(arguments[1]))->vmClass()->staticTable());
|
||||
(cast<GcJfield>(t, reinterpret_cast<object>(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<object>(arguments[1]);
|
||||
return fieldOffset
|
||||
(t, arrayBody
|
||||
(t, jfieldClazz(t, jfield)->vmClass()->fieldTable(), jfieldSlot(t, jfield)));
|
||||
GcJfield* jfield = cast<GcJfield>(t, reinterpret_cast<object>(arguments[1]));
|
||||
return cast<GcField>
|
||||
(t, cast<GcArray>
|
||||
(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<object>(arguments[1])));
|
||||
initClass(t, cast<GcJclass>(t, reinterpret_cast<object>(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<GcThrowable>(t, *throwable)->trace());
|
||||
}
|
||||
|
||||
uint64_t
|
||||
@ -3224,7 +3233,7 @@ jvmGetStackTraceElement(Thread* t, uintptr_t* arguments)
|
||||
return reinterpret_cast<uint64_t>
|
||||
(makeLocalReference
|
||||
(t, reinterpret_cast<object>(makeStackTraceElement
|
||||
(t, cast<GcTraceElement>(t, objectArrayBody(t, throwableTrace(t, *throwable), index))))));
|
||||
(t, cast<GcTraceElement>(t, objectArrayBody(t, cast<GcThrowable>(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<Thread*>(threadPeer(t, *thread));
|
||||
Thread* p = reinterpret_cast<Thread*>(cast<GcThread>(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<object>(getJClass(
|
||||
t,
|
||||
methodClass(t,
|
||||
traceElementMethod(t, objectArrayBody(t, trace, i)))));
|
||||
cast<GcMethod>(t, cast<GcTraceElement>(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<object>(makeByteArray(t, RUNTIME_ARRAY_BODY(chars)));
|
||||
|
||||
object array = hashMapFind
|
||||
(t, cast<GcHashMap>(t, root(t, Machine::PackageMap)), key, byteArrayHash, byteArrayEqual);
|
||||
GcByteArray* array = cast<GcByteArray>(t, hashMapFind
|
||||
(t, cast<GcHashMap>(t, root(t, Machine::PackageMap)), key, byteArrayHash, byteArrayEqual));
|
||||
|
||||
if (array) {
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(makeLocalReference
|
||||
(t, reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, array, 0, byteArrayLength(t, array)))));
|
||||
(t, reinterpret_cast<object>(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<int8_t>(*array, ArrayBody + index) = booleanValue(t, *value);
|
||||
fieldAtOffset<int8_t>(*array, ArrayBody + index) = cast<GcBoolean>(t, *value)->value();
|
||||
break;
|
||||
case 'B':
|
||||
fieldAtOffset<int8_t>(*array, ArrayBody + index) = byteValue(t, *value);
|
||||
fieldAtOffset<int8_t>(*array, ArrayBody + index) = cast<GcByte>(t, *value)->value();
|
||||
break;
|
||||
case 'C':
|
||||
fieldAtOffset<int16_t>(*array, ArrayBody + (index * 2)) = charValue(t, *value);
|
||||
fieldAtOffset<int16_t>(*array, ArrayBody + (index * 2)) = cast<GcChar>(t, *value)->value();
|
||||
break;
|
||||
case 'S':
|
||||
fieldAtOffset<int16_t>(*array, ArrayBody + (index * 2)) = shortValue(t, *value);
|
||||
fieldAtOffset<int16_t>(*array, ArrayBody + (index * 2)) = cast<GcShort>(t, *value)->value();
|
||||
break;
|
||||
case 'I':
|
||||
fieldAtOffset<int32_t>(*array, ArrayBody + (index * 4)) = intValue(t, *value);
|
||||
fieldAtOffset<int32_t>(*array, ArrayBody + (index * 4)) = cast<GcInt>(t, *value)->value();
|
||||
break;
|
||||
case 'F':
|
||||
fieldAtOffset<int32_t>(*array, ArrayBody + (index * 4)) = floatValue(t, *value);
|
||||
fieldAtOffset<int32_t>(*array, ArrayBody + (index * 4)) = cast<GcFloat>(t, *value)->value();
|
||||
break;
|
||||
case 'J':
|
||||
fieldAtOffset<int64_t>(*array, ArrayBody + (index * 8)) = longValue(t, *value);
|
||||
fieldAtOffset<int64_t>(*array, ArrayBody + (index * 8)) = cast<GcLong>(t, *value)->value();
|
||||
break;
|
||||
case 'D':
|
||||
fieldAtOffset<int64_t>(*array, ArrayBody + (index * 8)) = doubleValue(t, *value);
|
||||
fieldAtOffset<int64_t>(*array, ArrayBody + (index * 8)) = cast<GcDouble>(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<char*>
|
||||
(&byteArrayBody(t, local::getClassName(t, cast<GcClass>(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<object>(makeObjectArray(t, cast<GcClass>(t, c), length));
|
||||
return reinterpret_cast<object>(makeObjectArray(t, c, length));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3752,7 +3760,7 @@ jvmNewArray(Thread* t, uintptr_t* arguments)
|
||||
|
||||
return reinterpret_cast<uint64_t>
|
||||
(makeLocalReference
|
||||
(t, makeNewArray(t, reinterpret_cast<object>((*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<object>((*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<GcArray>(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<object>(getJClass(t, cast<GcClass>(t, arrayBody(t, table, i))));
|
||||
for (unsigned i = 0; i < table->length(); ++i) {
|
||||
object c = reinterpret_cast<object>(getJClass(t, cast<GcClass>(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<jobjectArray>(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<jobject>(arguments[0])));
|
||||
(t, cast<GcJclass>(t, *reinterpret_cast<jobject>(arguments[0]))->vmClass());
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT jint JNICALL
|
||||
@ -4194,7 +4202,7 @@ jvmGetDeclaredClasses(Thread* t, uintptr_t* arguments)
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(makeLocalReference
|
||||
(t, getDeclaredClasses
|
||||
(t, jclassVmClass(t, *reinterpret_cast<jobject>(arguments[0])), false)));
|
||||
(t, cast<GcJclass>(t, *reinterpret_cast<jobject>(arguments[0]))->vmClass(), false)));
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT jobjectArray JNICALL
|
||||
@ -4211,7 +4219,7 @@ jvmGetDeclaringClass(Thread* t, uintptr_t* arguments)
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(makeLocalReference
|
||||
(t, reinterpret_cast<object>(getDeclaringClass
|
||||
(t, jclassVmClass(t, *reinterpret_cast<jobject>(arguments[0]))))));
|
||||
(t, cast<GcJclass>(t, *reinterpret_cast<jobject>(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<GcByteArray>(t, addendum->signature());
|
||||
if (signature) {
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(makeLocalReference
|
||||
(t, reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1))));
|
||||
(t, reinterpret_cast<object>(signature), 0, signature->length() - 1))));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -4264,7 +4272,7 @@ jvmGetClassDeclaredMethods(Thread* t, uintptr_t* arguments)
|
||||
jclass c = reinterpret_cast<jclass>(arguments[0]);
|
||||
jboolean publicOnly = arguments[1];
|
||||
|
||||
object table = (*c)->vmClass()->methodTable();
|
||||
GcArray* table = cast<GcArray>(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<GcMethod>(t, arrayBody(t, table, i));
|
||||
GcMethod* vmMethod = cast<GcMethod>(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<jclass>(arguments[0]);
|
||||
jboolean publicOnly = arguments[1];
|
||||
object table = (*c)->vmClass()->fieldTable();
|
||||
GcArray* table = cast<GcArray>(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<GcField>(t, arrayBody(t, table, i));
|
||||
for (unsigned i = 0; i < table->length(); ++i) {
|
||||
GcField* vmField = cast<GcField>(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<jclass>(arguments[0]);
|
||||
jboolean publicOnly = arguments[1];
|
||||
|
||||
object table = (*c)->vmClass()->methodTable();
|
||||
GcArray* table = cast<GcArray>(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<GcMethod>(t, arrayBody(t, table, i));
|
||||
GcMethod* vmMethod = cast<GcMethod>(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<jobject>(arguments[1]);
|
||||
jobjectArray args = reinterpret_cast<jobjectArray>(arguments[2]);
|
||||
|
||||
GcMethod* vmMethod = cast<GcMethod>(t, arrayBody
|
||||
(t, jmethodClazz(t, *method)->vmClass()->methodTable(),
|
||||
jmethodSlot(t, *method)));
|
||||
GcMethod* vmMethod = cast<GcMethod>(t, cast<GcArray>
|
||||
(t, cast<GcJmethod>(t, *method)->clazz()->vmClass()->methodTable())->body()[
|
||||
cast<GcJmethod>(t, *method)->slot()]);
|
||||
|
||||
if (vmMethod->flags() & ACC_STATIC) {
|
||||
instance = 0;
|
||||
@ -4458,12 +4466,12 @@ jvmNewInstanceFromConstructor(Thread* t, uintptr_t* arguments)
|
||||
jobjectArray args = reinterpret_cast<jobjectArray>(arguments[1]);
|
||||
|
||||
object instance = make
|
||||
(t, jconstructorClazz(t, *constructor)->vmClass());
|
||||
(t, cast<GcJconstructor>(t, *constructor)->clazz()->vmClass());
|
||||
PROTECT(t, instance);
|
||||
|
||||
GcMethod* method = cast<GcMethod>(t, arrayBody
|
||||
(t, jconstructorClazz(t, *constructor)->vmClass()->methodTable(),
|
||||
jconstructorSlot(t, *constructor)));
|
||||
GcMethod* method = cast<GcMethod>(t, cast<GcArray>
|
||||
(t, cast<GcJconstructor>(t, *constructor)->clazz()->vmClass()->methodTable())->body()[
|
||||
cast<GcJconstructor>(t, *constructor)->slot()]);
|
||||
|
||||
invoke(t, method, reinterpret_cast<object>(instance), args ? reinterpret_cast<object>(*args) : 0);
|
||||
|
||||
@ -5265,20 +5273,20 @@ getEnclosingMethodInfo(Thread* t, uintptr_t* arguments)
|
||||
|
||||
set(t, array, ArrayBody, enclosingClass);
|
||||
|
||||
object enclosingMethod = addendum->enclosingMethod();
|
||||
GcPair* enclosingMethod = cast<GcPair>(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<GcByteArray>(t, enclosingMethod->first())->length() - 1);
|
||||
|
||||
set(t, array, ArrayBody + BytesPerWord, reinterpret_cast<object>(name));
|
||||
|
||||
GcString* spec = t->m->classpath->makeString
|
||||
(t, pairSecond(t, enclosingMethod), 0,
|
||||
byteArrayLength(t, pairSecond(t, enclosingMethod)) - 1);
|
||||
(t, enclosingMethod->second(), 0,
|
||||
cast<GcByteArray>(t, enclosingMethod->second())->length() - 1);
|
||||
|
||||
set(t, array, ArrayBody + (2 * BytesPerWord), reinterpret_cast<object>(spec));
|
||||
}
|
||||
|
@ -3241,7 +3241,7 @@ fromReflectedField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject f = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
return fieldID(t, t->m->classpath->getVMField(t, *f));
|
||||
return fieldID(t, t->m->classpath->getVMField(t, cast<GcJfield>(t, *f)));
|
||||
}
|
||||
|
||||
jfieldID JNICALL
|
||||
|
@ -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<GcClass*>(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<uint8_t*>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user