generate better typed accessors from type-generator (and switch to using standard library there)

This commit is contained in:
Joshua Warner 2014-06-20 22:16:33 -06:00 committed by Joshua Warner
parent 263e349cae
commit 9b36dca846
17 changed files with 1198 additions and 1701 deletions

View File

@ -443,6 +443,7 @@ asm-format = S
as = $(cc) as = $(cc)
ld = $(cc) ld = $(cc)
build-ld = $(build-cc) build-ld = $(build-cc)
build-ld-cpp = $(build-cxx)
default-remote-test-host = localhost default-remote-test-host = localhost
default-remote-test-port = 22 default-remote-test-port = 22
@ -1984,7 +1985,7 @@ endif
$(generator): $(generator-objects) $(generator-lzma-objects) $(generator): $(generator-objects) $(generator-lzma-objects)
@echo "linking $(@)" @echo "linking $(@)"
$(build-ld) $(^) $(build-lflags) -o $(@) $(build-ld-cpp) $(^) $(build-lflags) -o $(@)
$(openjdk-objects): $(build)/openjdk/%-openjdk.o: $(openjdk-src)/%.c \ $(openjdk-objects): $(build)/openjdk/%-openjdk.o: $(openjdk-src)/%.c \
$(openjdk-headers-dep) $(openjdk-headers-dep)

View File

