retypedef object to GcObject*, remove (almost?) all unnecessary reinterpret_casts

This commit is contained in:
Joshua Warner 2014-07-02 15:11:27 -06:00
parent b0490b8233
commit cbad6931af
13 changed files with 446 additions and 462 deletions

View File

@ -38,7 +38,7 @@ getTrace(Thread* t, unsigned skipCount)
{ {
return true; return true;
} else { } else {
trace = reinterpret_cast<object>(makeTrace(t, walker)); trace = makeTrace(t, walker);
return false; return false;
} }
} else { } else {
@ -54,16 +54,14 @@ getTrace(Thread* t, unsigned skipCount)
t->m->processor->walkStack(t, &v); t->m->processor->walkStack(t, &v);
if (v.trace == 0) v.trace = reinterpret_cast<object>(makeObjectArray(t, 0)); if (v.trace == 0) v.trace = makeObjectArray(t, 0);
return v.trace; return v.trace;
} }
bool bool
compatibleArrayTypes(Thread* t, object ao, object bo) compatibleArrayTypes(Thread* t UNUSED, GcClass* a, GcClass* b)
{ {
GcClass* a = cast<GcClass>(t, ao);
GcClass* b = cast<GcClass>(t, bo);
return a->arrayElementSize() return a->arrayElementSize()
and b->arrayElementSize() and b->arrayElementSize()
and (a == b and (a == b
@ -77,7 +75,7 @@ arrayCopy(Thread* t, object src, int32_t srcOffset, object dst,
{ {
if (LIKELY(src and dst)) { if (LIKELY(src and dst)) {
if (LIKELY(compatibleArrayTypes if (LIKELY(compatibleArrayTypes
(t, reinterpret_cast<object>(objectClass(t, src)), reinterpret_cast<object>(objectClass(t, dst))))) (t, objectClass(t, src), objectClass(t, dst))))
{ {
unsigned elementSize = objectClass(t, src)->arrayElementSize(); unsigned elementSize = objectClass(t, src)->arrayElementSize();
@ -300,7 +298,7 @@ makeStackTraceElement(Thread* t, GcTraceElement* e)
PROTECT(t, method_name); PROTECT(t, method_name);
GcString* method_name_string = t->m->classpath->makeString GcString* method_name_string = t->m->classpath->makeString
(t, reinterpret_cast<object>(method_name), 0, method_name->length() - 1); (t, method_name, 0, method_name->length() - 1);
PROTECT(t, method_name_string); PROTECT(t, method_name_string);
unsigned line = t->m->processor->lineNumber unsigned line = t->m->processor->lineNumber
@ -308,38 +306,38 @@ makeStackTraceElement(Thread* t, GcTraceElement* e)
GcByteArray* file = method->class_()->sourceFile(); GcByteArray* file = method->class_()->sourceFile();
GcString* file_string = file ? t->m->classpath->makeString GcString* file_string = file ? t->m->classpath->makeString
(t, reinterpret_cast<object>(file), 0, file->length() - 1) : 0; (t, file, 0, file->length() - 1) : 0;
return makeStackTraceElement(t, class_name_string, method_name_string, file_string, line); return makeStackTraceElement(t, class_name_string, method_name_string, file_string, line);
} }
object GcObject*
translateInvokeResult(Thread* t, unsigned returnCode, object o) translateInvokeResult(Thread* t, unsigned returnCode, object o)
{ {
switch (returnCode) { switch (returnCode) {
case ByteField: case ByteField:
return reinterpret_cast<object>(makeByte(t, cast<GcInt>(t, o)->value())); return makeByte(t, cast<GcInt>(t, o)->value());
case BooleanField: case BooleanField:
return reinterpret_cast<object>(makeBoolean(t, cast<GcInt>(t, o)->value() != 0)); return makeBoolean(t, cast<GcInt>(t, o)->value() != 0);
case CharField: case CharField:
return reinterpret_cast<object>(makeChar(t, cast<GcInt>(t, o)->value())); return makeChar(t, cast<GcInt>(t, o)->value());
case ShortField: case ShortField:
return reinterpret_cast<object>(makeShort(t, cast<GcInt>(t, o)->value())); return makeShort(t, cast<GcInt>(t, o)->value());
case FloatField: case FloatField:
return reinterpret_cast<object>(makeFloat(t, cast<GcInt>(t, o)->value())); return makeFloat(t, cast<GcInt>(t, o)->value());
case IntField: case IntField:
case LongField: case LongField:
case ObjectField: case ObjectField:
case VoidField: case VoidField:
return o; return reinterpret_cast<GcObject*>(o);
case DoubleField: case DoubleField:
return reinterpret_cast<object>(makeDouble(t, cast<GcLong>(t, o)->value())); return makeDouble(t, cast<GcLong>(t, o)->value());
default: default:
abort(t); abort(t);
@ -400,7 +398,7 @@ resolveParameterTypes(Thread* t, GcClassLoader* loader, GcByteArray* spec,
(t, loader, reinterpret_cast<char*>(&spec->body()[start]), (t, loader, reinterpret_cast<char*>(&spec->body()[start]),
offset - start); offset - start);
list = makePair(t, reinterpret_cast<object>(type), reinterpret_cast<object>(list)); list = makePair(t, type, list);
++ count; ++ count;
} break; } break;
@ -424,13 +422,13 @@ resolveParameterTypes(Thread* t, GcClassLoader* loader, GcByteArray* spec,
(t, loader, reinterpret_cast<char*>(&spec->body()[start]), (t, loader, reinterpret_cast<char*>(&spec->body()[start]),
offset - start); offset - start);
list = makePair(t, reinterpret_cast<object>(type), reinterpret_cast<object>(list)); list = makePair(t, type, list);
++ count; ++ count;
} break; } break;
default: default:
list = makePair list = makePair
(t, reinterpret_cast<object>(primitiveClass(t, spec->body()[offset])), reinterpret_cast<object>(list)); (t, primitiveClass(t, spec->body()[offset]), list);
++ offset; ++ offset;
++ count; ++ count;
break; break;
@ -456,7 +454,7 @@ resolveParameterJTypes(Thread* t, GcClassLoader* loader, GcByteArray* 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 = reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, list->first()))); object c = getJClass(t, cast<GcClass>(t, list->first()));
reinterpret_cast<GcArray*>(array)->setBodyElement(t, i, c); reinterpret_cast<GcArray*>(array)->setBodyElement(t, i, c);
list = cast<GcPair>(t, list->second()); list = cast<GcPair>(t, list->second());
} }
@ -489,12 +487,12 @@ resolveExceptionJTypes(Thread* t, GcClassLoader* loader, GcMethodAddendum* adden
object o = singletonObject(t, addendum->pool()->as<GcSingleton>(t), index); object o = singletonObject(t, addendum->pool()->as<GcSingleton>(t), index);
if (objectClass(t, o) == type(t, GcReference::Type)) { if (objectClass(t, o) == type(t, GcReference::Type)) {
o = reinterpret_cast<object>(resolveClass(t, loader, cast<GcReference>(t, o)->name())); o = resolveClass(t, loader, cast<GcReference>(t, o)->name());
addendum->pool()->setBodyElement(t, index, reinterpret_cast<uintptr_t>(o)); addendum->pool()->setBodyElement(t, index, reinterpret_cast<uintptr_t>(o));
} }
o = reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, o))); o = getJClass(t, cast<GcClass>(t, o));
reinterpret_cast<GcArray*>(array)->setBodyElement(t, i, o); reinterpret_cast<GcArray*>(array)->setBodyElement(t, i, o);
} }
@ -615,7 +613,7 @@ intercept(Thread* t, GcClass* c, const char* name, const char* spec,
// through the vtable. // through the vtable.
clone->flags() |= ACC_PRIVATE; clone->flags() |= ACC_PRIVATE;
GcNativeIntercept* native = makeNativeIntercept(t, function, true, reinterpret_cast<object>(clone)); GcNativeIntercept* native = makeNativeIntercept(t, function, true, clone);
PROTECT(t, native); PROTECT(t, native);
@ -691,7 +689,7 @@ getDeclaredClasses(Thread* t, GcClass* c, bool publicOnly)
for (unsigned i = 0; i < table->length(); ++i) { for (unsigned i = 0; i < table->length(); ++i) {
GcInnerClassReference* reference = cast<GcInnerClassReference>(t, table->body()[i]); GcInnerClassReference* reference = cast<GcInnerClassReference>(t, table->body()[i]);
GcByteArray* outer = reference->outer(); GcByteArray* outer = reference->outer();
if (outer and byteArrayEqual(t, reinterpret_cast<object>(outer), reinterpret_cast<object>(c->name())) if (outer and byteArrayEqual(t, outer, c->name())
and ((not publicOnly) and ((not publicOnly)
or (reference->flags() & ACC_PUBLIC))) or (reference->flags() & ACC_PUBLIC)))
{ {
@ -705,16 +703,16 @@ getDeclaredClasses(Thread* t, GcClass* c, bool publicOnly)
for (unsigned i = 0; i < table->length(); ++i) { for (unsigned i = 0; i < table->length(); ++i) {
GcInnerClassReference* reference = cast<GcInnerClassReference>(t, table->body()[i]); GcInnerClassReference* reference = cast<GcInnerClassReference>(t, table->body()[i]);
GcByteArray* outer = reference->outer(); GcByteArray* outer = reference->outer();
if (outer and byteArrayEqual(t, reinterpret_cast<object>(outer), reinterpret_cast<object>(c->name())) if (outer and byteArrayEqual(t, outer, c->name())
and ((not publicOnly) and ((not publicOnly)
or (reference->flags() & ACC_PUBLIC))) or (reference->flags() & ACC_PUBLIC)))
{ {
object inner = reinterpret_cast<object>(getJClass( object inner = getJClass(
t, t,
resolveClass( resolveClass(
t, t,
c->loader(), c->loader(),
reference->inner()))); reference->inner()));
-- count; -- count;
reinterpret_cast<GcArray*>(result)->setBodyElement(t, count, inner); reinterpret_cast<GcArray*>(result)->setBodyElement(t, count, inner);

View File

@ -16,9 +16,9 @@ namespace vm {
class Machine; class Machine;
class Thread; class Thread;
struct Object { }; class GcObject;;
typedef Object* object; typedef GcObject* object;
typedef uint8_t jboolean; typedef uint8_t jboolean;
typedef int8_t jbyte; typedef int8_t jbyte;

View File

@ -69,7 +69,7 @@ using namespace avian::util;
private: \ private: \
object name; \ object name; \
Thread::SingleProtector protector; \ Thread::SingleProtector protector; \
} MAKE_NAME(resource_)(t, reinterpret_cast<object>(name)); } MAKE_NAME(resource_)(t, name);
#define THREAD_RESOURCE(t, type, name, releaseBody) \ #define THREAD_RESOURCE(t, type, name, releaseBody) \
class MAKE_NAME(Resource_): public Thread::AutoResource { \ class MAKE_NAME(Resource_): public Thread::AutoResource { \
@ -1649,11 +1649,6 @@ objectClass(Thread*, object o)
{ {
return reinterpret_cast<GcClass*>(maskAlignedPointer(fieldAtOffset<object>(o, 0))); return reinterpret_cast<GcClass*>(maskAlignedPointer(fieldAtOffset<object>(o, 0)));
} }
inline GcClass*
objectClass(Thread*, GcObject* o)
{
return reinterpret_cast<GcClass*>(maskAlignedPointer(fieldAtOffset<object>(o, 0)));
}
inline unsigned inline unsigned
stackSizeInWords(Thread* t) stackSizeInWords(Thread* t)
@ -1877,13 +1872,6 @@ setField(Thread* t, object target, unsigned offset, object value)
mark(t, target, offset); mark(t, target, offset);
} }
inline void
setField(Thread* t, GcObject* target, unsigned offset, GcObject* value)
{
fieldAtOffset<GcObject*>(target, offset) = value;
mark(t, reinterpret_cast<object>(target), offset);
}
inline void inline void
setObject(Thread* t, GcObject* target, unsigned offset, GcObject* value) setObject(Thread* t, GcObject* target, unsigned offset, GcObject* value)
{ {
@ -1937,14 +1925,14 @@ T* GcObject::as(Thread* t UNUSED)
} }
assertT(t, assertT(t,
t->m->unsafe t->m->unsafe
|| instanceOf(t, reinterpret_cast<GcClass*>(arrayBodyUnsafe(t, t->m->types, T::Type)), reinterpret_cast<object>(this))); || instanceOf(t, reinterpret_cast<GcClass*>(arrayBodyUnsafe(t, t->m->types, T::Type)), this));
return static_cast<T*>(this); return static_cast<T*>(this);
} }
template <class T> template <class T>
bool GcObject::isa(Thread* t) bool GcObject::isa(Thread* t)
{ {
return instanceOf(t, reinterpret_cast<GcClass*>(arrayBodyUnsafe(t, t->m->types, T::Type)), reinterpret_cast<object>(this)); return instanceOf(t, reinterpret_cast<GcClass*>(arrayBodyUnsafe(t, t->m->types, T::Type)), this);
} }
template <class T> template <class T>
@ -2180,7 +2168,7 @@ type(Thread* t, Gc::Type type)
inline void inline void
setType(Thread* t, Gc::Type type, GcClass* value) setType(Thread* t, Gc::Type type, GcClass* value)
{ {
t->m->types->setBodyElement(t, type, reinterpret_cast<object>(value)); t->m->types->setBodyElement(t, type, value);
} }
inline bool inline bool
@ -2436,13 +2424,12 @@ stringHash(Thread* t, object so)
{ {
GcString* s = cast<GcString>(t, so); GcString* s = cast<GcString>(t, so);
if (s->hashCode() == 0 and s->length(t)) { if (s->hashCode() == 0 and s->length(t)) {
object data = reinterpret_cast<object>(s->data()); if (objectClass(t, s->data()) == type(t, GcByteArray::Type)) {
if (objectClass(t, data) == type(t, GcByteArray::Type)) {
s->hashCode() = hash s->hashCode() = hash
(cast<GcByteArray>(t, data)->body().subslice(s->offset(t), s->length(t))); (cast<GcByteArray>(t, s->data())->body().subslice(s->offset(t), s->length(t)));
} else { } else {
s->hashCode() = hash s->hashCode() = hash
(cast<GcCharArray>(t, data)->body().subslice(s->offset(t), s->length(t))); (cast<GcCharArray>(t, s->data())->body().subslice(s->offset(t), s->length(t)));
} }
} }
return s->hashCode(); return s->hashCode();
@ -2451,11 +2438,10 @@ stringHash(Thread* t, object so)
inline uint16_t inline uint16_t
stringCharAt(Thread* t, GcString* s, int i) stringCharAt(Thread* t, GcString* s, int i)
{ {
object data = reinterpret_cast<object>(s->data()); if (objectClass(t, s->data()) == type(t, GcByteArray::Type)) {
if (objectClass(t, data) == type(t, GcByteArray::Type)) { return cast<GcByteArray>(t, s->data())->body()[s->offset(t) + i];
return cast<GcByteArray>(t, data)->body()[s->offset(t) + i];
} else { } else {
return cast<GcCharArray>(t, data)->body()[s->offset(t) + i]; return cast<GcCharArray>(t, s->data())->body()[s->offset(t) + i];
} }
} }
@ -2482,8 +2468,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, reinterpret_cast<object>(method->name())) return byteArrayHash(t, method->name())
^ byteArrayHash(t, reinterpret_cast<object>(method->spec())); ^ byteArrayHash(t, method->spec());
} }
inline bool inline bool
@ -2492,8 +2478,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, reinterpret_cast<object>(a->name()), reinterpret_cast<object>(b->name())) and (byteArrayEqual(t, a->name(), b->name()) and
byteArrayEqual(t, reinterpret_cast<object>(a->spec()), reinterpret_cast<object>(b->spec()))); byteArrayEqual(t, a->spec(), b->spec()));
} }
class MethodSpecIterator { class MethodSpecIterator {
@ -2732,7 +2718,7 @@ makeThrowable
GcThrowable* result = cast<GcThrowable>(t, make(t, vm::type(t, type))); GcThrowable* result = cast<GcThrowable>(t, make(t, vm::type(t, type)));
result->setMessage(t, message); result->setMessage(t, message);
result->setTrace(t, reinterpret_cast<object>(trace)); result->setTrace(t, trace);
result->setCause(t, cause); result->setCause(t, cause);
return result; return result;
@ -2746,7 +2732,7 @@ makeThrowableV(Thread* t, Gc::Type type, const char* format, va_list a,
if (s) { if (s) {
GcString* message = t->m->classpath->makeString GcString* message = t->m->classpath->makeString
(t, reinterpret_cast<object>(s), 0, s->length() - 1); (t, s, 0, s->length() - 1);
return makeThrowable(t, type, message); return makeThrowable(t, type, message);
} else { } else {
@ -2904,7 +2890,7 @@ findInterfaceMethod(Thread* t, GcMethod* method, GcClass* class_)
{ {
assertT(t, (class_->vmFlags() & BootstrapFlag) == 0); assertT(t, (class_->vmFlags() & BootstrapFlag) == 0);
object interface = reinterpret_cast<object>(method->class_()); GcClass* interface = method->class_();
GcArray* itable = cast<GcArray>(t, class_->interfaceTable()); GcArray* itable = cast<GcArray>(t, class_->interfaceTable());
for (unsigned i = 0; i < itable->length(); i += 2) { for (unsigned i = 0; i < itable->length(); i += 2) {
if (itable->body()[i] == interface) { if (itable->body()[i] == interface) {
@ -3001,12 +2987,12 @@ monitorAtomicAppendAcquire(Thread* t, GcMonitor* monitor, GcMonitorNode* node)
if (tail == cast<GcMonitorNode>(t, monitor->acquireTail())) { if (tail == cast<GcMonitorNode>(t, monitor->acquireTail())) {
if (next) { if (next) {
atomicCompareAndSwapObject atomicCompareAndSwapObject
(t, reinterpret_cast<object>(monitor), MonitorAcquireTail, reinterpret_cast<object>(tail), next); (t, monitor, MonitorAcquireTail, tail, next);
} else if (atomicCompareAndSwapObject } else if (atomicCompareAndSwapObject
(t, reinterpret_cast<object>(tail), MonitorNodeNext, 0, reinterpret_cast<object>(node))) (t, tail, MonitorNodeNext, 0, node))
{ {
atomicCompareAndSwapObject atomicCompareAndSwapObject
(t, reinterpret_cast<object>(monitor), MonitorAcquireTail, reinterpret_cast<object>(tail), reinterpret_cast<object>(node)); (t, monitor, MonitorAcquireTail, tail, node);
return; return;
} }
} }
@ -3033,7 +3019,7 @@ monitorAtomicPollAcquire(Thread* t, GcMonitor* monitor, bool remove)
if (head == tail) { if (head == tail) {
if (next) { if (next) {
atomicCompareAndSwapObject atomicCompareAndSwapObject
(t, reinterpret_cast<object>(monitor), MonitorAcquireTail, reinterpret_cast<object>(tail), reinterpret_cast<object>(next)); (t, monitor, MonitorAcquireTail, tail, next);
} else { } else {
return 0; return 0;
} }
@ -3041,7 +3027,7 @@ monitorAtomicPollAcquire(Thread* t, GcMonitor* monitor, bool remove)
Thread* value = static_cast<Thread*>(next->value()); Thread* value = static_cast<Thread*>(next->value());
if ((not remove) if ((not remove)
or atomicCompareAndSwapObject or atomicCompareAndSwapObject
(t, reinterpret_cast<object>(monitor), MonitorAcquireHead, reinterpret_cast<object>(head), reinterpret_cast<object>(next))) (t, monitor, MonitorAcquireHead, head, next))
{ {
return value; return value;
} }
@ -3437,7 +3423,7 @@ exceptionMatch(Thread* t, GcClass* type, GcThrowable* exception)
{ {
return type == 0 return type == 0
or (exception != roots(t)->shutdownInProgress() or (exception != roots(t)->shutdownInProgress()
and instanceOf(t, type, reinterpret_cast<object>(t->exception))); and instanceOf(t, type, t->exception));
} }
object object
@ -3612,7 +3598,7 @@ resolveClassInObject(Thread* t, GcClassLoader* loader, object container,
if (c) { if (c) {
storeStoreMemoryBarrier(); storeStoreMemoryBarrier();
setField(t, container, classOffset, reinterpret_cast<object>(c)); setField(t, container, classOffset, c);
} }
return c; return c;
@ -3709,7 +3695,7 @@ acquireFieldForRead(Thread* t, GcField* field)
and (field->code() == DoubleField and (field->code() == DoubleField
or field->code() == LongField))) or field->code() == LongField)))
{ {
acquire(t, reinterpret_cast<object>(field)); acquire(t, field);
} }
} }
@ -3721,7 +3707,7 @@ releaseFieldForRead(Thread* t, GcField* field)
and (field->code() == DoubleField and (field->code() == DoubleField
or field->code() == LongField)) or field->code() == LongField))
{ {
release(t, reinterpret_cast<object>(field)); release(t, field);
} else { } else {
loadMemoryBarrier(); loadMemoryBarrier();
} }
@ -3751,7 +3737,7 @@ acquireFieldForWrite(Thread* t, GcField* field)
and (field->code() == DoubleField and (field->code() == DoubleField
or field->code() == LongField)) or field->code() == LongField))
{ {
acquire(t, reinterpret_cast<object>(field)); acquire(t, field);
} else { } else {
storeStoreMemoryBarrier(); storeStoreMemoryBarrier();
} }
@ -3766,7 +3752,7 @@ releaseFieldForWrite(Thread* t, GcField* field)
and (field->code() == DoubleField and (field->code() == DoubleField
or field->code() == LongField)) or field->code() == LongField))
{ {
release(t, reinterpret_cast<object>(field)); release(t, field);
} else { } else {
storeLoadMemoryBarrier(); storeLoadMemoryBarrier();
} }
@ -3827,7 +3813,7 @@ getClassRuntimeData(Thread* t, GcClass* c)
ACQUIRE(t, t->m->classLock); ACQUIRE(t, t->m->classLock);
if (c->runtimeDataIndex() == 0) { if (c->runtimeDataIndex() == 0) {
object runtimeData = reinterpret_cast<object>(makeClassRuntimeData(t, 0, 0, 0, 0)); GcClassRuntimeData* runtimeData = makeClassRuntimeData(t, 0, 0, 0, 0);
{ {
GcVector* v GcVector* v
@ -3859,7 +3845,7 @@ getMethodRuntimeData(Thread* t, GcMethod* method)
ACQUIRE(t, t->m->classLock); ACQUIRE(t, t->m->classLock);
if (method->runtimeDataIndex() == 0) { if (method->runtimeDataIndex() == 0) {
object runtimeData = reinterpret_cast<object>(makeMethodRuntimeData(t, 0)); GcMethodRuntimeData* runtimeData = makeMethodRuntimeData(t, 0);
{ {
GcVector* v GcVector* v
@ -3898,7 +3884,7 @@ getJClass(Thread* t, GcClass* c)
storeStoreMemoryBarrier(); storeStoreMemoryBarrier();
getClassRuntimeData(t, c)->setJclass(t, reinterpret_cast<object>(jclass)); getClassRuntimeData(t, c)->setJclass(t, jclass);
} }
} }

View File

@ -255,13 +255,13 @@ Avian_avian_SystemClassLoader_getPackageSource
GcByteArray* key = makeByteArray(t, RUNTIME_ARRAY_BODY(chars)); GcByteArray* key = makeByteArray(t, RUNTIME_ARRAY_BODY(chars));
GcByteArray* array = cast<GcByteArray>(t, hashMapFind GcByteArray* array = cast<GcByteArray>(t, hashMapFind
(t, roots(t)->packageMap(), reinterpret_cast<object>(key), byteArrayHash, byteArrayEqual)); (t, roots(t)->packageMap(), key, byteArrayHash, byteArrayEqual));
if (array) { if (array) {
return reinterpret_cast<uintptr_t>(makeLocalReference( return reinterpret_cast<uintptr_t>(makeLocalReference(
t, t,
reinterpret_cast<object>(t->m->classpath->makeString( t->m->classpath->makeString(
t, reinterpret_cast<object>(array), 0, array->length())))); t, array, 0, array->length())));
} else { } else {
return 0; return 0;
} }
@ -777,7 +777,7 @@ Avian_sun_misc_Unsafe_putObjectVolatile
object value = reinterpret_cast<object>(arguments[4]); object value = reinterpret_cast<object>(arguments[4]);
storeStoreMemoryBarrier(); storeStoreMemoryBarrier();
setField(t, o, offset, reinterpret_cast<object>(value)); setField(t, o, offset, value);
storeLoadMemoryBarrier(); storeLoadMemoryBarrier();
} }
@ -866,9 +866,9 @@ Avian_sun_misc_Unsafe_getLongVolatile
object lock; object lock;
if (BytesPerWord < 8) { if (BytesPerWord < 8) {
if (objectClass(t, o)->arrayDimensions()) { if (objectClass(t, o)->arrayDimensions()) {
lock = reinterpret_cast<object>(objectClass(t, o)); lock = objectClass(t, o);
} else { } else {
lock = reinterpret_cast<object>(fieldForOffset(t, cast<GcSingleton>(t, o), offset)); lock = fieldForOffset(t, cast<GcSingleton>(t, o), offset);
} }
PROTECT(t, o); PROTECT(t, o);
@ -898,9 +898,9 @@ Avian_sun_misc_Unsafe_putLongVolatile
object lock; object lock;
if (BytesPerWord < 8) { if (BytesPerWord < 8) {
if (objectClass(t, o)->arrayDimensions()) { if (objectClass(t, o)->arrayDimensions()) {
lock = reinterpret_cast<object>(objectClass(t, o)); lock = objectClass(t, o);
} else { } else {
lock = reinterpret_cast<object>(fieldForOffset(t, cast<GcSingleton>(t, o), offset)); lock = fieldForOffset(t, cast<GcSingleton>(t, o), offset);
} }
PROTECT(t, o); PROTECT(t, o);

View File

@ -131,18 +131,18 @@ makeMethodOrConstructor(Thread* t, GcJclass* c, unsigned index)
(t, method->class_()->loader(), method->addendum()); (t, method->class_()->loader(), method->addendum());
if (method->name()->body()[0] == '<') { if (method->name()->body()[0] == '<') {
return reinterpret_cast<object>(makeJconstructor return makeJconstructor
(t, 0, c, parameterTypes, exceptionTypes, 0, 0, 0, 0, index)); (t, 0, c, parameterTypes, exceptionTypes, 0, 0, 0, 0, index);
} else { } else {
PROTECT(t, exceptionTypes); PROTECT(t, exceptionTypes);
GcString* name = t->m->classpath->makeString GcString* name = t->m->classpath->makeString
(t, reinterpret_cast<object>(method->name()), 0, (t, method->name(), 0,
method->name()->length() - 1); method->name()->length() - 1);
return reinterpret_cast<object>(makeJmethod return makeJmethod
(t, 0, index, c, name, parameterTypes, exceptionTypes, returnType, 0, 0, (t, 0, index, c, name, parameterTypes, exceptionTypes, returnType, 0, 0,
0, 0, 0)); 0, 0, 0);
} }
} }
@ -165,10 +165,10 @@ makeField(Thread* t, GcJclass* c, unsigned index)
PROTECT(t, type); PROTECT(t, type);
GcString* name = t->m->classpath->makeString GcString* name = t->m->classpath->makeString
(t, reinterpret_cast<object>(field->name()), 0, (t, field->name(), 0,
field->name()->length() - 1); field->name()->length() - 1);
return reinterpret_cast<object>(makeJfield(t, 0, c, type, 0, 0, name, index)); return makeJfield(t, 0, c, type, 0, 0, name, index);
} }
void initVmThread(Thread* t, GcThread* thread, unsigned offset) void initVmThread(Thread* t, GcThread* thread, unsigned offset)
@ -188,7 +188,7 @@ void initVmThread(Thread* t, GcThread* thread, unsigned offset)
t->m->processor->invoke(t, constructor, instance, thread); t->m->processor->invoke(t, constructor, instance, thread);
setField(t, reinterpret_cast<object>(thread), offset, instance); setField(t, thread, offset, instance);
} }
if (thread->group() == 0) { if (thread->group() == 0) {
@ -220,7 +220,7 @@ translateStackTrace(Thread* t, object raw)
for (unsigned i = 0; i < objectArrayLength(t, array); ++i) { for (unsigned i = 0; i < objectArrayLength(t, array); ++i) {
GcStackTraceElement* e = makeStackTraceElement(t, cast<GcTraceElement>(t, objectArrayBody(t, raw, i))); GcStackTraceElement* e = makeStackTraceElement(t, cast<GcTraceElement>(t, objectArrayBody(t, raw, i)));
setField(t, array, ArrayBody + (i * BytesPerWord), reinterpret_cast<object>(e)); setField(t, array, ArrayBody + (i * BytesPerWord), e);
} }
return array; return array;
@ -238,7 +238,7 @@ class MyClasspath : public Classpath {
PROTECT(t, class_); PROTECT(t, class_);
GcJclass* c = reinterpret_cast<GcJclass*>(allocate(t, GcJclass::FixedSize, true)); GcJclass* c = reinterpret_cast<GcJclass*>(allocate(t, GcJclass::FixedSize, true));
setObjectClass(t, reinterpret_cast<object>(c), type(t, GcJclass::Type)); setObjectClass(t, c, type(t, GcJclass::Type));
c->setVmClass(t, class_); c->setVmClass(t, class_);
return c; return c;
@ -259,7 +259,7 @@ class MyClasspath : public Classpath {
charArray->body()[i] = byteArray->body()[offset + i]; charArray->body()[i] = byteArray->body()[offset + i];
} }
array = reinterpret_cast<object>(charArray); array = charArray;
} else { } else {
expect(t, objectClass(t, array) == type(t, GcCharArray::Type)); expect(t, objectClass(t, array) == type(t, GcCharArray::Type));
} }
@ -286,7 +286,7 @@ class MyClasspath : public Classpath {
GcMethod* constructor = resolveMethod GcMethod* constructor = resolveMethod
(t, type(t, GcThreadGroup::Type), "<init>", "()V"); (t, type(t, GcThreadGroup::Type), "<init>", "()V");
t->m->processor->invoke(t, constructor, reinterpret_cast<object>(group)); t->m->processor->invoke(t, constructor, group);
} }
resolveSystemClass resolveSystemClass
@ -301,7 +301,7 @@ class MyClasspath : public Classpath {
"(Ljava/lang/ThreadGroup;Ljava/lang/String;IZ)V"); "(Ljava/lang/ThreadGroup;Ljava/lang/String;IZ)V");
t->m->processor->invoke t->m->processor->invoke
(t, constructor, reinterpret_cast<object>(thread), group, 0, NormalPriority, false); (t, constructor, thread, group, 0, NormalPriority, false);
thread->setContextClassLoader(t, roots(t)->appLoader()); thread->setContextClassLoader(t, roots(t)->appLoader());
@ -315,7 +315,7 @@ class MyClasspath : public Classpath {
{ {
GcArray* table = cast<GcArray>(t, vmMethod->class_()->methodTable()); GcArray* table = cast<GcArray>(t, vmMethod->class_()->methodTable());
for (unsigned i = 0; i < table->length(); ++i) { for (unsigned i = 0; i < table->length(); ++i) {
if (reinterpret_cast<object>(vmMethod) == table->body()[i]) { if (vmMethod == table->body()[i]) {
return makeMethodOrConstructor return makeMethodOrConstructor
(t, getJClass(t, vmMethod->class_()), i); (t, getJClass(t, vmMethod->class_()), i);
} }
@ -340,7 +340,7 @@ class MyClasspath : public Classpath {
{ {
GcArray* table = cast<GcArray>(t, vmField->class_()->fieldTable()); GcArray* table = cast<GcArray>(t, vmField->class_()->fieldTable());
for (unsigned i = 0; i < table->length(); ++i) { for (unsigned i = 0; i < table->length(); ++i) {
if (reinterpret_cast<object>(vmField) == table->body()[i]) { if (vmField == table->body()[i]) {
return makeField(t, getJClass(t, vmField->class_()), i); return makeField(t, getJClass(t, vmField->class_()), i);
} }
} }
@ -366,7 +366,7 @@ class MyClasspath : public Classpath {
{ {
// force monitor creation so we don't get an OutOfMemory error // force monitor creation so we don't get an OutOfMemory error
// later when we try to acquire it: // later when we try to acquire it:
objectMonitor(t, reinterpret_cast<object>(t->javaThread), true); objectMonitor(t, t->javaThread, true);
GcField* field = resolveField( GcField* field = resolveField(
t, objectClass(t, t->javaThread), "vmThread", "Ljava/lang/VMThread;"); t, objectClass(t, t->javaThread), "vmThread", "Ljava/lang/VMThread;");
@ -383,10 +383,10 @@ class MyClasspath : public Classpath {
vm::release(t, vmt); vm::release(t, vmt);
} }
vm::acquire(t, reinterpret_cast<object>(t->javaThread)); vm::acquire(t, t->javaThread);
t->flags &= ~Thread::ActiveFlag; t->flags &= ~Thread::ActiveFlag;
vm::notifyAll(t, reinterpret_cast<object>(t->javaThread)); vm::notifyAll(t, t->javaThread);
vm::release(t, reinterpret_cast<object>(t->javaThread)); vm::release(t, t->javaThread);
}); });
initVmThread(t, t->javaThread, offset); initVmThread(t, t->javaThread, offset);
@ -394,7 +394,7 @@ class MyClasspath : public Classpath {
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, roots(t)->bootLoader(), "java/lang/Thread", "run", "()V"); (t, roots(t)->bootLoader(), "java/lang/Thread", "run", "()V");
t->m->processor->invoke(t, method, reinterpret_cast<object>(t->javaThread)); t->m->processor->invoke(t, method, t->javaThread);
} }
virtual void virtual void
@ -512,10 +512,10 @@ class MyClasspath : public Classpath {
PROTECT(t, constructor); PROTECT(t, constructor);
t->m->processor->invoke t->m->processor->invoke
(t, constructor, reinterpret_cast<object>(roots(t)->bootLoader()), 0, true); (t, constructor, roots(t)->bootLoader(), 0, true);
t->m->processor->invoke t->m->processor->invoke
(t, constructor, reinterpret_cast<object>(roots(t)->appLoader()), (t, constructor, roots(t)->appLoader(),
roots(t)->bootLoader(), false); roots(t)->bootLoader(), false);
} }
@ -725,7 +725,7 @@ getField(Thread* t, GcField* field, object instance)
object target; object target;
if (field->flags() & ACC_STATIC) { if (field->flags() & ACC_STATIC) {
target = reinterpret_cast<object>(field->class_()->staticTable()); target = field->class_()->staticTable();
} else if (instanceOf(t, field->class_(), instance)){ } else if (instanceOf(t, field->class_(), instance)){
target = instance; target = instance;
} else { } else {
@ -735,28 +735,28 @@ getField(Thread* t, GcField* field, object instance)
unsigned offset = field->offset(); unsigned offset = field->offset();
switch (field->code()) { switch (field->code()) {
case ByteField: case ByteField:
return reinterpret_cast<object>(makeByte(t, fieldAtOffset<int8_t>(target, offset))); return makeByte(t, fieldAtOffset<int8_t>(target, offset));
case BooleanField: case BooleanField:
return reinterpret_cast<object>(makeBoolean(t, fieldAtOffset<int8_t>(target, offset))); return makeBoolean(t, fieldAtOffset<int8_t>(target, offset));
case CharField: case CharField:
return reinterpret_cast<object>(makeChar(t, fieldAtOffset<int16_t>(target, offset))); return makeChar(t, fieldAtOffset<int16_t>(target, offset));
case ShortField: case ShortField:
return reinterpret_cast<object>(makeShort(t, fieldAtOffset<int16_t>(target, offset))); return makeShort(t, fieldAtOffset<int16_t>(target, offset));
case IntField: case IntField:
return reinterpret_cast<object>(makeInt(t, fieldAtOffset<int32_t>(target, offset))); return makeInt(t, fieldAtOffset<int32_t>(target, offset));
case LongField: case LongField:
return reinterpret_cast<object>(makeLong(t, fieldAtOffset<int64_t>(target, offset))); return makeLong(t, fieldAtOffset<int64_t>(target, offset));
case FloatField: case FloatField:
return reinterpret_cast<object>(makeFloat(t, fieldAtOffset<int32_t>(target, offset))); return makeFloat(t, fieldAtOffset<int32_t>(target, offset));
case DoubleField: case DoubleField:
return reinterpret_cast<object>(makeDouble(t, fieldAtOffset<int64_t>(target, offset))); return makeDouble(t, fieldAtOffset<int64_t>(target, offset));
case ObjectField: case ObjectField:
return fieldAtOffset<object>(target, offset); return fieldAtOffset<object>(target, offset);
@ -778,7 +778,7 @@ setField(Thread* t, GcField* field, object instance, object value)
object target; object target;
if ((field->flags() & ACC_STATIC) != 0) { if ((field->flags() & ACC_STATIC) != 0) {
target = reinterpret_cast<object>(field->class_()->staticTable()); target = field->class_()->staticTable();
} else if (instanceOf(t, field->class_(), instance)){ } else if (instanceOf(t, field->class_(), instance)){
target = instance; target = instance;
} else { } else {
@ -1477,7 +1477,7 @@ Avian_java_lang_VMThread_sleep
if (milliseconds <= 0) milliseconds = 1; if (milliseconds <= 0) milliseconds = 1;
if (t->javaThread->sleepLock() == 0) { if (t->javaThread->sleepLock() == 0) {
object lock = reinterpret_cast<object>(makeJobject(t)); object lock = makeJobject(t);
t->javaThread->setSleepLock(t, lock); t->javaThread->setSleepLock(t, lock);
} }
@ -1552,7 +1552,7 @@ Avian_dalvik_system_VMStack_getClasses
assertT(t, counter - 2 < objectArrayLength(t, array)); assertT(t, counter - 2 < objectArrayLength(t, array));
setField(t, array, ArrayBody + ((counter - 2) * BytesPerWord), reinterpret_cast<object>(c)); setField(t, array, ArrayBody + ((counter - 2) * BytesPerWord), c);
return true; return true;
} }
@ -2224,9 +2224,9 @@ Avian_java_lang_reflect_Field_getSignatureAnnotation
PROTECT(t, array); PROTECT(t, array);
GcString* string = t->m->classpath->makeString GcString* string = t->m->classpath->makeString
(t, reinterpret_cast<object>(signature), 0, signature->length() - 1); (t, signature, 0, signature->length() - 1);
setField(t, array, ArrayBody, reinterpret_cast<object>(string)); setField(t, array, ArrayBody, string);
return reinterpret_cast<uintptr_t>(array); return reinterpret_cast<uintptr_t>(array);
} }
@ -2296,7 +2296,7 @@ Avian_dalvik_system_VMRuntime_newNonMovableArray
(t, t->m->heap, Machine::FixedAllocation, (t, t->m->heap, Machine::FixedAllocation,
ArrayBody + arguments[2], false)); ArrayBody + arguments[2], false));
setObjectClass(t, reinterpret_cast<object>(array), type(t, GcByteArray::Type)); setObjectClass(t, array, type(t, GcByteArray::Type));
array->length() = arguments[2]; array->length() = arguments[2];
return reinterpret_cast<intptr_t>(array); return reinterpret_cast<intptr_t>(array);

View File

@ -64,7 +64,7 @@ class MyClasspath : public Classpath {
GcJmethod* jmethod = makeJmethod(t, vmMethod, false); GcJmethod* jmethod = makeJmethod(t, vmMethod, false);
return vmMethod->name()->body()[0] == '<' return vmMethod->name()->body()[0] == '<'
? reinterpret_cast<object>(makeJconstructor(t, jmethod)) : reinterpret_cast<object>(jmethod); ? (object)makeJconstructor(t, jmethod) : (object)jmethod;
} }
virtual GcMethod* virtual GcMethod*
@ -78,7 +78,7 @@ class MyClasspath : public Classpath {
virtual object virtual object
makeJField(Thread* t, GcField* vmField) makeJField(Thread* t, GcField* vmField)
{ {
return reinterpret_cast<object>(makeJfield(t, vmField, false)); return makeJfield(t, vmField, false);
} }
virtual GcField* virtual GcField*
@ -232,7 +232,7 @@ enumerateThreads(Thread* t, Thread* x, GcArray* array, unsigned* index,
unsigned limit) unsigned limit)
{ {
if (*index < limit) { if (*index < limit) {
array->setBodyElement(t, *index, reinterpret_cast<object>(x->javaThread)); array->setBodyElement(t, *index, x->javaThread);
++ (*index); ++ (*index);
if (x->peer) enumerateThreads(t, x->peer, array, index, limit); if (x->peer) enumerateThreads(t, x->peer, array, index, limit);
@ -547,7 +547,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
for (unsigned i = 0; i < t->m->propertyCount; ++i) { for (unsigned i = 0; i < t->m->propertyCount; ++i) {
GcString* s = makeString(t, "%s", t->m->properties[i]); GcString* s = makeString(t, "%s", t->m->properties[i]);
reinterpret_cast<GcArray*>(array)->setBodyElement(t, i, reinterpret_cast<object>(s)); reinterpret_cast<GcArray*>(array)->setBodyElement(t, i, s);
} }
return reinterpret_cast<int64_t>(array); return reinterpret_cast<int64_t>(array);
@ -618,7 +618,7 @@ Avian_java_lang_Runtime_addShutdownHook
ACQUIRE(t, t->m->shutdownLock); ACQUIRE(t, t->m->shutdownLock);
GcPair* p = makePair(t, hook, reinterpret_cast<object>(roots(t)->shutdownHooks())); GcPair* p = makePair(t, hook, roots(t)->shutdownHooks());
// sequence point, for gc (don't recombine statements) // sequence point, for gc (don't recombine statements)
roots(t)->setShutdownHooks(t, p); roots(t)->setShutdownHooks(t, p);
} }
@ -644,7 +644,7 @@ Avian_java_lang_Throwable_resolveTrace
for (unsigned i = 0; i < length; ++i) { for (unsigned i = 0; i < length; ++i) {
GcStackTraceElement* ste = makeStackTraceElement(t, cast<GcTraceElement>(t, objectArrayBody(t, trace, i))); GcStackTraceElement* ste = makeStackTraceElement(t, cast<GcTraceElement>(t, objectArrayBody(t, trace, i)));
reinterpret_cast<GcArray*>(array)->setBodyElement(t, i, reinterpret_cast<object>(ste)); reinterpret_cast<GcArray*>(array)->setBodyElement(t, i, ste);
} }
return reinterpret_cast<int64_t>(array); return reinterpret_cast<int64_t>(array);

View File

@ -490,7 +490,7 @@ class MyClasspath : public Classpath {
PROTECT(t, name); PROTECT(t, name);
GcJclass* c = reinterpret_cast<GcJclass*>(allocate(t, GcJclass::FixedSize, true)); GcJclass* c = reinterpret_cast<GcJclass*>(allocate(t, GcJclass::FixedSize, true));
setObjectClass(t, reinterpret_cast<object>(c), type(t, GcJclass::Type)); setObjectClass(t, c, type(t, GcJclass::Type));
c->setName(t, name); c->setName(t, name);
c->setVmClass(t, class_); c->setVmClass(t, class_);
@ -527,7 +527,7 @@ class MyClasspath : public Classpath {
charArray->body()[i] = array->body()[offset + i]; charArray->body()[i] = array->body()[offset + i];
} }
oarray = reinterpret_cast<object>(charArray); oarray = charArray;
} else { } else {
expect(t, objectClass(t, oarray) == type(t, GcCharArray::Type)); expect(t, objectClass(t, oarray) == type(t, GcCharArray::Type));
} }
@ -546,14 +546,14 @@ class MyClasspath : public Classpath {
group = parent->javaThread->group(); group = parent->javaThread->group();
} else { } else {
group = reinterpret_cast<GcThreadGroup*>(allocate(t, GcThreadGroup::FixedSize, true)); group = reinterpret_cast<GcThreadGroup*>(allocate(t, GcThreadGroup::FixedSize, true));
setObjectClass(t, reinterpret_cast<object>(group), type(t, GcThreadGroup::Type)); setObjectClass(t, group, type(t, GcThreadGroup::Type));
group->maxPriority() = MaxPriority; group->maxPriority() = MaxPriority;
} }
PROTECT(t, group); PROTECT(t, group);
GcThread* thread = reinterpret_cast<GcThread*>(allocate(t, GcThread::FixedSize, true)); GcThread* thread = reinterpret_cast<GcThread*>(allocate(t, GcThread::FixedSize, true));
setObjectClass(t, reinterpret_cast<object>(thread), type(t, GcThread::Type)); setObjectClass(t, thread, type(t, GcThread::Type));
thread->priority() = NormalPriority; thread->priority() = NormalPriority;
thread->setGroup(t, group); thread->setGroup(t, group);
@ -563,7 +563,7 @@ class MyClasspath : public Classpath {
PROTECT(t, thread); PROTECT(t, thread);
GcJobject* blockerLock = makeJobject(t); GcJobject* blockerLock = makeJobject(t);
thread->setBlockerLock(t, reinterpret_cast<object>(blockerLock)); thread->setBlockerLock(t, blockerLock);
const unsigned BufferSize = 256; const unsigned BufferSize = 256;
char buffer[BufferSize]; char buffer[BufferSize];
@ -583,8 +583,8 @@ class MyClasspath : public Classpath {
PROTECT(t, vmMethod); PROTECT(t, vmMethod);
return vmMethod->name()->body()[0] == '<' return vmMethod->name()->body()[0] == '<'
? reinterpret_cast<object>(makeJconstructor(t, vmMethod)) ? makeJconstructor(t, vmMethod)
: reinterpret_cast<object>(makeJmethod(t, vmMethod)); : makeJmethod(t, vmMethod);
} }
virtual GcMethod* virtual GcMethod*
@ -610,7 +610,7 @@ class MyClasspath : public Classpath {
virtual object virtual object
makeJField(Thread* t, GcField* vmField) makeJField(Thread* t, GcField* vmField)
{ {
return reinterpret_cast<object>(makeJfield(t, vmField)); return makeJfield(t, vmField);
} }
virtual GcField* virtual GcField*
@ -633,13 +633,13 @@ class MyClasspath : public Classpath {
{ {
// force monitor creation so we don't get an OutOfMemory error // force monitor creation so we don't get an OutOfMemory error
// later when we try to acquire it: // later when we try to acquire it:
objectMonitor(t, reinterpret_cast<object>(t->javaThread), true); objectMonitor(t, t->javaThread, true);
THREAD_RESOURCE0(t, { THREAD_RESOURCE0(t, {
vm::acquire(t, reinterpret_cast<object>(t->javaThread)); vm::acquire(t, t->javaThread);
t->flags &= ~Thread::ActiveFlag; t->flags &= ~Thread::ActiveFlag;
vm::notifyAll(t, reinterpret_cast<object>(t->javaThread)); vm::notifyAll(t, t->javaThread);
vm::release(t, reinterpret_cast<object>(t->javaThread)); vm::release(t, t->javaThread);
GcThrowable* e = t->exception; GcThrowable* e = t->exception;
PROTECT(t, e); PROTECT(t, e);
@ -648,7 +648,7 @@ class MyClasspath : public Classpath {
t->m->processor->invoke t->m->processor->invoke
(t, cast<GcMethod>(t, roots(t)->threadTerminated()), (t, cast<GcMethod>(t, roots(t)->threadTerminated()),
reinterpret_cast<object>(t->javaThread->group()), t->javaThread); t->javaThread->group(), t->javaThread);
t->exception = e; t->exception = e;
}); });
@ -656,7 +656,7 @@ class MyClasspath : public Classpath {
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, roots(t)->bootLoader(), "java/lang/Thread", "run", "()V"); (t, roots(t)->bootLoader(), "java/lang/Thread", "run", "()V");
t->m->processor->invoke(t, method, reinterpret_cast<object>(t->javaThread)); t->m->processor->invoke(t, method, t->javaThread);
} }
virtual void virtual void
@ -708,7 +708,7 @@ class MyClasspath : public Classpath {
(t, roots(t)->bootLoader(), "java/lang/ThreadGroup", (t, roots(t)->bootLoader(), "java/lang/ThreadGroup",
"threadTerminated", "(Ljava/lang/Thread;)V"); "threadTerminated", "(Ljava/lang/Thread;)V");
// sequence point, for gc (don't recombine statements) // sequence point, for gc (don't recombine statements)
roots(t)->setThreadTerminated(t, reinterpret_cast<object>(method)); roots(t)->setThreadTerminated(t, method);
#ifdef AVIAN_OPENJDK_SRC #ifdef AVIAN_OPENJDK_SRC
interceptFileOperations(t, true); interceptFileOperations(t, true);
@ -750,10 +750,10 @@ class MyClasspath : public Classpath {
PROTECT(t, constructor); PROTECT(t, constructor);
t->m->processor->invoke(t, constructor, reinterpret_cast<object>(roots(t)->bootLoader()), 0); t->m->processor->invoke(t, constructor, roots(t)->bootLoader(), 0);
t->m->processor->invoke t->m->processor->invoke
(t, constructor, reinterpret_cast<object>(roots(t)->appLoader()), (t, constructor, roots(t)->appLoader(),
roots(t)->bootLoader()); roots(t)->bootLoader());
} }
@ -1107,7 +1107,7 @@ getFileLength
stringChars(t, path, RUNTIME_ARRAY_BODY(p)); stringChars(t, path, RUNTIME_ARRAY_BODY(p));
replace('\\', '/', RUNTIME_ARRAY_BODY(p)); replace('\\', '/', RUNTIME_ARRAY_BODY(p));
EmbeddedFile ef(cp, RUNTIME_ARRAY_BODY(p), stringLength(t, path)); EmbeddedFile ef(cp, RUNTIME_ARRAY_BODY(p), stringLength(t, path));
if (ef.jar) { if (ef.jar) {
if (ef.jarLength == 0) { if (ef.jarLength == 0) {
return 0; return 0;
@ -2153,7 +2153,7 @@ countFields(Thread* t, GcClass* c, bool publicOnly)
} }
return count; return count;
} else { } else {
return objectArrayLength(t, reinterpret_cast<object>(table)); return objectArrayLength(t, table);
} }
} }
@ -2233,8 +2233,8 @@ makeJmethod(Thread* t, GcMethod* vmMethod, int index)
PROTECT(t, vmMethod); PROTECT(t, vmMethod);
object name = intern object name = intern
(t, reinterpret_cast<object>(t->m->classpath->makeString (t, t->m->classpath->makeString
(t, reinterpret_cast<object>(vmMethod->name()), 0, vmMethod->name()->length() - 1))); (t, vmMethod->name(), 0, vmMethod->name()->length() - 1));
PROTECT(t, name); PROTECT(t, name);
unsigned parameterCount; unsigned parameterCount;
@ -2265,8 +2265,8 @@ makeJmethod(Thread* t, GcMethod* vmMethod, int index)
if (signature) { if (signature) {
PROTECT(t, addendum); PROTECT(t, addendum);
signature = reinterpret_cast<object>(t->m->classpath->makeString signature = t->m->classpath->makeString
(t, signature, 0, cast<GcByteArray>(t, signature)->length() - 1)); (t, signature, 0, cast<GcByteArray>(t, signature)->length() - 1);
} }
annotationTable = addendum->annotationTable(); annotationTable = addendum->annotationTable();
@ -2290,13 +2290,13 @@ makeJmethod(Thread* t, GcMethod* vmMethod, int index)
GcClassRuntimeData* runtimeData = getClassRuntimeData(t, vmMethod->class_()); GcClassRuntimeData* runtimeData = getClassRuntimeData(t, vmMethod->class_());
runtimeData->setPool(t, runtimeData->setPool(t,
reinterpret_cast<object>(vmMethod->addendum()->pool())); vmMethod->addendum()->pool());
} }
if (index == -1) { if (index == -1) {
GcArray* table = cast<GcArray>(t, vmMethod->class_()->methodTable()); GcArray* table = cast<GcArray>(t, vmMethod->class_()->methodTable());
for (unsigned i = 0; i < table->length(); ++i) { for (unsigned i = 0; i < table->length(); ++i) {
if (reinterpret_cast<object>(vmMethod) == table->body()[i]) { if (vmMethod == table->body()[i]) {
index = i; index = i;
break; break;
} }
@ -2307,10 +2307,10 @@ makeJmethod(Thread* t, GcMethod* vmMethod, int index)
GcJclass* jclass = getJClass(t, vmMethod->class_()); GcJclass* jclass = getJClass(t, vmMethod->class_());
return reinterpret_cast<object>(makeJmethod return makeJmethod
(t, true, 0, jclass, index, cast<GcString>(t, name), returnType, parameterTypes, (t, true, 0, jclass, index, cast<GcString>(t, name), returnType, parameterTypes,
exceptionTypes, vmMethod->flags(), cast<GcString>(t, signature), 0, cast<GcByteArray>(t, annotationTable), exceptionTypes, vmMethod->flags(), cast<GcString>(t, signature), 0, cast<GcByteArray>(t, annotationTable),
cast<GcByteArray>(t, parameterAnnotationTable), cast<GcByteArray>(t, annotationDefault), 0, 0, 0)); cast<GcByteArray>(t, parameterAnnotationTable), cast<GcByteArray>(t, annotationDefault), 0, 0, 0);
} }
object object
@ -2339,8 +2339,8 @@ makeJconstructor(Thread* t, GcMethod* vmMethod, int index)
if (signature) { if (signature) {
PROTECT(t, addendum); PROTECT(t, addendum);
signature = reinterpret_cast<object>(t->m->classpath->makeString signature = t->m->classpath->makeString
(t, signature, 0, cast<GcByteArray>(t, signature)->length() - 1)); (t, signature, 0, cast<GcByteArray>(t, signature)->length() - 1);
} }
annotationTable = addendum->annotationTable(); annotationTable = addendum->annotationTable();
@ -2359,13 +2359,13 @@ makeJconstructor(Thread* t, GcMethod* vmMethod, int index)
GcClassRuntimeData* runtimeData = getClassRuntimeData(t, vmMethod->class_()); GcClassRuntimeData* runtimeData = getClassRuntimeData(t, vmMethod->class_());
runtimeData->setPool(t, runtimeData->setPool(t,
reinterpret_cast<object>(vmMethod->addendum()->pool())); vmMethod->addendum()->pool());
} }
if (index == -1) { if (index == -1) {
GcArray* table = cast<GcArray>(t, vmMethod->class_()->methodTable()); GcArray* table = cast<GcArray>(t, vmMethod->class_()->methodTable());
for (unsigned i = 0; i < table->length(); ++i) { for (unsigned i = 0; i < table->length(); ++i) {
if (reinterpret_cast<object>(vmMethod) == table->body()[i]) { if (vmMethod == table->body()[i]) {
index = i; index = i;
break; break;
} }
@ -2376,7 +2376,7 @@ makeJconstructor(Thread* t, GcMethod* vmMethod, int index)
GcJclass* jclass = getJClass(t, vmMethod->class_()); GcJclass* jclass = getJClass(t, vmMethod->class_());
return reinterpret_cast<object>( return
makeJconstructor(t, makeJconstructor(t,
true, true,
0, 0,
@ -2391,7 +2391,7 @@ makeJconstructor(Thread* t, GcMethod* vmMethod, int index)
cast<GcByteArray>(t, parameterAnnotationTable), cast<GcByteArray>(t, parameterAnnotationTable),
0, 0,
0, 0,
0)); 0);
} }
object object
@ -2400,8 +2400,8 @@ makeJfield(Thread* t, GcField* vmField, int index)
PROTECT(t, vmField); PROTECT(t, vmField);
object name = intern object name = intern
(t, reinterpret_cast<object>(t->m->classpath->makeString (t, t->m->classpath->makeString
(t, reinterpret_cast<object>(vmField->name()), 0, vmField->name()->length() - 1))); (t, vmField->name(), 0, vmField->name()->length() - 1));
PROTECT(t, name); PROTECT(t, name);
GcClass* type = resolveClassBySpec GcClass* type = resolveClassBySpec
@ -2421,8 +2421,8 @@ makeJfield(Thread* t, GcField* vmField, int index)
if (signature) { if (signature) {
PROTECT(t, addendum); PROTECT(t, addendum);
signature = reinterpret_cast<object>(t->m->classpath->makeString signature = t->m->classpath->makeString
(t, signature, 0, cast<GcByteArray>(t, signature)->length() - 1)); (t, signature, 0, cast<GcByteArray>(t, signature)->length() - 1);
} }
annotationTable = addendum->annotationTable(); annotationTable = addendum->annotationTable();
@ -2438,13 +2438,13 @@ makeJfield(Thread* t, GcField* vmField, int index)
GcClassRuntimeData* runtimeData = getClassRuntimeData(t, vmField->class_()); GcClassRuntimeData* runtimeData = getClassRuntimeData(t, vmField->class_());
runtimeData->setPool(t, runtimeData->setPool(t,
reinterpret_cast<object>(vmField->addendum()->pool())); vmField->addendum()->pool());
} }
if (index == -1) { if (index == -1) {
GcArray* table = cast<GcArray>(t, vmField->class_()->fieldTable()); GcArray* table = cast<GcArray>(t, vmField->class_()->fieldTable());
for (unsigned i = 0; i < table->length(); ++i) { for (unsigned i = 0; i < table->length(); ++i) {
if (reinterpret_cast<object>(vmField) == table->body()[i]) { if (vmField == table->body()[i]) {
index = i; index = i;
break; break;
} }
@ -2455,8 +2455,8 @@ makeJfield(Thread* t, GcField* vmField, int index)
GcJclass* jclass = getJClass(t, vmField->class_()); GcJclass* jclass = getJClass(t, vmField->class_());
return reinterpret_cast<object>(makeJfield return makeJfield
(t, true, 0, jclass, index, cast<GcString>(t, name), jtype, vmField->flags(), cast<GcString>(t, signature), 0, cast<GcByteArray>(t, annotationTable), 0, 0, 0, 0)); (t, true, 0, jclass, index, cast<GcString>(t, name), jtype, vmField->flags(), cast<GcString>(t, signature), 0, cast<GcByteArray>(t, annotationTable), 0, 0, 0, 0);
} }
void void
@ -3231,8 +3231,8 @@ jvmGetStackTraceElement(Thread* t, uintptr_t* arguments)
return reinterpret_cast<uint64_t> return reinterpret_cast<uint64_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(makeStackTraceElement (t, makeStackTraceElement
(t, cast<GcTraceElement>(t, objectArrayBody(t, cast<GcThrowable>(t, *throwable)->trace(), index)))))); (t, cast<GcTraceElement>(t, objectArrayBody(t, cast<GcThrowable>(t, *throwable)->trace(), index)))));
} }
extern "C" AVIAN_EXPORT jobject JNICALL extern "C" AVIAN_EXPORT jobject JNICALL
@ -3334,7 +3334,7 @@ jvmSleep(Thread* t, uintptr_t* arguments)
if (t->javaThread->sleepLock() == 0) { if (t->javaThread->sleepLock() == 0) {
GcJobject* lock = makeJobject(t); GcJobject* lock = makeJobject(t);
t->javaThread->setSleepLock(t, reinterpret_cast<object>(lock)); t->javaThread->setSleepLock(t, lock);
} }
acquire(t, t->javaThread->sleepLock()); acquire(t, t->javaThread->sleepLock());
@ -3358,7 +3358,7 @@ EXPORT(JVM_CurrentThread)(Thread* t, jclass)
{ {
ENTER(t, Thread::ActiveState); ENTER(t, Thread::ActiveState);
return makeLocalReference(t, reinterpret_cast<object>(t->javaThread)); return makeLocalReference(t, t->javaThread);
} }
extern "C" AVIAN_EXPORT jint JNICALL extern "C" AVIAN_EXPORT jint JNICALL
@ -3447,8 +3447,8 @@ jvmDumpThreads(Thread* t, uintptr_t* arguments)
PROTECT(t, array); PROTECT(t, array);
for (unsigned traceIndex = 0; traceIndex < traceLength; ++ traceIndex) { for (unsigned traceIndex = 0; traceIndex < traceLength; ++ traceIndex) {
object ste = reinterpret_cast<object>(makeStackTraceElement object ste = makeStackTraceElement
(t, cast<GcTraceElement>(t, objectArrayBody(t, trace, traceIndex)))); (t, cast<GcTraceElement>(t, objectArrayBody(t, trace, traceIndex)));
setField(t, array, ArrayBody + (traceIndex * BytesPerWord), ste); setField(t, array, ArrayBody + (traceIndex * BytesPerWord), ste);
} }
@ -3490,9 +3490,9 @@ 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 = reinterpret_cast<object>(getJClass( object c = getJClass(
t, t,
cast<GcMethod>(t, cast<GcTraceElement>(t, objectArrayBody(t, trace, i))->method())->class_())); cast<GcMethod>(t, cast<GcTraceElement>(t, objectArrayBody(t, trace, i))->method())->class_());
setField(t, context, ArrayBody + (i * BytesPerWord), c); setField(t, context, ArrayBody + (i * BytesPerWord), c);
} }
@ -3522,7 +3522,7 @@ jvmGetSystemPackage(Thread* t, uintptr_t* arguments)
THREAD_RUNTIME_ARRAY(t, char, chars, (*s)->length(t) + 1); THREAD_RUNTIME_ARRAY(t, char, chars, (*s)->length(t) + 1);
stringChars(t, *s, RUNTIME_ARRAY_BODY(chars)); stringChars(t, *s, RUNTIME_ARRAY_BODY(chars));
object key = reinterpret_cast<object>(makeByteArray(t, RUNTIME_ARRAY_BODY(chars))); object key = makeByteArray(t, RUNTIME_ARRAY_BODY(chars));
GcByteArray* array = cast<GcByteArray>(t, hashMapFind GcByteArray* array = cast<GcByteArray>(t, hashMapFind
(t, roots(t)->packageMap(), key, byteArrayHash, byteArrayEqual)); (t, roots(t)->packageMap(), key, byteArrayHash, byteArrayEqual));
@ -3530,8 +3530,8 @@ jvmGetSystemPackage(Thread* t, uintptr_t* arguments)
if (array) { if (array) {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(t->m->classpath->makeString (t, t->m->classpath->makeString
(t, reinterpret_cast<object>(array), 0, array->length())))); (t, array, 0, array->length())));
} else { } else {
return 0; return 0;
} }
@ -3604,7 +3604,7 @@ EXPORT(JVM_LatestUserDefinedLoader)(Thread* t)
t->m->processor->walkStack(t, &v); t->m->processor->walkStack(t, &v);
return makeLocalReference(t, reinterpret_cast<object>(v.loader)); return makeLocalReference(t, v.loader);
} }
extern "C" AVIAN_EXPORT jclass JNICALL extern "C" AVIAN_EXPORT jclass JNICALL
@ -3629,35 +3629,35 @@ jvmGetArrayElement(Thread* t, uintptr_t* arguments)
case 'Z': case 'Z':
return reinterpret_cast<intptr_t> return reinterpret_cast<intptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(makeBoolean(t, fieldAtOffset<int8_t>(*array, ArrayBody + index))))); (t, makeBoolean(t, fieldAtOffset<int8_t>(*array, ArrayBody + index))));
case 'B': case 'B':
return reinterpret_cast<intptr_t> return reinterpret_cast<intptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(makeByte(t, fieldAtOffset<int8_t>(*array, ArrayBody + index))))); (t, makeByte(t, fieldAtOffset<int8_t>(*array, ArrayBody + index))));
case 'C': case 'C':
return reinterpret_cast<intptr_t> return reinterpret_cast<intptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(makeChar(t, fieldAtOffset<int16_t>(*array, ArrayBody + (index * 2)))))); (t, makeChar(t, fieldAtOffset<int16_t>(*array, ArrayBody + (index * 2)))));
case 'S': case 'S':
return reinterpret_cast<intptr_t> return reinterpret_cast<intptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(makeShort(t, fieldAtOffset<int16_t>(*array, ArrayBody + (index * 2)))))); (t, makeShort(t, fieldAtOffset<int16_t>(*array, ArrayBody + (index * 2)))));
case 'I': case 'I':
return reinterpret_cast<intptr_t> return reinterpret_cast<intptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(makeInt(t, fieldAtOffset<int32_t>(*array, ArrayBody + (index * 4)))))); (t, makeInt(t, fieldAtOffset<int32_t>(*array, ArrayBody + (index * 4)))));
case 'F': case 'F':
return reinterpret_cast<intptr_t> return reinterpret_cast<intptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(makeFloat(t, fieldAtOffset<int32_t>(*array, ArrayBody + (index * 4)))))); (t, makeFloat(t, fieldAtOffset<int32_t>(*array, ArrayBody + (index * 4)))));
case 'J': case 'J':
return reinterpret_cast<intptr_t> return reinterpret_cast<intptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(makeLong(t, fieldAtOffset<int64_t>(*array, ArrayBody + (index * 8)))))); (t, makeLong(t, fieldAtOffset<int64_t>(*array, ArrayBody + (index * 8)))));
case 'D': case 'D':
return reinterpret_cast<intptr_t> return reinterpret_cast<intptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(makeDouble(t, fieldAtOffset<int64_t>(*array, ArrayBody + (index * 8)))))); (t, makeDouble(t, fieldAtOffset<int64_t>(*array, ArrayBody + (index * 8)))));
case 'L': case 'L':
case '[': case '[':
return reinterpret_cast<intptr_t> return reinterpret_cast<intptr_t>
@ -3734,20 +3734,20 @@ makeNewArray(Thread* t, GcClass* c, unsigned length)
switch (*name) { switch (*name) {
case 'b': case 'b':
if (name[1] == 'o') { if (name[1] == 'o') {
return reinterpret_cast<object>(makeBooleanArray(t, length)); return makeBooleanArray(t, length);
} else { } else {
return reinterpret_cast<object>(makeByteArray(t, length)); return makeByteArray(t, length);
} }
case 'c': return reinterpret_cast<object>(makeCharArray(t, length)); case 'c': return makeCharArray(t, length);
case 'd': return reinterpret_cast<object>(makeDoubleArray(t, length)); case 'd': return makeDoubleArray(t, length);
case 'f': return reinterpret_cast<object>(makeFloatArray(t, length)); case 'f': return makeFloatArray(t, length);
case 'i': return reinterpret_cast<object>(makeIntArray(t, length)); case 'i': return makeIntArray(t, length);
case 'l': return reinterpret_cast<object>(makeLongArray(t, length)); case 'l': return makeLongArray(t, length);
case 's': return reinterpret_cast<object>(makeShortArray(t, length)); case 's': return makeShortArray(t, length);
default: abort(t); default: abort(t);
} }
} else { } else {
return reinterpret_cast<object>(makeObjectArray(t, c, length)); return makeObjectArray(t, c, length);
} }
} }
@ -3815,7 +3815,7 @@ EXPORT(JVM_GetCallerClass)(Thread* t, int target)
GcMethod* method = getCaller(t, target, true); GcMethod* method = getCaller(t, target, true);
return method ? reinterpret_cast<jclass>(makeLocalReference return method ? reinterpret_cast<jclass>(makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, method->class_())))) : 0; (t, getJClass(t, method->class_()))) : 0;
} }
extern "C" AVIAN_EXPORT jclass JNICALL extern "C" AVIAN_EXPORT jclass JNICALL
@ -3827,32 +3827,32 @@ EXPORT(JVM_FindPrimitiveClass)(Thread* t, const char* name)
case 'b': case 'b':
if (name[1] == 'o') { if (name[1] == 'o') {
return reinterpret_cast<jclass>(makeLocalReference return reinterpret_cast<jclass>(makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, type(t, GcJboolean::Type))))); (t, getJClass(t, type(t, GcJboolean::Type))));
} else { } else {
return reinterpret_cast<jclass>(makeLocalReference return reinterpret_cast<jclass>(makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, type(t, GcJbyte::Type))))); (t, getJClass(t, type(t, GcJbyte::Type))));
} }
case 'c': case 'c':
return reinterpret_cast<jclass>(makeLocalReference return reinterpret_cast<jclass>(makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, type(t, GcJchar::Type))))); (t, getJClass(t, type(t, GcJchar::Type))));
case 'd': case 'd':
return reinterpret_cast<jclass>(makeLocalReference return reinterpret_cast<jclass>(makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, type(t, GcJdouble::Type))))); (t, getJClass(t, type(t, GcJdouble::Type))));
case 'f': case 'f':
return reinterpret_cast<jclass>(makeLocalReference return reinterpret_cast<jclass>(makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, type(t, GcJfloat::Type))))); (t, getJClass(t, type(t, GcJfloat::Type))));
case 'i': case 'i':
return reinterpret_cast<jclass>(makeLocalReference return reinterpret_cast<jclass>(makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, type(t, GcJint::Type))))); (t, getJClass(t, type(t, GcJint::Type))));
case 'l': case 'l':
return reinterpret_cast<jclass>(makeLocalReference return reinterpret_cast<jclass>(makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, type(t, GcJlong::Type))))); (t, getJClass(t, type(t, GcJlong::Type))));
case 's': case 's':
return reinterpret_cast<jclass>(makeLocalReference return reinterpret_cast<jclass>(makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, type(t, GcJshort::Type))))); (t, getJClass(t, type(t, GcJshort::Type))));
case 'v': case 'v':
return reinterpret_cast<jclass>(makeLocalReference return reinterpret_cast<jclass>(makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, type(t, GcJvoid::Type))))); (t, getJClass(t, type(t, GcJvoid::Type))));
default: default:
throwNew(t, GcIllegalArgumentException::Type); throwNew(t, GcIllegalArgumentException::Type);
} }
@ -3899,7 +3899,7 @@ jvmFindClassFromClassLoader(Thread* t, uintptr_t* arguments)
initClass(t, c); initClass(t, c);
} }
return reinterpret_cast<uint64_t>(makeLocalReference(t, reinterpret_cast<object>(getJClass(t, c)))); return reinterpret_cast<uint64_t>(makeLocalReference(t, getJClass(t, c)));
} }
extern "C" AVIAN_EXPORT jclass JNICALL extern "C" AVIAN_EXPORT jclass JNICALL
@ -3942,7 +3942,7 @@ jvmFindLoadedClass(Thread* t, uintptr_t* arguments)
GcClass* c = findLoadedClass(t, cast<GcClassLoader>(t, *loader), spec); GcClass* c = findLoadedClass(t, cast<GcClassLoader>(t, *loader), spec);
return reinterpret_cast<uint64_t> return reinterpret_cast<uint64_t>
(c ? makeLocalReference(t, reinterpret_cast<object>(getJClass(t, c))) : 0); (c ? makeLocalReference(t, getJClass(t, c)) : 0);
} }
extern "C" AVIAN_EXPORT jclass JNICALL extern "C" AVIAN_EXPORT jclass JNICALL
@ -3963,7 +3963,7 @@ jvmDefineClass(Thread* t, uintptr_t* arguments)
return reinterpret_cast<uint64_t> return reinterpret_cast<uint64_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, defineClass(t, cast<GcClassLoader>(t, *loader), data, length)))))); (t, getJClass(t, cast<GcClass>(t, defineClass(t, cast<GcClassLoader>(t, *loader), data, length)))));
} }
extern "C" AVIAN_EXPORT jclass JNICALL extern "C" AVIAN_EXPORT jclass JNICALL
@ -3998,7 +3998,7 @@ EXPORT(JVM_GetClassName)(Thread* t, jclass c)
{ {
ENTER(t, Thread::ActiveState); ENTER(t, Thread::ActiveState);
return reinterpret_cast<jstring>(makeLocalReference(t, reinterpret_cast<object>((*c)->name()))); return reinterpret_cast<jstring>(makeLocalReference(t, (*c)->name()));
} }
uint64_t uint64_t
@ -4017,7 +4017,7 @@ jvmGetClassInterfaces(Thread* t, uintptr_t* arguments)
PROTECT(t, array); PROTECT(t, array);
for (unsigned i = 0; i < table->length(); ++i) { for (unsigned i = 0; i < table->length(); ++i) {
object c = reinterpret_cast<object>(getJClass(t, cast<GcClass>(t, table->body()[i]))); object c = getJClass(t, cast<GcClass>(t, table->body()[i]));
setField(t, array, ArrayBody + (i * BytesPerWord), c); setField(t, array, ArrayBody + (i * BytesPerWord), c);
} }
@ -4057,10 +4057,10 @@ EXPORT(JVM_GetClassLoader)(Thread* t, jclass c)
{ {
return 0; return 0;
} else { } else {
return makeLocalReference(t, reinterpret_cast<object>(roots(t)->bootLoader())); return makeLocalReference(t, roots(t)->bootLoader());
} }
} else { } else {
return makeLocalReference(t, reinterpret_cast<object>(loader)); return makeLocalReference(t, loader);
} }
} }
@ -4161,11 +4161,11 @@ jvmGetComponentType(Thread* t, uintptr_t* arguments)
uint8_t n = (*c)->vmClass()->name()->body()[1]; uint8_t n = (*c)->vmClass()->name()->body()[1];
if (n != 'L' and n != '[') { if (n != 'L' and n != '[') {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(makeLocalReference(t, reinterpret_cast<object>(getJClass(t, primitiveClass(t, n))))); (makeLocalReference(t, getJClass(t, primitiveClass(t, n))));
} else { } else {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(getJClass(t, (*c)->vmClass()->arrayElementClass())))); (t, getJClass(t, (*c)->vmClass()->arrayElementClass())));
} }
} else { } else {
return 0; return 0;
@ -4217,8 +4217,8 @@ jvmGetDeclaringClass(Thread* t, uintptr_t* arguments)
{ {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(getDeclaringClass (t, getDeclaringClass
(t, cast<GcJclass>(t, *reinterpret_cast<jobject>(arguments[0]))->vmClass())))); (t, cast<GcJclass>(t, *reinterpret_cast<jobject>(arguments[0]))->vmClass())));
} }
extern "C" AVIAN_EXPORT jclass JNICALL extern "C" AVIAN_EXPORT jclass JNICALL
@ -4240,8 +4240,8 @@ jvmGetClassSignature(Thread* t, uintptr_t* arguments)
if (signature) { if (signature) {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(t->m->classpath->makeString (t, t->m->classpath->makeString
(t, reinterpret_cast<object>(signature), 0, signature->length() - 1)))); (t, signature, 0, signature->length() - 1)));
} }
} }
return 0; return 0;
@ -4444,7 +4444,7 @@ jvmInvokeMethod(Thread* t, uintptr_t* arguments)
return reinterpret_cast<uint64_t> return reinterpret_cast<uint64_t>
(makeLocalReference (makeLocalReference
(t, invoke (t, invoke
(t, vmMethod, instance ? reinterpret_cast<object>(*instance) : 0, args ? reinterpret_cast<object>(*args) : 0))); (t, vmMethod, instance ? *instance : 0, args ? reinterpret_cast<object>(*args) : 0)));
} }
extern "C" AVIAN_EXPORT jobject JNICALL extern "C" AVIAN_EXPORT jobject JNICALL
@ -4472,7 +4472,7 @@ jvmNewInstanceFromConstructor(Thread* t, uintptr_t* arguments)
(t, cast<GcJconstructor>(t, *constructor)->clazz()->vmClass()->methodTable())->body()[ (t, cast<GcJconstructor>(t, *constructor)->clazz()->vmClass()->methodTable())->body()[
cast<GcJconstructor>(t, *constructor)->slot()]); cast<GcJconstructor>(t, *constructor)->slot()]);
invoke(t, method, reinterpret_cast<object>(instance), args ? reinterpret_cast<object>(*args) : 0); invoke(t, method, instance, args ? reinterpret_cast<object>(*args) : 0);
return reinterpret_cast<uint64_t>(makeLocalReference(t, instance)); return reinterpret_cast<uint64_t>(makeLocalReference(t, instance));
} }
@ -4497,7 +4497,7 @@ EXPORT(JVM_GetClassConstantPool)(Thread* t, jclass c)
GcClassAddendum* addendum = vmClass->addendum(); GcClassAddendum* addendum = vmClass->addendum();
object pool; object pool;
if (addendum) { if (addendum) {
pool = reinterpret_cast<object>(addendum->pool()); pool = addendum->pool();
} else { } else {
pool = 0; pool = 0;
} }
@ -4506,7 +4506,7 @@ EXPORT(JVM_GetClassConstantPool)(Thread* t, jclass c)
pool = getClassRuntimeData(t, vmClass)->pool(); pool = getClassRuntimeData(t, vmClass)->pool();
} }
return makeLocalReference(t, reinterpret_cast<object>(makeConstantPool(t, pool))); return makeLocalReference(t, makeConstantPool(t, pool));
} }
extern "C" AVIAN_EXPORT jint JNICALL extern "C" AVIAN_EXPORT jint JNICALL
@ -4601,8 +4601,8 @@ jvmConstantPoolGetUTF8At(Thread* t, uintptr_t* arguments)
return reinterpret_cast<uint64_t> return reinterpret_cast<uint64_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(t->m->classpath->makeString (t, t->m->classpath->makeString
(t, array, 0, fieldAtOffset<uintptr_t>(array, BytesPerWord) - 1)))); (t, array, 0, fieldAtOffset<uintptr_t>(array, BytesPerWord) - 1)));
} }
extern "C" AVIAN_EXPORT jstring JNICALL extern "C" AVIAN_EXPORT jstring JNICALL
@ -4620,9 +4620,9 @@ maybeWrap(Thread* t, bool wrapException)
{ {
if (t->exception if (t->exception
and wrapException and wrapException
and not (instanceOf(t, type(t, GcError::Type), reinterpret_cast<object>(t->exception)) and not (instanceOf(t, type(t, GcError::Type), t->exception)
or instanceOf or instanceOf
(t, type(t, GcRuntimeException::Type), reinterpret_cast<object>(t->exception)))) (t, type(t, GcRuntimeException::Type), t->exception)))
{ {
GcThrowable* exception = t->exception; GcThrowable* exception = t->exception;
t->exception = 0; t->exception = 0;
@ -4641,7 +4641,7 @@ maybeWrap(Thread* t, bool wrapException)
GcThrowable* result = cast<GcThrowable>(t, make(t, paeClass)); GcThrowable* result = cast<GcThrowable>(t, make(t, paeClass));
PROTECT(t, result); PROTECT(t, result);
t->m->processor->invoke(t, paeConstructor, reinterpret_cast<object>(result), exception); t->m->processor->invoke(t, paeConstructor, result, exception);
t->exception = result; t->exception = result;
} }
@ -5139,7 +5139,7 @@ getInputArgumentArray(Thread* t, uintptr_t*)
for (unsigned i = 0; i < t->m->argumentCount; ++i) { for (unsigned i = 0; i < t->m->argumentCount; ++i) {
GcString* argument = makeString(t, t->m->arguments[i]); GcString* argument = makeString(t, t->m->arguments[i]);
setField(t, array, ArrayBody + (i * BytesPerWord), reinterpret_cast<object>(argument)); setField(t, array, ArrayBody + (i * BytesPerWord), argument);
} }
return reinterpret_cast<uintptr_t>(makeLocalReference(t, array)); return reinterpret_cast<uintptr_t>(makeLocalReference(t, array));
@ -5267,8 +5267,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 = reinterpret_cast<object>(getJClass enclosingClass = getJClass
(t, resolveClass(t, class_->loader(), cast<GcByteArray>(t, enclosingClass)))); (t, resolveClass(t, class_->loader(), cast<GcByteArray>(t, enclosingClass)));
setField(t, array, ArrayBody, enclosingClass); setField(t, array, ArrayBody, enclosingClass);
@ -5281,13 +5281,13 @@ getEnclosingMethodInfo(Thread* t, uintptr_t* arguments)
(t, enclosingMethod->first(), 0, (t, enclosingMethod->first(), 0,
cast<GcByteArray>(t, enclosingMethod->first())->length() - 1); cast<GcByteArray>(t, enclosingMethod->first())->length() - 1);
setField(t, array, ArrayBody + BytesPerWord, reinterpret_cast<object>(name)); setField(t, array, ArrayBody + BytesPerWord, name);
GcString* spec = t->m->classpath->makeString GcString* spec = t->m->classpath->makeString
(t, enclosingMethod->second(), 0, (t, enclosingMethod->second(), 0,
cast<GcByteArray>(t, enclosingMethod->second())->length() - 1); cast<GcByteArray>(t, enclosingMethod->second())->length() - 1);
setField(t, array, ArrayBody + (2 * BytesPerWord), reinterpret_cast<object>(spec)); setField(t, array, ArrayBody + (2 * BytesPerWord), spec);
} }
return reinterpret_cast<uintptr_t>(makeLocalReference(t, array)); return reinterpret_cast<uintptr_t>(makeLocalReference(t, array));
@ -5386,7 +5386,7 @@ Avian_java_util_TimeZone_getSystemTimeZoneID
// implementing findJavaTZ_md ourselves from scratch, but that would // implementing findJavaTZ_md ourselves from scratch, but that would
// be a lot of code to implement and maintain. // be a lot of code to implement and maintain.
object country = reinterpret_cast<object>(arguments[1]); object country = arguments[1];
THREAD_RUNTIME_ARRAY(t, char, countryChars, stringLength(t, country) + 1); THREAD_RUNTIME_ARRAY(t, char, countryChars, stringLength(t, country) + 1);
stringChars(t, country, RUNTIME_ARRAY_BODY(countryChars)); stringChars(t, country, RUNTIME_ARRAY_BODY(countryChars));