@ -31,9 +31,9 @@ getTrace(Thread* t, unsigned skipCount)
if (skipCount == 0) { if (skipCount == 0) {
GcMethod* method = walker->method(); GcMethod* method = walker->method();
if (isAssignableFrom if (isAssignableFrom
(t, type(t, GcThrowable::Type), cast<GcClass>(t, method->class_())) (t, type(t, GcThrowable::Type), method->class_())
and vm::strcmp(reinterpret_cast<const int8_t*>("<init>"), and vm::strcmp(reinterpret_cast<const int8_t*>("<init>"),
&byteArrayBody(t, method->name(), 0)) method->name()->body().begin())
== 0) == 0)
{ {
return true; return true;
@ -266,7 +266,7 @@ clone(Thread* t, object o)
reinterpret_cast<void**>(o) + 1, reinterpret_cast<void**>(o) + 1,
size - BytesPerWord); size - BytesPerWord);
} else { } else {
object classNameSlash = objectClass(t, o)->name(); object classNameSlash = reinterpret_cast<object>(objectClass(t, o)->name());
THREAD_RUNTIME_ARRAY(t, char, classNameDot, byteArrayLength(t, classNameSlash)); THREAD_RUNTIME_ARRAY(t, char, classNameDot, byteArrayLength(t, classNameSlash));
replace('/', '.', RUNTIME_ARRAY_BODY(classNameDot), replace('/', '.', RUNTIME_ARRAY_BODY(classNameDot),
reinterpret_cast<char*>(&byteArrayBody(t, classNameSlash, 0))); reinterpret_cast<char*>(&byteArrayBody(t, classNameSlash, 0)));
@ -285,7 +285,7 @@ makeStackTraceElement(Thread* t, object e)
GcMethod* method = cast<GcMethod>(t, traceElementMethod(t, e)); GcMethod* method = cast<GcMethod>(t, traceElementMethod(t, e));
PROTECT(t, method); PROTECT(t, method);
object class_name = className(t, method->class_()); object class_name = reinterpret_cast<object>(method->class_()->name());
PROTECT(t, class_name); PROTECT(t, class_name);
THREAD_RUNTIME_ARRAY(t, char, s, byteArrayLength(t, class_name)); THREAD_RUNTIME_ARRAY(t, char, s, byteArrayLength(t, class_name));
@ -293,7 +293,7 @@ makeStackTraceElement(Thread* t, object e)
reinterpret_cast<char*>(&byteArrayBody(t, class_name, 0))); reinterpret_cast<char*>(&byteArrayBody(t, class_name, 0)));
class_name = makeString(t, "%s", RUNTIME_ARRAY_BODY(s)); class_name = makeString(t, "%s", RUNTIME_ARRAY_BODY(s));
object method_name = method->name(); object method_name = reinterpret_cast<object>(method->name());
PROTECT(t, method_name); PROTECT(t, method_name);
method_name = t->m->classpath->makeString method_name = t->m->classpath->makeString
@ -302,11 +302,11 @@ makeStackTraceElement(Thread* t, object e)
unsigned line = t->m->processor->lineNumber unsigned line = t->m->processor->lineNumber
(t, method, traceElementIp(t, e)); (t, method, traceElementIp(t, e));
object file = classSourceFile(t, method->class_()); object file = reinterpret_cast<object>(method->class_()->sourceFile());
file = file ? t->m->classpath->makeString file = file ? t->m->classpath->makeString
(t, file, 0, byteArrayLength(t, file) - 1) : 0; (t, file, 0, byteArrayLength(t, file) - 1) : 0;
return reinterpret_cast<object>(makeStackTraceElement(t, class_name, method_name, file, line)); return reinterpret_cast<object>(makeStackTraceElement(t, cast<GcString>(t, class_name), cast<GcString>(t, method_name), cast<GcString>(t, file), line));
} }
object object
@ -366,7 +366,7 @@ resolveClassBySpec(Thread* t, object loader, const char* spec,
} }
} }
object GcJclass*
resolveJType(Thread* t, object loader, const char* spec, unsigned specLength) resolveJType(Thread* t, object loader, const char* spec, unsigned specLength)
{ {
return getJClass(t, resolveClassBySpec(t, loader, spec, specLength)); return getJClass(t, resolveClassBySpec(t, loader, spec, specLength));
@ -452,7 +452,7 @@ resolveParameterJTypes(Thread* t, object loader, object spec,
PROTECT(t, array); PROTECT(t, array);
for (int i = *parameterCount - 1; i >= 0; --i) { for (int i = *parameterCount - 1; i >= 0; --i) {
object c = getJClass(t, cast<GcClass>(t, pairFirst(t, list))); object c = reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, pairFirst(t, list))));
set(t, array, ArrayBody + (i * BytesPerWord), c); set(t, array, ArrayBody + (i * BytesPerWord), c);
list = pairSecond(t, list); list = pairSecond(t, list);
} }
@ -490,7 +490,7 @@ resolveExceptionJTypes(Thread* t, object loader, object addendum)
o); o);
} }
o = getJClass(t, cast<GcClass>(t, o)); o = reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, o)));
set(t, array, ArrayBody + (i * BytesPerWord), o); set(t, array, ArrayBody + (i * BytesPerWord), o);
} }
@ -516,10 +516,10 @@ invoke(Thread* t, GcMethod* method, object instance, object args)
} }
if (method->parameterCount()) { if (method->parameterCount()) {
unsigned specLength = byteArrayLength(t, method->spec()); unsigned specLength = method->spec()->length();
THREAD_RUNTIME_ARRAY(t, char, spec, specLength); THREAD_RUNTIME_ARRAY(t, char, spec, specLength);
memcpy(RUNTIME_ARRAY_BODY(spec), memcpy(RUNTIME_ARRAY_BODY(spec),
&byteArrayBody(t, method->spec(), 0), specLength); method->spec()->body().begin(), specLength);
unsigned i = 0; unsigned i = 0;
for (MethodSpecIterator it(t, RUNTIME_ARRAY_BODY(spec)); it.hasNext();) { for (MethodSpecIterator it(t, RUNTIME_ARRAY_BODY(spec)); it.hasNext();) {
GcClass* type; GcClass* type;
@ -549,7 +549,7 @@ invoke(Thread* t, GcMethod* method, object instance, object args)
memcpy(RUNTIME_ARRAY_BODY(name), p, nameLength - 1); memcpy(RUNTIME_ARRAY_BODY(name), p, nameLength - 1);
RUNTIME_ARRAY_BODY(name)[nameLength - 1] = 0; RUNTIME_ARRAY_BODY(name)[nameLength - 1] = 0;
type = resolveClass type = resolveClass
(t, classLoader(t, method->class_()), (t, reinterpret_cast<object>(method->class_()->loader()),
RUNTIME_ARRAY_BODY(name)); RUNTIME_ARRAY_BODY(name));
} break; } break;
@ -568,7 +568,7 @@ invoke(Thread* t, GcMethod* method, object instance, object args)
} }
} }
initClass(t, cast<GcClass>(t, method->class_())); initClass(t, method->class_());
unsigned returnCode = method->returnCode(); unsigned returnCode = method->returnCode();
@ -706,12 +706,12 @@ getDeclaredClasses(Thread* t, object c, bool publicOnly)
and ((not publicOnly) and ((not publicOnly)
or (innerClassReferenceFlags(t, reference) & ACC_PUBLIC))) or (innerClassReferenceFlags(t, reference) & ACC_PUBLIC)))
{ {
object inner = getJClass( object inner = reinterpret_cast<object>(getJClass(
t, t,
resolveClass( resolveClass(
t, t,
classLoader(t, c), classLoader(t, c),
innerClassReferenceInner(t, arrayBody(t, table, i)))); innerClassReferenceInner(t, arrayBody(t, table, i)))));
-- count; -- count;
set(t, result, ArrayBody + (count * BytesPerWord), inner); set(t, result, ArrayBody + (count * BytesPerWord), inner);
@ -725,7 +725,7 @@ getDeclaredClasses(Thread* t, object c, bool publicOnly)
return makeObjectArray(t, type(t, GcJclass::Type), 0); return makeObjectArray(t, type(t, GcJclass::Type), 0);
} }
object GcJclass*
getDeclaringClass(Thread* t, object c) getDeclaringClass(Thread* t, object c)
{ {
object addendum = classAddendum(t, c); object addendum = classAddendum(t, c);

View File

@ -1207,6 +1207,7 @@ class GcObject {
}; };
class GcFinalizer; class GcFinalizer;
class GcClassLoader;
class Machine { class Machine {
public: public:
@ -1447,7 +1448,7 @@ class Thread {
class LibraryLoadStack: public AutoResource { class LibraryLoadStack: public AutoResource {
public: public:
LibraryLoadStack(Thread* t, object classLoader) LibraryLoadStack(Thread* t, GcClassLoader* classLoader)
: AutoResource(t), : AutoResource(t),
next(t->libraryLoadStack), next(t->libraryLoadStack),
classLoader(classLoader), classLoader(classLoader),
@ -1465,7 +1466,7 @@ class Thread {
} }
LibraryLoadStack* next; LibraryLoadStack* next;
object classLoader; GcClassLoader* classLoader;
SingleProtector protector; SingleProtector protector;
}; };
@ -1634,7 +1635,7 @@ class Classpath {
canTailCall(Thread* t, GcMethod* caller, object calleeClassName, canTailCall(Thread* t, GcMethod* caller, object calleeClassName,
object calleeMethodName, object calleeMethodSpec) = 0; object calleeMethodName, object calleeMethodSpec) = 0;
virtual object libraryClassLoader(Thread* t, GcMethod* caller) = 0; virtual GcClassLoader* libraryClassLoader(Thread* t, GcMethod* caller) = 0;
virtual void virtual void
shutDown(Thread* t) = 0; shutDown(Thread* t) = 0;
@ -1985,6 +1986,12 @@ T* cast(Thread* t UNUSED, object o)
#include "type-declarations.cpp" #include "type-declarations.cpp"
inline object&
arrayBodyUnsafe(Thread*, object a, unsigned index)
{
return reinterpret_cast<GcArray*>(a)->body()[index];
}
inline uint64_t inline uint64_t
runRaw(Thread* t, runRaw(Thread* t,
uint64_t (*function)(Thread*, uintptr_t*), uintptr_t* arguments) uint64_t (*function)(Thread*, uintptr_t*), uintptr_t* arguments)
@ -2433,7 +2440,7 @@ inline uint32_t
stringHash(Thread* t, object s) stringHash(Thread* t, object s)
{ {
if (stringHashCode(t, s) == 0 and stringLength(t, s)) { if (stringHashCode(t, s) == 0 and stringLength(t, s)) {
object data = stringData(t, s); object data = reinterpret_cast<object>(stringData(t, s));
if (objectClass(t, data) == type(t, GcByteArray::Type)) { if (objectClass(t, data) == type(t, GcByteArray::Type)) {
stringHashCode(t, s) = hash stringHashCode(t, s) = hash
(&byteArrayBody(t, data, stringOffset(t, s)), stringLength(t, s)); (&byteArrayBody(t, data, stringOffset(t, s)), stringLength(t, s));
@ -2448,7 +2455,7 @@ stringHash(Thread* t, object s)
inline uint16_t inline uint16_t
stringCharAt(Thread* t, object s, int i) stringCharAt(Thread* t, object s, int i)
{ {
object data = stringData(t, s); object data = reinterpret_cast<object>(stringData(t, s));
if (objectClass(t, data) == type(t, GcByteArray::Type)) { if (objectClass(t, data) == type(t, GcByteArray::Type)) {
return byteArrayBody(t, data, stringOffset(t, s) + i); return byteArrayBody(t, data, stringOffset(t, s) + i);
} else { } else {
@ -2477,8 +2484,8 @@ inline uint32_t
methodHash(Thread* t, object mo) methodHash(Thread* t, object mo)
{ {
GcMethod* method = cast<GcMethod>(t, mo); GcMethod* method = cast<GcMethod>(t, mo);
return byteArrayHash(t, method->name()) return byteArrayHash(t, reinterpret_cast<object>(method->name()))
^ byteArrayHash(t, method->spec()); ^ byteArrayHash(t, reinterpret_cast<object>(method->spec()));
} }
inline bool inline bool
@ -2487,8 +2494,8 @@ methodEqual(Thread* t, object ao, object bo)
GcMethod* a = cast<GcMethod>(t, ao); GcMethod* a = cast<GcMethod>(t, ao);
GcMethod* b = cast<GcMethod>(t, bo); GcMethod* b = cast<GcMethod>(t, bo);
return a == b or return a == b or
(byteArrayEqual(t, a->name(), b->name()) and (byteArrayEqual(t, reinterpret_cast<object>(a->name()), reinterpret_cast<object>(b->name())) and
byteArrayEqual(t, a->spec(), b->spec())); byteArrayEqual(t, reinterpret_cast<object>(a->spec()), reinterpret_cast<object>(b->spec())));
} }
class MethodSpecIterator { class MethodSpecIterator {
@ -2865,7 +2872,7 @@ findInHierarchy(Thread* t, GcClass* class_, object name, object spec,
throwNew(t, errorType, "%s %s not found in %s", throwNew(t, errorType, "%s %s not found in %s",
&byteArrayBody(t, name, 0), &byteArrayBody(t, name, 0),
&byteArrayBody(t, spec, 0), &byteArrayBody(t, spec, 0),
&byteArrayBody(t, class_->name(), 0)); class_->name()->body().begin());
} }
return o; return o;
@ -2899,10 +2906,10 @@ findInterfaceMethod(Thread* t, GcMethod* method, GcClass* class_)
{ {
assertT(t, (class_->vmFlags() & BootstrapFlag) == 0); assertT(t, (class_->vmFlags() & BootstrapFlag) == 0);
object interface = method->class_(); GcClass* interface = method->class_();
object itable = class_->interfaceTable(); object itable = class_->interfaceTable();
for (unsigned i = 0; i < arrayLength(t, itable); i += 2) { for (unsigned i = 0; i < arrayLength(t, itable); i += 2) {
if (arrayBody(t, itable, i) == interface) { if (arrayBody(t, itable, i) == reinterpret_cast<object>(interface)) {
return cast<GcMethod>(t, arrayBody return cast<GcMethod>(t, arrayBody
(t, arrayBody(t, itable, i + 1), method->offset())); (t, arrayBody(t, itable, i + 1), method->offset()));
} }
@ -2923,7 +2930,7 @@ objectArrayBody(Thread* t UNUSED, object array, unsigned index)
{ {
assertT(t, objectClass(t, array)->fixedSize() == BytesPerWord * 2); assertT(t, objectClass(t, array)->fixedSize() == BytesPerWord * 2);
assertT(t, objectClass(t, array)->arrayElementSize() == BytesPerWord); assertT(t, objectClass(t, array)->arrayElementSize() == BytesPerWord);
assertT(t, objectClass(t, array)->objectMask() assertT(t, reinterpret_cast<object>(objectClass(t, array)->objectMask())
== classObjectMask(t, arrayBody == classObjectMask(t, arrayBody
(t, t->m->types, GcArray::Type))); (t, t->m->types, GcArray::Type)));
return fieldAtOffset<object>(array, ArrayBody + (index * BytesPerWord)); return fieldAtOffset<object>(array, ArrayBody + (index * BytesPerWord));
@ -3462,10 +3469,10 @@ disposeLocalReference(Thread* t, jobject r)
} }
inline bool inline bool
methodVirtual(Thread* t, GcMethod* method) methodVirtual(Thread* t UNUSED, GcMethod* method)
{ {
return (method->flags() & (ACC_STATIC | ACC_PRIVATE)) == 0 return (method->flags() & (ACC_STATIC | ACC_PRIVATE)) == 0
and byteArrayBody(t, method->name(), 0) != '<'; and method->name()->body()[0] != '<';
} }
inline unsigned inline unsigned
@ -3644,7 +3651,7 @@ inline GcClass*
resolveClassInPool(Thread* t, GcMethod* method, unsigned index, resolveClassInPool(Thread* t, GcMethod* method, unsigned index,
bool throw_ = true) bool throw_ = true)
{ {
return resolveClassInPool(t, classLoader(t, method->class_()), return resolveClassInPool(t, reinterpret_cast<object>(method->class_()->loader()),
method, index, throw_); method, index, throw_);
} }
@ -3696,7 +3703,7 @@ inline object
resolveField(Thread* t, GcMethod* method, unsigned index, bool throw_ = true) resolveField(Thread* t, GcMethod* method, unsigned index, bool throw_ = true)
{ {
return resolveField return resolveField
(t, classLoader(t, method->class_()), method, index, throw_); (t, reinterpret_cast<object>(method->class_()->loader()), method, index, throw_);
} }
inline void inline void
@ -3798,7 +3805,7 @@ inline GcMethod*
resolveMethod(Thread* t, GcMethod* method, unsigned index, bool throw_ = true) resolveMethod(Thread* t, GcMethod* method, unsigned index, bool throw_ = true)
{ {
return resolveMethod return resolveMethod
(t, classLoader(t, method->class_()), method, index, throw_); (t, reinterpret_cast<object>(method->class_()->loader()), method, index, throw_);
} }
object object
@ -3867,25 +3874,25 @@ getMethodRuntimeData(Thread* t, GcMethod* method)
method->runtimeDataIndex() - 1); method->runtimeDataIndex() - 1);
} }
inline object inline GcJclass*
getJClass(Thread* t, GcClass* c) getJClass(Thread* t, GcClass* c)
{ {
PROTECT(t, c); PROTECT(t, c);
object jclass = classRuntimeDataJclass(t, getClassRuntimeData(t, c)); GcJclass* jclass = cast<GcJclass>(t, classRuntimeDataJclass(t, getClassRuntimeData(t, c)));
loadMemoryBarrier(); loadMemoryBarrier();
if (jclass == 0) { if (jclass == 0) {
ACQUIRE(t, t->m->classLock); ACQUIRE(t, t->m->classLock);
jclass = classRuntimeDataJclass(t, getClassRuntimeData(t, c)); jclass = cast<GcJclass>(t, classRuntimeDataJclass(t, getClassRuntimeData(t, c)));
if (jclass == 0) { if (jclass == 0) {
jclass = t->m->classpath->makeJclass(t, c); jclass = cast<GcJclass>(t, t->m->classpath->makeJclass(t, c));
storeStoreMemoryBarrier(); storeStoreMemoryBarrier();
set(t, getClassRuntimeData(t, c), ClassRuntimeDataJclass, jclass); set(t, getClassRuntimeData(t, c), ClassRuntimeDataJclass, reinterpret_cast<object>(jclass));
} }
} }

View File

@ -37,9 +37,9 @@ codeReadInt32(Thread* t, object code, unsigned& ip)
} }
inline bool inline bool
isSuperclass(Thread* t, GcClass* class_, GcClass* base) isSuperclass(Thread* t UNUSED, GcClass* class_, GcClass* base)
{ {
for (GcClass* oc = cast<GcClass>(t, base->super()); oc; oc = cast<GcClass>(t, oc->super())) { for (GcClass* oc = base->super(); oc; oc = oc->super()) {
if (oc == class_) { if (oc == class_) {
return true; return true;
} }
@ -52,8 +52,8 @@ isSpecialMethod(Thread* t, GcMethod* method, GcClass* class_)
{ {
return (class_->flags() & ACC_SUPER) return (class_->flags() & ACC_SUPER)
and strcmp(reinterpret_cast<const int8_t*>("<init>"), and strcmp(reinterpret_cast<const int8_t*>("<init>"),
&byteArrayBody(t, method->name(), 0)) != 0 method->name()->body().begin()) != 0
and isSuperclass(t, cast<GcClass>(t, method->class_()), class_); and isSuperclass(t, method->class_(), class_);
} }
void void

View File

@ -51,7 +51,7 @@ resolveSystemClassThrow(Thread* t, object loader, object spec)
object object
fieldForOffsetInClass(Thread* t, GcClass* c, unsigned offset) fieldForOffsetInClass(Thread* t, GcClass* c, unsigned offset)
{ {
GcClass* super = cast<GcClass>(t, c->super()); GcClass* super = c->super();
if (super) { if (super) {
object field = fieldForOffsetInClass(t, super, offset); object field = fieldForOffsetInClass(t, super, offset);
if (field) { if (field) {

View File

@ -55,7 +55,8 @@ loadLibrary(Thread* t, object, uintptr_t* arguments)
{ {
object name = reinterpret_cast<object>(arguments[1]); object name = reinterpret_cast<object>(arguments[1]);
Thread::LibraryLoadStack stack(t, reinterpret_cast<object>(arguments[2])); Thread::LibraryLoadStack stack(
t, cast<GcClassLoader>(t, reinterpret_cast<object>(arguments[2])));
unsigned length = stringLength(t, name); unsigned length = stringLength(t, name);
THREAD_RUNTIME_ARRAY(t, char, n, length + 1); THREAD_RUNTIME_ARRAY(t, char, n, length + 1);
@ -106,12 +107,12 @@ void JNICALL
closeMemoryMappedFile(Thread*, GcMethod*, uintptr_t*); closeMemoryMappedFile(Thread*, GcMethod*, uintptr_t*);
object object
makeMethodOrConstructor(Thread* t, object c, unsigned index) makeMethodOrConstructor(Thread* t, GcJclass* c, unsigned index)
{ {
PROTECT(t, c); PROTECT(t, c);
object method = arrayBody object method = arrayBody
(t, classMethodTable(t, jclassVmClass(t, c)), index); (t, classMethodTable(t, c->vmClass()), index);
PROTECT(t, method); PROTECT(t, method);
unsigned parameterCount; unsigned parameterCount;
@ -121,7 +122,7 @@ makeMethodOrConstructor(Thread* t, object c, unsigned index)
&parameterCount, &returnTypeSpec); &parameterCount, &returnTypeSpec);
PROTECT(t, parameterTypes); PROTECT(t, parameterTypes);
object returnType = resolveJType GcJclass* returnType = resolveJType
(t, classLoader(t, methodClass(t, method)), reinterpret_cast<char*> (t, classLoader(t, methodClass(t, method)), reinterpret_cast<char*>
(&byteArrayBody(t, methodSpec(t, method), returnTypeSpec)), (&byteArrayBody(t, methodSpec(t, method), returnTypeSpec)),
byteArrayLength(t, methodSpec(t, method)) - 1 - returnTypeSpec); byteArrayLength(t, methodSpec(t, method)) - 1 - returnTypeSpec);
@ -136,9 +137,9 @@ makeMethodOrConstructor(Thread* t, object c, unsigned index)
} else { } else {
PROTECT(t, exceptionTypes); PROTECT(t, exceptionTypes);
object name = t->m->classpath->makeString GcString* name = cast<GcString>(t, t->m->classpath->makeString
(t, methodName(t, method), 0, (t, methodName(t, method), 0,
byteArrayLength(t, methodName(t, method)) - 1); byteArrayLength(t, methodName(t, method)) - 1));
return reinterpret_cast<object>(makeJmethod return reinterpret_cast<object>(makeJmethod
(t, 0, index, c, name, parameterTypes, exceptionTypes, returnType, 0, 0, (t, 0, index, c, name, parameterTypes, exceptionTypes, returnType, 0, 0,
@ -147,16 +148,16 @@ makeMethodOrConstructor(Thread* t, object c, unsigned index)
} }
object object
makeField(Thread* t, object c, unsigned index) makeField(Thread* t, GcJclass* c, unsigned index)
{ {
PROTECT(t, c); PROTECT(t, c);
object field = arrayBody object field = arrayBody
(t, classFieldTable(t, jclassVmClass(t, c)), index); (t, classFieldTable(t, c->vmClass()), index);
PROTECT(t, field); PROTECT(t, field);
object type = getJClass GcJclass* type = getJClass
(t, resolveClassBySpec (t, resolveClassBySpec
(t, classLoader(t, fieldClass(t, field)), (t, classLoader(t, fieldClass(t, field)),
reinterpret_cast<char*> reinterpret_cast<char*>
@ -164,9 +165,9 @@ makeField(Thread* t, object c, unsigned index)
byteArrayLength(t, fieldSpec(t, field)) - 1)); byteArrayLength(t, fieldSpec(t, field)) - 1));
PROTECT(t, type); PROTECT(t, type);
object name = t->m->classpath->makeString GcString* name = cast<GcString>(t, t->m->classpath->makeString
(t, fieldName(t, field), 0, (t, fieldName(t, field), 0,
byteArrayLength(t, fieldName(t, field)) - 1); byteArrayLength(t, fieldName(t, field)) - 1));
return reinterpret_cast<object>(makeJfield(t, 0, c, type, 0, 0, name, index)); return reinterpret_cast<object>(makeJfield(t, 0, c, type, 0, 0, name, index));
} }
@ -279,7 +280,7 @@ class MyClasspath : public Classpath {
} else { } else {
resolveSystemClass resolveSystemClass
(t, root(t, Machine::BootLoader), (t, root(t, Machine::BootLoader),
type(t, GcThreadGroup::Type)->name(), false); reinterpret_cast<object>(type(t, GcThreadGroup::Type)->name()), false);
group = makeNew(t, type(t, GcThreadGroup::Type)); group = makeNew(t, type(t, GcThreadGroup::Type));
@ -291,7 +292,7 @@ class MyClasspath : public Classpath {
resolveSystemClass resolveSystemClass
(t, root(t, Machine::BootLoader), (t, root(t, Machine::BootLoader),
type(t, GcThread::Type)->name(), false); reinterpret_cast<object>(type(t, GcThread::Type)->name()), false);
object thread = makeNew(t, type(t, GcThread::Type)); object thread = makeNew(t, type(t, GcThread::Type));
PROTECT(t, thread); PROTECT(t, thread);
@ -313,11 +314,11 @@ class MyClasspath : public Classpath {
virtual object virtual object
makeJMethod(Thread* t, GcMethod* vmMethod) makeJMethod(Thread* t, GcMethod* vmMethod)
{ {
object table = classMethodTable(t, vmMethod->class_()); object table = vmMethod->class_()->methodTable();
for (unsigned i = 0; i < arrayLength(t, table); ++i) { for (unsigned i = 0; i < arrayLength(t, table); ++i) {
if (reinterpret_cast<object>(vmMethod) == arrayBody(t, table, i)) { if (reinterpret_cast<object>(vmMethod) == arrayBody(t, table, i)) {
return makeMethodOrConstructor return makeMethodOrConstructor
(t, getJClass(t, cast<GcClass>(t, vmMethod->class_())), i); (t, getJClass(t, vmMethod->class_()), i);
} }
} }
abort(t); abort(t);
@ -570,15 +571,15 @@ class MyClasspath : public Classpath {
return true; return true;
} }
virtual object libraryClassLoader(Thread* t, GcMethod* caller) virtual GcClassLoader* libraryClassLoader(Thread* t, GcMethod* caller)
{ {
return strcmp( return strcmp(
"java/lang/Runtime", "java/lang/Runtime",
reinterpret_cast<char*>( reinterpret_cast<char*>(
&byteArrayBody(t, className(t, caller->class_()), 0))) caller->class_()->name()->body().begin()))
== 0 == 0
? t->libraryLoadStack->classLoader ? t->libraryLoadStack->classLoader
: classLoader(t, caller->class_()); : caller->class_()->loader();
} }
virtual void virtual void
@ -1088,9 +1089,9 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_Class_getInterfaces Avian_java_lang_Class_getInterfaces
(Thread* t, object, uintptr_t* arguments) (Thread* t, object, uintptr_t* arguments)
{ {
object c = reinterpret_cast<object>(arguments[0]); GcJclass* c = cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]));
object addendum = classAddendum(t, jclassVmClass(t, c)); object addendum = classAddendum(t, c->vmClass());
if (addendum) { if (addendum) {
object table = classAddendumInterfaceTable(t, addendum); object table = classAddendumInterfaceTable(t, addendum);
if (table) { if (table) {
@ -1100,8 +1101,8 @@ Avian_java_lang_Class_getInterfaces
PROTECT(t, array); PROTECT(t, array);
for (unsigned i = 0; i < arrayLength(t, table); ++i) { for (unsigned i = 0; i < arrayLength(t, table); ++i) {
object c = getJClass(t, cast<GcClass>(t, arrayBody(t, table, i))); GcJclass* c = getJClass(t, cast<GcClass>(t, arrayBody(t, table, i)));
set(t, array, ArrayBody + (i * BytesPerWord), c); set(t, array, ArrayBody + (i * BytesPerWord), reinterpret_cast<object>(c));
} }
return reinterpret_cast<uintptr_t>(array); return reinterpret_cast<uintptr_t>(array);
@ -1144,8 +1145,8 @@ Avian_java_lang_Class_getEnclosingMethod
if (enclosingClass) { if (enclosingClass) {
PROTECT(t, enclosingClass); PROTECT(t, enclosingClass);
enclosingClass = getJClass // enclosingClass = getJClass
(t, resolveClass(t, classLoader(t, c), enclosingClass)); // (t, resolveClass(t, classLoader(t, c), enclosingClass));
object enclosingMethod = classAddendumEnclosingMethod(t, addendum); object enclosingMethod = classAddendumEnclosingMethod(t, addendum);
if (enclosingMethod) { if (enclosingMethod) {
@ -1196,16 +1197,16 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_Class_getComponentType Avian_java_lang_Class_getComponentType
(Thread* t, object, uintptr_t* arguments) (Thread* t, object, uintptr_t* arguments)
{ {
object c = reinterpret_cast<object>(arguments[0]); GcJclass* c = cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]));
if (classArrayDimensions(t, jclassVmClass(t, c))) { if (classArrayDimensions(t, c->vmClass())) {
uint8_t n = byteArrayBody(t, className(t, jclassVmClass(t, c)), 1); uint8_t n = byteArrayBody(t, className(t, c->vmClass()), 1);
if (n != 'L' and n != '[') { if (n != 'L' and n != '[') {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(getJClass(t, primitiveClass(t, n))); (getJClass(t, primitiveClass(t, n)));
} else { } else {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(getJClass(t, cast<GcClass>(t, classStaticTable(t, jclassVmClass(t, c))))); (getJClass(t, cast<GcClass>(t, classStaticTable(t, c->vmClass()))));
} }
} else { } else {
return 0; return 0;
@ -1235,7 +1236,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_Class_getDeclaredField Avian_java_lang_Class_getDeclaredField
(Thread* t, object, uintptr_t* arguments) (Thread* t, object, uintptr_t* arguments)
{ {
object c = reinterpret_cast<object>(arguments[0]); GcJclass* c = cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]));
PROTECT(t, c); PROTECT(t, c);
object name = reinterpret_cast<object>(arguments[1]); object name = reinterpret_cast<object>(arguments[1]);
@ -1247,7 +1248,7 @@ Avian_java_lang_Class_getDeclaredField
int index = intValue int index = intValue
(t, t->m->processor->invoke (t, t->m->processor->invoke
(t, method, 0, jclassVmClass(t, c), name)); (t, method, 0, c->vmClass(), name));
if (index >= 0) { if (index >= 0) {
return reinterpret_cast<uintptr_t>(local::makeField(t, c, index)); return reinterpret_cast<uintptr_t>(local::makeField(t, c, index));
@ -1260,7 +1261,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_Class_getDeclaredConstructorOrMethod Avian_java_lang_Class_getDeclaredConstructorOrMethod
(Thread* t, object, uintptr_t* arguments) (Thread* t, object, uintptr_t* arguments)
{ {
object c = reinterpret_cast<object>(arguments[0]); GcJclass* c = cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]));
PROTECT(t, c); PROTECT(t, c);
object name = reinterpret_cast<object>(arguments[1]); object name = reinterpret_cast<object>(arguments[1]);
@ -1275,7 +1276,7 @@ Avian_java_lang_Class_getDeclaredConstructorOrMethod
int index = intValue int index = intValue
(t, t->m->processor->invoke (t, t->m->processor->invoke
(t, method, 0, jclassVmClass(t, c), name, parameterTypes)); (t, method, 0, c->vmClass(), name, parameterTypes));
if (index >= 0) { if (index >= 0) {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
@ -1520,13 +1521,13 @@ Avian_dalvik_system_VMStack_getCallingClassLoader
if (counter--) { if (counter--) {
return true; return true;
} else { } else {
this->loader = classLoader(t, walker->method()->class_()); this->loader = walker->method()->class_()->loader();
return false; return false;
} }
} }
Thread* t; Thread* t;
object loader; GcClassLoader* loader;
unsigned counter; unsigned counter;
} v(t); } v(t);
@ -1554,11 +1555,11 @@ Avian_dalvik_system_VMStack_getClasses
(t, type(t, GcJclass::Type), walker->count()); (t, type(t, GcJclass::Type), walker->count());
} }
object c = getJClass(t, cast<GcClass>(t, walker->method()->class_())); GcJclass* c = getJClass(t, walker->method()->class_());
assertT(t, counter - 2 < objectArrayLength(t, array)); assertT(t, counter - 2 < objectArrayLength(t, array));
set(t, array, ArrayBody + ((counter - 2) * BytesPerWord), c); set(t, array, ArrayBody + ((counter - 2) * BytesPerWord), reinterpret_cast<object>(c));
return true; return true;
} }
@ -1828,7 +1829,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_Class_getDeclaredMethods Avian_java_lang_Class_getDeclaredMethods
(Thread* t, object, uintptr_t* arguments) (Thread* t, object, uintptr_t* arguments)
{ {
object c = reinterpret_cast<object>(arguments[0]); GcJclass* c = cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]));
PROTECT(t, c); PROTECT(t, c);
bool publicOnly = arguments[1]; bool publicOnly = arguments[1];
@ -1838,14 +1839,14 @@ Avian_java_lang_Class_getDeclaredMethods
"(Lavian/VMClass;Z)[Ljava/lang/reflect/Method;"); "(Lavian/VMClass;Z)[Ljava/lang/reflect/Method;");
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(t->m->processor->invoke(t, get, 0, jclassVmClass(t, c), publicOnly)); (t->m->processor->invoke(t, get, 0, c->vmClass(), publicOnly));
} }
extern "C" AVIAN_EXPORT int64_t JNICALL extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_Class_getDeclaredFields Avian_java_lang_Class_getDeclaredFields
(Thread* t, object, uintptr_t* arguments) (Thread* t, object, uintptr_t* arguments)
{ {
object c = reinterpret_cast<object>(arguments[0]); GcJclass* c = cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]));
PROTECT(t, c); PROTECT(t, c);
bool publicOnly = arguments[1]; bool publicOnly = arguments[1];
@ -1855,7 +1856,7 @@ Avian_java_lang_Class_getDeclaredFields
"(Lavian/VMClass;Z)[Ljava/lang/reflect/Field;"); "(Lavian/VMClass;Z)[Ljava/lang/reflect/Field;");
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(t->m->processor->invoke(t, get, 0, jclassVmClass(t, c), publicOnly)); (t->m->processor->invoke(t, get, 0, c->vmClass(), publicOnly));
} }
extern "C" AVIAN_EXPORT int64_t JNICALL extern "C" AVIAN_EXPORT int64_t JNICALL
@ -2282,7 +2283,7 @@ Avian_avian_Classes_makeMethod
{ {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(local::makeMethodOrConstructor (local::makeMethodOrConstructor
(t, reinterpret_cast<object>(arguments[0]), arguments[1])); (t, cast<GcJclass>(t, reinterpret_cast<object>(arguments[0])), arguments[1]));
} }
extern "C" AVIAN_EXPORT int64_t JNICALL extern "C" AVIAN_EXPORT int64_t JNICALL
@ -2291,7 +2292,7 @@ Avian_avian_Classes_makeField
{ {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(local::makeField (local::makeField
(t, reinterpret_cast<object>(arguments[0]), arguments[1])); (t, cast<GcJclass>(t, reinterpret_cast<object>(arguments[0])), arguments[1]));
} }
extern "C" AVIAN_EXPORT int64_t JNICALL extern "C" AVIAN_EXPORT int64_t JNICALL

View File

@ -29,7 +29,7 @@ class MyClasspath : public Classpath {
virtual object virtual object
makeJclass(Thread* t, GcClass* class_) makeJclass(Thread* t, GcClass* class_)
{ {
return reinterpret_cast<object>(vm::makeJclass(t, reinterpret_cast<object>(class_))); return reinterpret_cast<object>(vm::makeJclass(t, class_));
} }
virtual object virtual object
@ -53,7 +53,7 @@ class MyClasspath : public Classpath {
return reinterpret_cast<object>(vm::makeThread return reinterpret_cast<object>(vm::makeThread
(t, 0, 0, 0, 0, 0, NewState, NormalPriority, 0, 0, 0, (t, 0, 0, 0, 0, 0, NewState, NormalPriority, 0, 0, 0,
root(t, Machine::AppLoader), 0, 0, group, 0)); cast<GcClassLoader>(t, root(t, Machine::AppLoader)), 0, 0, cast<GcThreadGroup>(t, group), 0));
} }
virtual object virtual object
@ -61,10 +61,10 @@ class MyClasspath : public Classpath {
{ {
PROTECT(t, vmMethod); PROTECT(t, vmMethod);
object jmethod = reinterpret_cast<object>(makeJmethod(t, reinterpret_cast<object>(vmMethod), false)); object jmethod = reinterpret_cast<object>(makeJmethod(t, vmMethod, false));
return byteArrayBody(t, vmMethod->name(), 0) == '<' return vmMethod->name()->body()[0] == '<'
? reinterpret_cast<object>(makeJconstructor(t, jmethod)) : jmethod; ? reinterpret_cast<object>(makeJconstructor(t, cast<GcJmethod>(t, jmethod))) : jmethod;
} }
virtual object virtual object
@ -78,7 +78,7 @@ class MyClasspath : public Classpath {
virtual object virtual object
makeJField(Thread* t, object vmField) makeJField(Thread* t, object vmField)
{ {
return reinterpret_cast<object>(makeJfield(t, vmField, false)); return reinterpret_cast<object>(makeJfield(t, cast<GcField>(t, vmField), false));
} }
virtual object virtual object
@ -204,12 +204,12 @@ class MyClasspath : public Classpath {
&byteArrayBody(t, calleeClassName, 0))))); &byteArrayBody(t, calleeClassName, 0)))));
} }
virtual object libraryClassLoader(Thread* t, GcMethod* caller) virtual GcClassLoader* libraryClassLoader(Thread* t, GcMethod* caller)
{ {
return (caller->class_() == reinterpret_cast<object>(type(t, Gc::ClassLoaderType)) return (caller->class_() == type(t, Gc::ClassLoaderType)
and t->libraryLoadStack) and t->libraryLoadStack)
? t->libraryLoadStack->classLoader ? t->libraryLoadStack->classLoader
: classLoader(t, caller->class_()); : caller->class_()->loader();
} }
virtual void virtual void
@ -265,7 +265,7 @@ Avian_java_lang_Object_toString
unsigned hash = objectHash(t, this_); unsigned hash = objectHash(t, this_);
object s = makeString object s = makeString
(t, "%s@0x%x", (t, "%s@0x%x",
&byteArrayBody(t, objectClass(t, this_)->name(), 0), objectClass(t, this_)->name()->body().begin(),
hash); hash);
return reinterpret_cast<int64_t>(s); return reinterpret_cast<int64_t>(s);
@ -581,7 +581,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_ClassLoader_getCaller(Thread* t, object, uintptr_t*) Avian_java_lang_ClassLoader_getCaller(Thread* t, object, uintptr_t*)
{ {
return reinterpret_cast<int64_t>( return reinterpret_cast<int64_t>(
getJClass(t, cast<GcClass>(t, getCaller(t, 2)->class_()))); getJClass(t, getCaller(t, 2)->class_()));
} }
extern "C" AVIAN_EXPORT void JNICALL extern "C" AVIAN_EXPORT void JNICALL
@ -591,7 +591,7 @@ extern "C" AVIAN_EXPORT void JNICALL
Thread::LibraryLoadStack stack( Thread::LibraryLoadStack stack(
t, t,
classLoader(t, jclassVmClass(t, reinterpret_cast<object>(arguments[1])))); cast<GcJclass>(t, reinterpret_cast<object>(arguments[1]))->vmClass()->loader());
bool mapName = arguments[2]; bool mapName = arguments[2];

View File

@ -331,7 +331,7 @@ getClassName(Thread* t, GcClass* c)
} }
} }
return c->name(); return reinterpret_cast<object>(c->name());
} }
object object
@ -579,7 +579,7 @@ class MyClasspath : public Classpath {
{ {
PROTECT(t, vmMethod); PROTECT(t, vmMethod);
return byteArrayBody(t, vmMethod->name(), 0) == '<' return vmMethod->name()->body()[0] == '<'
? reinterpret_cast<object>(makeJconstructor(t, reinterpret_cast<object>(vmMethod))) ? reinterpret_cast<object>(makeJconstructor(t, reinterpret_cast<object>(vmMethod)))
: reinterpret_cast<object>(makeJmethod(t, reinterpret_cast<object>(vmMethod))); : reinterpret_cast<object>(makeJmethod(t, reinterpret_cast<object>(vmMethod)));
} }
@ -653,11 +653,11 @@ class MyClasspath : public Classpath {
resolveNative(Thread* t, GcMethod* method) resolveNative(Thread* t, GcMethod* method)
{ {
if (strcmp(reinterpret_cast<const int8_t*>("sun/font/SunFontManager"), if (strcmp(reinterpret_cast<const int8_t*>("sun/font/SunFontManager"),
&byteArrayBody(t, className(t, method->class_()), 0)) == 0 method->class_()->name()->body().begin()) == 0
and strcmp(reinterpret_cast<const int8_t*>("initIDs"), and strcmp(reinterpret_cast<const int8_t*>("initIDs"),
&byteArrayBody(t, method->name(), 0)) == 0 method->name()->body().begin()) == 0
and strcmp(reinterpret_cast<const int8_t*>("()V"), and strcmp(reinterpret_cast<const int8_t*>("()V"),
&byteArrayBody(t, method->spec(), 0)) == 0) method->spec()->body().begin()) == 0)
{ {
PROTECT(t, method); PROTECT(t, method);
@ -692,7 +692,7 @@ class MyClasspath : public Classpath {
globalMachine = t->m; globalMachine = t->m;
resolveSystemClass(t, root(t, Machine::BootLoader), resolveSystemClass(t, root(t, Machine::BootLoader),
type(t, GcClassLoader::Type)->name()); reinterpret_cast<object>(type(t, GcClassLoader::Type)->name()));
setRoot(t, Machine::ThreadTerminated, reinterpret_cast<object>(resolveMethod setRoot(t, Machine::ThreadTerminated, reinterpret_cast<object>(resolveMethod
(t, root(t, Machine::BootLoader), "java/lang/ThreadGroup", (t, root(t, Machine::BootLoader), "java/lang/ThreadGroup",
@ -844,30 +844,28 @@ class MyClasspath : public Classpath {
(&byteArrayBody(t, calleeClassName, 0)))); (&byteArrayBody(t, calleeClassName, 0))));
} }
virtual object libraryClassLoader(Thread* t, GcMethod* caller) virtual GcClassLoader* libraryClassLoader(Thread* t, GcMethod* caller)
{ {
#ifdef AVIAN_OPENJDK_SRC #ifdef AVIAN_OPENJDK_SRC
return (caller->class_() == type(t, Machine::ClassLoaderType) return (caller->class_()
and t->libraryLoadStack) == type(t, Machine::ClassLoaderType) and t->libraryLoadStack)
? t->libraryLoadStack->classLoader ? t->libraryLoadStack->classLoader
#else #else
return strcmp( return strcmp("java/lang/ClassLoader$NativeLibrary",
"java/lang/ClassLoader$NativeLibrary", reinterpret_cast
reinterpret_cast<char*>( <char*>(caller->class_()->name()->body().begin())) == 0
&byteArrayBody(t, className(t, caller->class_()), 0))) ? cast<GcClass>(
== 0
? classLoader(
t, t,
jclassVmClass(t, cast<GcJclass>(t,
t->m->processor->invoke( t->m->processor->invoke(
t, t,
resolveMethod(t, resolveMethod(t,
cast<GcClass>(t, caller->class_()), caller->class_(),
"getFromClass", "getFromClass",
"()Ljava/lang/Class;"), "()Ljava/lang/Class;"),
0))) 0))->vmClass())->loader()
#endif #endif
: classLoader(t, caller->class_()); : caller->class_()->loader();
} }
virtual void virtual void
@ -2236,7 +2234,7 @@ makeJmethod(Thread* t, object vmMethod, int index)
&parameterCount, &returnTypeSpec); &parameterCount, &returnTypeSpec);
PROTECT(t, parameterTypes); PROTECT(t, parameterTypes);
object returnType = resolveJType GcJclass* returnType = resolveJType
(t, classLoader(t, methodClass(t, vmMethod)), reinterpret_cast<char*> (t, classLoader(t, methodClass(t, vmMethod)), reinterpret_cast<char*>
(&byteArrayBody(t, methodSpec(t, vmMethod), returnTypeSpec)), (&byteArrayBody(t, methodSpec(t, vmMethod), returnTypeSpec)),
byteArrayLength(t, methodSpec(t, vmMethod)) - 1 - returnTypeSpec); byteArrayLength(t, methodSpec(t, vmMethod)) - 1 - returnTypeSpec);
@ -2298,12 +2296,12 @@ makeJmethod(Thread* t, object vmMethod, int index)
expect(t, index != -1); expect(t, index != -1);
object jclass = getJClass(t, cast<GcClass>(t, methodClass(t, vmMethod))); GcJclass* jclass = getJClass(t, cast<GcClass>(t, methodClass(t, vmMethod)));
return reinterpret_cast<object>(makeJmethod return reinterpret_cast<object>(makeJmethod
(t, true, 0, jclass, index, name, returnType, parameterTypes, (t, true, 0, jclass, index, cast<GcString>(t, name), returnType, parameterTypes,
exceptionTypes, methodFlags(t, vmMethod), signature, 0, annotationTable, exceptionTypes, methodFlags(t, vmMethod), cast<GcString>(t, signature), 0, cast<GcByteArray>(t, annotationTable),
parameterAnnotationTable, annotationDefault, 0, 0, 0)); cast<GcByteArray>(t, parameterAnnotationTable), cast<GcByteArray>(t, annotationDefault), 0, 0, 0));
} }
object object
@ -2368,11 +2366,11 @@ makeJconstructor(Thread* t, object vmMethod, int index)
expect(t, index != -1); expect(t, index != -1);
object jclass = getJClass(t, cast<GcClass>(t, methodClass(t, vmMethod))); GcJclass* jclass = getJClass(t, cast<GcClass>(t, methodClass(t, vmMethod)));
return reinterpret_cast<object>(makeJconstructor return reinterpret_cast<object>(makeJconstructor
(t, true, 0, jclass, index, parameterTypes, exceptionTypes, methodFlags (t, true, 0, jclass, index, parameterTypes, exceptionTypes, methodFlags
(t, vmMethod), signature, 0, annotationTable, parameterAnnotationTable, (t, vmMethod), cast<GcString>(t, signature), 0, cast<GcByteArray>(t, annotationTable), cast<GcByteArray>(t, parameterAnnotationTable),
0, 0, 0)); 0, 0, 0));
} }
@ -2394,7 +2392,7 @@ makeJfield(Thread* t, object vmField, int index)
byteArrayLength(t, fieldSpec(t, vmField)) - 1); byteArrayLength(t, fieldSpec(t, vmField)) - 1);
PROTECT(t, type); PROTECT(t, type);
object jtype = getJClass(t, type); GcJclass* jtype = getJClass(t, type);
object signature; object signature;
object annotationTable; object annotationTable;
@ -2436,11 +2434,11 @@ makeJfield(Thread* t, object vmField, int index)
expect(t, index != -1); expect(t, index != -1);
object jclass = getJClass(t, cast<GcClass>(t, fieldClass(t, vmField))); GcJclass* jclass = getJClass(t, cast<GcClass>(t, fieldClass(t, vmField)));
return reinterpret_cast<object>(makeJfield return reinterpret_cast<object>(makeJfield
(t, true, 0, jclass, index, name, jtype, fieldFlags (t, true, 0, jclass, index, cast<GcString>(t, name), jtype, fieldFlags
(t, vmField), signature, 0, annotationTable, 0, 0, 0, 0)); (t, vmField), cast<GcString>(t, signature), 0, cast<GcByteArray>(t, annotationTable), 0, 0, 0, 0));
} }
void void
@ -3414,7 +3412,7 @@ jvmDumpThreads(Thread* t, uintptr_t* arguments)
unsigned threadsLength = objectArrayLength(t, *threads); unsigned threadsLength = objectArrayLength(t, *threads);
GcClass* arrayClass = resolveObjectArrayClass GcClass* arrayClass = resolveObjectArrayClass
(t, type(t, GcStackTraceElement::Type)->loader(), (t, reinterpret_cast<object>(type(t, GcStackTraceElement::Type)->loader()),
reinterpret_cast<object>(type(t, GcStackTraceElement::Type))); reinterpret_cast<object>(type(t, GcStackTraceElement::Type)));
object result = makeObjectArray(t, arrayClass, threadsLength); object result = makeObjectArray(t, arrayClass, threadsLength);
PROTECT(t, result); PROTECT(t, result);
@ -3478,12 +3476,12 @@ jvmGetClassContext(Thread* t, uintptr_t*)
PROTECT(t, context); PROTECT(t, context);
for (unsigned i = 0; i < objectArrayLength(t, trace); ++i) { for (unsigned i = 0; i < objectArrayLength(t, trace); ++i) {
object c = getJClass( object c = reinterpret_cast<object>(getJClass(
t, t,
cast<GcClass>( cast<GcClass>(
t, t,
methodClass(t, methodClass(t,
traceElementMethod(t, objectArrayBody(t, trace, i))))); traceElementMethod(t, objectArrayBody(t, trace, i))))));
set(t, context, ArrayBody + (i * BytesPerWord), c); set(t, context, ArrayBody + (i * BytesPerWord), c);
} }
@ -3574,11 +3572,11 @@ EXPORT(JVM_LatestUserDefinedLoader)(Thread* t)
{ } { }
virtual bool visit(Processor::StackWalker* walker) { virtual bool visit(Processor::StackWalker* walker) {
object loader = classLoader(t, walker->method()->class_()); object loader = reinterpret_cast<object>(walker->method()->class_()->loader());
if (loader if (loader
and loader != root(t, Machine::BootLoader) and loader != root(t, Machine::BootLoader)
and strcmp and strcmp
(&byteArrayBody(t, objectClass(t, loader)->name(), 0), (objectClass(t, loader)->name()->body().begin(),
reinterpret_cast<const int8_t*> reinterpret_cast<const int8_t*>
("sun/reflect/DelegatingClassLoader"))) ("sun/reflect/DelegatingClassLoader")))
{ {
@ -3616,7 +3614,7 @@ jvmGetArrayElement(Thread* t, uintptr_t* arguments)
jobject array = reinterpret_cast<jobject>(arguments[0]); jobject array = reinterpret_cast<jobject>(arguments[0]);
jint index = arguments[1]; jint index = arguments[1];
switch (byteArrayBody(t, objectClass(t, *array)->name(), 1)) { switch (objectClass(t, *array)->name()->body()[1]) {
case 'Z': case 'Z':
return reinterpret_cast<intptr_t> return reinterpret_cast<intptr_t>
(makeLocalReference (makeLocalReference
@ -3677,7 +3675,7 @@ EXPORT(JVM_SetArrayElement)(Thread* t, jobject array, jint index,
{ {
ENTER(t, Thread::ActiveState); ENTER(t, Thread::ActiveState);
switch (byteArrayBody(t, objectClass(t, *array)->name(), 1)) { switch (objectClass(t, *array)->name()->body()[1]) {
case 'Z': case 'Z':
fieldAtOffset<int8_t>(*array, ArrayBody + index) = booleanValue(t, *value); fieldAtOffset<int8_t>(*array, ArrayBody + index) = booleanValue(t, *value);
break; break;
@ -3806,7 +3804,7 @@ EXPORT(JVM_GetCallerClass)(Thread* t, int target)
GcMethod* method = getCaller(t, target, true); GcMethod* method = getCaller(t, target, true);
return method ? makeLocalReference return method ? makeLocalReference
(t, getJClass(t, cast<GcClass>(t, method->class_()))) : 0; (t, reinterpret_cast<object>(getJClass(t, method->class_()))) : 0;
} }
extern "C" AVIAN_EXPORT jclass JNICALL extern "C" AVIAN_EXPORT jclass JNICALL
@ -3818,32 +3816,32 @@ EXPORT(JVM_FindPrimitiveClass)(Thread* t, const char* name)
case 'b': case 'b':
if (name[1] == 'o') { if (name[1] == 'o') {
return makeLocalReference return makeLocalReference
(t, getJClass(t, type(t, GcJboolean::Type))); (t, reinterpret_cast<object>(getJClass(t, type(t, GcJboolean::Type))));
} else { } else {
return makeLocalReference return makeLocalReference
(t, getJClass(t, type(t, GcJbyte::Type))); (t, reinterpret_cast<object>(getJClass(t, type(t, GcJbyte::Type))));
} }
case 'c': case 'c':
return makeLocalReference return makeLocalReference
(t, getJClass(t, type(t, GcJchar::Type))); (t, reinterpret_cast<object>(getJClass(t, type(t, GcJchar::Type))));
case 'd': case 'd':
return makeLocalReference return makeLocalReference
(t, getJClass(t, type(t, GcJdouble::Type))); (t, reinterpret_cast<object>(getJClass(t, type(t, GcJdouble::Type))));
case 'f': case 'f':
return makeLocalReference return makeLocalReference
(t, getJClass(t, type(t, GcJfloat::Type))); (t, reinterpret_cast<object>(getJClass(t, type(t, GcJfloat::Type))));
case 'i': case 'i':
return makeLocalReference return makeLocalReference
(t, getJClass(t, type(t, GcJint::Type))); (t, reinterpret_cast<object>(getJClass(t, type(t, GcJint::Type))));
case 'l': case 'l':
return makeLocalReference return makeLocalReference
(t, getJClass(t, type(t, GcJlong::Type))); (t, reinterpret_cast<object>(getJClass(t, type(t, GcJlong::Type))));
case 's': case 's':
return makeLocalReference return makeLocalReference
(t, getJClass(t, type(t, GcJshort::Type))); (t, reinterpret_cast<object>(getJClass(t, type(t, GcJshort::Type))));
case 'v': case 'v':
return makeLocalReference return makeLocalReference
(t, getJClass(t, type(t, GcJvoid::Type))); (t, reinterpret_cast<object>(getJClass(t, type(t, GcJvoid::Type))));
default: default:
throwNew(t, GcIllegalArgumentException::Type); throwNew(t, GcIllegalArgumentException::Type);
} }
@ -3890,7 +3888,7 @@ jvmFindClassFromClassLoader(Thread* t, uintptr_t* arguments)
initClass(t, c); initClass(t, c);
} }
return reinterpret_cast<uint64_t>(makeLocalReference(t, getJClass(t, c))); return reinterpret_cast<uint64_t>(makeLocalReference(t, reinterpret_cast<object>(getJClass(t, c))));
} }
extern "C" AVIAN_EXPORT jclass JNICALL extern "C" AVIAN_EXPORT jclass JNICALL
@ -3933,7 +3931,7 @@ jvmFindLoadedClass(Thread* t, uintptr_t* arguments)
GcClass* c = findLoadedClass(t, *loader, spec); GcClass* c = findLoadedClass(t, *loader, spec);
return reinterpret_cast<uint64_t> return reinterpret_cast<uint64_t>
(c ? makeLocalReference(t, getJClass(t, c)) : 0); (c ? makeLocalReference(t, reinterpret_cast<object>(getJClass(t, c))) : 0);
} }
extern "C" AVIAN_EXPORT jclass JNICALL extern "C" AVIAN_EXPORT jclass JNICALL
@ -3954,7 +3952,7 @@ jvmDefineClass(Thread* t, uintptr_t* arguments)
return reinterpret_cast<uint64_t> return reinterpret_cast<uint64_t>
(makeLocalReference (makeLocalReference
(t, getJClass(t, cast<GcClass>(t, defineClass(t, *loader, data, length))))); (t, reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, defineClass(t, *loader, data, length))))));
} }
extern "C" AVIAN_EXPORT jclass JNICALL extern "C" AVIAN_EXPORT jclass JNICALL
@ -4008,7 +4006,7 @@ jvmGetClassInterfaces(Thread* t, uintptr_t* arguments)
PROTECT(t, array); PROTECT(t, array);
for (unsigned i = 0; i < arrayLength(t, table); ++i) { for (unsigned i = 0; i < arrayLength(t, table); ++i) {
object c = getJClass(t, cast<GcClass>(t, arrayBody(t, table, i))); object c = reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, arrayBody(t, table, i))));
set(t, array, ArrayBody + (i * BytesPerWord), c); set(t, array, ArrayBody + (i * BytesPerWord), c);
} }
@ -4043,7 +4041,7 @@ EXPORT(JVM_GetClassLoader)(Thread* t, jclass c)
GcMethod* caller = getCaller(t, 2); GcMethod* caller = getCaller(t, 2);
if (caller and strcmp if (caller and strcmp
(reinterpret_cast<const char*> (reinterpret_cast<const char*>
(&byteArrayBody(t, className(t, caller->class_()), 0)), (caller->class_()->name()->body().begin()),
"sun/misc/Unsafe") == 0) "sun/misc/Unsafe") == 0)
{ {
return 0; return 0;
@ -4152,11 +4150,11 @@ jvmGetComponentType(Thread* t, uintptr_t* arguments)
uint8_t n = byteArrayBody(t, className(t, jclassVmClass(t, *c)), 1); uint8_t n = byteArrayBody(t, className(t, jclassVmClass(t, *c)), 1);
if (n != 'L' and n != '[') { if (n != 'L' and n != '[') {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(makeLocalReference(t, getJClass(t, primitiveClass(t, n)))); (makeLocalReference(t, reinterpret_cast<object>(getJClass(t, primitiveClass(t, n)))));
} else { } else {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(makeLocalReference (makeLocalReference
(t, getJClass(t, cast<GcClass>(t, classStaticTable(t, jclassVmClass(t, *c)))))); (t, reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, classStaticTable(t, jclassVmClass(t, *c)))))));
} }
} else { } else {
return 0; return 0;
@ -4208,8 +4206,8 @@ jvmGetDeclaringClass(Thread* t, uintptr_t* arguments)
{ {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(makeLocalReference (makeLocalReference
(t, getDeclaringClass (t, reinterpret_cast<object>(getDeclaringClass
(t, jclassVmClass(t, *reinterpret_cast<jobject>(arguments[0]))))); (t, jclassVmClass(t, *reinterpret_cast<jobject>(arguments[0]))))));
} }
extern "C" AVIAN_EXPORT jclass JNICALL extern "C" AVIAN_EXPORT jclass JNICALL
@ -4429,7 +4427,7 @@ jvmInvokeMethod(Thread* t, uintptr_t* arguments)
instance = 0; instance = 0;
} }
if (instance and not instanceOf(t, cast<GcClass>(t, vmMethod->class_()), *instance)) { if (instance and not instanceOf(t, vmMethod->class_(), *instance)) {
throwNew(t, GcIllegalArgumentException::Type); throwNew(t, GcIllegalArgumentException::Type);
} }
@ -5260,8 +5258,8 @@ getEnclosingMethodInfo(Thread* t, uintptr_t* arguments)
object array = makeObjectArray(t, type(t, GcJobject::Type), 3); object array = makeObjectArray(t, type(t, GcJobject::Type), 3);
PROTECT(t, array); PROTECT(t, array);
enclosingClass = getJClass enclosingClass = reinterpret_cast<object>(getJClass
(t, resolveClass(t, classLoader(t, class_), enclosingClass)); (t, resolveClass(t, classLoader(t, class_), enclosingClass)));
set(t, array, ArrayBody, enclosingClass); set(t, array, ArrayBody, enclosingClass);

View File

@ -318,7 +318,7 @@ GcMethod*
findMethod(Thread* t, GcMethod* method, object instance) findMethod(Thread* t, GcMethod* method, object instance)
{ {
if ((method->flags() & ACC_STATIC) == 0) { if ((method->flags() & ACC_STATIC) == 0) {
if (classFlags(t, method->class_()) & ACC_INTERFACE) { if (method->class_()->flags() & ACC_INTERFACE) {
return findInterfaceMethod(t, method, objectClass(t, instance)); return findInterfaceMethod(t, method, objectClass(t, instance));
} else if (methodVirtual(t, method)) { } else if (methodVirtual(t, method)) {
return findVirtualMethod(t, method, objectClass(t, instance)); return findVirtualMethod(t, method, objectClass(t, instance));
@ -336,10 +336,10 @@ resolveTarget(MyThread* t, void* stack, GcMethod* method)
PROTECT(t, method); PROTECT(t, method);
PROTECT(t, class_); PROTECT(t, class_);
resolveSystemClass(t, root(t, Machine::BootLoader), class_->name()); resolveSystemClass(t, root(t, Machine::BootLoader), reinterpret_cast<object>(class_->name()));
} }
if (classFlags(t, method->class_()) & ACC_INTERFACE) { if (method->class_()->flags() & ACC_INTERFACE) {
return findInterfaceMethod(t, method, class_); return findInterfaceMethod(t, method, class_);
} else { } else {
return findVirtualMethod(t, method, class_); return findVirtualMethod(t, method, class_);
@ -352,7 +352,7 @@ resolveTarget(MyThread* t, GcClass* class_, unsigned index)
if (class_->vmFlags() & BootstrapFlag) { if (class_->vmFlags() & BootstrapFlag) {
PROTECT(t, class_); PROTECT(t, class_);
resolveSystemClass(t, root(t, Machine::BootLoader), class_->name()); resolveSystemClass(t, root(t, Machine::BootLoader), reinterpret_cast<object>(class_->name()));
} }
return cast<GcMethod>(t, arrayBody(t, class_->virtualTable(), index)); return cast<GcMethod>(t, arrayBody(t, class_->virtualTable(), index));
@ -456,11 +456,11 @@ nextFrame(MyThread* t, void** ip, void** sp, GcMethod* method, GcMethod* target,
} }
// fprintf(stderr, "nextFrame %s.%s%s target %s.%s%s ip %p sp %p\n", // fprintf(stderr, "nextFrame %s.%s%s target %s.%s%s ip %p sp %p\n",
// &byteArrayBody(t, className(t, method->class_()), 0), // method->class_()->name()->body().begin(),
// &byteArrayBody(t, method->name(), 0), // method->name()->body().begin(),
// &byteArrayBody(t, method->spec(), 0), // method->spec()->body().begin(),
// target // target
// ? &byteArrayBody(t, className(t, target->class_()), 0) // ? &byteArrayBody(t, target->class_()->name(), 0)
// : 0, // : 0,
// target // target
// ? &byteArrayBody(t, methodName(t, target), 0) // ? &byteArrayBody(t, methodName(t, target), 0)
@ -2006,7 +2006,7 @@ releaseLock(MyThread* t, GcMethod* method, void* stack)
if (t->methodLockIsClean) { if (t->methodLockIsClean) {
object lock; object lock;
if (method->flags() & ACC_STATIC) { if (method->flags() & ACC_STATIC) {
lock = method->class_(); lock = reinterpret_cast<object>(method->class_());
} else { } else {
lock = *localObject lock = *localObject
(t, stackForFrame(t, stack, method), method, (t, stackForFrame(t, stack, method), method,
@ -2301,9 +2301,9 @@ prepareMethodForCall(MyThread* t, GcMethod* target)
{ {
if (methodAbstract(t, target)) { if (methodAbstract(t, target)) {
throwNew(t, GcAbstractMethodError::Type, "%s.%s%s", throwNew(t, GcAbstractMethodError::Type, "%s.%s%s",
&byteArrayBody(t, className(t, target->class_()), 0), target->class_()->name()->body().begin(),
&byteArrayBody(t, target->name(), 0), target->name()->body().begin(),
&byteArrayBody(t, target->spec(), 0)); target->spec()->body().begin());
} else { } else {
if (unresolved(t, methodAddress(t, target))) { if (unresolved(t, methodAddress(t, target))) {
PROTECT(t, target); PROTECT(t, target);
@ -2347,9 +2347,9 @@ checkMethod(Thread* t, GcMethod* method, bool shouldBeStatic)
if (((method->flags() & ACC_STATIC) == 0) == shouldBeStatic) { if (((method->flags() & ACC_STATIC) == 0) == shouldBeStatic) {
throwNew(t, GcIncompatibleClassChangeError::Type, throwNew(t, GcIncompatibleClassChangeError::Type,
"expected %s.%s%s to be %s", "expected %s.%s%s to be %s",
&byteArrayBody(t, className(t, method->class_()), 0), method->class_()->name()->body().begin(),
&byteArrayBody(t, method->name(), 0), method->name()->body().begin(),
&byteArrayBody(t, method->spec(), 0), method->spec()->body().begin(),
shouldBeStatic ? "static" : "non-static"); shouldBeStatic ? "static" : "non-static");
} }
} }
@ -2375,7 +2375,7 @@ findSpecialMethodFromReference(MyThread* t, object pair)
GcClass* class_ = cast<GcClass>(t, methodClass(t, pairFirst(t, pair))); GcClass* class_ = cast<GcClass>(t, methodClass(t, pairFirst(t, pair)));
if (isSpecialMethod(t, target, class_)) { if (isSpecialMethod(t, target, class_)) {
target = findVirtualMethod(t, target, cast<GcClass>(t, class_->super())); target = findVirtualMethod(t, target, class_->super());
} }
checkMethod(t, target, false); checkMethod(t, target, false);
@ -2440,8 +2440,8 @@ traceSize(Thread* t)
t->m->processor->walkStack(t, &counter); t->m->processor->walkStack(t, &counter);
return GcArray::FixedSize + (counter.count * ArrayElementSizeOfArray) return pad(GcArray::FixedSize) + (counter.count * pad(ArrayElementSizeOfArray))
+ (counter.count * GcTraceElement::FixedSize); + (counter.count * pad(GcTraceElement::FixedSize));
} }
void NO_RETURN void NO_RETURN
@ -2690,8 +2690,8 @@ void
checkCast(MyThread* t, GcClass* class_, object o) checkCast(MyThread* t, GcClass* class_, object o)
{ {
if (UNLIKELY(o and not isAssignableFrom(t, class_, objectClass(t, o)))) { if (UNLIKELY(o and not isAssignableFrom(t, class_, objectClass(t, o)))) {
object classNameFrom = objectClass(t, o)->name(); object classNameFrom = reinterpret_cast<object>(objectClass(t, o)->name());
object classNameTo = class_->name(); object classNameTo = reinterpret_cast<object>(class_->name());
THREAD_RUNTIME_ARRAY(t, char, classFrom, byteArrayLength(t, classNameFrom)); THREAD_RUNTIME_ARRAY(t, char, classFrom, byteArrayLength(t, classNameFrom));
THREAD_RUNTIME_ARRAY(t, char, classTo, byteArrayLength(t, classNameTo)); THREAD_RUNTIME_ARRAY(t, char, classTo, byteArrayLength(t, classNameTo));
replace('/', '.', RUNTIME_ARRAY_BODY(classFrom), replace('/', '.', RUNTIME_ARRAY_BODY(classFrom),
@ -3121,7 +3121,7 @@ compileDirectInvoke(MyThread* t, Frame* frame, GcMethod* target, bool tailCall)
// don't bother calling an empty method unless calling it might // don't bother calling an empty method unless calling it might
// cause the class to be initialized, which may have side effects // cause the class to be initialized, which may have side effects
if (emptyMethod(t, target) if (emptyMethod(t, target)
and (not classNeedsInit(t, cast<GcClass>(t, target->class_())))) and (not classNeedsInit(t, target->class_())))
{ {
frame->popFootprint(target->parameterFootprint()); frame->popFootprint(target->parameterFootprint());
tailCall = false; tailCall = false;
@ -3129,7 +3129,7 @@ compileDirectInvoke(MyThread* t, Frame* frame, GcMethod* target, bool tailCall)
BootContext* bc = frame->context->bootContext; BootContext* bc = frame->context->bootContext;
if (bc) { if (bc) {
if ((target->class_() == frame->context->method->class_() if ((target->class_() == frame->context->method->class_()
or (not classNeedsInit(t, cast<GcClass>(t, target->class_())))) or (not classNeedsInit(t, target->class_())))
and (not (avian::codegen::TailCalls and tailCall and (not (avian::codegen::TailCalls and tailCall
and (target->flags() & ACC_NATIVE)))) and (target->flags() & ACC_NATIVE))))
{ {
@ -3144,7 +3144,7 @@ compileDirectInvoke(MyThread* t, Frame* frame, GcMethod* target, bool tailCall)
compileDirectInvoke(t, frame, target, tailCall, true, 0); compileDirectInvoke(t, frame, target, tailCall, true, 0);
} }
} else if (unresolved(t, methodAddress(t, target)) } else if (unresolved(t, methodAddress(t, target))
or classNeedsInit(t, cast<GcClass>(t, target->class_()))) or classNeedsInit(t, target->class_()))
{ {
compileDirectInvoke(t, frame, target, tailCall, true, 0); compileDirectInvoke(t, frame, target, tailCall, true, 0);
} else { } else {
@ -3230,7 +3230,7 @@ handleMonitorEvent(MyThread* t, Frame* frame, intptr_t function)
if (method->flags() & ACC_STATIC) { if (method->flags() & ACC_STATIC) {
PROTECT(t, method); PROTECT(t, method);
lock = frame->append(method->class_()); lock = frame->append(reinterpret_cast<object>(method->class_()));
} else { } else {
lock = loadLocal( lock = loadLocal(
frame->context, 1, ir::Type::object(), savedTargetIndex(t, method)); frame->context, 1, ir::Type::object(), savedTargetIndex(t, method));
@ -3294,10 +3294,10 @@ inTryBlock(MyThread* t, object code, unsigned ip)
} }
bool bool
needsReturnBarrier(MyThread* t, GcMethod* method) needsReturnBarrier(MyThread* t UNUSED, GcMethod* method)
{ {
return (method->flags() & ConstructorFlag) return (method->flags() & ConstructorFlag)
and (classVmFlags(t, method->class_()) & HasFinalMemberFlag); and (method->class_()->vmFlags() & HasFinalMemberFlag);
} }
bool bool
@ -3354,8 +3354,8 @@ isTailCall(MyThread* t, object code, unsigned ip, GcMethod* caller, GcMethod* ca
{ {
return isTailCall return isTailCall
(t, code, ip, caller, callee->returnCode(), (t, code, ip, caller, callee->returnCode(),
className(t, callee->class_()), callee->name(), reinterpret_cast<object>(callee->class_()->name()), reinterpret_cast<object>(callee->name()),
callee->spec()); reinterpret_cast<object>(callee->spec()));
} }
bool bool
@ -3531,14 +3531,14 @@ ir::Value* popLongAddress(Frame* frame)
} }
bool bool
intrinsic(MyThread* t, Frame* frame, GcMethod* target) intrinsic(MyThread* t UNUSED, Frame* frame, GcMethod* target)
{ {
#define MATCH(name, constant) \ #define MATCH(name, constant) \
(byteArrayLength(t, name) \ (name->length() \
== sizeof(constant) and::strcmp( \ == sizeof(constant) and::strcmp( \
reinterpret_cast<char*>(&byteArrayBody(t, name, 0)), constant) == 0) reinterpret_cast<char*>(name->body().begin()), constant) == 0)
object className = vm::className(t, target->class_()); GcByteArray* className = target->class_()->name();
if (UNLIKELY(MATCH(className, "java/lang/Math"))) { if (UNLIKELY(MATCH(className, "java/lang/Math"))) {
avian::codegen::Compiler* c = frame->c; avian::codegen::Compiler* c = frame->c;
if (MATCH(target->name(), "sqrt") and MATCH(target->spec(), "(D)D")) { if (MATCH(target->name(), "sqrt") and MATCH(target->spec(), "(D)D")) {
@ -4970,9 +4970,9 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
GcMethod* target = resolveMethod(t, context->method, index - 1, false); GcMethod* target = resolveMethod(t, context->method, index - 1, false);
if (LIKELY(target)) { if (LIKELY(target)) {
GcClass* class_ = cast<GcClass>(t, context->method->class_()); GcClass* class_ = context->method->class_();
if (isSpecialMethod(t, target, class_)) { if (isSpecialMethod(t, target, class_)) {
target = findVirtualMethod(t, target, cast<GcClass>(t, class_->super())); target = findVirtualMethod(t, target, class_->super());
} }
checkMethod(t, target, false); checkMethod(t, target, false);
@ -6751,22 +6751,22 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context)
logCompile logCompile
(t, 0, 0, (t, 0, 0,
reinterpret_cast<const char*> reinterpret_cast<const char*>
(&byteArrayBody(t, className(t, context->method->class_()), 0)), (context->method->class_()->name()->body().begin()),
reinterpret_cast<const char*> reinterpret_cast<const char*>
(&byteArrayBody(t, context->method->name(), 0)), (context->method->name()->body().begin()),
reinterpret_cast<const char*> reinterpret_cast<const char*>
(&byteArrayBody(t, context->method->spec(), 0))); (context->method->spec()->body().begin()));
} }
// for debugging: // for debugging:
if (false and if (false and
::strcmp ::strcmp
(reinterpret_cast<const char*> (reinterpret_cast<const char*>
(&byteArrayBody(t, className(t, context->method->class_()), 0)), (context->method->class_()->name()->body().begin()),
"java/lang/System") == 0 and "java/lang/System") == 0 and
::strcmp ::strcmp
(reinterpret_cast<const char*> (reinterpret_cast<const char*>
(&byteArrayBody(t, context->method->name(), 0)), (context->method->name()->body().begin()),
"<clinit>") == 0) "<clinit>") == 0)
{ {
trap(); trap();
@ -6804,7 +6804,7 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context)
context->executableSize = (allocator->memory.begin() + allocator->offset) context->executableSize = (allocator->memory.begin() + allocator->offset)
- static_cast<uint8_t*>(context->executableStart); - static_cast<uint8_t*>(context->executableStart);
initArray(t, pool, context->objectPoolCount + 1); initArray(t, reinterpret_cast<GcArray*>(pool), context->objectPoolCount + 1);
mark(t, pool, 0); mark(t, pool, 0);
set(t, pool, ArrayBody, root(t, ObjectPools)); set(t, pool, ArrayBody, root(t, ObjectPools));
@ -6883,21 +6883,21 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context)
logCompile logCompile
(t, start, codeSize, (t, start, codeSize,
reinterpret_cast<const char*> reinterpret_cast<const char*>
(&byteArrayBody(t, className(t, context->method->class_()), 0)), (context->method->class_()->name()->body().begin()),
reinterpret_cast<const char*> reinterpret_cast<const char*>
(&byteArrayBody(t, context->method->name(), 0)), (context->method->name()->body().begin()),
reinterpret_cast<const char*> reinterpret_cast<const char*>
(&byteArrayBody(t, context->method->spec(), 0))); (context->method->spec()->body().begin()));
// for debugging: // for debugging:
if (false and if (false and
::strcmp ::strcmp
(reinterpret_cast<const char*> (reinterpret_cast<const char*>
(&byteArrayBody(t, className(t, context->method->class_()), 0)), (context->method->class_()->name()->body().begin()),
"java/lang/System") == 0 and "java/lang/System") == 0 and
::strcmp ::strcmp
(reinterpret_cast<const char*> (reinterpret_cast<const char*>
(&byteArrayBody(t, context->method->name(), 0)), (context->method->name()->body().begin()),
"<clinit>") == 0) "<clinit>") == 0)
{ {
trap(); trap();
@ -6913,9 +6913,9 @@ compile(MyThread* t, Context* context)
avian::codegen::Compiler* c = context->compiler; avian::codegen::Compiler* c = context->compiler;
// fprintf(stderr, "compiling %s.%s%s\n", // fprintf(stderr, "compiling %s.%s%s\n",
// &byteArrayBody(t, className(t, context->method->class_()), 0), // context->method->class_()->name()->body().begin(),
// &byteArrayBody(t, context->method->name(), 0), // context->method->name()->body().begin(),
// &byteArrayBody(t, context->method->spec(), 0)); // context->method->spec()->body().begin());
unsigned footprint = context->method->parameterFootprint(); unsigned footprint = context->method->parameterFootprint();
unsigned locals = localSize(t, context->method); unsigned locals = localSize(t, context->method);
@ -6934,7 +6934,7 @@ compile(MyThread* t, Context* context)
for (MethodSpecIterator it for (MethodSpecIterator it
(t, reinterpret_cast<const char*> (t, reinterpret_cast<const char*>
(&byteArrayBody(t, context->method->spec(), 0))); (context->method->spec()->body().begin()));
it.hasNext();) it.hasNext();)
{ {
switch (*it.next()) { switch (*it.next()) {
@ -7148,11 +7148,11 @@ invokeNativeSlow(MyThread* t, GcMethod* method, void* function)
+ t->arch->frameFooterSize() + t->arch->frameFooterSize()
+ t->arch->frameReturnAddressSize(); + t->arch->frameReturnAddressSize();
object jclass = 0; GcJclass* jclass = 0;
PROTECT(t, jclass); PROTECT(t, jclass);
if (method->flags() & ACC_STATIC) { if (method->flags() & ACC_STATIC) {
jclass = getJClass(t, cast<GcClass>(t, method->class_())); jclass = getJClass(t, method->class_());
RUNTIME_ARRAY_BODY(args)[argOffset++] RUNTIME_ARRAY_BODY(args)[argOffset++]
= reinterpret_cast<uintptr_t>(&jclass); = reinterpret_cast<uintptr_t>(&jclass);
} else { } else {
@ -7163,7 +7163,7 @@ invokeNativeSlow(MyThread* t, GcMethod* method, void* function)
MethodSpecIterator it MethodSpecIterator it
(t, reinterpret_cast<const char*> (t, reinterpret_cast<const char*>
(&byteArrayBody(t, method->spec(), 0))); (method->spec()->body().begin()));
while (it.hasNext()) { while (it.hasNext()) {
unsigned type = RUNTIME_ARRAY_BODY(types)[typeOffset++] unsigned type = RUNTIME_ARRAY_BODY(types)[typeOffset++]
@ -7204,13 +7204,13 @@ invokeNativeSlow(MyThread* t, GcMethod* method, void* function)
if (DebugNatives) { if (DebugNatives) {
fprintf(stderr, "invoke native method %s.%s\n", fprintf(stderr, "invoke native method %s.%s\n",
&byteArrayBody(t, className(t, method->class_()), 0), method->class_()->name()->body().begin(),
&byteArrayBody(t, method->name(), 0)); method->name()->body().begin());
} }
if (method->flags() & ACC_SYNCHRONIZED) { if (method->flags() & ACC_SYNCHRONIZED) {
if (method->flags() & ACC_STATIC) { if (method->flags() & ACC_STATIC) {
acquire(t, method->class_()); acquire(t, reinterpret_cast<object>(method->class_()));
} else { } else {
acquire(t, *reinterpret_cast<object*>(RUNTIME_ARRAY_BODY(args)[1])); acquire(t, *reinterpret_cast<object*>(RUNTIME_ARRAY_BODY(args)[1]));
} }
@ -7234,7 +7234,7 @@ invokeNativeSlow(MyThread* t, GcMethod* method, void* function)
if (method->flags() & ACC_SYNCHRONIZED) { if (method->flags() & ACC_SYNCHRONIZED) {
if (method->flags() & ACC_STATIC) { if (method->flags() & ACC_STATIC) {
release(t, method->class_()); release(t, reinterpret_cast<object>(method->class_()));
} else { } else {
release(t, *reinterpret_cast<object*>(RUNTIME_ARRAY_BODY(args)[1])); release(t, *reinterpret_cast<object*>(RUNTIME_ARRAY_BODY(args)[1]));
} }
@ -7242,8 +7242,8 @@ invokeNativeSlow(MyThread* t, GcMethod* method, void* function)
if (DebugNatives) { if (DebugNatives) {
fprintf(stderr, "return from native method %s.%s\n", fprintf(stderr, "return from native method %s.%s\n",
&byteArrayBody(t, className(t, method->class_()), 0), method->class_()->name()->body().begin(),
&byteArrayBody(t, method->name(), 0)); method->name()->body().begin());
} }
if (UNLIKELY(t->exception)) { if (UNLIKELY(t->exception)) {
@ -7498,7 +7498,7 @@ visitArguments(MyThread* t, Heap::Visitor* v, void* stack, GcMethod* method)
for (MethodSpecIterator it for (MethodSpecIterator it
(t, reinterpret_cast<const char*> (t, reinterpret_cast<const char*>
(&byteArrayBody(t, method->spec(), 0))); (method->spec()->body().begin()));
it.hasNext();) it.hasNext();)
{ {
switch (*it.next()) { switch (*it.next()) {
@ -7633,7 +7633,7 @@ callContinuation(MyThread* t, object continuation, object result,
int8_t* int8_t*
returnSpec(MyThread* t, GcMethod* method) returnSpec(MyThread* t, GcMethod* method)
{ {
int8_t* s = &byteArrayBody(t, method->spec(), 0); int8_t* s = method->spec()->body().begin();
while (*s and *s != ')') ++ s; while (*s and *s != ')') ++ s;
expect(t, *s == ')'); expect(t, *s == ')');
return s + 1; return s + 1;
@ -7657,7 +7657,7 @@ returnClass(MyThread* t, GcMethod* method)
memcpy(&byteArrayBody(t, name, 0), spec + 1, length - 2); memcpy(&byteArrayBody(t, name, 0), spec + 1, length - 2);
} }
return resolveClass(t, classLoader(t, method->class_()), name); return resolveClass(t, reinterpret_cast<object>(method->class_()->loader()), name);
} }
bool bool
@ -7769,7 +7769,7 @@ callContinuation(MyThread* t, object continuation, object result,
and continuationContextContinuation(t, unwindContext)) and continuationContextContinuation(t, unwindContext))
{ {
nextContinuation = continuationContextContinuation(t, unwindContext); nextContinuation = continuationContextContinuation(t, unwindContext);
result = reinterpret_cast<object>(makeUnwindResult(t, continuation, result, exception)); result = reinterpret_cast<object>(makeUnwindResult(t, continuation, result, cast<GcThrowable>(t, exception)));
action = Unwind; action = Unwind;
} else if (rewindContext } else if (rewindContext
and continuationContextContinuation(t, rewindContext)) and continuationContextContinuation(t, rewindContext))
@ -8186,7 +8186,7 @@ class SignalHandler: public SignalRegistrar::Handler {
static_cast<void**>(*stack) - t->arch->frameReturnAddressSize(), static_cast<void**>(*stack) - t->arch->frameReturnAddressSize(),
t->continuation, t->trace); t->continuation, t->trace);
if (ensure(t, fixedSize + traceSize(t))) { if (ensure(t, pad(fixedSize) + traceSize(t))) {
atomicOr(&(t->flags), Thread::TracingFlag); atomicOr(&(t->flags), Thread::TracingFlag);
t->exception = makeThrowable(t, type); t->exception = makeThrowable(t, type);
atomicAnd(&(t->flags), ~Thread::TracingFlag); atomicAnd(&(t->flags), ~Thread::TracingFlag);
@ -8454,10 +8454,10 @@ class MyProcessor: public Processor {
offset, offset,
0, 0,
0, 0,
reinterpret_cast<object>(name), name,
reinterpret_cast<object>(spec), spec,
addendum, cast<GcMethodAddendum>(t, addendum),
reinterpret_cast<object>(class_), class_,
reinterpret_cast<object>(code)); reinterpret_cast<object>(code));
} }
@ -8488,17 +8488,17 @@ class MyProcessor: public Processor {
arrayElementSize, arrayElementSize,
arrayDimensions, arrayDimensions,
0, 0,
objectMask, cast<GcIntArray>(t, objectMask),
name, cast<GcByteArray>(t, name),
sourceFile, cast<GcByteArray>(t, sourceFile),
super, cast<GcClass>(t, super),
interfaceTable, interfaceTable,
virtualTable, virtualTable,
fieldTable, fieldTable,
methodTable, methodTable,
staticTable, reinterpret_cast<GcClassAddendum*>(staticTable), // DANGER DANGER DANGER!!!!!!!!!
addendum, addendum,
loader, cast<GcClassLoader>(t, loader),
0, 0,
vtableLength); vtableLength);
} }
@ -8626,7 +8626,7 @@ class MyProcessor: public Processor {
method = findMethod(t, method, this_); method = findMethod(t, method, this_);
const char* spec = reinterpret_cast<char*> const char* spec = reinterpret_cast<char*>
(&byteArrayBody(t, method->spec(), 0)); (method->spec()->body().begin());
unsigned size = method->parameterFootprint(); unsigned size = method->parameterFootprint();
THREAD_RUNTIME_ARRAY(t, uintptr_t, array, size); THREAD_RUNTIME_ARRAY(t, uintptr_t, array, size);
@ -8656,7 +8656,7 @@ class MyProcessor: public Processor {
method = findMethod(t, method, this_); method = findMethod(t, method, this_);
const char* spec = reinterpret_cast<char*> const char* spec = reinterpret_cast<char*>
(&byteArrayBody(t, method->spec(), 0)); (method->spec()->body().begin());
unsigned size = method->parameterFootprint(); unsigned size = method->parameterFootprint();
THREAD_RUNTIME_ARRAY(t, uintptr_t, array, size); THREAD_RUNTIME_ARRAY(t, uintptr_t, array, size);
@ -8687,7 +8687,7 @@ class MyProcessor: public Processor {
method = findMethod(t, method, this_); method = findMethod(t, method, this_);
const char* spec = reinterpret_cast<char*> const char* spec = reinterpret_cast<char*>
(&byteArrayBody(t, method->spec(), 0)); (method->spec()->body().begin());
unsigned size = method->parameterFootprint(); unsigned size = method->parameterFootprint();
THREAD_RUNTIME_ARRAY(t, uintptr_t, array, size); THREAD_RUNTIME_ARRAY(t, uintptr_t, array, size);
@ -9484,11 +9484,11 @@ fixupMethods(Thread* t, GcHashMap* map, BootImage* image UNUSED, uint8_t* code)
reinterpret_cast<uint8_t*>(methodCompiled(t, method)), reinterpret_cast<uint8_t*>(methodCompiled(t, method)),
methodCompiledSize(t, method), methodCompiledSize(t, method),
reinterpret_cast<char*> reinterpret_cast<char*>
(&byteArrayBody(t, className(t, method->class_()), 0)), (method->class_()->name()->body().begin()),
reinterpret_cast<char*> reinterpret_cast<char*>
(&byteArrayBody(t, method->name(), 0)), (method->name()->body().begin()),
reinterpret_cast<char*> reinterpret_cast<char*>
(&byteArrayBody(t, method->spec(), 0))); (method->spec()->body().begin()));
} }
} }
} }
@ -10007,7 +10007,7 @@ compile(MyThread* t, FixedAllocator* allocator, BootContext* bootContext,
PROTECT(t, method); PROTECT(t, method);
if (bootContext == 0 and method->flags() & ACC_STATIC) { if (bootContext == 0 and method->flags() & ACC_STATIC) {
initClass(t, cast<GcClass>(t, method->class_())); initClass(t, method->class_());
} }
if (methodAddress(t, method) != defaultThunk(t)) { if (methodAddress(t, method) != defaultThunk(t)) {
@ -10091,7 +10091,7 @@ compile(MyThread* t, FixedAllocator* allocator, BootContext* bootContext,
set(t, reinterpret_cast<object>(method), MethodCode, clone->code()); set(t, reinterpret_cast<object>(method), MethodCode, clone->code());
if (methodVirtual(t, method)) { if (methodVirtual(t, method)) {
classVtable(t, method->class_(), method->offset()) classVtable(t, reinterpret_cast<object>(method->class_()), method->offset())
= reinterpret_cast<void*>(methodCompiled(t, clone)); = reinterpret_cast<void*>(methodCompiled(t, clone));
} }

View File

@ -318,7 +318,7 @@ pushFrame(Thread* t, GcMethod* method)
// to release a monitor we never successfully acquired when we try // to release a monitor we never successfully acquired when we try
// to pop the frame back off. // to pop the frame back off.
if (method->flags() & ACC_STATIC) { if (method->flags() & ACC_STATIC) {
acquire(t, method->class_()); acquire(t, reinterpret_cast<object>(method->class_()));
} else { } else {
acquire(t, peekObject(t, base)); acquire(t, peekObject(t, base));
} }
@ -356,7 +356,7 @@ popFrame(Thread* t)
if (method->flags() & ACC_SYNCHRONIZED) { if (method->flags() & ACC_SYNCHRONIZED) {
if (method->flags() & ACC_STATIC) { if (method->flags() & ACC_STATIC) {
release(t, method->class_()); release(t, reinterpret_cast<object>(method->class_()));
} else { } else {
release(t, peekObject(t, frameBase(t, t->frame))); release(t, peekObject(t, frameBase(t, t->frame)));
} }
@ -494,7 +494,7 @@ marshalArguments(Thread* t, uintptr_t* args, uint8_t* types, unsigned sp,
{ {
MethodSpecIterator it MethodSpecIterator it
(t, reinterpret_cast<const char*> (t, reinterpret_cast<const char*>
(&byteArrayBody(t, method->spec(), 0))); (method->spec()->body().begin()));
unsigned argOffset = 0; unsigned argOffset = 0;
unsigned typeOffset = 0; unsigned typeOffset = 0;
@ -565,7 +565,7 @@ invokeNativeSlow(Thread* t, GcMethod* method, void* function)
unsigned sp; unsigned sp;
if (method->flags() & ACC_STATIC) { if (method->flags() & ACC_STATIC) {
sp = frameBase(t, t->frame); sp = frameBase(t, t->frame);
jclass = getJClass(t, cast<GcClass>(t, method->class_())); jclass = getJClass(t, method->class_());
RUNTIME_ARRAY_BODY(args)[argOffset++] RUNTIME_ARRAY_BODY(args)[argOffset++]
= reinterpret_cast<uintptr_t>(&jclass); = reinterpret_cast<uintptr_t>(&jclass);
} else { } else {
@ -588,8 +588,8 @@ invokeNativeSlow(Thread* t, GcMethod* method, void* function)
if (DebugRun) { if (DebugRun) {
fprintf(stderr, "invoke native method %s.%s\n", fprintf(stderr, "invoke native method %s.%s\n",
&byteArrayBody(t, className(t, method->class_()), 0), method->class_()->name()->body().begin(),
&byteArrayBody(t, method->name(), 0)); method->name()->body().begin());
} }
{ ENTER(t, Thread::IdleState); { ENTER(t, Thread::IdleState);
@ -608,10 +608,8 @@ invokeNativeSlow(Thread* t, GcMethod* method, void* function)
if (DebugRun) { if (DebugRun) {
fprintf(stderr, "return from native method %s.%s\n", fprintf(stderr, "return from native method %s.%s\n",
&byteArrayBody frameMethod(t, t->frame)->class_()->name()->body().begin(),
(t, className(t, frameMethod(t, t->frame)->class_()), 0), frameMethod(t, t->frame)->name()->body().begin());
&byteArrayBody
(t, frameMethod(t, t->frame)->name(), 0));
} }
popFrame(t); popFrame(t);
@ -797,10 +795,8 @@ interpret3(Thread* t, const int base)
fprintf(stderr, "ip: %d; instruction: 0x%x in %s.%s ", fprintf(stderr, "ip: %d; instruction: 0x%x in %s.%s ",
ip - 1, ip - 1,
instruction, instruction,
&byteArrayBody frameMethod(t, frame)->class_()->name()->body().begin(),
(t, className(t, frameMethod(t, frame)->class_()), 0), frameMethod(t, frame)->name()->body().begin());
&byteArrayBody
(t, frameMethod(t, frame)->name(), 0));
int line = findLineNumber(t, frameMethod(t, frame), ip); int line = findLineNumber(t, frameMethod(t, frame), ip);
switch (line) { switch (line) {
@ -1076,9 +1072,8 @@ interpret3(Thread* t, const int base)
if (not instanceOf(t, class_, peekObject(t, sp - 1))) { if (not instanceOf(t, class_, peekObject(t, sp - 1))) {
exception = makeThrowable exception = makeThrowable
(t, GcClassCastException::Type, "%s as %s", (t, GcClassCastException::Type, "%s as %s",
&byteArrayBody objectClass(t, peekObject(t, sp - 1))->name()->body().begin(),
(t, objectClass(t, peekObject(t, sp - 1))->name(), 0), class_->name()->body().begin());
&byteArrayBody(t, class_->name(), 0));
goto throw_; goto throw_;
} }
} }
@ -1862,9 +1857,9 @@ interpret3(Thread* t, const int base)
unsigned parameterFootprint = method->parameterFootprint(); unsigned parameterFootprint = method->parameterFootprint();
if (LIKELY(peekObject(t, sp - parameterFootprint))) { if (LIKELY(peekObject(t, sp - parameterFootprint))) {
GcClass* class_ = cast<GcClass>(t, frameMethod(t, frame)->class_()); GcClass* class_ = frameMethod(t, frame)->class_();
if (isSpecialMethod(t, method, class_)) { if (isSpecialMethod(t, method, class_)) {
class_ = cast<GcClass>(t, class_->super()); class_ = class_->super();
PROTECT(t, method); PROTECT(t, method);
PROTECT(t, class_); PROTECT(t, class_);
@ -1888,7 +1883,7 @@ interpret3(Thread* t, const int base)
GcMethod* method = resolveMethod(t, frameMethod(t, frame), index - 1); GcMethod* method = resolveMethod(t, frameMethod(t, frame), index - 1);
PROTECT(t, method); PROTECT(t, method);
initClass(t, cast<GcClass>(t, method->class_())); initClass(t, method->class_());
code = reinterpret_cast<object>(method); code = reinterpret_cast<object>(method);
} goto invoke; } goto invoke;
@ -2563,7 +2558,7 @@ interpret3(Thread* t, const int base)
case return_: { case return_: {
GcMethod* method = frameMethod(t, frame); GcMethod* method = frameMethod(t, frame);
if ((method->flags() & ConstructorFlag) if ((method->flags() & ConstructorFlag)
and (classVmFlags(t, method->class_()) & HasFinalMemberFlag)) and (method->class_()->vmFlags() & HasFinalMemberFlag))
{ {
storeStoreMemoryBarrier(); storeStoreMemoryBarrier();
} }
@ -2670,8 +2665,8 @@ interpret3(Thread* t, const int base)
GcClass* class_ = objectClass(t, peekObject(t, sp - parameterFootprint)); GcClass* class_ = objectClass(t, peekObject(t, sp - parameterFootprint));
assertT(t, class_->vmFlags() & BootstrapFlag); assertT(t, class_->vmFlags() & BootstrapFlag);
resolveClass(t, classLoader(t, frameMethod(t, frame)->class_()), resolveClass(t, reinterpret_cast<object>(frameMethod(t, frame)->class_()->loader()),
class_->name()); reinterpret_cast<object>(class_->name()));
ip -= 3; ip -= 3;
} goto loop; } goto loop;
@ -2896,16 +2891,16 @@ invoke(Thread* t, GcMethod* method)
class_ = objectClass(t, peekObject(t, t->sp - parameterFootprint)); class_ = objectClass(t, peekObject(t, t->sp - parameterFootprint));
if (class_->vmFlags() & BootstrapFlag) { if (class_->vmFlags() & BootstrapFlag) {
resolveClass(t, root(t, Machine::BootLoader), class_->name()); resolveClass(t, root(t, Machine::BootLoader), reinterpret_cast<object>(class_->name()));
} }
if (classFlags(t, method->class_()) & ACC_INTERFACE) { if (method->class_()->flags() & ACC_INTERFACE) {
method = findInterfaceMethod(t, method, class_); method = findInterfaceMethod(t, method, class_);
} else { } else {
method = findVirtualMethod(t, method, class_); method = findVirtualMethod(t, method, class_);
} }
} else { } else {
class_ = cast<GcClass>(t, method->class_()); class_ = method->class_();
} }
if (method->flags() & ACC_STATIC) { if (method->flags() & ACC_STATIC) {
@ -3001,10 +2996,10 @@ class MyProcessor: public Processor {
offset, offset,
0, 0,
0, 0,
reinterpret_cast<object>(name), name,
reinterpret_cast<object>(spec), spec,
addendum, cast<GcMethodAddendum>(t, addendum),
reinterpret_cast<object>(class_), class_,
reinterpret_cast<object>(code)); reinterpret_cast<object>(code));
} }
@ -3028,10 +3023,26 @@ class MyProcessor: public Processor {
object loader, object loader,
unsigned vtableLength UNUSED) unsigned vtableLength UNUSED)
{ {
return vm::makeClass return vm::makeClass(t,
(t, flags, vmFlags, fixedSize, arrayElementSize, arrayDimensions, 0, flags,
objectMask, name, sourceFile, super, interfaceTable, virtualTable, vmFlags,
fieldTable, methodTable, addendum, staticTable, loader, 0, 0); fixedSize,
arrayElementSize,
arrayDimensions,
0,
cast<GcIntArray>(t, objectMask),
cast<GcByteArray>(t, name),
cast<GcByteArray>(t, sourceFile),
cast<GcClass>(t, super),
interfaceTable,
virtualTable,
fieldTable,
methodTable,
cast<GcClassAddendum>(t, addendum),
staticTable,
cast<GcClassLoader>(t, loader),
0,
0);
} }
virtual void virtual void
@ -3133,7 +3144,7 @@ class MyProcessor: public Processor {
} }
const char* spec = reinterpret_cast<char*> const char* spec = reinterpret_cast<char*>
(&byteArrayBody(t, method->spec(), 0)); (method->spec()->body().begin());
pushArguments(t, this_, spec, arguments); pushArguments(t, this_, spec, arguments);
return local::invoke(t, method); return local::invoke(t, method);
@ -3157,7 +3168,7 @@ class MyProcessor: public Processor {
} }
const char* spec = reinterpret_cast<char*> const char* spec = reinterpret_cast<char*>
(&byteArrayBody(t, method->spec(), 0)); (method->spec()->body().begin());
pushArguments(t, this_, spec, arguments); pushArguments(t, this_, spec, arguments);
return local::invoke(t, method); return local::invoke(t, method);
@ -3181,7 +3192,7 @@ class MyProcessor: public Processor {
} }
const char* spec = reinterpret_cast<char*> const char* spec = reinterpret_cast<char*>
(&byteArrayBody(t, method->spec(), 0)); (method->spec()->body().begin());
pushArguments(t, this_, spec, indirectObjects, arguments); pushArguments(t, this_, spec, indirectObjects, arguments);
return local::invoke(t, method); return local::invoke(t, method);

View File

@ -323,11 +323,11 @@ defineClass(Thread* t, uintptr_t* arguments)
return reinterpret_cast<uint64_t>(makeLocalReference( return reinterpret_cast<uint64_t>(makeLocalReference(
t, t,
getJClass(t, reinterpret_cast<object>(getJClass(t,
cast<GcClass>(t, defineClass(t, cast<GcClass>(t, defineClass(t,
loader ? *loader : root(t, Machine::BootLoader), loader ? *loader : root(t, Machine::BootLoader),
buffer, buffer,
length))))); length))))));
} }
jclass JNICALL jclass JNICALL
@ -351,10 +351,12 @@ findClass(Thread* t, uintptr_t* arguments)
GcMethod* caller = getCaller(t, 0); GcMethod* caller = getCaller(t, 0);
GcClass* c = resolveClass(t, GcClass* c = resolveClass(
caller ? t->m->classpath->libraryClassLoader(t, caller) t,
: root(t, Machine::AppLoader), caller ? reinterpret_cast
n); <object>(t->m->classpath->libraryClassLoader(t, caller))
: root(t, Machine::AppLoader),
n);
if (t->m->classpath->mayInitClasses()) { if (t->m->classpath->mayInitClasses()) {
PROTECT(t, c); PROTECT(t, c);
@ -362,7 +364,7 @@ findClass(Thread* t, uintptr_t* arguments)
initClass(t, c); initClass(t, c);
} }
return reinterpret_cast<uint64_t>(makeLocalReference(t, getJClass(t, c))); return reinterpret_cast<uint64_t>(makeLocalReference(t, reinterpret_cast<object>(getJClass(t, c))));
} }
jclass JNICALL jclass JNICALL
@ -451,7 +453,7 @@ getObjectClass(Thread* t, uintptr_t* arguments)
jobject o = reinterpret_cast<jclass>(arguments[0]); jobject o = reinterpret_cast<jclass>(arguments[0]);
return reinterpret_cast<uint64_t>(makeLocalReference( return reinterpret_cast<uint64_t>(makeLocalReference(
t, getJClass(t, objectClass(t, *o)))); t, reinterpret_cast<object>(getJClass(t, objectClass(t, *o)))));
} }
jclass JNICALL jclass JNICALL
@ -471,7 +473,7 @@ getSuperclass(Thread* t, uintptr_t* arguments)
} else { } else {
object super = classSuper(t, class_); object super = classSuper(t, class_);
return super ? reinterpret_cast<uint64_t> return super ? reinterpret_cast<uint64_t>
(makeLocalReference(t, getJClass(t, cast<GcClass>(t, super)))) : 0; (makeLocalReference(t, reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, super))))) : 0;
} }
} }

View File

@ -738,7 +738,7 @@ invoke(Thread* t, uintptr_t* arguments)
void void
finalizeObject(Thread* t, object o, const char* name) finalizeObject(Thread* t, object o, const char* name)
{ {
for (GcClass* c = objectClass(t, o); c; c = cast<GcClass>(t, c->super())) { for (GcClass* c = objectClass(t, o); c; c = c->super()) {
for (unsigned i = 0; i < arrayLength(t, c->methodTable()); ++i) { for (unsigned i = 0; i < arrayLength(t, c->methodTable()); ++i) {
object m = arrayBody(t, c->methodTable(), i); object m = arrayBody(t, c->methodTable(), i);
@ -1070,7 +1070,7 @@ parsePoolEntry(Thread* t, Stream& s, uint32_t* index, GcSingleton* pool, unsigne
GcMethod* template_ = makeMethod GcMethod* template_ = makeMethod
(t, 0, returnCode, parameterCount, parameterFootprint, 0, 0, 0, 0, (t, 0, returnCode, parameterCount, parameterFootprint, 0, 0, 0, 0,
pairFirst(t, nameAndType), pairSecond(t, nameAndType), 0, 0, 0); cast<GcByteArray>(t, pairFirst(t, nameAndType)), cast<GcByteArray>(t, pairSecond(t, nameAndType)), 0, 0, 0);
object value = reinterpret_cast object value = reinterpret_cast
<object>(makeInvocation(t, <object>(makeInvocation(t,
@ -1195,8 +1195,12 @@ addInterfaces(Thread* t, GcClass* class_, GcHashMap* map)
for (unsigned i = 0; i < arrayLength(t, table); i += increment) { for (unsigned i = 0; i < arrayLength(t, table); i += increment) {
GcClass* interface = cast<GcClass>(t, arrayBody(t, table, i)); GcClass* interface = cast<GcClass>(t, arrayBody(t, table, i));
object name = interface->name(); GcByteArray* name = interface->name();
hashMapInsertMaybe(t, map, name, reinterpret_cast<object>(interface), byteArrayHash, hashMapInsertMaybe(t,
map,
reinterpret_cast<object>(name),
reinterpret_cast<object>(interface),
byteArrayHash,
byteArrayEqual); byteArrayEqual);
} }
} }
@ -1205,7 +1209,7 @@ addInterfaces(Thread* t, GcClass* class_, GcHashMap* map)
GcClassAddendum* GcClassAddendum*
getClassAddendum(Thread* t, GcClass* class_, GcSingleton* pool) getClassAddendum(Thread* t, GcClass* class_, GcSingleton* pool)
{ {
GcClassAddendum* addendum = cast<GcClassAddendum>(t, class_->addendum()); GcClassAddendum* addendum = class_->addendum();
if (addendum == 0) { if (addendum == 0) {
PROTECT(t, class_); PROTECT(t, class_);
@ -1229,7 +1233,7 @@ parseInterfaceTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool,
PROTECT(t, map); PROTECT(t, map);
if (class_->super()) { if (class_->super()) {
addInterfaces(t, cast<GcClass>(t, class_->super()), map); addInterfaces(t, class_->super(), map);
} }
unsigned count = s.read2(); unsigned count = s.read2();
@ -1249,7 +1253,7 @@ parseInterfaceTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool,
PROTECT(t, name); PROTECT(t, name);
GcClass* interface = resolveClass GcClass* interface = resolveClass
(t, class_->loader(), name, true, throwType); (t, reinterpret_cast<object>(class_->loader()), name, true, throwType);
PROTECT(t, interface); PROTECT(t, interface);
@ -1301,7 +1305,7 @@ parseFieldTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
unsigned memberOffset = BytesPerWord; unsigned memberOffset = BytesPerWord;
if (class_->super()) { if (class_->super()) {
memberOffset = classFixedSize(t, class_->super()); memberOffset = class_->super()->fixedSize();
} }
unsigned count = s.read2(); unsigned count = s.read2();
@ -1377,10 +1381,10 @@ parseFieldTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
flags, flags,
0, // offset 0, // offset
0, // native ID 0, // native ID
singletonObject(t, pool, name - 1), cast<GcByteArray>(t, singletonObject(t, pool, name - 1)),
singletonObject(t, pool, spec - 1), cast<GcByteArray>(t, singletonObject(t, pool, spec - 1)),
addendum, cast<GcFieldAddendum>(t, addendum),
reinterpret_cast<object>(class_)); class_);
unsigned size = fieldSize(t, code); unsigned size = fieldSize(t, code);
if (flags & ACC_STATIC) { if (flags & ACC_STATIC) {
@ -1474,13 +1478,13 @@ parseFieldTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
} }
} }
class_->fixedSize() = pad(memberOffset); class_->fixedSize() = memberOffset;
if (class_->super() if (class_->super()
and memberOffset == classFixedSize(t, class_->super())) and memberOffset == class_->super()->fixedSize())
{ {
set(t, reinterpret_cast<object>(class_), ClassObjectMask, set(t, reinterpret_cast<object>(class_), ClassObjectMask,
classObjectMask(t, class_->super())); reinterpret_cast<object>(class_->super()->objectMask()));
} else { } else {
object mask = reinterpret_cast<object>(makeIntArray object mask = reinterpret_cast<object>(makeIntArray
(t, ceilingDivide(class_->fixedSize(), 32 * BytesPerWord))); (t, ceilingDivide(class_->fixedSize(), 32 * BytesPerWord)));
@ -1488,11 +1492,11 @@ parseFieldTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
object superMask = 0; object superMask = 0;
if (class_->super()) { if (class_->super()) {
superMask = classObjectMask(t, class_->super()); superMask = reinterpret_cast<object>(class_->super()->objectMask());
if (superMask) { if (superMask) {
memcpy(&intArrayBody(t, mask, 0), memcpy(&intArrayBody(t, mask, 0),
&intArrayBody(t, superMask, 0), &intArrayBody(t, superMask, 0),
ceilingDivide(classFixedSize(t, class_->super()), ceilingDivide(class_->super()->fixedSize(),
32 * BytesPerWord) 32 * BytesPerWord)
* 4); * 4);
} }
@ -1999,7 +2003,7 @@ addInterfaceMethods(Thread* t, GcClass* class_, GcHashMap* virtualMap,
method->name(), method->name(),
method->spec(), method->spec(),
0, 0,
reinterpret_cast<object>(class_), class_,
0); 0);
hashMapInsert(t, hashMapInsert(t,
@ -2042,7 +2046,7 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
if ((class_->flags() & ACC_INTERFACE) == 0) { if ((class_->flags() & ACC_INTERFACE) == 0) {
if (class_->super()) { if (class_->super()) {
superVirtualTable = classVirtualTable(t, class_->super()); superVirtualTable = class_->super()->virtualTable();
} }
if (superVirtualTable) { if (superVirtualTable) {
@ -2207,10 +2211,10 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
if (UNLIKELY((class_->flags() & ACC_INTERFACE) == 0 if (UNLIKELY((class_->flags() & ACC_INTERFACE) == 0
and vm::strcmp and vm::strcmp
(reinterpret_cast<const int8_t*>("finalize"), (reinterpret_cast<const int8_t*>("finalize"),
&byteArrayBody(t, method->name(), 0)) == 0 method->name()->body().begin()) == 0
and vm::strcmp and vm::strcmp
(reinterpret_cast<const int8_t*>("()V"), (reinterpret_cast<const int8_t*>("()V"),
&byteArrayBody(t, method->spec(), 0)) == 0 method->spec()->body().begin()) == 0
and (not emptyMethod(t, method)))) and (not emptyMethod(t, method))))
{ {
class_->vmFlags() |= HasFinalizerFlag; class_->vmFlags() |= HasFinalizerFlag;
@ -2219,13 +2223,13 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
method->offset() = i; method->offset() = i;
if (vm::strcmp(reinterpret_cast<const int8_t*>("<clinit>"), if (vm::strcmp(reinterpret_cast<const int8_t*>("<clinit>"),
&byteArrayBody(t, method->name(), 0)) == 0) method->name()->body().begin()) == 0)
{ {
method->vmFlags() |= ClassInitFlag; method->vmFlags() |= ClassInitFlag;
class_->vmFlags() |= NeedInitFlag; class_->vmFlags() |= NeedInitFlag;
} else if (vm::strcmp } else if (vm::strcmp
(reinterpret_cast<const int8_t*>("<init>"), (reinterpret_cast<const int8_t*>("<init>"),
&byteArrayBody(t, method->name(), 0)) == 0) method->name()->body().begin()) == 0)
{ {
method->vmFlags() |= ConstructorFlag; method->vmFlags() |= ConstructorFlag;
} }
@ -2253,14 +2257,14 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
// inherit virtual table from superclass // inherit virtual table from superclass
set(t, reinterpret_cast<object>(class_), ClassVirtualTable, superVirtualTable); set(t, reinterpret_cast<object>(class_), ClassVirtualTable, superVirtualTable);
if (classInterfaceTable(t, class_->super()) if (class_->super()->interfaceTable()
and arrayLength(t, class_->interfaceTable()) and arrayLength(t, class_->interfaceTable())
== arrayLength == arrayLength
(t, classInterfaceTable(t, class_->super()))) (t, class_->super()->interfaceTable()))
{ {
// inherit interface table from superclass // inherit interface table from superclass
set(t, reinterpret_cast<object>(class_), ClassInterfaceTable, set(t, reinterpret_cast<object>(class_), ClassInterfaceTable,
classInterfaceTable(t, class_->super())); class_->super()->interfaceTable());
} else { } else {
populateInterfaceVtables = true; populateInterfaceVtables = true;
} }
@ -2411,9 +2415,9 @@ parseAttributeTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
object reference = reinterpret_cast<object>(makeInnerClassReference object reference = reinterpret_cast<object>(makeInnerClassReference
(t, (t,
inner ? referenceName(t, singletonObject(t, pool, inner - 1)) : 0, cast<GcByteArray>(t, inner ? referenceName(t, singletonObject(t, pool, inner - 1)) : 0),
outer ? referenceName(t, singletonObject(t, pool, outer - 1)) : 0, cast<GcByteArray>(t, outer ? referenceName(t, singletonObject(t, pool, outer - 1)) : 0),
name ? singletonObject(t, pool, name - 1) : 0, cast<GcByteArray>(t, name ? singletonObject(t, pool, name - 1) : 0),
flags)); flags));
set(t, table, ArrayBody + (i * BytesPerWord), reference); set(t, table, ArrayBody + (i * BytesPerWord), reference);
@ -2506,13 +2510,13 @@ updateBootstrapClass(Thread* t, GcClass* bootstrapClass, GcClass* class_)
bootstrapClass->vmFlags() |= class_->vmFlags(); bootstrapClass->vmFlags() |= class_->vmFlags();
bootstrapClass->flags() |= class_->flags(); bootstrapClass->flags() |= class_->flags();
set(t, reinterpret_cast<object>(bootstrapClass), ClassSuper, class_->super()); set(t, reinterpret_cast<object>(bootstrapClass), ClassSuper, reinterpret_cast<object>(class_->super()));
set(t, reinterpret_cast<object>(bootstrapClass), ClassInterfaceTable, class_->interfaceTable()); set(t, reinterpret_cast<object>(bootstrapClass), ClassInterfaceTable, reinterpret_cast<object>(class_->interfaceTable()));
set(t, reinterpret_cast<object>(bootstrapClass), ClassVirtualTable, class_->virtualTable()); set(t, reinterpret_cast<object>(bootstrapClass), ClassVirtualTable, reinterpret_cast<object>(class_->virtualTable()));
set(t, reinterpret_cast<object>(bootstrapClass), ClassFieldTable, class_->fieldTable()); set(t, reinterpret_cast<object>(bootstrapClass), ClassFieldTable, reinterpret_cast<object>(class_->fieldTable()));
set(t, reinterpret_cast<object>(bootstrapClass), ClassMethodTable, class_->methodTable()); set(t, reinterpret_cast<object>(bootstrapClass), ClassMethodTable, reinterpret_cast<object>(class_->methodTable()));
set(t, reinterpret_cast<object>(bootstrapClass), ClassStaticTable, class_->staticTable()); set(t, reinterpret_cast<object>(bootstrapClass), ClassStaticTable, reinterpret_cast<object>(class_->staticTable()));
set(t, reinterpret_cast<object>(bootstrapClass), ClassAddendum, class_->addendum()); set(t, reinterpret_cast<object>(bootstrapClass), ClassAddendum, reinterpret_cast<object>(class_->addendum()));
updateClassTables(t, bootstrapClass, class_); updateClassTables(t, bootstrapClass, class_);
} }
@ -2532,7 +2536,7 @@ makeArrayClass(Thread* t, object loader, unsigned dimensions, object spec,
// make a stack trace for a ClassNotFoundException. // make a stack trace for a ClassNotFoundException.
resolveSystemClass resolveSystemClass
(t, root(t, Machine::BootLoader), (t, root(t, Machine::BootLoader),
type(t, GcJobject::Type)->name(), false); reinterpret_cast<object>(type(t, GcJobject::Type)->name()), false);
} }
object vtable = type(t, GcJobject::Type)->virtualTable(); object vtable = type(t, GcJobject::Type)->virtualTable();
@ -2544,7 +2548,7 @@ makeArrayClass(Thread* t, object loader, unsigned dimensions, object spec,
2 * BytesPerWord, 2 * BytesPerWord,
BytesPerWord, BytesPerWord,
dimensions, dimensions,
type(t, GcArray::Type)->objectMask(), reinterpret_cast<object>(type(t, GcArray::Type)->objectMask()),
spec, spec,
0, 0,
reinterpret_cast<object>(type(t, GcJobject::Type)), reinterpret_cast<object>(type(t, GcJobject::Type)),
@ -2579,7 +2583,7 @@ saveLoadedClass(Thread* t, object loader, GcClass* c)
hashMapInsert(t, hashMapInsert(t,
cast<GcHashMap>(t, classLoaderMap(t, loader)), cast<GcHashMap>(t, classLoaderMap(t, loader)),
c->name(), reinterpret_cast<object>(c->name()),
reinterpret_cast<object>(c), reinterpret_cast<object>(c),
byteArrayHash); byteArrayHash);
} }
@ -2643,17 +2647,17 @@ makeArrayClass(Thread* t, object loader, object spec, bool throw_,
ACQUIRE(t, t->m->classLock); ACQUIRE(t, t->m->classLock);
GcClass* class_ = findLoadedClass(t, elementClass->loader(), spec); GcClass* class_ = findLoadedClass(t, reinterpret_cast<object>(elementClass->loader()), spec);
if (class_) { if (class_) {
return class_; return class_;
} }
class_ = makeArrayClass class_ = makeArrayClass
(t, elementClass->loader(), dimensions, spec, reinterpret_cast<object>(elementClass)); (t, reinterpret_cast<object>(elementClass->loader()), dimensions, spec, reinterpret_cast<object>(elementClass));
PROTECT(t, class_); PROTECT(t, class_);
saveLoadedClass(t, elementClass->loader(), class_); saveLoadedClass(t, reinterpret_cast<object>(elementClass->loader()), class_);
return class_; return class_;
} }
@ -2721,10 +2725,10 @@ bootClass(Thread* t, Gc::Type type, int superType, uint32_t objectMask,
if (objectMask) { if (objectMask) {
if (super if (super
and super->objectMask() and super->objectMask()
and intArrayBody(t, super->objectMask(), 0) and super->objectMask()->body()[0]
== static_cast<int32_t>(objectMask)) == static_cast<int32_t>(objectMask))
{ {
mask = vm::type(t, static_cast<Gc::Type>(superType))->objectMask(); mask = reinterpret_cast<object>(vm::type(t, static_cast<Gc::Type>(superType))->objectMask());
} else { } else {
mask = reinterpret_cast<object>(makeIntArray(t, 1)); mask = reinterpret_cast<object>(makeIntArray(t, 1));
intArrayBody(t, mask, 0) = objectMask; intArrayBody(t, mask, 0) = objectMask;
@ -3156,7 +3160,7 @@ updatePackageMap(Thread* t, GcClass* class_)
setRoot(t, Machine::PackageMap, reinterpret_cast<object>(makeHashMap(t, 0, 0))); setRoot(t, Machine::PackageMap, reinterpret_cast<object>(makeHashMap(t, 0, 0)));
} }
object className = class_->name(); object className = reinterpret_cast<object>(class_->name());
if ('[' != byteArrayBody(t, className, 0)) { if ('[' != byteArrayBody(t, className, 0)) {
THREAD_RUNTIME_ARRAY THREAD_RUNTIME_ARRAY
(t, char, packageName, byteArrayLength(t, className)); (t, char, packageName, byteArrayLength(t, className));
@ -3179,7 +3183,7 @@ updatePackageMap(Thread* t, GcClass* class_)
(t, cast<GcHashMap>(t, root(t, Machine::PackageMap)), key, byteArrayHash, (t, cast<GcHashMap>(t, root(t, Machine::PackageMap)), key, byteArrayHash,
byteArrayEqual); byteArrayEqual);
object source = class_->source(); object source = reinterpret_cast<object>(class_->source());
if (source) { if (source) {
// note that we strip the "file:" prefix, since OpenJDK's // note that we strip the "file:" prefix, since OpenJDK's
// Package.defineSystemPackage expects an unadorned filename: // Package.defineSystemPackage expects an unadorned filename:
@ -4115,7 +4119,7 @@ isAssignableFrom(Thread* t, GcClass* a, GcClass* b)
} else if ((a->vmFlags() & PrimitiveFlag) } else if ((a->vmFlags() & PrimitiveFlag)
== (b->vmFlags() & PrimitiveFlag)) == (b->vmFlags() & PrimitiveFlag))
{ {
for (; b; b = cast<GcClass>(t, b->super())) { for (; b; b = b->super()) {
if (b == a) { if (b == a) {
return true; return true;
} }
@ -4131,7 +4135,7 @@ instanceOf(Thread* t, GcClass* class_, object o)
if (o == 0) { if (o == 0) {
return false; return false;
} else { } else {
return isAssignableFrom(t, class_, reinterpret_cast<GcClass*>(objectClass(t, o))); return isAssignableFrom(t, class_, objectClass(t, o));
} }
} }
@ -4273,8 +4277,7 @@ parseClass(Thread* t, object loader, const uint8_t* data, unsigned size,
0, // array dimensions 0, // array dimensions
0, // runtime data index 0, // runtime data index
0, // object mask 0, // object mask
referenceName cast<GcByteArray>(t, referenceName(t, singletonObject(t, pool, name - 1))),
(t, singletonObject(t, pool, name - 1)),
0, // source file 0, // source file
0, // super 0, // super
0, // interfaces 0, // interfaces
@ -4283,7 +4286,7 @@ parseClass(Thread* t, object loader, const uint8_t* data, unsigned size,
0, // methods 0, // methods
0, // addendum 0, // addendum
0, // static table 0, // static table
loader, cast<GcClassLoader>(t, loader),
0, // source 0, // source
0);// vtable length 0);// vtable length
PROTECT(t, class_); PROTECT(t, class_);
@ -4324,17 +4327,17 @@ parseClass(Thread* t, object loader, const uint8_t* data, unsigned size,
class_->fixedSize(), class_->fixedSize(),
class_->arrayElementSize(), class_->arrayElementSize(),
class_->arrayDimensions(), class_->arrayDimensions(),
class_->objectMask(), reinterpret_cast<object>(class_->objectMask()),
class_->name(), reinterpret_cast<object>(class_->name()),
class_->sourceFile(), reinterpret_cast<object>(class_->sourceFile()),
class_->super(), reinterpret_cast<object>(class_->super()),
class_->interfaceTable(), reinterpret_cast<object>(class_->interfaceTable()),
class_->virtualTable(), reinterpret_cast<object>(class_->virtualTable()),
class_->fieldTable(), reinterpret_cast<object>(class_->fieldTable()),
class_->methodTable(), reinterpret_cast<object>(class_->methodTable()),
class_->addendum(), reinterpret_cast<object>(class_->addendum()),
class_->staticTable(), reinterpret_cast<object>(class_->staticTable()),
class_->loader(), reinterpret_cast<object>(class_->loader()),
vtableLength); vtableLength);
PROTECT(t, real); PROTECT(t, real);
@ -4345,7 +4348,7 @@ parseClass(Thread* t, object loader, const uint8_t* data, unsigned size,
if (root(t, Machine::PoolMap)) { if (root(t, Machine::PoolMap)) {
object bootstrapClass = hashMapFind object bootstrapClass = hashMapFind
(t, cast<GcHashMap>(t, root(t, Machine::BootstrapClassMap)), class_->name(), (t, cast<GcHashMap>(t, root(t, Machine::BootstrapClassMap)), reinterpret_cast<object>(class_->name()),
byteArrayHash, byteArrayEqual); byteArrayHash, byteArrayEqual);
hashMapInsert( hashMapInsert(
@ -4523,7 +4526,7 @@ resolveClass(Thread* t, object loader, object spec, bool throw_,
if (classLoaderClass->vmFlags() & BootstrapFlag) { if (classLoaderClass->vmFlags() & BootstrapFlag) {
resolveSystemClass resolveSystemClass
(t, root(t, Machine::BootLoader), (t, root(t, Machine::BootLoader),
classLoaderClass->name()); reinterpret_cast<object>(classLoaderClass->name()));
} }
} }
} }
@ -4589,8 +4592,7 @@ resolveMethod(Thread* t, GcClass* class_, const char* methodName,
if (method == 0) { if (method == 0) {
throwNew(t, GcNoSuchMethodError::Type, "%s %s not found in %s", throwNew(t, GcNoSuchMethodError::Type, "%s %s not found in %s",
methodName, methodSpec, &byteArrayBody methodName, methodSpec, class_->name()->body().begin());
(t, class_->name(), 0));
} else { } else {
return method; return method;
} }
@ -4613,13 +4615,13 @@ resolveField(Thread* t, GcClass* class_, const char* fieldName,
GcClass* c = class_; GcClass* c = class_;
PROTECT(t, c); PROTECT(t, c);
for (; c != 0 and field == 0; c = cast<GcClass>(t, c->super())) { for (; c != 0 and field == 0; c = c->super()) {
field = findFieldInClass(t, c, name, spec); field = findFieldInClass(t, c, name, spec);
} }
if (field == 0) { if (field == 0) {
throwNew(t, GcNoSuchFieldError::Type, "%s %s not found in %s", throwNew(t, GcNoSuchFieldError::Type, "%s %s not found in %s",
fieldName, fieldSpec, &byteArrayBody(t, class_->name(), 0)); fieldName, fieldSpec, class_->name()->body().begin());
} else { } else {
return field; return field;
} }
@ -4673,7 +4675,7 @@ preInitClass(Thread* t, GcClass* c)
} }
} else if (c->vmFlags() & InitErrorFlag) { } else if (c->vmFlags() & InitErrorFlag) {
throwNew(t, GcNoClassDefFoundError::Type, "%s", throwNew(t, GcNoClassDefFoundError::Type, "%s",
&byteArrayBody(t, c->name(), 0)); c->name()->body().begin());
} else { } else {
c->vmFlags() |= InitFlag; c->vmFlags() |= InitFlag;
return true; return true;
@ -4715,7 +4717,7 @@ initClass(Thread* t, GcClass* c)
{ {
PROTECT(t, c); PROTECT(t, c);
object super = c->super(); object super = reinterpret_cast<object>(c->super());
if (super) { if (super) {
initClass(t, cast<GcClass>(t, super)); initClass(t, cast<GcClass>(t, super));
} }
@ -4779,7 +4781,7 @@ object
makeObjectArray(Thread* t, GcClass* elementClass, unsigned count) makeObjectArray(Thread* t, GcClass* elementClass, unsigned count)
{ {
GcClass* arrayClass = resolveObjectArrayClass GcClass* arrayClass = resolveObjectArrayClass
(t, elementClass->loader(), reinterpret_cast<object>(elementClass)); (t, reinterpret_cast<object>(elementClass->loader()), reinterpret_cast<object>(elementClass));
PROTECT(t, arrayClass); PROTECT(t, arrayClass);
@ -4818,7 +4820,7 @@ findInHierarchyOrNull(Thread* t, GcClass* class_, object name, object spec,
} }
if (o == 0) { if (o == 0) {
for (; o == 0 and class_; class_ = cast<GcClass>(t, class_->super())) { for (; o == 0 and class_; class_ = class_->super()) {
o = find(t, class_, name, spec); o = find(t, class_, name, spec);
} }
@ -5050,8 +5052,7 @@ printTrace(Thread* t, object exception)
logTrace(errorLog(t), "caused by: "); logTrace(errorLog(t), "caused by: ");
} }
logTrace(errorLog(t), "%s", &byteArrayBody logTrace(errorLog(t), "%s", objectClass(t, e)->name()->body().begin());
(t, objectClass(t, e)->name(), 0));
if (throwableMessage(t, e)) { if (throwableMessage(t, e)) {
object m = throwableMessage(t, e); object m = throwableMessage(t, e);
@ -5281,9 +5282,9 @@ getCaller(Thread* t, unsigned target, bool skipMethodInvoke)
virtual bool visit(Processor::StackWalker* walker) { virtual bool visit(Processor::StackWalker* walker) {
if (skipMethodInvoke if (skipMethodInvoke
and cast<GcClass>(t, walker->method()->class_()) and walker->method()->class_()
== type(t, GcJmethod::Type) == type(t, GcJmethod::Type)
and strcmp(&byteArrayBody(t, walker->method()->name(), 0), and strcmp(walker->method()->name()->body().begin(),
reinterpret_cast<const int8_t*>("invoke")) == 0) { reinterpret_cast<const int8_t*>("invoke")) == 0) {
return true; return true;
} }
@ -5348,7 +5349,7 @@ populateMultiArray(Thread* t, object array, int32_t* counts,
PROTECT(t, array); PROTECT(t, array);
object spec = objectClass(t, array)->name(); object spec = reinterpret_cast<object>(objectClass(t, array)->name());
PROTECT(t, spec); PROTECT(t, spec);
object elementSpec = reinterpret_cast<object>(makeByteArray(t, byteArrayLength(t, spec) - 1)); object elementSpec = reinterpret_cast<object>(makeByteArray(t, byteArrayLength(t, spec) - 1));
@ -5357,7 +5358,7 @@ populateMultiArray(Thread* t, object array, int32_t* counts,
byteArrayLength(t, spec) - 1); byteArrayLength(t, spec) - 1);
GcClass* class_ = resolveClass GcClass* class_ = resolveClass
(t, objectClass(t, array)->loader(), elementSpec); (t, reinterpret_cast<object>(objectClass(t, array)->loader()), elementSpec);
PROTECT(t, class_); PROTECT(t, class_);
for (int32_t i = 0; i < counts[index]; ++i) { for (int32_t i = 0; i < counts[index]; ++i) {
@ -5449,10 +5450,8 @@ vmfPrintTrace(Thread* t, FILE* out)
Visitor(Thread* t, FILE* out): t(t), out(out) { } Visitor(Thread* t, FILE* out): t(t), out(out) { }
virtual bool visit(Processor::StackWalker* walker) { virtual bool visit(Processor::StackWalker* walker) {
const int8_t* class_ = &byteArrayBody const int8_t* class_ = walker->method()->class_()->name()->body().begin();
(t, className(t, walker->method()->class_()), 0); const int8_t* method = walker->method()->name()->body().begin();
const int8_t* method = &byteArrayBody
(t, walker->method()->name(), 0);
int line = t->m->processor->lineNumber int line = t->m->processor->lineNumber
(t, walker->method(), walker->ip()); (t, walker->method(), walker->ip());

View File

@ -71,14 +71,14 @@ jniNameLength(Thread* t, GcMethod* method, bool decorate)
{ {
unsigned size = 0; unsigned size = 0;
object className = ::className(t, method->class_()); object className = reinterpret_cast<object>(method->class_()->name());
for (unsigned i = 0; i < byteArrayLength(t, className) - 1; ++i) { for (unsigned i = 0; i < byteArrayLength(t, className) - 1; ++i) {
size += mangledSize(byteArrayBody(t, className, i)); size += mangledSize(byteArrayBody(t, className, i));
} }
++ size; ++ size;
object methodName = method->name(); object methodName = reinterpret_cast<object>(method->name());
for (unsigned i = 0; i < byteArrayLength(t, methodName) - 1; ++i) { for (unsigned i = 0; i < byteArrayLength(t, methodName) - 1; ++i) {
size += mangledSize(byteArrayBody(t, methodName, i)); size += mangledSize(byteArrayBody(t, methodName, i));
} }
@ -86,7 +86,7 @@ jniNameLength(Thread* t, GcMethod* method, bool decorate)
if (decorate) { if (decorate) {
size += 2; size += 2;
object methodSpec = method->spec(); object methodSpec = reinterpret_cast<object>(method->spec());
for (unsigned i = 1; i < byteArrayLength(t, methodSpec) - 1 for (unsigned i = 1; i < byteArrayLength(t, methodSpec) - 1
and byteArrayBody(t, methodSpec, i) != ')'; ++i) and byteArrayBody(t, methodSpec, i) != ')'; ++i)
{ {
@ -104,14 +104,14 @@ makeJNIName(Thread* t, const char* prefix, unsigned prefixLength, char* name,
memcpy(name, prefix, prefixLength); memcpy(name, prefix, prefixLength);
name += prefixLength; name += prefixLength;
object className = ::className(t, method->class_()); object className = reinterpret_cast<object>(method->class_()->name());
for (unsigned i = 0; i < byteArrayLength(t, className) - 1; ++i) { for (unsigned i = 0; i < byteArrayLength(t, className) - 1; ++i) {
name += mangle(byteArrayBody(t, className, i), name); name += mangle(byteArrayBody(t, className, i), name);
} }
*(name++) = '_'; *(name++) = '_';
object methodName = method->name(); object methodName = reinterpret_cast<object>(method->name());
for (unsigned i = 0; i < byteArrayLength(t, methodName) - 1; ++i) { for (unsigned i = 0; i < byteArrayLength(t, methodName) - 1; ++i) {
name += mangle(byteArrayBody(t, methodName, i), name); name += mangle(byteArrayBody(t, methodName, i), name);
} }
@ -120,7 +120,7 @@ makeJNIName(Thread* t, const char* prefix, unsigned prefixLength, char* name,
*(name++) = '_'; *(name++) = '_';
*(name++) = '_'; *(name++) = '_';
object methodSpec = method->spec(); object methodSpec = reinterpret_cast<object>(method->spec());
for (unsigned i = 1; i < byteArrayLength(t, methodSpec) - 1 for (unsigned i = 1; i < byteArrayLength(t, methodSpec) - 1
and byteArrayBody(t, methodSpec, i) != ')'; ++i) and byteArrayBody(t, methodSpec, i) != ')'; ++i)
{ {
@ -232,15 +232,15 @@ resolveNative(Thread* t, GcMethod* method)
assertT(t, method->flags() & ACC_NATIVE); assertT(t, method->flags() & ACC_NATIVE);
initClass(t, cast<GcClass>(t, method->class_())); initClass(t, method->class_());
if (methodRuntimeDataNative(t, getMethodRuntimeData(t, method)) == 0) { if (methodRuntimeDataNative(t, getMethodRuntimeData(t, method)) == 0) {
object native = resolveNativeMethod(t, method); object native = resolveNativeMethod(t, method);
if (UNLIKELY(native == 0)) { if (UNLIKELY(native == 0)) {
throwNew(t, GcUnsatisfiedLinkError::Type, "%s.%s%s", throwNew(t, GcUnsatisfiedLinkError::Type, "%s.%s%s",
&byteArrayBody(t, className(t, method->class_()), 0), method->class_()->name()->body().begin(),
&byteArrayBody(t, method->name(), 0), method->name()->body().begin(),
&byteArrayBody(t, method->spec(), 0)); method->spec()->body().begin());
} }
PROTECT(t, native); PROTECT(t, native);

View File

@ -618,13 +618,11 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
if (((methodName == 0 if (((methodName == 0
or ::strcmp or ::strcmp
(reinterpret_cast<char*> (reinterpret_cast<char*>
(&byteArrayBody (method->name()->body().begin()), methodName) == 0)
(t, method->name(), 0)), methodName) == 0)
and (methodSpec == 0 and (methodSpec == 0
or ::strcmp or ::strcmp
(reinterpret_cast<char*> (reinterpret_cast<char*>
(&byteArrayBody (method->spec()->body().begin()), methodSpec)
(t, method->spec(), 0)), methodSpec)
== 0))) == 0)))
{ {
if (method->code() if (method->code()
@ -640,26 +638,26 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
} }
} }
object addendum = method->addendum(); GcMethodAddendum* addendum = method->addendum();
if (addendum and methodAddendumExceptionTable(t, addendum)) { if (addendum and addendum->exceptionTable()) {
PROTECT(t, addendum); PROTECT(t, addendum);
// resolve exception types now to avoid trying to update // resolve exception types now to avoid trying to update
// immutable references at runtime // immutable references at runtime
for (unsigned i = 0; i < shortArrayLength for (unsigned i = 0; i < shortArrayLength
(t, methodAddendumExceptionTable(t, addendum)); ++i) (t, addendum->exceptionTable()); ++i)
{ {
uint16_t index = shortArrayBody uint16_t index = shortArrayBody
(t, methodAddendumExceptionTable(t, addendum), i) - 1; (t, addendum->exceptionTable(), i) - 1;
object o = singletonObject object o = singletonObject
(t, cast<GcSingleton>(t, addendumPool(t, addendum)), index); (t, cast<GcSingleton>(t, addendum->pool()), index);
if (objectClass(t, o) == type(t, GcReference::Type)) { if (objectClass(t, o) == type(t, GcReference::Type)) {
o = reinterpret_cast<object>(resolveClass o = reinterpret_cast<object>(resolveClass
(t, root(t, Machine::BootLoader), referenceName(t, o))); (t, root(t, Machine::BootLoader), referenceName(t, o)));
set(t, addendumPool(t, addendum), set(t, addendum->pool(),
SingletonBody + (index * BytesPerWord), o); SingletonBody + (index * BytesPerWord), o);
} }
} }

View File

@ -7,7 +7,9 @@
There is NO WARRANTY for this software. See license.txt for There is NO WARRANTY for this software. See license.txt for
details. */ details. */
#include <string>
#include "assert.h" #include "assert.h"
#ifndef AVIAN_TOOLS_TYPE_GENERATOR_IO_H #ifndef AVIAN_TOOLS_TYPE_GENERATOR_IO_H
@ -101,7 +103,7 @@ class Output {
virtual void dispose() = 0; virtual void dispose() = 0;
virtual void write(const char* s) = 0; virtual void write(const std::string& s) = 0;
void write(int i) { void write(int i) {
static const int Size = 32; static const int Size = 32;
@ -133,8 +135,8 @@ class FileOutput : public Output {
} }
} }
virtual void write(const char* s) { virtual void write(const std::string& s) {
fputs(s, stream); fputs(s.c_str(), stream);
} }
const char* filename() { const char* filename() {

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,6 @@ class Object {
Method, Method,
Type, Type,
Pair, Pair,
Number,
Character, Character,
String, String,
Eos Eos