View File

@ -1375,15 +1375,15 @@ class Frame {
} }
} }
ir::Value* append(GcObject* o) ir::Value* append(object o)
{ {
BootContext* bc = context->bootContext; BootContext* bc = context->bootContext;
if (bc) { if (bc) {
avian::codegen::Promise* p = new (bc->zone) avian::codegen::ListenPromise(t->m->system, bc->zone); avian::codegen::Promise* p = new (bc->zone) avian::codegen::ListenPromise(t->m->system, bc->zone);
PROTECT(t, o); PROTECT(t, o);
object pointer = reinterpret_cast<object>(makePointer(t, p)); object pointer = makePointer(t, p);
bc->constants = makeTriple(t, reinterpret_cast<object>(o), pointer, reinterpret_cast<object>(bc->constants)); bc->constants = makeTriple(t, o, pointer, bc->constants);
return c->binaryOp( return c->binaryOp(
lir::Add, lir::Add,
@ -1393,12 +1393,12 @@ class Frame {
c->promiseConstant(p, ir::Type::object())); c->promiseConstant(p, ir::Type::object()));
} else { } else {
for (PoolElement* e = context->objectPool; e; e = e->next) { for (PoolElement* e = context->objectPool; e; e = e->next) {
if (reinterpret_cast<object>(o) == e->target) { if (o == e->target) {
return c->address(ir::Type::object(), e); return c->address(ir::Type::object(), e);
} }
} }
context->objectPool = new(&context->zone) PoolElement(t, reinterpret_cast<object>(o), context->objectPool); context->objectPool = new(&context->zone) PoolElement(t, o, context->objectPool);
++ context->objectPoolCount; ++ context->objectPoolCount;
@ -1994,7 +1994,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 = reinterpret_cast<object>(method->class_()); lock = method->class_();
} else { } else {
lock = *localObject lock = *localObject
(t, stackForFrame(t, stack, method), method, (t, stackForFrame(t, stack, method), method,
@ -2269,7 +2269,7 @@ resolveMethod(Thread* t, GcPair* pair)
PROTECT(t, reference); PROTECT(t, reference);
GcClass* class_ = resolveClassInObject GcClass* class_ = resolveClassInObject
(t, cast<GcMethod>(t, pair->first())->class_()->loader(), reinterpret_cast<object>(reference), (t, cast<GcMethod>(t, pair->first())->class_()->loader(), reference,
ReferenceClass); ReferenceClass);
return cast<GcMethod>(t, findInHierarchy return cast<GcMethod>(t, findInHierarchy
@ -2614,7 +2614,7 @@ makeMultidimensionalArray2(MyThread* t, GcClass* class_, uintptr_t* countStack,
} }
} }
object array = reinterpret_cast<object>(makeArray(t, RUNTIME_ARRAY_BODY(counts)[0])); object array = makeArray(t, RUNTIME_ARRAY_BODY(counts)[0]);
setObjectClass(t, array, class_); setObjectClass(t, array, class_);
PROTECT(t, array); PROTECT(t, array);
@ -2711,7 +2711,7 @@ resolveField(Thread* t, GcPair* pair)
PROTECT(t, reference); PROTECT(t, reference);
GcClass* class_ = resolveClassInObject GcClass* class_ = resolveClassInObject
(t, cast<GcMethod>(t, pair->first())->class_()->loader(), reinterpret_cast<object>(reference), (t, cast<GcMethod>(t, pair->first())->class_()->loader(), reference,
ReferenceClass); ReferenceClass);
return cast<GcField>(t, findInHierarchy return cast<GcField>(t, findInHierarchy
@ -2757,7 +2757,7 @@ getStaticFieldValueFromReference(MyThread* t, GcPair* pair)
ACQUIRE_FIELD_FOR_READ(t, field); ACQUIRE_FIELD_FOR_READ(t, field);
return getFieldValue(t, reinterpret_cast<object>(field->class_()->staticTable()), field); return getFieldValue(t, field->class_()->staticTable(), field);
} }
uint64_t uint64_t
@ -2813,7 +2813,7 @@ setStaticObjectFieldValueFromReference(MyThread* t, GcPair* pair, object value)
ACQUIRE_FIELD_FOR_WRITE(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field);
setField(t, reinterpret_cast<object>(field->class_()->staticTable()), field->offset(), setField(t, field->class_()->staticTable(), field->offset(),
value); value);
} }
@ -2866,7 +2866,7 @@ setStaticFieldValueFromReference(MyThread* t, GcPair* pair, uint32_t value)
ACQUIRE_FIELD_FOR_WRITE(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field);
setFieldValue(t, reinterpret_cast<object>(field->class_()->staticTable()), field, value); setFieldValue(t, field->class_()->staticTable(), field, value);
} }
void void
@ -3124,8 +3124,8 @@ compileDirectInvoke(MyThread* t, Frame* frame, GcMethod* target, bool tailCall)
avian::codegen::Promise* p = new(bc->zone) avian::codegen::ListenPromise(t->m->system, bc->zone); avian::codegen::Promise* p = new(bc->zone) avian::codegen::ListenPromise(t->m->system, bc->zone);
PROTECT(t, target); PROTECT(t, target);
object pointer = reinterpret_cast<object>(makePointer(t, p)); object pointer = makePointer(t, p);
bc->calls = makeTriple(t, reinterpret_cast<object>(target), pointer, reinterpret_cast<object>(bc->calls)); bc->calls = makeTriple(t, target, pointer, bc->calls);
compileDirectInvoke(t, frame, target, tailCall, false, p); compileDirectInvoke(t, frame, target, tailCall, false, p);
} else { } else {
@ -3164,7 +3164,7 @@ compileDirectReferenceInvoke(MyThread* t, Frame* frame, Thunk thunk,
PROTECT(t, reference); PROTECT(t, reference);
GcPair* pair = makePair(t, reinterpret_cast<object>(frame->context->method), reinterpret_cast<object>(reference)); GcPair* pair = makePair(t, frame->context->method, reference);
compileReferenceInvoke( compileReferenceInvoke(
frame, frame,
@ -4098,10 +4098,10 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
object argument; object argument;
Thunk thunk; Thunk thunk;
if (LIKELY(class_)) { if (LIKELY(class_)) {
argument = reinterpret_cast<object>(class_); argument = class_;
thunk = makeBlankObjectArrayThunk; thunk = makeBlankObjectArrayThunk;
} else { } else {
argument = reinterpret_cast<object>(makePair(t, reinterpret_cast<object>(context->method), reinterpret_cast<object>(reference))); argument = makePair(t, context->method, reference);
thunk = makeBlankObjectArrayFromReferenceThunk; thunk = makeBlankObjectArrayFromReferenceThunk;
} }
@ -4112,7 +4112,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
ir::Type::object(), ir::Type::object(),
3, 3,
c->threadRegister(), c->threadRegister(),
frame->append(reinterpret_cast<GcObject*>(argument)), frame->append(argument),
length)); length));
} break; } break;
@ -4182,10 +4182,10 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
object argument; object argument;
Thunk thunk; Thunk thunk;
if (LIKELY(class_)) { if (LIKELY(class_)) {
argument = reinterpret_cast<object>(class_); argument = class_;
thunk = checkCastThunk; thunk = checkCastThunk;
} else { } else {
argument = reinterpret_cast<object>(makePair(t, reinterpret_cast<object>(context->method), reinterpret_cast<object>(reference))); argument = makePair(t, context->method, reference);
thunk = checkCastFromReferenceThunk; thunk = checkCastFromReferenceThunk;
} }
@ -4197,7 +4197,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
ir::Type::void_(), ir::Type::void_(),
3, 3,
c->threadRegister(), c->threadRegister(),
frame->append(reinterpret_cast<GcObject*>(argument)), frame->append(argument),
instance); instance);
} break; } break;
@ -4558,7 +4558,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
int fieldCode = vm::fieldCode int fieldCode = vm::fieldCode
(t, ref->spec()->body()[0]); (t, ref->spec()->body()[0]);
GcPair* pair = makePair(t, reinterpret_cast<object>(context->method), reference); GcPair* pair = makePair(t, context->method, reference);
ir::Type rType = operandTypeForFieldCode(t, fieldCode); ir::Type rType = operandTypeForFieldCode(t, fieldCode);
@ -4864,10 +4864,10 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
object argument; object argument;
Thunk thunk; Thunk thunk;
if (LIKELY(class_)) { if (LIKELY(class_)) {
argument = reinterpret_cast<object>(class_); argument = class_;
thunk = instanceOf64Thunk; thunk = instanceOf64Thunk;
} else { } else {
argument = reinterpret_cast<object>(makePair(t, reinterpret_cast<object>(context->method), reinterpret_cast<object>(reference))); argument = makePair(t, context->method, reference);
thunk = instanceOfFromReferenceThunk; thunk = instanceOfFromReferenceThunk;
} }
@ -4878,7 +4878,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
ir::Type::i4(), ir::Type::i4(),
3, 3,
c->threadRegister(), c->threadRegister(),
frame->append(reinterpret_cast<GcObject*>(argument)), frame->append(argument),
instance)); instance));
} break; } break;
@ -4903,7 +4903,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
if (LIKELY(target)) { if (LIKELY(target)) {
checkMethod(t, target, false); checkMethod(t, target, false);
argument = reinterpret_cast<object>(target); argument = target;
thunk = findInterfaceMethodFromInstanceThunk; thunk = findInterfaceMethodFromInstanceThunk;
parameterFootprint = target->parameterFootprint(); parameterFootprint = target->parameterFootprint();
returnCode = target->returnCode(); returnCode = target->returnCode();
@ -4911,7 +4911,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
} else { } else {
GcReference* ref = cast<GcReference>(t, reference); GcReference* ref = cast<GcReference>(t, reference);
PROTECT(t, ref); PROTECT(t, ref);
argument = reinterpret_cast<object>(makePair(t, reinterpret_cast<object>(context->method), reference)); argument = makePair(t, context->method, reference);
thunk = findInterfaceMethodFromInstanceAndReferenceThunk; thunk = findInterfaceMethodFromInstanceAndReferenceThunk;
parameterFootprint = methodReferenceParameterFootprint parameterFootprint = methodReferenceParameterFootprint
(t, ref, false); (t, ref, false);
@ -4929,7 +4929,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
ir::Type::iptr(), ir::Type::iptr(),
3, 3,
c->threadRegister(), c->threadRegister(),
frame->append(reinterpret_cast<GcObject*>(argument)), frame->append(argument),
c->peek(1, parameterFootprint - 1)), c->peek(1, parameterFootprint - 1)),
tailCall ? Compiler::TailJump : 0, tailCall ? Compiler::TailJump : 0,
frame->trace(0, 0), frame->trace(0, 0),
@ -5058,7 +5058,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
PROTECT(t, reference); PROTECT(t, reference);
PROTECT(t, ref); PROTECT(t, ref);
GcPair* pair = makePair(t, reinterpret_cast<object>(context->method), reference); GcPair* pair = makePair(t, context->method, reference);
compileReferenceInvoke( compileReferenceInvoke(
frame, frame,
@ -5241,7 +5241,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
GcReference* reference = cast<GcReference>(t, v); GcReference* reference = cast<GcReference>(t, v);
PROTECT(t, reference); PROTECT(t, reference);
v = reinterpret_cast<object>(resolveClassInPool(t, context->method, index - 1, false)); v = resolveClassInPool(t, context->method, index - 1, false);
if (UNLIKELY(v == 0)) { if (UNLIKELY(v == 0)) {
frame->push( frame->push(
@ -5254,7 +5254,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
ir::Type::object(), ir::Type::object(),
2, 2,
c->threadRegister(), c->threadRegister(),
frame->append(makePair(t, reinterpret_cast<object>(context->method), reinterpret_cast<object>(reference))))); frame->append(makePair(t, context->method, reference))));
} }
} }
@ -5268,9 +5268,9 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
ir::Type::object(), ir::Type::object(),
2, 2,
c->threadRegister(), c->threadRegister(),
frame->append(reinterpret_cast<GcObject*>(v)))); frame->append(v)));
} else { } else {
frame->push(ir::Type::object(), frame->append(reinterpret_cast<GcObject*>(v))); frame->push(ir::Type::object(), frame->append(v));
} }
} }
} else { } else {
@ -5523,10 +5523,10 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
object argument; object argument;
Thunk thunk; Thunk thunk;
if (LIKELY(class_)) { if (LIKELY(class_)) {
argument = reinterpret_cast<object>(class_); argument = class_;
thunk = makeMultidimensionalArrayThunk; thunk = makeMultidimensionalArrayThunk;
} else { } else {
argument = reinterpret_cast<object>(makePair(t, reinterpret_cast<object>(context->method), reinterpret_cast<object>(reference))); argument = makePair(t, context->method, reference);
thunk = makeMultidimensionalArrayFromReferenceThunk; thunk = makeMultidimensionalArrayFromReferenceThunk;
} }
@ -5542,7 +5542,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
ir::Type::object(), ir::Type::object(),
4, 4,
c->threadRegister(), c->threadRegister(),
frame->append(reinterpret_cast<GcObject*>(argument)), frame->append(argument),
c->constant(dimensions, ir::Type::i4()), c->constant(dimensions, ir::Type::i4()),
c->constant(offset, ir::Type::i4())); c->constant(offset, ir::Type::i4()));
@ -5563,15 +5563,15 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
object argument; object argument;
Thunk thunk; Thunk thunk;
if (LIKELY(class_)) { if (LIKELY(class_)) {
argument = reinterpret_cast<object>(class_); argument = class_;
if (class_->vmFlags() & (WeakReferenceFlag | HasFinalizerFlag)) { if (class_->vmFlags() & (WeakReferenceFlag | HasFinalizerFlag)) {
thunk = makeNewGeneral64Thunk; thunk = makeNewGeneral64Thunk;
} else { } else {
thunk = makeNew64Thunk; thunk = makeNew64Thunk;
} }
} else { } else {
argument = reinterpret_cast<object>( argument =
makePair(t, reinterpret_cast<object>(context->method), reference)); makePair(t, context->method, reference);
thunk = makeNewFromReferenceThunk; thunk = makeNewFromReferenceThunk;
} }
@ -5582,7 +5582,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
ir::Type::object(), ir::Type::object(),
2, 2,
c->threadRegister(), c->threadRegister(),
frame->append(reinterpret_cast<GcObject*>(argument)))); frame->append(argument)));
} break; } break;
case newarray: { case newarray: {
@ -5644,7 +5644,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->append(field->class_())); frame->append(field->class_()));
} }
staticTable = reinterpret_cast<object>(field->class_()->staticTable()); staticTable = field->class_()->staticTable();
} else { } else {
checkField(t, field, false); checkField(t, field, false);
@ -5680,7 +5680,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
if (instruction == putstatic) { if (instruction == putstatic) {
PROTECT(t, field); PROTECT(t, field);
table = frame->append(reinterpret_cast<GcObject*>(staticTable)); table = frame->append(staticTable);
} else { } else {
table = frame->pop(ir::Type::object()); table = frame->pop(ir::Type::object());
} }
@ -5784,7 +5784,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
ir::Value* value = popField(t, frame, fieldCode); ir::Value* value = popField(t, frame, fieldCode);
ir::Type rType = operandTypeForFieldCode(t, fieldCode); ir::Type rType = operandTypeForFieldCode(t, fieldCode);
GcPair* pair = makePair(t, reinterpret_cast<object>(context->method), reference); GcPair* pair = makePair(t, context->method, reference);
switch (fieldCode) { switch (fieldCode) {
case ByteField: case ByteField:
@ -6304,8 +6304,8 @@ GcArray* translateExceptionHandlerTable(MyThread* t,
object type; object type;
if (exceptionHandlerCatchType(oldHandler)) { if (exceptionHandlerCatchType(oldHandler)) {
type = reinterpret_cast<object>(resolveClassInPool( type = resolveClassInPool(
t, context->method, exceptionHandlerCatchType(oldHandler) - 1)); t, context->method, exceptionHandlerCatchType(oldHandler) - 1);
} else { } else {
type = 0; type = 0;
} }
@ -6322,7 +6322,7 @@ GcArray* translateExceptionHandlerTable(MyThread* t,
newTable = truncateArray(t, newTable, ni + 1); newTable = truncateArray(t, newTable, ni + 1);
} }
newTable->setBodyElement(t, 0, reinterpret_cast<object>(newIndex)); newTable->setBodyElement(t, 0, newIndex);
return newTable; return newTable;
} else { } else {
@ -6837,7 +6837,7 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context)
GcCode* code = context->method->code(); GcCode* code = context->method->code();
code = makeCode code = makeCode
(t, 0, 0, reinterpret_cast<object>(newExceptionHandlerTable), newLineNumberTable, (t, 0, 0, newExceptionHandlerTable, newLineNumberTable,
reinterpret_cast<uintptr_t>(start), codeSize, code->maxStack(), reinterpret_cast<uintptr_t>(start), codeSize, code->maxStack(),
code->maxLocals(), 0); code->maxLocals(), 0);
@ -7203,7 +7203,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) {
acquire(t, reinterpret_cast<object>(method->class_())); acquire(t, method->class_());
} else { } else {
acquire(t, *reinterpret_cast<object*>(RUNTIME_ARRAY_BODY(args)[1])); acquire(t, *reinterpret_cast<object*>(RUNTIME_ARRAY_BODY(args)[1]));
} }
@ -7227,7 +7227,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, reinterpret_cast<object>(method->class_())); release(t, method->class_());
} else { } else {
release(t, *reinterpret_cast<object*>(RUNTIME_ARRAY_BODY(args)[1])); release(t, *reinterpret_cast<object*>(RUNTIME_ARRAY_BODY(args)[1]));
} }
@ -7698,7 +7698,7 @@ callContinuation(MyThread* t, GcContinuation* continuation, object result,
and unwindContext->continuation()) and unwindContext->continuation())
{ {
nextContinuation = cast<GcContinuation>(t, unwindContext->continuation()); nextContinuation = cast<GcContinuation>(t, unwindContext->continuation());
result = reinterpret_cast<object>(makeUnwindResult(t, continuation, result, exception)); result = makeUnwindResult(t, continuation, result, exception);
action = Unwind; action = Unwind;
} else if (rewindContext } else if (rewindContext
and rewindContext->continuation()) and rewindContext->continuation())
@ -7826,7 +7826,7 @@ dynamicWind(MyThread* t, object before, object thunk, object after)
t->continuation->context(), t->continuation->context(),
before, before,
after, after,
reinterpret_cast<object>(t->continuation), t->continuation,
t->trace->originalMethod); t->trace->originalMethod);
t->continuation->setContext(t, newContext); t->continuation->setContext(t, newContext);
@ -8072,12 +8072,12 @@ invoke(Thread* thread, GcMethod* method, ArgumentList* arguments)
case ShortField: case ShortField:
case FloatField: case FloatField:
case IntField: case IntField:
r = reinterpret_cast<object>(makeInt(t, result)); r = makeInt(t, result);
break; break;
case LongField: case LongField:
case DoubleField: case DoubleField:
r = reinterpret_cast<object>(makeLong(t, result)); r = makeLong(t, result);
break; break;
case ObjectField: case ObjectField:
@ -8814,11 +8814,11 @@ class MyProcessor: public Processor {
virtual void visitRoots(Thread* t, HeapWalker* w) { virtual void visitRoots(Thread* t, HeapWalker* w) {
bootImage->methodTree bootImage->methodTree
= w->visitRoot(reinterpret_cast<object>(compileRoots(t)->methodTree())); = w->visitRoot(compileRoots(t)->methodTree());
bootImage->methodTreeSentinal = w->visitRoot( bootImage->methodTreeSentinal = w->visitRoot(
reinterpret_cast<object>(compileRoots(t)->methodTreeSentinal())); compileRoots(t)->methodTreeSentinal());
bootImage->virtualThunks = w->visitRoot( bootImage->virtualThunks = w->visitRoot(
reinterpret_cast<object>(compileRoots(t)->virtualThunks())); compileRoots(t)->virtualThunks());
} }
virtual void normalizeVirtualThunks(Thread* t) { virtual void normalizeVirtualThunks(Thread* t) {
@ -8850,7 +8850,7 @@ class MyProcessor: public Processor {
p->address() p->address()
- reinterpret_cast<uintptr_t>(codeAllocator.memory.begin())); - reinterpret_cast<uintptr_t>(codeAllocator.memory.begin()));
table[index++] = targetVW( table[index++] = targetVW(
w->map()->find(reinterpret_cast<object>(p->target())) w->map()->find(p->target())
| (static_cast<unsigned>(p->flags()) << TargetBootShift)); | (static_cast<unsigned>(p->flags()) << TargetBootShift));
} }
} }
@ -9219,7 +9219,7 @@ resizeTable(MyThread* t, GcArray* oldTable, unsigned newLength)
oldNode->flags(), oldNode->flags(),
cast<GcCallNode>(t, newTable->body()[index])); cast<GcCallNode>(t, newTable->body()[index]));
newTable->setBodyElement(t, index, reinterpret_cast<object>(newNode)); newTable->setBodyElement(t, index, newNode);
} }
} }
@ -9247,7 +9247,7 @@ insertCallNode(MyThread* t, GcArray* table, unsigned* size, GcCallNode* node)
unsigned index = static_cast<uintptr_t>(key) & (table->length() - 1); unsigned index = static_cast<uintptr_t>(key) & (table->length() - 1);
node->setNext(t, cast<GcCallNode>(t, table->body()[index])); node->setNext(t, cast<GcCallNode>(t, table->body()[index]));
table->setBodyElement(t, index, reinterpret_cast<object>(node)); table->setBodyElement(t, index, node);
return table; return table;
} }
@ -9271,7 +9271,7 @@ makeClassMap(Thread* t, unsigned* table, unsigned count,
for (unsigned i = 0; i < count; ++i) { for (unsigned i = 0; i < count; ++i) {
GcClass* c = cast<GcClass>(t, bootObject(heap, table[i])); GcClass* c = cast<GcClass>(t, bootObject(heap, table[i]));
hashMapInsert(t, map, reinterpret_cast<object>(c->name()), reinterpret_cast<object>(c), byteArrayHash); hashMapInsert(t, map, c->name(), c, byteArrayHash);
} }
return map; return map;
@ -9285,12 +9285,12 @@ makeStaticTableArray(Thread* t, unsigned* bootTable, unsigned bootCount,
for (unsigned i = 0; i < bootCount; ++i) { for (unsigned i = 0; i < bootCount; ++i) {
array->setBodyElement(t, i, array->setBodyElement(t, i,
reinterpret_cast<object>(cast<GcClass>(t, bootObject(heap, bootTable[i]))->staticTable())); cast<GcClass>(t, bootObject(heap, bootTable[i]))->staticTable());
} }
for (unsigned i = 0; i < appCount; ++i) { for (unsigned i = 0; i < appCount; ++i) {
array->setBodyElement(t, (bootCount + i), array->setBodyElement(t, (bootCount + i),
reinterpret_cast<object>(cast<GcClass>(t, bootObject(heap, appTable[i]))->staticTable())); cast<GcClass>(t, bootObject(heap, appTable[i]))->staticTable());
} }
return array; return array;
@ -9533,7 +9533,7 @@ boot(MyThread* t, BootImage* image, uint8_t* code)
{ {
GcHashMap* map = makeClassMap(t, bootClassTable, image->bootClassCount, heap); GcHashMap* map = makeClassMap(t, bootClassTable, image->bootClassCount, heap);
// sequence point, for gc (don't recombine statements) // sequence point, for gc (don't recombine statements)
roots(t)->bootLoader()->setMap(t, reinterpret_cast<object>(map)); roots(t)->bootLoader()->setMap(t, map);
} }
roots(t)->bootLoader()->as<GcSystemClassLoader>(t)->finder() = t->m->bootFinder; roots(t)->bootLoader()->as<GcSystemClassLoader>(t)->finder() = t->m->bootFinder;
@ -9541,7 +9541,7 @@ boot(MyThread* t, BootImage* image, uint8_t* code)
{ {
GcHashMap* map = makeClassMap(t, appClassTable, image->appClassCount, heap); GcHashMap* map = makeClassMap(t, appClassTable, image->appClassCount, heap);
// sequence point, for gc (don't recombine statements) // sequence point, for gc (don't recombine statements)
roots(t)->appLoader()->setMap(t, reinterpret_cast<object>(map)); roots(t)->appLoader()->setMap(t, map);
} }
roots(t)->appLoader()->as<GcSystemClassLoader>(t)->finder() = t->m->appFinder; roots(t)->appLoader()->as<GcSystemClassLoader>(t)->finder() = t->m->appFinder;
@ -9569,7 +9569,7 @@ boot(MyThread* t, BootImage* image, uint8_t* code)
(t, bootClassTable, image->bootClassCount, (t, bootClassTable, image->bootClassCount,
appClassTable, image->appClassCount, heap); appClassTable, image->appClassCount, heap);
// sequence point, for gc (don't recombine statements) // sequence point, for gc (don't recombine statements)
compileRoots(t)->setStaticTableArray(t, reinterpret_cast<object>(staticTableArray)); compileRoots(t)->setStaticTableArray(t, staticTableArray);
} }
findThunks(t, image, code); findThunks(t, image, code);
@ -10048,7 +10048,7 @@ compile(MyThread* t, FixedAllocator* allocator, BootContext* bootContext,
&(context.zone), &(context.zone),
compileRoots(t)->methodTree(), compileRoots(t)->methodTree(),
methodCompiled(t, clone), methodCompiled(t, clone),
reinterpret_cast<object>(clone), clone,
compileRoots(t)->methodTreeSentinal(), compileRoots(t)->methodTreeSentinal(),
compareIpToMethodBounds); compareIpToMethodBounds);
// sequence point, for gc (don't recombine statements) // sequence point, for gc (don't recombine statements)
@ -10071,7 +10071,7 @@ compile(MyThread* t, FixedAllocator* allocator, BootContext* bootContext,
treeUpdate(t, treeUpdate(t,
compileRoots(t)->methodTree(), compileRoots(t)->methodTree(),
methodCompiled(t, clone), methodCompiled(t, clone),
reinterpret_cast<object>(method), method,
compileRoots(t)->methodTreeSentinal(), compileRoots(t)->methodTreeSentinal(),
compareIpToMethodBounds); compareIpToMethodBounds);
} }

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, reinterpret_cast<object>(method->class_())); acquire(t, method->class_());
} else { } else {
acquire(t, peekObject(t, base)); acquire(t, peekObject(t, base));
} }
@ -345,7 +345,7 @@ pushFrame(Thread* t, GcMethod* method)
t->sp = frame + FrameFootprint; t->sp = frame + FrameFootprint;
pokeInt(t, frame + FrameBaseOffset, base); pokeInt(t, frame + FrameBaseOffset, base);
pokeObject(t, frame + FrameMethodOffset, reinterpret_cast<object>(method)); pokeObject(t, frame + FrameMethodOffset, method);
pokeInt(t, t->frame + FrameIpOffset, 0); pokeInt(t, t->frame + FrameIpOffset, 0);
} }
@ -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, reinterpret_cast<object>(method->class_())); release(t, method->class_());
} else { } else {
release(t, peekObject(t, frameBase(t, t->frame))); release(t, peekObject(t, frameBase(t, t->frame)));
} }
@ -889,7 +889,7 @@ interpret3(Thread* t, const int base)
GcClass* class_ = resolveClassInPool(t, frameMethod(t, frame), index - 1); GcClass* class_ = resolveClassInPool(t, frameMethod(t, frame), index - 1);
pushObject(t, reinterpret_cast<object>(makeObjectArray(t, class_, count))); pushObject(t, makeObjectArray(t, class_, count));
} else { } else {
exception = makeThrowable exception = makeThrowable
(t, GcNegativeArraySizeException::Type, "%d", count); (t, GcNegativeArraySizeException::Type, "%d", count);
@ -1498,7 +1498,7 @@ interpret3(Thread* t, const int base)
ACQUIRE_FIELD_FOR_READ(t, field); ACQUIRE_FIELD_FOR_READ(t, field);
pushField(t, reinterpret_cast<object>(field->class_()->staticTable()), field); pushField(t, field->class_()->staticTable(), field);
} goto loop; } goto loop;
case goto_: { case goto_: {
@ -1948,7 +1948,7 @@ interpret3(Thread* t, const int base)
pushInt(t, result); pushInt(t, result);
goto loop; goto loop;
} else { } else {
return reinterpret_cast<object>(makeInt(t, result)); return makeInt(t, result);
} }
} goto loop; } goto loop;
@ -2258,7 +2258,7 @@ interpret3(Thread* t, const int base)
pushLong(t, result); pushLong(t, result);
goto loop; goto loop;
} else { } else {
return reinterpret_cast<object>(makeLong(t, result)); return makeLong(t, result);
} }
} goto loop; } goto loop;
@ -2360,7 +2360,7 @@ interpret3(Thread* t, const int base)
} }
} }
object array = reinterpret_cast<object>(makeArray(t, RUNTIME_ARRAY_BODY(counts)[0])); object array = makeArray(t, RUNTIME_ARRAY_BODY(counts)[0]);
setObjectClass(t, array, class_); setObjectClass(t, array, class_);
PROTECT(t, array); PROTECT(t, array);
@ -2390,35 +2390,35 @@ interpret3(Thread* t, const int base)
switch (type) { switch (type) {
case T_BOOLEAN: case T_BOOLEAN:
array = reinterpret_cast<object>(makeBooleanArray(t, count)); array = makeBooleanArray(t, count);
break; break;
case T_CHAR: case T_CHAR:
array = reinterpret_cast<object>(makeCharArray(t, count)); array = makeCharArray(t, count);
break; break;
case T_FLOAT: case T_FLOAT:
array = reinterpret_cast<object>(makeFloatArray(t, count)); array = makeFloatArray(t, count);
break; break;
case T_DOUBLE: case T_DOUBLE:
array = reinterpret_cast<object>(makeDoubleArray(t, count)); array = makeDoubleArray(t, count);
break; break;
case T_BYTE: case T_BYTE:
array = reinterpret_cast<object>(makeByteArray(t, count)); array = makeByteArray(t, count);
break; break;
case T_SHORT: case T_SHORT:
array = reinterpret_cast<object>(makeShortArray(t, count)); array = makeShortArray(t, count);
break; break;
case T_INT: case T_INT:
array = reinterpret_cast<object>(makeIntArray(t, count)); array = makeIntArray(t, count);
break; break;
case T_LONG: case T_LONG:
array = reinterpret_cast<object>(makeLongArray(t, count)); array = makeLongArray(t, count);
break; break;
default: abort(t); default: abort(t);
@ -2560,7 +2560,7 @@ interpret3(Thread* t, const int base)
} break; } break;
case ObjectField: { case ObjectField: {
setField(t, reinterpret_cast<object>(table), field->offset(), popObject(t)); setField(t, table, field->offset(), popObject(t));
} break; } break;
default: abort(t); default: abort(t);
@ -2756,7 +2756,7 @@ interpret3(Thread* t, const int base)
if (eh) { if (eh) {
sp = frame + FrameFootprint; sp = frame + FrameFootprint;
ip = exceptionHandlerIp(eh); ip = exceptionHandlerIp(eh);
pushObject(t, reinterpret_cast<object>(exception)); pushObject(t, exception);
exception = 0; exception = 0;
goto loop; goto loop;
} }
@ -2937,12 +2937,12 @@ invoke(Thread* t, GcMethod* method)
case ShortField: case ShortField:
case FloatField: case FloatField:
case IntField: case IntField:
result = reinterpret_cast<object>(makeInt(t, popInt(t))); result = makeInt(t, popInt(t));
break; break;
case LongField: case LongField:
case DoubleField: case DoubleField:
result = reinterpret_cast<object>(makeLong(t, popLong(t))); result = makeLong(t, popLong(t));
break; break;
case ObjectField: case ObjectField:

View File

@ -187,7 +187,7 @@ GetStringCritical(Thread* t, jstring s, jboolean* isCopy)
*isCopy = true; *isCopy = true;
} }
object data = reinterpret_cast<object>((*s)->data()); object data = (*s)->data();
if (objectClass(t, data) == type(t, GcByteArray::Type)) { if (objectClass(t, data) == type(t, GcByteArray::Type)) {
return GetStringChars(t, s, isCopy); return GetStringChars(t, s, isCopy);
} else { } else {
@ -267,8 +267,8 @@ newString(Thread* t, uintptr_t* arguments)
return reinterpret_cast<uint64_t>( return reinterpret_cast<uint64_t>(
makeLocalReference(t, makeLocalReference(t,
reinterpret_cast<object>(t->m->classpath->makeString( t->m->classpath->makeString(
t, reinterpret_cast<object>(a), 0, size)))); t, a, 0, size)));
} }
jstring JNICALL jstring JNICALL
@ -291,8 +291,8 @@ newStringUTF(Thread* t, uintptr_t* arguments)
return reinterpret_cast<uint64_t> return reinterpret_cast<uint64_t>
(makeLocalReference (makeLocalReference
(t, reinterpret_cast<object>(t->m->classpath->makeString (t, t->m->classpath->makeString
(t, array, 0, fieldAtOffset<uintptr_t>(array, BytesPerWord) - 1)))); (t, array, 0, fieldAtOffset<uintptr_t>(array, BytesPerWord) - 1)));
} }
jstring JNICALL jstring JNICALL
@ -325,14 +325,14 @@ defineClass(Thread* t, uintptr_t* arguments)
return reinterpret_cast<uint64_t>(makeLocalReference( return reinterpret_cast<uint64_t>(makeLocalReference(
t, t,
reinterpret_cast<object>(getJClass(t, getJClass(t,
cast<GcClass>( cast<GcClass>(
t, t,
defineClass(t, defineClass(t,
loader ? cast<GcClassLoader>(t, *loader) loader ? cast<GcClassLoader>(t, *loader)
: roots(t)->bootLoader(), : roots(t)->bootLoader(),
buffer, buffer,
length)))))); length)))));
} }
jclass JNICALL jclass JNICALL
@ -368,7 +368,7 @@ findClass(Thread* t, uintptr_t* arguments)
initClass(t, c); initClass(t, c);
} }
return reinterpret_cast<uint64_t>(makeLocalReference(t, reinterpret_cast<object>(getJClass(t, c)))); return reinterpret_cast<uint64_t>(makeLocalReference(t, getJClass(t, c)));
} }
jclass JNICALL jclass JNICALL
@ -457,7 +457,7 @@ getObjectClass(Thread* t, uintptr_t* arguments)
jobject o = reinterpret_cast<jobject>(arguments[0]); jobject o = reinterpret_cast<jobject>(arguments[0]);
return reinterpret_cast<uint64_t>(makeLocalReference( return reinterpret_cast<uint64_t>(makeLocalReference(
t, reinterpret_cast<object>(getJClass(t, objectClass(t, *o))))); t, getJClass(t, objectClass(t, *o))));
} }
jclass JNICALL jclass JNICALL
@ -477,7 +477,7 @@ getSuperclass(Thread* t, uintptr_t* arguments)
} else { } else {
GcClass* super = class_->super(); GcClass* super = class_->super();
return super ? reinterpret_cast<uint64_t> return super ? reinterpret_cast<uint64_t>
(makeLocalReference(t, reinterpret_cast<object>(getJClass(t, super)))) : 0; (makeLocalReference(t, getJClass(t, super))) : 0;
} }
} }
@ -549,7 +549,7 @@ methodID(Thread* t, GcMethod* method)
if (method->nativeID() == 0) { if (method->nativeID() == 0) {
GcVector* v = vectorAppend( GcVector* v = vectorAppend(
t, roots(t)->jNIMethodTable(), reinterpret_cast<object>(method)); t, roots(t)->jNIMethodTable(), method);
// sequence point, for gc (don't recombine statements) // sequence point, for gc (don't recombine statements)
roots(t)->setJNIMethodTable(t, v); roots(t)->setJNIMethodTable(t, v);
@ -1503,7 +1503,7 @@ fieldID(Thread* t, GcField* field)
if (field->nativeID() == 0) { if (field->nativeID() == 0) {
GcVector* v = vectorAppend( GcVector* v = vectorAppend(
t, roots(t)->jNIFieldTable(), reinterpret_cast<object>(field)); t, roots(t)->jNIFieldTable(), field);
// sequence point, for gc (don't recombine statements) // sequence point, for gc (don't recombine statements)
roots(t)->setJNIFieldTable(t, v); roots(t)->setJNIFieldTable(t, v);
@ -2229,7 +2229,7 @@ setStaticObjectField(Thread* t, uintptr_t* arguments)
PROTECT(t, field); PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field); ACQUIRE_FIELD_FOR_WRITE(t, field);
setField(t, reinterpret_cast<object>(c->vmClass()->staticTable()), field->offset(), setField(t, c->vmClass()->staticTable(), field->offset(),
(v ? *v : 0)); (v ? *v : 0));
return 1; return 1;
@ -2547,7 +2547,7 @@ ExceptionOccurred(Thread* t)
{ {
ENTER(t, Thread::ActiveState); ENTER(t, Thread::ActiveState);
return reinterpret_cast<jthrowable>(makeLocalReference(t, reinterpret_cast<object>(t->exception))); return reinterpret_cast<jthrowable>(makeLocalReference(t, t->exception));
} }
void JNICALL void JNICALL
@ -2578,7 +2578,7 @@ newObjectArray(Thread* t, uintptr_t* arguments)
for (jsize i = 0; i < length; ++i) { for (jsize i = 0; i < length; ++i) {
reinterpret_cast<GcArray*>(a)->setBodyElement(t, i, value); reinterpret_cast<GcArray*>(a)->setBodyElement(t, i, value);
} }
return reinterpret_cast<uint64_t>(makeLocalReference(t, reinterpret_cast<object>(a))); return reinterpret_cast<uint64_t>(makeLocalReference(t, a));
} }
jobjectArray JNICALL jobjectArray JNICALL
@ -2633,7 +2633,7 @@ NewBooleanArray(Thread* t, jsize length)
object object
makeByteArray0(Thread* t, unsigned length) makeByteArray0(Thread* t, unsigned length)
{ {
return reinterpret_cast<object>(makeByteArray(t, length)); return makeByteArray(t, length);
} }
jbyteArray JNICALL jbyteArray JNICALL

View File

@ -398,7 +398,7 @@ finalizerTargetUnreachable(Thread* t, Heap::Visitor* v, GcFinalizer** p)
if (function) { if (function) {
// TODO: use set() here? // TODO: use set() here?
finalizer->next() = reinterpret_cast<object>(t->m->finalizeQueue); finalizer->next() = t->m->finalizeQueue;
t->m->finalizeQueue = finalizer; t->m->finalizeQueue = finalizer;
} else { } else {
finalizer->setQueueTarget(t, finalizer->target()); finalizer->setQueueTarget(t, finalizer->target());
@ -500,7 +500,7 @@ void
clearTargetIfFinalizable(Thread* t, GcJreference* r) clearTargetIfFinalizable(Thread* t, GcJreference* r)
{ {
if (isFinalizable if (isFinalizable
(t, reinterpret_cast<object>(t->m->heap->follow(r->target())))) (t, t->m->heap->follow(r->target())))
{ {
r->target() = 0; r->target() = 0;
} }
@ -550,7 +550,7 @@ postVisit(Thread* t, Heap::Visitor* v)
*p = cast<GcFinalizer>(t, finalizer->next()); *p = cast<GcFinalizer>(t, finalizer->next());
finalizer->next() = unreachable; finalizer->next() = unreachable;
unreachable = reinterpret_cast<object>(finalizer); unreachable = finalizer;
} else { } else {
p = reinterpret_cast<GcFinalizer**>(&(*p)->next()); p = reinterpret_cast<GcFinalizer**>(&(*p)->next());
} }
@ -570,7 +570,7 @@ postVisit(Thread* t, Heap::Visitor* v)
GcFinalizer* finalizer = *p; GcFinalizer* finalizer = *p;
*p = cast<GcFinalizer>(t, finalizer->next()); *p = cast<GcFinalizer>(t, finalizer->next());
finalizer->next() = reinterpret_cast<object>(firstNewTenuredFinalizer); finalizer->next() = firstNewTenuredFinalizer;
firstNewTenuredFinalizer = finalizer; firstNewTenuredFinalizer = finalizer;
} else { } else {
p = reinterpret_cast<GcFinalizer**>(&(*p)->next()); p = reinterpret_cast<GcFinalizer**>(&(*p)->next());
@ -611,7 +611,7 @@ postVisit(Thread* t, Heap::Visitor* v)
GcJreference* reference = (*p); GcJreference* reference = (*p);
*p = cast<GcJreference>(t, reference->vmNext()); *p = cast<GcJreference>(t, reference->vmNext());
reference->vmNext() = reinterpret_cast<object>(firstNewTenuredWeakReference); reference->vmNext() = firstNewTenuredWeakReference;
firstNewTenuredWeakReference = reference; firstNewTenuredWeakReference = reference;
} else { } else {
p = reinterpret_cast<GcJreference**>(&(*p)->vmNext()); p = reinterpret_cast<GcJreference**>(&(*p)->vmNext());
@ -629,7 +629,7 @@ postVisit(Thread* t, Heap::Visitor* v)
*p = cast<GcFinalizer>(t, finalizer->next()); *p = cast<GcFinalizer>(t, finalizer->next());
finalizer->next() = unreachable; finalizer->next() = unreachable;
unreachable = reinterpret_cast<object>(finalizer); unreachable = finalizer;
} else { } else {
p = reinterpret_cast<GcFinalizer**>(&(*p)->next()); p = reinterpret_cast<GcFinalizer**>(&(*p)->next());
} }
@ -666,13 +666,13 @@ postVisit(Thread* t, Heap::Visitor* v)
} }
if (lastNewTenuredFinalizer) { if (lastNewTenuredFinalizer) {
lastNewTenuredFinalizer->next() = reinterpret_cast<object>(m->tenuredFinalizers); lastNewTenuredFinalizer->next() = m->tenuredFinalizers;
m->tenuredFinalizers = firstNewTenuredFinalizer; m->tenuredFinalizers = firstNewTenuredFinalizer;
} }
if (lastNewTenuredWeakReference) { if (lastNewTenuredWeakReference) {
lastNewTenuredWeakReference->vmNext() lastNewTenuredWeakReference->vmNext()
= reinterpret_cast<object>(m->tenuredWeakReferences); = m->tenuredWeakReferences;
m->tenuredWeakReferences = firstNewTenuredWeakReference; m->tenuredWeakReferences = firstNewTenuredWeakReference;
} }
@ -841,7 +841,7 @@ object parseUtf8(Thread* t, AbstractStream& s, unsigned length)
if (a & 0x80) { if (a & 0x80) {
if (a & 0x20) { if (a & 0x20) {
// 3 bytes // 3 bytes
return reinterpret_cast<object>(parseUtf8NonAscii(t, s, value, vi, si, a, NoByte)); return parseUtf8NonAscii(t, s, value, vi, si, a, NoByte);
} else { } else {
// 2 bytes // 2 bytes
unsigned b = s.read1(); unsigned b = s.read1();
@ -851,7 +851,7 @@ object parseUtf8(Thread* t, AbstractStream& s, unsigned length)
assertT(t, si < length); assertT(t, si < length);
value->body()[vi++] = 0; value->body()[vi++] = 0;
} else { } else {
return reinterpret_cast<object>(parseUtf8NonAscii(t, s, value, vi, si, a, b)); return parseUtf8NonAscii(t, s, value, vi, si, a, b);
} }
} }
} else { } else {
@ -867,7 +867,7 @@ object parseUtf8(Thread* t, AbstractStream& s, unsigned length)
value = v; value = v;
} }
return reinterpret_cast<object>(value); return value;
} }
GcByteArray* GcByteArray*
@ -896,12 +896,12 @@ internByteArray(Thread* t, GcByteArray* array)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
GcTriple* n = hashMapFindNode GcTriple* n = hashMapFindNode
(t, roots(t)->byteArrayMap(), reinterpret_cast<object>(array), byteArrayHash, byteArrayEqual); (t, roots(t)->byteArrayMap(), array, byteArrayHash, byteArrayEqual);
if (n) { if (n) {
return cast<GcByteArray>(t, cast<GcJreference>(t, n->first())->target()); return cast<GcByteArray>(t, cast<GcJreference>(t, n->first())->target());
} else { } else {
hashMapInsert(t, roots(t)->byteArrayMap(), reinterpret_cast<object>(array), 0, byteArrayHash); hashMapInsert(t, roots(t)->byteArrayMap(), array, 0, byteArrayHash);
addFinalizer(t, reinterpret_cast<object>(array), removeByteArray); addFinalizer(t, array, removeByteArray);
return array; return array;
} }
} }
@ -965,8 +965,8 @@ parsePoolEntry(Thread* t, Stream& s, uint32_t* index, GcSingleton* pool, unsigne
parsePoolEntry(t, s, index, pool, si); parsePoolEntry(t, s, index, pool, si);
object value = parseUtf8(t, cast<GcByteArray>(t, singletonObject(t, pool, si))); object value = parseUtf8(t, cast<GcByteArray>(t, singletonObject(t, pool, si)));
value = reinterpret_cast<object>(t->m->classpath->makeString value = t->m->classpath->makeString
(t, value, 0, fieldAtOffset<uintptr_t>(value, BytesPerWord) - 1)); (t, value, 0, fieldAtOffset<uintptr_t>(value, BytesPerWord) - 1);
value = intern(t, value); value = intern(t, value);
pool->setBodyElement(t, i, reinterpret_cast<uintptr_t>(value)); pool->setBodyElement(t, i, reinterpret_cast<uintptr_t>(value));
@ -986,7 +986,7 @@ parsePoolEntry(Thread* t, Stream& s, uint32_t* index, GcSingleton* pool, unsigne
GcByteArray* name = cast<GcByteArray>(t, singletonObject(t, pool, ni)); GcByteArray* name = cast<GcByteArray>(t, singletonObject(t, pool, ni));
GcByteArray* type = cast<GcByteArray>(t, singletonObject(t, pool, ti)); GcByteArray* type = cast<GcByteArray>(t, singletonObject(t, pool, ti));
GcPair* value = makePair(t, reinterpret_cast<object>(name), reinterpret_cast<object>(type)); GcPair* value = makePair(t, name, type);
pool->setBodyElement(t, i, reinterpret_cast<uintptr_t>(value)); pool->setBodyElement(t, i, reinterpret_cast<uintptr_t>(value));
if(DebugClassReader) { if(DebugClassReader) {
@ -1008,12 +1008,12 @@ parsePoolEntry(Thread* t, Stream& s, uint32_t* index, GcSingleton* pool, unsigne
GcByteArray* className = cast<GcReference>(t, singletonObject(t, pool, ci))->name(); GcByteArray* className = cast<GcReference>(t, singletonObject(t, pool, ci))->name();
GcPair* nameAndType = cast<GcPair>(t, singletonObject(t, pool, nti)); GcPair* nameAndType = cast<GcPair>(t, singletonObject(t, pool, nti));
object value = reinterpret_cast<object>( object value =
makeReference(t, makeReference(t,
0, 0,
className, className,
cast<GcByteArray>(t, nameAndType->first()), cast<GcByteArray>(t, nameAndType->first()),
cast<GcByteArray>(t, nameAndType->second()))); cast<GcByteArray>(t, nameAndType->second()));
pool->setBodyElement(t, i, reinterpret_cast<uintptr_t>(value)); pool->setBodyElement(t, i, reinterpret_cast<uintptr_t>(value));
if(DebugClassReader) { if(DebugClassReader) {
@ -1086,8 +1086,8 @@ parsePoolEntry(Thread* t, Stream& s, uint32_t* index, GcSingleton* pool, unsigne
bootstrap, bootstrap,
-1, -1,
0, 0,
reinterpret_cast<object>(pool), pool,
reinterpret_cast<object>(template_), template_,
0)); 0));
pool->setBodyElement(t, i, reinterpret_cast<uintptr_t>(value)); pool->setBodyElement(t, i, reinterpret_cast<uintptr_t>(value));
@ -1207,8 +1207,8 @@ addInterfaces(Thread* t, GcClass* class_, GcHashMap* map)
GcByteArray* name = interface->name(); GcByteArray* name = interface->name();
hashMapInsertMaybe(t, hashMapInsertMaybe(t,
map, map,
reinterpret_cast<object>(name), name,
reinterpret_cast<object>(interface), interface,
byteArrayHash, byteArrayHash,
byteArrayEqual); byteArrayEqual);
} }
@ -1224,9 +1224,9 @@ getClassAddendum(Thread* t, GcClass* class_, GcSingleton* pool)
addendum = makeClassAddendum(t, pool, 0, 0, 0, 0, -1, 0, 0); addendum = makeClassAddendum(t, pool, 0, 0, 0, 0, -1, 0, 0);
setField(t, setField(t,
reinterpret_cast<object>(class_), class_,
ClassAddendum, ClassAddendum,
reinterpret_cast<object>(addendum)); addendum);
} }
return addendum; return addendum;
} }
@ -1253,7 +1253,7 @@ parseInterfaceTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool,
table = makeArray(t, count); table = makeArray(t, count);
GcClassAddendum* addendum = getClassAddendum(t, class_, pool); GcClassAddendum* addendum = getClassAddendum(t, class_, pool);
addendum->setInterfaceTable(t, reinterpret_cast<object>(table)); addendum->setInterfaceTable(t, table);
} }
for (unsigned i = 0; i < count; ++i) { for (unsigned i = 0; i < count; ++i) {
@ -1265,9 +1265,9 @@ parseInterfaceTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool,
PROTECT(t, interface); PROTECT(t, interface);
table->setBodyElement(t, i, reinterpret_cast<object>(interface)); table->setBodyElement(t, i, interface);
hashMapInsertMaybe(t, map, reinterpret_cast<object>(name), reinterpret_cast<object>(interface), byteArrayHash, byteArrayEqual); hashMapInsertMaybe(t, map, name, interface, byteArrayHash, byteArrayEqual);
addInterfaces(t, interface, map); addInterfaces(t, interface, map);
} }
@ -1285,7 +1285,7 @@ parseInterfaceTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool,
for (HashMapIterator it(t, map); it.hasMore();) { for (HashMapIterator it(t, map); it.hasMore();) {
GcClass* interface = cast<GcClass>(t, it.next()->second()); GcClass* interface = cast<GcClass>(t, it.next()->second());
interfaceTable->setBodyElement(t, i, reinterpret_cast<object>(interface)); interfaceTable->setBodyElement(t, i, interface);
++ i; ++ i;
if ((class_->flags() & ACC_INTERFACE) == 0) { if ((class_->flags() & ACC_INTERFACE) == 0) {
@ -1294,7 +1294,7 @@ parseInterfaceTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool,
// we'll fill in this table in parseMethodTable(): // we'll fill in this table in parseMethodTable():
GcArray* vtable = makeArray(t, vt->length()); GcArray* vtable = makeArray(t, vt->length());
interfaceTable->setBodyElement(t, i, reinterpret_cast<object>(vtable)); interfaceTable->setBodyElement(t, i, vtable);
} }
++i; ++i;
@ -1302,7 +1302,7 @@ parseInterfaceTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool,
} }
} }
class_->setInterfaceTable(t, reinterpret_cast<object>(interfaceTable)); class_->setInterfaceTable(t, interfaceTable);
} }
void void
@ -1373,7 +1373,7 @@ parseFieldTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
s.read(reinterpret_cast<uint8_t*>(body->body().begin()), s.read(reinterpret_cast<uint8_t*>(body->body().begin()),
length); length);
addendum->setAnnotationTable(t, reinterpret_cast<object>(body)); addendum->setAnnotationTable(t, body);
} else { } else {
s.skip(length); s.skip(length);
} }
@ -1414,10 +1414,10 @@ parseFieldTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
memberOffset += size; memberOffset += size;
} }
fieldTable->setBodyElement(t, i, reinterpret_cast<object>(field)); fieldTable->setBodyElement(t, i, field);
} }
class_->setFieldTable(t, reinterpret_cast<object>(fieldTable)); class_->setFieldTable(t, fieldTable);
if (staticCount) { if (staticCount) {
unsigned footprint = ceilingDivide(staticOffset - (BytesPerWord * 2), unsigned footprint = ceilingDivide(staticOffset - (BytesPerWord * 2),
@ -1936,7 +1936,7 @@ parseCode(Thread* t, Stream& s, GcSingleton* pool)
(start, end, ip, catchType); (start, end, ip, catchType);
} }
code->setExceptionHandlerTable(t, reinterpret_cast<object>(eht)); code->setExceptionHandlerTable(t, eht);
} }
unsigned attributeCount = s.read2(); unsigned attributeCount = s.read2();
@ -1991,7 +1991,7 @@ addInterfaceMethods(Thread* t, GcClass* class_, GcHashMap* virtualMap,
method = cast<GcMethod>(t, vtable->body()[j]); method = cast<GcMethod>(t, vtable->body()[j]);
GcTriple* n = hashMapFindNode(t, GcTriple* n = hashMapFindNode(t,
virtualMap, virtualMap,
reinterpret_cast<object>(method), method,
methodHash, methodHash,
methodEqual); methodEqual);
if (n == 0) { if (n == 0) {
@ -2012,15 +2012,15 @@ addInterfaceMethods(Thread* t, GcClass* class_, GcHashMap* virtualMap,
hashMapInsert(t, hashMapInsert(t,
virtualMap, virtualMap,
reinterpret_cast<object>(method), method,
reinterpret_cast<object>(method), method,
methodHash); methodHash);
if (makeList) { if (makeList) {
if (list == 0) { if (list == 0) {
list = vm::makeList(t, 0, 0, 0); list = vm::makeList(t, 0, 0, 0);
} }
listAppend(t, list, reinterpret_cast<object>(method)); listAppend(t, list, method);
} }
} }
} }
@ -2115,7 +2115,7 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
for (unsigned i = 0; i < exceptionCount; ++i) { for (unsigned i = 0; i < exceptionCount; ++i) {
body->body()[i] = s.read2(); body->body()[i] = s.read2();
} }
addendum->setExceptionTable(t, reinterpret_cast<object>(body)); addendum->setExceptionTable(t, body);
} else if (vm::strcmp(reinterpret_cast<const int8_t*> } else if (vm::strcmp(reinterpret_cast<const int8_t*>
("AnnotationDefault"), ("AnnotationDefault"),
attributeName->body().begin()) == 0) attributeName->body().begin()) == 0)
@ -2128,7 +2128,7 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
s.read(reinterpret_cast<uint8_t*>(body->body().begin()), s.read(reinterpret_cast<uint8_t*>(body->body().begin()),
length); length);
addendum->setAnnotationDefault(t, reinterpret_cast<object>(body)); addendum->setAnnotationDefault(t, body);
} else if (vm::strcmp(reinterpret_cast<const int8_t*>("Signature"), } else if (vm::strcmp(reinterpret_cast<const int8_t*>("Signature"),
attributeName->body().begin()) == 0) attributeName->body().begin()) == 0)
{ {
@ -2149,7 +2149,7 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
s.read(reinterpret_cast<uint8_t*>(body->body().begin()), s.read(reinterpret_cast<uint8_t*>(body->body().begin()),
length); length);
addendum->setAnnotationTable(t, reinterpret_cast<object>(body)); addendum->setAnnotationTable(t, body);
} else if (vm::strcmp(reinterpret_cast<const int8_t*> } else if (vm::strcmp(reinterpret_cast<const int8_t*>
("RuntimeVisibleParameterAnnotations"), ("RuntimeVisibleParameterAnnotations"),
attributeName->body().begin()) == 0) attributeName->body().begin()) == 0)
@ -2162,7 +2162,7 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
s.read(reinterpret_cast<uint8_t*>(body->body().begin()), s.read(reinterpret_cast<uint8_t*>(body->body().begin()),
length); length);
addendum->setParameterAnnotationTable(t, reinterpret_cast<object>(body)); addendum->setParameterAnnotationTable(t, body);
} else { } else {
s.skip(length); s.skip(length);
} }
@ -2197,18 +2197,18 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
++ declaredVirtualCount; ++ declaredVirtualCount;
GcTriple* p = hashMapFindNode GcTriple* p = hashMapFindNode
(t, virtualMap, reinterpret_cast<object>(method), methodHash, methodEqual); (t, virtualMap, method, methodHash, methodEqual);
if (p) { if (p) {
method->offset() = cast<GcMethod>(t, p->first())->offset(); method->offset() = cast<GcMethod>(t, p->first())->offset();
p->setSecond(t, reinterpret_cast<object>(method)); p->setSecond(t, method);
} else { } else {
method->offset() = virtualCount++; method->offset() = virtualCount++;
listAppend(t, newVirtuals, reinterpret_cast<object>(method)); listAppend(t, newVirtuals, method);
hashMapInsert(t, virtualMap, reinterpret_cast<object>(method), reinterpret_cast<object>(method), methodHash); hashMapInsert(t, virtualMap, method, method, methodHash);
} }
if (UNLIKELY((class_->flags() & ACC_INTERFACE) == 0 if (UNLIKELY((class_->flags() & ACC_INTERFACE) == 0
@ -2238,10 +2238,10 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
} }
} }
methodTable->setBodyElement(t, i, reinterpret_cast<object>(method)); methodTable->setBodyElement(t, i, method);
} }
class_->setMethodTable(t, reinterpret_cast<object>(methodTable)); class_->setMethodTable(t, methodTable);
} }
@ -2258,7 +2258,7 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
{ {
if (class_->super()) { if (class_->super()) {
// inherit virtual table from superclass // inherit virtual table from superclass
class_->setVirtualTable(t, reinterpret_cast<object>(superVirtualTable)); class_->setVirtualTable(t, superVirtualTable);
if (class_->super()->interfaceTable() if (class_->super()->interfaceTable()
and cast<GcArray>(t, class_->interfaceTable())->length() and cast<GcArray>(t, class_->interfaceTable())->length()
@ -2274,7 +2274,7 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
// apparently, Object does not have any virtual methods. We // apparently, Object does not have any virtual methods. We
// give it a vtable anyway so code doesn't break elsewhere. // give it a vtable anyway so code doesn't break elsewhere.
GcArray* vtable = makeArray(t, 0); GcArray* vtable = makeArray(t, 0);
class_->setVirtualTable(t, reinterpret_cast<object>(vtable)); class_->setVirtualTable(t, vtable);
} }
} else if (virtualCount) { } else if (virtualCount) {
// generate class vtable // generate class vtable
@ -2288,7 +2288,7 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
for (HashMapIterator it(t, virtualMap); it.hasMore();) { for (HashMapIterator it(t, virtualMap); it.hasMore();) {
GcMethod* method = cast<GcMethod>(t, it.next()->first()); GcMethod* method = cast<GcMethod>(t, it.next()->first());
assertT(t, vtable->body()[method->offset()] == 0); assertT(t, vtable->body()[method->offset()] == 0);
vtable->setBodyElement(t, method->offset(), reinterpret_cast<object>(method)); vtable->setBodyElement(t, method->offset(), method);
++ i; ++ i;
} }
} else { } else {
@ -2331,7 +2331,7 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
} }
} }
mark(t, reinterpret_cast<object>(newMethodTable), ArrayBody, oldLength); mark(t, newMethodTable, ArrayBody, oldLength);
unsigned mti = oldLength; unsigned mti = oldLength;
for (GcPair* p = cast<GcPair>(t, abstractVirtuals->front()); for (GcPair* p = cast<GcPair>(t, abstractVirtuals->front());
@ -2346,12 +2346,12 @@ parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
assertT(t, newMethodTable->length() == mti); assertT(t, newMethodTable->length() == mti);
class_->setMethodTable(t, reinterpret_cast<object>(newMethodTable)); class_->setMethodTable(t, newMethodTable);
} }
assertT(t, vtable->length() == i); assertT(t, vtable->length() == i);
class_->setVirtualTable(t, reinterpret_cast<object>(vtable)); class_->setVirtualTable(t, vtable);
} }
if (populateInterfaceVtables) { if (populateInterfaceVtables) {
@ -2420,11 +2420,11 @@ parseAttributeTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
name ? cast<GcByteArray>(t, singletonObject(t, pool, name - 1)) : 0, name ? cast<GcByteArray>(t, singletonObject(t, pool, name - 1)) : 0,
flags); flags);
table->setBodyElement(t, i, reinterpret_cast<object>(reference)); table->setBodyElement(t, i, reference);
} }
GcClassAddendum* addendum = getClassAddendum(t, class_, pool); GcClassAddendum* addendum = getClassAddendum(t, class_, pool);
addendum->setInnerClassTable(t, reinterpret_cast<object>(table)); addendum->setInnerClassTable(t, table);
} else if (vm::strcmp(reinterpret_cast<const int8_t*> } else if (vm::strcmp(reinterpret_cast<const int8_t*>
("RuntimeVisibleAnnotations"), ("RuntimeVisibleAnnotations"),
name->body().begin()) == 0) name->body().begin()) == 0)
@ -2434,7 +2434,7 @@ parseAttributeTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
s.read(reinterpret_cast<uint8_t*>(body->body().begin()), length); s.read(reinterpret_cast<uint8_t*>(body->body().begin()), length);
GcClassAddendum* addendum = getClassAddendum(t, class_, pool); GcClassAddendum* addendum = getClassAddendum(t, class_, pool);
addendum->setAnnotationTable(t, reinterpret_cast<object>(body)); addendum->setAnnotationTable(t, body);
} else if (vm::strcmp(reinterpret_cast<const int8_t*> } else if (vm::strcmp(reinterpret_cast<const int8_t*>
("EnclosingMethod"), ("EnclosingMethod"),
name->body().begin()) == 0) name->body().begin()) == 0)
@ -2555,8 +2555,8 @@ makeArrayClass(Thread* t, GcClassLoader* loader, unsigned dimensions, GcByteArra
spec, spec,
0, 0,
type(t, GcJobject::Type), type(t, GcJobject::Type),
reinterpret_cast<object>(roots(t)->arrayInterfaceTable()), roots(t)->arrayInterfaceTable(),
reinterpret_cast<object>(vtable), vtable,
0, 0,
0, 0,
0, 0,
@ -2581,13 +2581,13 @@ saveLoadedClass(Thread* t, GcClassLoader* loader, GcClass* c)
if (loader->map() == 0) { if (loader->map() == 0) {
GcHashMap* map = makeHashMap(t, 0, 0); GcHashMap* map = makeHashMap(t, 0, 0);
loader->setMap(t, reinterpret_cast<object>(map)); loader->setMap(t, map);
} }
hashMapInsert(t, hashMapInsert(t,
cast<GcHashMap>(t, loader->map()), cast<GcHashMap>(t, loader->map()),
reinterpret_cast<object>(c->name()), c->name(),
reinterpret_cast<object>(c), c,
byteArrayHash); byteArrayHash);
} }
@ -2638,7 +2638,7 @@ makeArrayClass(Thread* t, GcClassLoader* loader, GcByteArray* spec, bool throw_,
} }
GcClass* elementClass = cast<GcClass>(t, hashMapFind GcClass* elementClass = cast<GcClass>(t, hashMapFind
(t, roots(t)->bootstrapClassMap(), reinterpret_cast<object>(elementSpec), byteArrayHash, (t, roots(t)->bootstrapClassMap(), elementSpec, byteArrayHash,
byteArrayEqual)); byteArrayEqual));
if (elementClass == 0) { if (elementClass == 0) {
@ -2672,7 +2672,7 @@ resolveArrayClass(Thread* t, GcClassLoader* loader, GcByteArray* spec, bool thro
GcClass* c = cast<GcClass>(t, GcClass* c = cast<GcClass>(t,
hashMapFind(t, hashMapFind(t,
roots(t)->bootstrapClassMap(), roots(t)->bootstrapClassMap(),
reinterpret_cast<object>(spec), spec,
byteArrayHash, byteArrayHash,
byteArrayEqual)); byteArrayEqual));
@ -2774,12 +2774,12 @@ bootJavaClass(Thread* t, Gc::Type type, int superType, const char* name,
vtable = cast<GcArray>(t, vm::type(t, static_cast<Gc::Type>(superType))->virtualTable()); vtable = cast<GcArray>(t, vm::type(t, static_cast<Gc::Type>(superType))->virtualTable());
} }
class_->setVirtualTable(t, reinterpret_cast<object>(vtable)); class_->setVirtualTable(t, vtable);
t->m->processor->initVtable(t, class_); t->m->processor->initVtable(t, class_);
hashMapInsert hashMapInsert
(t, roots(t)->bootstrapClassMap(), reinterpret_cast<object>(n), reinterpret_cast<object>(class_), byteArrayHash); (t, roots(t)->bootstrapClassMap(), n, class_, byteArrayHash);
} }
void void
@ -2794,9 +2794,9 @@ makeArrayInterfaceTable(Thread* t)
{ {
GcArray* interfaceTable = makeArray(t, 4); GcArray* interfaceTable = makeArray(t, 4);
interfaceTable->setBodyElement(t, 0, reinterpret_cast<object>(type(t, GcSerializable::Type))); interfaceTable->setBodyElement(t, 0, type(t, GcSerializable::Type));
interfaceTable->setBodyElement(t, 2, reinterpret_cast<object>(type(t, GcCloneable::Type))); interfaceTable->setBodyElement(t, 2, type(t, GcCloneable::Type));
roots(t)->setArrayInterfaceTable(t, interfaceTable); roots(t)->setArrayInterfaceTable(t, interfaceTable);
} }
@ -2889,13 +2889,13 @@ boot(Thread* t)
type(t, GcDoubleArray::Type)->setArrayElementClass(t, type(t, GcJdouble::Type)); type(t, GcDoubleArray::Type)->setArrayElementClass(t, type(t, GcJdouble::Type));
{ GcHashMap* map = makeHashMap(t, 0, 0); { GcHashMap* map = makeHashMap(t, 0, 0);
roots(t)->bootLoader()->setMap(t, reinterpret_cast<object>(map)); roots(t)->bootLoader()->setMap(t, map);
} }
roots(t)->bootLoader()->as<GcSystemClassLoader>(t)->finder() = m->bootFinder; roots(t)->bootLoader()->as<GcSystemClassLoader>(t)->finder() = m->bootFinder;
{ GcHashMap* map = makeHashMap(t, 0, 0); { GcHashMap* map = makeHashMap(t, 0, 0);
roots(t)->appLoader()->setMap(t, reinterpret_cast<object>(map)); roots(t)->appLoader()->setMap(t, map);
} }
roots(t)->appLoader()->as<GcSystemClassLoader>(t)->finder() = m->appFinder; roots(t)->appLoader()->as<GcSystemClassLoader>(t)->finder() = m->appFinder;
@ -2916,21 +2916,21 @@ boot(Thread* t)
makeArrayInterfaceTable(t); makeArrayInterfaceTable(t);
type(t, GcBooleanArray::Type)->setInterfaceTable(t, reinterpret_cast<object>(roots(t)->arrayInterfaceTable())); type(t, GcBooleanArray::Type)->setInterfaceTable(t, roots(t)->arrayInterfaceTable());
type(t, GcByteArray::Type)->setInterfaceTable(t, reinterpret_cast<object>(roots(t)->arrayInterfaceTable())); type(t, GcByteArray::Type)->setInterfaceTable(t, roots(t)->arrayInterfaceTable());
type(t, GcCharArray::Type)->setInterfaceTable(t, reinterpret_cast<object>(roots(t)->arrayInterfaceTable())); type(t, GcCharArray::Type)->setInterfaceTable(t, roots(t)->arrayInterfaceTable());
type(t, GcShortArray::Type)->setInterfaceTable(t, reinterpret_cast<object>(roots(t)->arrayInterfaceTable())); type(t, GcShortArray::Type)->setInterfaceTable(t, roots(t)->arrayInterfaceTable());
type(t, GcIntArray::Type)->setInterfaceTable(t, reinterpret_cast<object>(roots(t)->arrayInterfaceTable())); type(t, GcIntArray::Type)->setInterfaceTable(t, roots(t)->arrayInterfaceTable());
type(t, GcLongArray::Type)->setInterfaceTable(t, reinterpret_cast<object>(roots(t)->arrayInterfaceTable())); type(t, GcLongArray::Type)->setInterfaceTable(t, roots(t)->arrayInterfaceTable());
type(t, GcFloatArray::Type)->setInterfaceTable(t, reinterpret_cast<object>(roots(t)->arrayInterfaceTable())); type(t, GcFloatArray::Type)->setInterfaceTable(t, roots(t)->arrayInterfaceTable());
type(t, GcDoubleArray::Type)->setInterfaceTable(t, reinterpret_cast<object>(roots(t)->arrayInterfaceTable())); type(t, GcDoubleArray::Type)->setInterfaceTable(t, roots(t)->arrayInterfaceTable());
m->processor->boot(t, 0, 0); m->processor->boot(t, 0, 0);
{ GcCode* bootCode = makeCode(t, 0, 0, 0, 0, 0, 0, 0, 0, 1); { GcCode* bootCode = makeCode(t, 0, 0, 0, 0, 0, 0, 0, 0, 1);
bootCode->body()[0] = impdep1; bootCode->body()[0] = impdep1;
object bootMethod = reinterpret_cast<object>(makeMethod object bootMethod = makeMethod
(t, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, bootCode)); (t, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, bootCode);
PROTECT(t, bootMethod); PROTECT(t, bootMethod);
#include "type-java-initializations.cpp" #include "type-java-initializations.cpp"
@ -3173,7 +3173,7 @@ updatePackageMap(Thread* t, GcClass* class_)
PROTECT(t, key); PROTECT(t, key);
hashMapRemove hashMapRemove
(t, roots(t)->packageMap(), reinterpret_cast<object>(key), byteArrayHash, (t, roots(t)->packageMap(), key, byteArrayHash,
byteArrayEqual); byteArrayEqual);
GcByteArray* source = class_->source(); GcByteArray* source = class_->source();
@ -3194,7 +3194,7 @@ updatePackageMap(Thread* t, GcClass* class_)
} }
hashMapInsert hashMapInsert
(t, roots(t)->packageMap(), reinterpret_cast<object>(key), reinterpret_cast<object>(source), byteArrayHash); (t, roots(t)->packageMap(), key, source, byteArrayHash);
} }
} }
} }
@ -3911,7 +3911,7 @@ makeNewGeneral(Thread* t, GcClass* class_)
if (class_->vmFlags() & WeakReferenceFlag) { if (class_->vmFlags() & WeakReferenceFlag) {
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
cast<GcJreference>(t, instance)->vmNext() = reinterpret_cast<object>(t->m->weakReferences); cast<GcJreference>(t, instance)->vmNext() = t->m->weakReferences;
t->m->weakReferences = cast<GcJreference>(t, instance); t->m->weakReferences = cast<GcJreference>(t, instance);
} }
@ -3979,7 +3979,7 @@ makeString(Thread* t, const char* format, ...)
va_end(a); va_end(a);
if (s) { if (s) {
return t->m->classpath->makeString(t, reinterpret_cast<object>(s), 0, s->length() - 1); return t->m->classpath->makeString(t, s, 0, s->length() - 1);
} else { } else {
size *= 2; size *= 2;
} }
@ -3992,7 +3992,7 @@ stringUTFLength(Thread* t, GcString* string, unsigned start, unsigned length)
unsigned result = 0; unsigned result = 0;
if (length) { if (length) {
object data = reinterpret_cast<object>(string->data()); object data = string->data();
if (objectClass(t, data) == type(t, GcByteArray::Type)) { if (objectClass(t, data) == type(t, GcByteArray::Type)) {
result = length; result = length;
} else { } else {
@ -4015,7 +4015,7 @@ stringChars(Thread* t, GcString* string, unsigned start, unsigned length,
char* chars) char* chars)
{ {
if (length) { if (length) {
object data = reinterpret_cast<object>(string->data()); object data = string->data();
if (objectClass(t, data) == type(t, GcByteArray::Type)) { if (objectClass(t, data) == type(t, GcByteArray::Type)) {
GcByteArray* b = cast<GcByteArray>(t, data); GcByteArray* b = cast<GcByteArray>(t, data);
memcpy(chars, memcpy(chars,
@ -4036,7 +4036,7 @@ stringChars(Thread* t, GcString* string, unsigned start, unsigned length,
uint16_t* chars) uint16_t* chars)
{ {
if (length) { if (length) {
object data = reinterpret_cast<object>(string->data()); object data = string->data();
if (objectClass(t, data) == type(t, GcByteArray::Type)) { if (objectClass(t, data) == type(t, GcByteArray::Type)) {
GcByteArray* b = cast<GcByteArray>(t, data); GcByteArray* b = cast<GcByteArray>(t, data);
for (unsigned i = 0; i < length; ++i) { for (unsigned i = 0; i < length; ++i) {
@ -4059,7 +4059,7 @@ stringUTFChars(Thread* t, GcString* string, unsigned start, unsigned length,
assertT(t, static_cast<unsigned> assertT(t, static_cast<unsigned>
(stringUTFLength(t, string, start, length)) == charsLength); (stringUTFLength(t, string, start, length)) == charsLength);
object data = reinterpret_cast<object>(string->data()); object data = string->data();
if (objectClass(t, data) == type(t, GcByteArray::Type)) { if (objectClass(t, data) == type(t, GcByteArray::Type)) {
GcByteArray* b = cast<GcByteArray>(t, data); GcByteArray* b = cast<GcByteArray>(t, data);
memcpy(chars, memcpy(chars,
@ -4120,7 +4120,7 @@ isAssignableFrom(Thread* t, GcClass* a, GcClass* b)
if (itable) { if (itable) {
unsigned stride = (b->flags() & ACC_INTERFACE) ? 1 : 2; unsigned stride = (b->flags() & ACC_INTERFACE) ? 1 : 2;
for (unsigned i = 0; i < itable->length(); i += stride) { for (unsigned i = 0; i < itable->length(); i += stride) {
if (itable->body()[i] == reinterpret_cast<object>(a)) { if (itable->body()[i] == a) {
return true; return true;
} }
} }
@ -4365,14 +4365,14 @@ parseClass(Thread* t, GcClassLoader* loader, const uint8_t* data, unsigned size,
if (roots(t)->poolMap()) { if (roots(t)->poolMap()) {
object bootstrapClass = hashMapFind object bootstrapClass = hashMapFind
(t, roots(t)->bootstrapClassMap(), reinterpret_cast<object>(class_->name()), (t, roots(t)->bootstrapClassMap(), class_->name(),
byteArrayHash, byteArrayEqual); byteArrayHash, byteArrayEqual);
hashMapInsert( hashMapInsert(
t, t,
roots(t)->poolMap(), roots(t)->poolMap(),
bootstrapClass ? bootstrapClass : reinterpret_cast<object>(real), bootstrapClass ? bootstrapClass : real,
reinterpret_cast<object>(pool), pool,
objectHash); objectHash);
} }
@ -4400,7 +4400,7 @@ resolveSystemClass(Thread* t, GcClassLoader* loader, GcByteArray* spec, bool thr
ACQUIRE(t, t->m->classLock); ACQUIRE(t, t->m->classLock);
GcClass* class_ = cast<GcClass>(t, hashMapFind GcClass* class_ = cast<GcClass>(t, hashMapFind
(t, cast<GcHashMap>(t, loader->map()), reinterpret_cast<object>(spec), byteArrayHash, byteArrayEqual)); (t, cast<GcHashMap>(t, loader->map()), spec, byteArrayHash, byteArrayEqual));
if (class_ == 0) { if (class_ == 0) {
PROTECT(t, class_); PROTECT(t, class_);
@ -4479,7 +4479,7 @@ resolveSystemClass(Thread* t, GcClassLoader* loader, GcByteArray* spec, bool thr
} }
GcClass* bootstrapClass = cast<GcClass>(t, hashMapFind GcClass* bootstrapClass = cast<GcClass>(t, hashMapFind
(t, roots(t)->bootstrapClassMap(), reinterpret_cast<object>(spec), byteArrayHash, (t, roots(t)->bootstrapClassMap(), spec, byteArrayHash,
byteArrayEqual)); byteArrayEqual));
if (bootstrapClass) { if (bootstrapClass) {
@ -4492,7 +4492,7 @@ resolveSystemClass(Thread* t, GcClassLoader* loader, GcByteArray* spec, bool thr
} }
if (class_) { if (class_) {
hashMapInsert(t, cast<GcHashMap>(t, loader->map()), reinterpret_cast<object>(spec), reinterpret_cast<object>(class_), byteArrayHash); hashMapInsert(t, cast<GcHashMap>(t, loader->map()), spec, class_, byteArrayHash);
updatePackageMap(t, class_); updatePackageMap(t, class_);
} else if (throw_) { } else if (throw_) {
@ -4512,7 +4512,7 @@ findLoadedClass(Thread* t, GcClassLoader* loader, GcByteArray* spec)
ACQUIRE(t, t->m->classLock); ACQUIRE(t, t->m->classLock);
return loader->map() ? cast<GcClass>(t, hashMapFind return loader->map() ? cast<GcClass>(t, hashMapFind
(t, cast<GcHashMap>(t, loader->map()), reinterpret_cast<object>(spec), byteArrayHash, byteArrayEqual)) : 0; (t, cast<GcHashMap>(t, loader->map()), spec, byteArrayHash, byteArrayEqual)) : 0;
} }
GcClass* GcClass*
@ -4712,7 +4712,7 @@ postInitClass(Thread* t, GcClass* c)
ACQUIRE(t, t->m->classLock); ACQUIRE(t, t->m->classLock);
if (t->exception if (t->exception
and instanceOf(t, type(t, GcException::Type), reinterpret_cast<object>(t->exception))) { and instanceOf(t, type(t, GcException::Type), t->exception)) {
c->vmFlags() |= NeedInitFlag | InitErrorFlag; c->vmFlags() |= NeedInitFlag | InitErrorFlag;
c->vmFlags() &= ~InitFlag; c->vmFlags() &= ~InitFlag;
@ -4790,7 +4790,7 @@ resolveObjectArrayClass(Thread* t, GcClassLoader* loader, GcClass* elementClass)
GcClass* arrayClass = resolveClass(t, loader, spec); GcClass* arrayClass = resolveClass(t, loader, spec);
getClassRuntimeData(t, elementClass)->setArrayClass(t, reinterpret_cast<object>(arrayClass)); getClassRuntimeData(t, elementClass)->setArrayClass(t, arrayClass);
return arrayClass; return arrayClass;
} }
@ -4803,7 +4803,7 @@ makeObjectArray(Thread* t, GcClass* elementClass, unsigned count)
PROTECT(t, arrayClass); PROTECT(t, arrayClass);
object array = reinterpret_cast<object>(makeArray(t, count)); object array = makeArray(t, count);
setObjectClass(t, array, arrayClass); setObjectClass(t, array, arrayClass);
return array; return array;
@ -4901,7 +4901,7 @@ addFinalizer(Thread* t, object target, void (*finalize)(Thread*, object))
GcFinalizer* f = makeFinalizer(t, 0, function, 0, 0, 0); GcFinalizer* f = makeFinalizer(t, 0, function, 0, 0, 0);
f->target() = target; f->target() = target;
f->next() = reinterpret_cast<object>(t->m->finalizers); f->next() = t->m->finalizers;
t->m->finalizers = f; t->m->finalizers = f;
} }
@ -4937,8 +4937,8 @@ objectMonitor(Thread* t, object o, bool createNew)
return cast<GcMonitor>(t, m); return cast<GcMonitor>(t, m);
} }
object head = reinterpret_cast<object>(makeMonitorNode(t, 0, 0)); object head = makeMonitorNode(t, 0, 0);
m = reinterpret_cast<object>(makeMonitor(t, 0, 0, 0, head, head, 0)); m = makeMonitor(t, 0, 0, 0, head, head, 0);
if (DebugMonitors) { if (DebugMonitors) {
fprintf(stderr, "made monitor %p for object %x\n", m, fprintf(stderr, "made monitor %p for object %x\n", m,
@ -4967,7 +4967,7 @@ intern(Thread* t, object s)
(t, roots(t)->stringMap(), s, stringHash, stringEqual); (t, roots(t)->stringMap(), s, stringHash, stringEqual);
if (n) { if (n) {
return reinterpret_cast<object>(cast<GcJreference>(t, n->first())->target()); return cast<GcJreference>(t, n->first())->target();
} else { } else {
hashMapInsert(t, roots(t)->stringMap(), s, 0, stringHash); hashMapInsert(t, roots(t)->stringMap(), s, 0, stringHash);
addFinalizer(t, s, removeString); addFinalizer(t, s, removeString);
@ -5097,7 +5097,7 @@ printTrace(Thread* t, GcThrowable* exception)
logTrace(errorLog(t), "\n"); logTrace(errorLog(t), "\n");
} }
object trace = reinterpret_cast<object>(e->trace()); object trace = e->trace();
if (trace) { if (trace) {
for (unsigned i = 0; i < objectArrayLength(t, trace); ++i) { for (unsigned i = 0; i < objectArrayLength(t, trace); ++i) {
GcTraceElement* e = cast<GcTraceElement>(t, objectArrayBody(t, trace, i)); GcTraceElement* e = cast<GcTraceElement>(t, objectArrayBody(t, trace, i));
@ -5143,9 +5143,9 @@ makeTrace(Thread* t, Processor::StackWalker* walker)
assertT(t, trace); assertT(t, trace);
} }
GcTraceElement* e = makeTraceElement(t, reinterpret_cast<object>(walker->method()), walker->ip()); GcTraceElement* e = makeTraceElement(t, walker->method(), walker->ip());
assertT(t, index < objectArrayLength(t, reinterpret_cast<object>(trace))); assertT(t, index < objectArrayLength(t, trace));
reinterpret_cast<GcArray*>(trace)->setBodyElement(t, index, reinterpret_cast<object>(e)); reinterpret_cast<GcArray*>(trace)->setBodyElement(t, index, e);
++ index; ++ index;
return true; return true;
} }
@ -5218,7 +5218,7 @@ runFinalizeThread(Thread* t)
} }
for (; cleanList; cleanList = cleanList->queueNext()) { for (; cleanList; cleanList = cleanList->queueNext()) {
finalizeObject(t, reinterpret_cast<object>(cleanList), "clean"); finalizeObject(t, cleanList, "clean");
} }
} }
} }
@ -5252,7 +5252,7 @@ parseUtf8(Thread* t, GcByteArray* array)
} }
} }
return reinterpret_cast<object>(array); return array;
slow_path: slow_path:
class Client: public Stream::Client { class Client: public Stream::Client {
@ -5348,7 +5348,7 @@ defineClass(Thread* t, GcClassLoader* loader, const uint8_t* buffer, unsigned le
{ {
PROTECT(t, loader); PROTECT(t, loader);
object c = reinterpret_cast<object>(parseClass(t, loader, buffer, length)); object c = parseClass(t, loader, buffer, length);
// char name[byteArrayLength(t, className(t, c))]; // char name[byteArrayLength(t, className(t, c))];
// memcpy(name, &byteArrayBody(t, className(t, c), 0), // memcpy(name, &byteArrayBody(t, className(t, c), 0),
@ -5399,10 +5399,10 @@ populateMultiArray(Thread* t, object array, int32_t* counts,
(t, ceilingDivide (t, ceilingDivide
(counts[index + 1] * class_->arrayElementSize(), BytesPerWord)); (counts[index + 1] * class_->arrayElementSize(), BytesPerWord));
a->length() = counts[index + 1]; a->length() = counts[index + 1];
setObjectClass(t, reinterpret_cast<object>(a), class_); setObjectClass(t, a, class_);
setField(t, array, ArrayBody + (i * BytesPerWord), reinterpret_cast<object>(a)); setField(t, array, ArrayBody + (i * BytesPerWord), a);
populateMultiArray(t, reinterpret_cast<object>(a), counts, index + 1, dimensions); populateMultiArray(t, a, counts, index + 1, dimensions);
} }
} }
@ -5418,12 +5418,12 @@ interruptLock(Thread* t, GcThread* thread)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
if (thread->interruptLock() == 0) { if (thread->interruptLock() == 0) {
object head = reinterpret_cast<object>(makeMonitorNode(t, 0, 0)); object head = makeMonitorNode(t, 0, 0);
GcMonitor* lock = makeMonitor(t, 0, 0, 0, head, head, 0); GcMonitor* lock = makeMonitor(t, 0, 0, 0, head, head, 0);
storeStoreMemoryBarrier(); storeStoreMemoryBarrier();
thread->setInterruptLock(t, reinterpret_cast<object>(lock)); thread->setInterruptLock(t, lock);
} }
} }

View File

@ -1024,7 +1024,7 @@ void writeClassAccessors(Output* out, Module& module, Class* cl)
out->write(cppFieldType(module, f)); out->write(cppFieldType(module, f));
out->write(" value) { "); out->write(" value) { ");
if(isFieldGcMarkable(module, f)) { if(isFieldGcMarkable(module, f)) {
out->write("setField(t, reinterpret_cast<object>(this), "); out->write("setField(t, this , ");
out->write(capitalize(cl->name)); out->write(capitalize(cl->name));
out->write(capitalize(f.name)); out->write(capitalize(f.name));
out->write(", reinterpret_cast<object>(value));"); out->write(", reinterpret_cast<object>(value));");
@ -1105,7 +1105,7 @@ void writeClassAccessors(Output* out, Module& module, Class* cl)
out->write(cppFieldType(module, f)); out->write(cppFieldType(module, f));
out->write(" value) { "); out->write(" value) { ");
if(isFieldGcMarkable(module, f)) { if(isFieldGcMarkable(module, f)) {
out->write("setField(t, reinterpret_cast<object>(this), "); out->write("setField(t, this , ");
out->write(capitalize(cl->name)); out->write(capitalize(cl->name));
out->write(capitalize(f.name)); out->write(capitalize(f.name));
out->write(" + index * ("); out->write(" + index * (");

View File

@ -327,7 +327,7 @@ hashMapFindNode(Thread* t, GcHashMap* map, object key,
for (GcTriple* n = cast<GcTriple>(t, array->body()[index]); n; n = cast<GcTriple>(t, n->third())) { for (GcTriple* n = cast<GcTriple>(t, array->body()[index]); n; n = cast<GcTriple>(t, n->third())) {
object k = n->first(); object k = n->first();
if (weak) { if (weak) {
k = reinterpret_cast<object>(cast<GcJreference>(t, k)->target()); k = cast<GcJreference>(t, k)->target();
if (k == 0) { if (k == 0) {
continue; continue;
} }
@ -375,7 +375,7 @@ hashMapResize(Thread* t, GcHashMap* map, uint32_t (*hash)(Thread*, object),
object k = p->first(); object k = p->first();
if (weak) { if (weak) {
k = reinterpret_cast<object>(cast<GcJreference>(t, k)->target()); k = cast<GcJreference>(t, k)->target();
if (k == 0) { if (k == 0) {
continue; continue;
} }
@ -384,7 +384,7 @@ hashMapResize(Thread* t, GcHashMap* map, uint32_t (*hash)(Thread*, object),
unsigned index = hash(t, k) & (newLength - 1); unsigned index = hash(t, k) & (newLength - 1);
p->setThird(t, newArray->body()[index]); p->setThird(t, newArray->body()[index]);
newArray->setBodyElement(t, index, reinterpret_cast<object>(p)); newArray->setBodyElement(t, index, p);
} }
} }
} }
@ -429,9 +429,9 @@ hashMapInsert(Thread* t, GcHashMap* map, object key, object value,
GcWeakReference* r = makeWeakReference(t, 0, 0, 0, 0); GcWeakReference* r = makeWeakReference(t, 0, 0, 0, 0);
r->setTarget(t, key); r->setTarget(t, key);
r->setVmNext(t, reinterpret_cast<object>(t->m->weakReferences)); r->setVmNext(t, t->m->weakReferences);
t->m->weakReferences = r->as<GcJreference>(t); t->m->weakReferences = r->as<GcJreference>(t);
k = reinterpret_cast<object>(r); k = r;
array = map->array(); array = map->array();
} }
@ -443,7 +443,7 @@ hashMapInsert(Thread* t, GcHashMap* map, object key, object value,
unsigned index = h & (array->length() - 1); unsigned index = h & (array->length() - 1);
n->setThird(t, array->body()[index]); n->setThird(t, array->body()[index]);
array->setBodyElement(t, index, reinterpret_cast<object>(n)); array->setBodyElement(t, index, n);
if (map->size() <= array->length() / 3) { if (map->size() <= array->length() / 3) {
// this might happen if nodes were removed during GC in which case // this might happen if nodes were removed during GC in which case
@ -479,7 +479,7 @@ hashMapRemove(Thread* t, GcHashMap* map, object key,
for (GcTriple* n = cast<GcTriple>(t, array->body()[index]); n;) { for (GcTriple* n = cast<GcTriple>(t, array->body()[index]); n;) {
object k = n->first(); object k = n->first();
if (weak) { if (weak) {
k = reinterpret_cast<object>(cast<GcJreference>(t, k)->target()); k = cast<GcJreference>(t, k)->target();
if (k == 0) { if (k == 0) {
n = cast<GcTriple>(t, hashMapRemoveNode(t, map, index, p, n)->third()); n = cast<GcTriple>(t, hashMapRemoveNode(t, map, index, p, n)->third());
continue; continue;
@ -513,7 +513,7 @@ listAppend(Thread* t, GcList* list, object value)
++ list->size(); ++ list->size();
object p = reinterpret_cast<object>(makePair(t, value, 0)); object p = makePair(t, value, 0);
if (list->front()) { if (list->front()) {
cast<GcPair>(t, list->rear())->setSecond(t, p); cast<GcPair>(t, list->rear())->setSecond(t, p);
} else { } else {