move Machine::*Type to GcObject::*Type

This commit is contained in:
Joshua Warner 2014-05-28 22:17:25 -06:00 committed by Joshua Warner
parent 13452beaab
commit b5699cc9dc
22 changed files with 2916 additions and 2732 deletions

View File

@ -160,4 +160,4 @@ class DelayedPromise: public ListenPromise {
} // namespace codegen
} // namespace avian
#endif // AVIAN_CODEGEN_PROMISE_H
#endif // AVIAN_CODEGEN_PROMISE_H

View File

@ -70,4 +70,4 @@ public:
} // namespace codegen
} // namespace avian
#endif // AVIAN_CODEGEN_REGISTERS_H
#endif // AVIAN_CODEGEN_REGISTERS_H

View File

@ -46,4 +46,4 @@ public:
} // namespace avian
} // namespace util
#endif // AVIAN_UTIL_ARG_PARSER_H
#endif // AVIAN_UTIL_ARG_PARSER_H

View File

@ -29,16 +29,16 @@ getTrace(Thread* t, unsigned skipCount)
virtual bool visit(Processor::StackWalker* walker) {
if (skipCount == 0) {
object method = walker->method();
GcMethod* method = walker->method();
if (isAssignableFrom
(t, type(t, Machine::ThrowableType), methodClass(t, method))
(t, type(t, GcThrowable::Type), cast<GcClass>(t, method->class_()))
and vm::strcmp(reinterpret_cast<const int8_t*>("<init>"),
&byteArrayBody(t, methodName(t, method), 0))
&byteArrayBody(t, method->name(), 0))
== 0)
{
return true;
} else {
trace = makeTrace(t, walker);
trace = reinterpret_cast<object>(makeTrace(t, walker));
return false;
}
} else {
@ -75,9 +75,9 @@ arrayCopy(Thread* t, object src, int32_t srcOffset, object dst,
{
if (LIKELY(src and dst)) {
if (LIKELY(compatibleArrayTypes
(t, objectClass(t, src), objectClass(t, dst))))
(t, reinterpret_cast<object>(objectClass(t, src)), reinterpret_cast<object>(objectClass(t, dst)))))
{
unsigned elementSize = classArrayElementSize(t, objectClass(t, src));
unsigned elementSize = objectClass(t, src)->arrayElementSize();
if (LIKELY(elementSize)) {
intptr_t sl = fieldAtOffset<uintptr_t>(src, BytesPerWord);
@ -98,13 +98,13 @@ arrayCopy(Thread* t, object src, int32_t srcOffset, object dst,
length * elementSize);
}
if (classObjectMask(t, objectClass(t, dst))) {
if (objectClass(t, dst)->objectMask()) {
mark(t, dst, ArrayBody + (dstOffset * BytesPerWord), length);
}
return;
} else {
throwNew(t, Machine::IndexOutOfBoundsExceptionType);
throwNew(t, GcIndexOutOfBoundsException::Type);
}
} else {
return;
@ -112,11 +112,11 @@ arrayCopy(Thread* t, object src, int32_t srcOffset, object dst,
}
}
} else {
throwNew(t, Machine::NullPointerExceptionType);
throwNew(t, GcNullPointerException::Type);
return;
}
throwNew(t, Machine::ArrayStoreExceptionType);
throwNew(t, GcArrayStoreException::Type);
}
void
@ -239,7 +239,7 @@ loadLibrary(Thread* t, const char* path, const char* name, bool mapName,
runOnLoadIfFound(t, lib);
}
} else if (throw_) {
throwNew(t, Machine::UnsatisfiedLinkErrorType,
throwNew(t, GcUnsatisfiedLinkError::Type,
"library not found in %s: %s", path, name);
}
@ -251,26 +251,26 @@ clone(Thread* t, object o)
{
PROTECT(t, o);
object class_ = objectClass(t, o);
GcClass* class_ = objectClass(t, o);
unsigned size = baseSize(t, o, class_) * BytesPerWord;
object clone;
if (classArrayElementSize(t, class_)) {
clone = static_cast<object>(allocate(t, size, classObjectMask(t, class_)));
if (class_->arrayElementSize()) {
clone = static_cast<object>(allocate(t, size, class_->objectMask()));
memcpy(clone, o, size);
// clear any object header flags:
setObjectClass(t, o, objectClass(t, o));
} else if (instanceOf(t, type(t, Machine::CloneableType), o)) {
} else if (instanceOf(t, type(t, GcCloneable::Type), o)) {
clone = make(t, class_);
memcpy(reinterpret_cast<void**>(clone) + 1,
reinterpret_cast<void**>(o) + 1,
size - BytesPerWord);
} else {
object classNameSlash = className(t, objectClass(t, o));
object classNameSlash = objectClass(t, o)->name();
THREAD_RUNTIME_ARRAY(t, char, classNameDot, byteArrayLength(t, classNameSlash));
replace('/', '.', RUNTIME_ARRAY_BODY(classNameDot),
reinterpret_cast<char*>(&byteArrayBody(t, classNameSlash, 0)));
throwNew(t, Machine::CloneNotSupportedExceptionType, "%s",
throwNew(t, GcCloneNotSupportedException::Type, "%s",
RUNTIME_ARRAY_BODY(classNameDot));
}
@ -282,13 +282,13 @@ makeStackTraceElement(Thread* t, object e)
{
PROTECT(t, e);
object class_ = className(t, methodClass(t, traceElementMethod(t, e)));
PROTECT(t, class_);
object class_name = className(t, methodClass(t, traceElementMethod(t, e)));
PROTECT(t, class_name);
THREAD_RUNTIME_ARRAY(t, char, s, byteArrayLength(t, class_));
THREAD_RUNTIME_ARRAY(t, char, s, byteArrayLength(t, class_name));
replace('/', '.', RUNTIME_ARRAY_BODY(s),
reinterpret_cast<char*>(&byteArrayBody(t, class_, 0)));
class_ = makeString(t, "%s", RUNTIME_ARRAY_BODY(s));
reinterpret_cast<char*>(&byteArrayBody(t, class_name, 0)));
class_name = makeString(t, "%s", RUNTIME_ARRAY_BODY(s));
object method = methodName(t, traceElementMethod(t, e));
PROTECT(t, method);
@ -297,13 +297,13 @@ makeStackTraceElement(Thread* t, object e)
(t, method, 0, byteArrayLength(t, method) - 1);
unsigned line = t->m->processor->lineNumber
(t, traceElementMethod(t, e), traceElementIp(t, e));
(t, cast<GcMethod>(t, traceElementMethod(t, e)), traceElementIp(t, e));
object file = classSourceFile(t, methodClass(t, traceElementMethod(t, e)));
file = file ? t->m->classpath->makeString
(t, file, 0, byteArrayLength(t, file) - 1) : 0;
return makeStackTraceElement(t, class_, method, file, line);
return reinterpret_cast<object>(makeStackTraceElement(t, class_name, method, file, line));
}
object
@ -311,19 +311,19 @@ translateInvokeResult(Thread* t, unsigned returnCode, object o)
{
switch (returnCode) {
case ByteField:
return makeByte(t, intValue(t, o));
return reinterpret_cast<object>(makeByte(t, intValue(t, o)));
case BooleanField:
return makeBoolean(t, intValue(t, o) != 0);
return reinterpret_cast<object>(makeBoolean(t, intValue(t, o) != 0));
case CharField:
return makeChar(t, intValue(t, o));
return reinterpret_cast<object>(makeChar(t, intValue(t, o)));
case ShortField:
return makeShort(t, intValue(t, o));
return reinterpret_cast<object>(makeShort(t, intValue(t, o)));
case FloatField:
return makeFloat(t, intValue(t, o));
return reinterpret_cast<object>(makeFloat(t, intValue(t, o)));
case IntField:
case LongField:
@ -332,14 +332,14 @@ translateInvokeResult(Thread* t, unsigned returnCode, object o)
return o;
case DoubleField:
return makeDouble(t, longValue(t, o));
return reinterpret_cast<object>(makeDouble(t, longValue(t, o)));
default:
abort(t);
}
}
object
GcClass*
resolveClassBySpec(Thread* t, object loader, const char* spec,
unsigned specLength)
{
@ -350,7 +350,7 @@ resolveClassBySpec(Thread* t, object loader, const char* spec,
RUNTIME_ARRAY_BODY(s)[specLength - 2] = 0;
return resolveClass(t, loader, RUNTIME_ARRAY_BODY(s));
}
case '[': {
THREAD_RUNTIME_ARRAY(t, char, s, specLength + 1);
memcpy(RUNTIME_ARRAY_BODY(s), spec, specLength);
@ -389,15 +389,15 @@ resolveParameterTypes(Thread* t, object loader, object spec,
while (byteArrayBody(t, spec, offset) != ';') ++ offset;
++ offset;
object type = resolveClassBySpec
GcClass* type = resolveClassBySpec
(t, loader, reinterpret_cast<char*>(&byteArrayBody(t, spec, start)),
offset - start);
list = makePair(t, type, list);
list = reinterpret_cast<object>(makePair(t, reinterpret_cast<object>(type), list));
++ count;
} break;
case '[': {
unsigned start = offset;
while (byteArrayBody(t, spec, offset) == '[') ++ offset;
@ -412,18 +412,18 @@ resolveParameterTypes(Thread* t, object loader, object spec,
++ offset;
break;
}
object type = resolveClassBySpec
GcClass* type = resolveClassBySpec
(t, loader, reinterpret_cast<char*>(&byteArrayBody(t, spec, start)),
offset - start);
list = makePair(t, type, list);
list = reinterpret_cast<object>(makePair(t, reinterpret_cast<object>(type), list));
++ count;
} break;
default:
list = makePair
(t, primitiveClass(t, byteArrayBody(t, spec, offset)), list);
list = reinterpret_cast<object>(makePair
(t, reinterpret_cast<object>(primitiveClass(t, byteArrayBody(t, spec, offset))), list));
++ offset;
++ count;
break;
@ -443,13 +443,13 @@ resolveParameterJTypes(Thread* t, object loader, object spec,
(t, loader, spec, parameterCount, returnTypeSpec);
PROTECT(t, list);
object array = makeObjectArray
(t, type(t, Machine::JclassType), *parameterCount);
(t, type(t, GcJclass::Type), *parameterCount);
PROTECT(t, array);
for (int i = *parameterCount - 1; i >= 0; --i) {
object c = getJClass(t, pairFirst(t, list));
object c = getJClass(t, cast<GcClass>(t, pairFirst(t, list)));
set(t, array, ArrayBody + (i * BytesPerWord), c);
list = pairSecond(t, list);
}
@ -461,14 +461,14 @@ object
resolveExceptionJTypes(Thread* t, object loader, object addendum)
{
if (addendum == 0 or methodAddendumExceptionTable(t, addendum) == 0) {
return makeObjectArray(t, type(t, Machine::JclassType), 0);
return makeObjectArray(t, type(t, GcJclass::Type), 0);
}
PROTECT(t, loader);
PROTECT(t, addendum);
object array = makeObjectArray
(t, type(t, Machine::JclassType),
(t, type(t, GcJclass::Type),
shortArrayLength(t, methodAddendumExceptionTable(t, addendum)));
PROTECT(t, array);
@ -478,16 +478,16 @@ resolveExceptionJTypes(Thread* t, object loader, object addendum)
uint16_t index = shortArrayBody
(t, methodAddendumExceptionTable(t, addendum), i) - 1;
object o = singletonObject(t, addendumPool(t, addendum), index);
object o = singletonObject(t, cast<GcSingleton>(t, addendumPool(t, addendum)), index);
if (objectClass(t, o) == type(t, GcReference::Type)) {
o = reinterpret_cast<object>(resolveClass(t, loader, referenceName(t, o)));
if (objectClass(t, o) == type(t, Machine::ReferenceType)) {
o = resolveClass(t, loader, referenceName(t, o));
set(t, addendumPool(t, addendum), SingletonBody + (index * BytesPerWord),
o);
}
o = getJClass(t, o);
o = getJClass(t, cast<GcClass>(t, o));
set(t, array, ArrayBody + (i * BytesPerWord), o);
}
@ -496,41 +496,41 @@ resolveExceptionJTypes(Thread* t, object loader, object addendum)
}
object
invoke(Thread* t, object method, object instance, object args)
invoke(Thread* t, GcMethod* method, object instance, object args)
{
PROTECT(t, method);
PROTECT(t, instance);
PROTECT(t, args);
if (methodFlags(t, method) & ACC_STATIC) {
if (method->flags() & ACC_STATIC) {
instance = 0;
}
if ((args == 0 ? 0 : objectArrayLength(t, args))
!= methodParameterCount(t, method))
!= method->parameterCount())
{
throwNew(t, Machine::IllegalArgumentExceptionType);
throwNew(t, GcIllegalArgumentException::Type);
}
if (methodParameterCount(t, method)) {
unsigned specLength = byteArrayLength(t, methodSpec(t, method));
if (method->parameterCount()) {
unsigned specLength = byteArrayLength(t, method->spec());
THREAD_RUNTIME_ARRAY(t, char, spec, specLength);
memcpy(RUNTIME_ARRAY_BODY(spec),
&byteArrayBody(t, methodSpec(t, method), 0), specLength);
&byteArrayBody(t, method->spec(), 0), specLength);
unsigned i = 0;
for (MethodSpecIterator it(t, RUNTIME_ARRAY_BODY(spec)); it.hasNext();) {
object type;
GcClass* type;
bool objectType = false;
const char* p = it.next();
switch (*p) {
case 'Z': type = vm::type(t, Machine::BooleanType); break;
case 'B': type = vm::type(t, Machine::ByteType); break;
case 'S': type = vm::type(t, Machine::ShortType); break;
case 'C': type = vm::type(t, Machine::CharType); break;
case 'I': type = vm::type(t, Machine::IntType); break;
case 'F': type = vm::type(t, Machine::FloatType); break;
case 'J': type = vm::type(t, Machine::LongType); break;
case 'D': type = vm::type(t, Machine::DoubleType); break;
case 'Z': type = vm::type(t, GcBoolean::Type); break;
case 'B': type = vm::type(t, GcByte::Type); break;
case 'S': type = vm::type(t, GcShort::Type); break;
case 'C': type = vm::type(t, GcChar::Type); break;
case 'I': type = vm::type(t, GcInt::Type); break;
case 'F': type = vm::type(t, GcFloat::Type); break;
case 'J': type = vm::type(t, GcLong::Type); break;
case 'D': type = vm::type(t, GcDouble::Type); break;
case 'L':
case '[': {
@ -546,7 +546,7 @@ invoke(Thread* t, object method, object instance, object args)
memcpy(RUNTIME_ARRAY_BODY(name), p, nameLength - 1);
RUNTIME_ARRAY_BODY(name)[nameLength - 1] = 0;
type = resolveClass
(t, classLoader(t, methodClass(t, method)),
(t, classLoader(t, method->class_()),
RUNTIME_ARRAY_BODY(name));
} break;
@ -560,20 +560,20 @@ invoke(Thread* t, object method, object instance, object args)
{
// fprintf(stderr, "%s is not a %s\n", arg ? &byteArrayBody(t, className(t, objectClass(t, arg)), 0) : reinterpret_cast<const int8_t*>("<null>"), &byteArrayBody(t, className(t, type), 0));
throwNew(t, Machine::IllegalArgumentExceptionType);
throwNew(t, GcIllegalArgumentException::Type);
}
}
}
initClass(t, methodClass(t, method));
initClass(t, cast<GcClass>(t, method->class_()));
unsigned returnCode = methodReturnCode(t, method);
unsigned returnCode = method->returnCode();
THREAD_RESOURCE0(t, {
if (t->exception) {
t->exception = makeThrowable
(t, Machine::InvocationTargetExceptionType, 0, 0, t->exception);
(t, GcInvocationTargetException::Type, 0, 0, t->exception);
set(t, t->exception, InvocationTargetExceptionTarget,
throwableCause(t, t->exception));
}
@ -592,29 +592,29 @@ invoke(Thread* t, object method, object instance, object args)
// only safe to call during bootstrap when there's only one thread
// running:
void
intercept(Thread* t, object c, const char* name, const char* spec,
intercept(Thread* t, GcClass* c, const char* name, const char* spec,
void* function, bool updateRuntimeData)
{
object m = findMethodOrNull(t, c, name, spec);
GcMethod* m = findMethodOrNull(t, c, name, spec);
if (m) {
PROTECT(t, m);
methodFlags(t, m) |= ACC_NATIVE;
m->flags() |= ACC_NATIVE;
if (updateRuntimeData) {
object clone = methodClone(t, m);
GcMethod* clone = methodClone(t, m);
// make clone private to prevent vtable updates at compilation
// time. Otherwise, our interception might be bypassed by calls
// through the vtable.
methodFlags(t, clone) |= ACC_PRIVATE;
clone->flags() |= ACC_PRIVATE;
object native = reinterpret_cast<object>(makeNativeIntercept(t, function, true, reinterpret_cast<object>(clone)));
object native = makeNativeIntercept(t, function, true, clone);
PROTECT(t, native);
object runtimeData = getMethodRuntimeData(t, m);
set(t, runtimeData, MethodRuntimeDataNative, native);
}
} else {
@ -633,7 +633,7 @@ Finder*
getFinder(Thread* t, const char* name, unsigned nameLength)
{
ACQUIRE(t, t->m->referenceLock);
for (object p = root(t, Machine::VirtualFileFinders);
p; p = finderNext(t, p))
{
@ -646,7 +646,7 @@ getFinder(Thread* t, const char* name, unsigned nameLength)
}
}
object n = makeByteArray(t, nameLength + 1);
object n = reinterpret_cast<object>(makeByteArray(t, nameLength + 1));
memcpy(&byteArrayBody(t, n, 0), name, nameLength);
void* p = t->m->libraries->resolve
@ -660,8 +660,8 @@ getFinder(Thread* t, const char* name, unsigned nameLength)
uint8_t* data = function(&size);
if (data) {
Finder* f = makeFinder(t->m->system, t->m->heap, data, size);
object finder = makeFinder
(t, f, n, root(t, Machine::VirtualFileFinders));
object finder = reinterpret_cast<object>(makeFinder
(t, f, n, root(t, Machine::VirtualFileFinders)));
setRoot(t, Machine::VirtualFileFinders, finder);
@ -693,7 +693,7 @@ getDeclaredClasses(Thread* t, object c, bool publicOnly)
}
}
object result = makeObjectArray(t, type(t, Machine::JclassType), count);
object result = makeObjectArray(t, type(t, GcJclass::Type), count);
PROTECT(t, result);
for (unsigned i = 0; i < arrayLength(t, table); ++i) {
@ -703,11 +703,13 @@ getDeclaredClasses(Thread* t, object c, bool publicOnly)
and ((not publicOnly)
or (innerClassReferenceFlags(t, reference) & ACC_PUBLIC)))
{
object inner = getJClass
(t, resolveClass
(t, classLoader(t, c),
innerClassReferenceInner(t, arrayBody(t, table, i))));
object inner = getJClass(
t,
resolveClass(
t,
classLoader(t, c),
innerClassReferenceInner(t, arrayBody(t, table, i))));
-- count;
set(t, result, ArrayBody + (count * BytesPerWord), inner);
}
@ -717,7 +719,7 @@ getDeclaredClasses(Thread* t, object c, bool publicOnly)
}
}
return makeObjectArray(t, type(t, Machine::JclassType), 0);
return makeObjectArray(t, type(t, GcJclass::Type), 0);
}
object
@ -733,9 +735,11 @@ getDeclaringClass(Thread* t, object c)
(&byteArrayBody(t, innerClassReferenceInner(t, reference), 0),
&byteArrayBody(t, className(t, c), 0)) == 0)
{
return getJClass
(t, resolveClass
(t, classLoader(t, c), innerClassReferenceOuter(t, reference)));
return getJClass(
t,
resolveClass(t,
classLoader(t, c),
innerClassReferenceOuter(t, reference)));
}
}
}
@ -758,7 +762,7 @@ classModifiers(Thread* t, object c)
&byteArrayBody(t, innerClassReferenceInner(t, reference), 0)))
{
return innerClassReferenceFlags(t, reference);
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -37,9 +37,9 @@ codeReadInt32(Thread* t, object code, unsigned& ip)
}
inline bool
isSuperclass(Thread* t, object class_, object base)
isSuperclass(Thread* t, GcClass* class_, GcClass* base)
{
for (object oc = classSuper(t, base); oc; oc = classSuper(t, oc)) {
for (GcClass* oc = cast<GcClass>(t, base->super()); oc; oc = cast<GcClass>(t, oc->super())) {
if (oc == class_) {
return true;
}
@ -48,19 +48,19 @@ isSuperclass(Thread* t, object class_, object base)
}
inline bool
isSpecialMethod(Thread* t, object method, object class_)
isSpecialMethod(Thread* t, GcMethod* method, GcClass* class_)
{
return (classFlags(t, class_) & ACC_SUPER)
return (class_->flags() & ACC_SUPER)
and strcmp(reinterpret_cast<const int8_t*>("<init>"),
&byteArrayBody(t, methodName(t, method), 0)) != 0
and isSuperclass(t, methodClass(t, method), class_);
&byteArrayBody(t, method->name(), 0)) != 0
and isSuperclass(t, cast<GcClass>(t, method->class_()), class_);
}
void
resolveNative(Thread* t, object method);
resolveNative(Thread* t, GcMethod* method);
int
findLineNumber(Thread* t, object method, unsigned ip);
findLineNumber(Thread* t, GcMethod* method, unsigned ip);
} // namespace vm

View File

@ -32,6 +32,11 @@ class Slice;
namespace vm {
class GcByteArray;
class GcCode;
class GcClass;
class GcMethod;
class Processor {
public:
class StackWalker;
@ -45,7 +50,7 @@ class Processor {
public:
virtual void walk(StackVisitor* v) = 0;
virtual object method() = 0;
virtual GcMethod* method() = 0;
virtual int ip() = 0;
@ -62,7 +67,7 @@ class Processor {
virtual Thread*
makeThread(Machine* m, object javaThread, Thread* parent) = 0;
virtual object
virtual GcMethod*
makeMethod(Thread* t,
uint8_t vmFlags,
uint8_t returnCode,
@ -70,13 +75,13 @@ class Processor {
uint8_t parameterFootprint,
uint16_t flags,
uint16_t offset,
object name,
object spec,
GcByteArray* name,
GcByteArray* spec,
object addendum,
object class_,
object code) = 0;
GcClass* class_,
GcCode* code) = 0;
virtual object
virtual GcClass*
makeClass(Thread* t,
uint16_t flags,
uint16_t vmFlags,
@ -97,7 +102,7 @@ class Processor {
unsigned vtableLength) = 0;
virtual void
initVtable(Thread* t, object c) = 0;
initVtable(Thread* t, GcClass* c) = 0;
virtual void
visitObjects(Thread* t, Heap::Visitor* v) = 0;
@ -106,7 +111,7 @@ class Processor {
walkStack(Thread* t, StackVisitor* v) = 0;
virtual int
lineNumber(Thread* t, object method, int ip) = 0;
lineNumber(Thread* t, GcMethod* method, int ip) = 0;
virtual object*
makeLocalReference(Thread* t, object o) = 0;
@ -121,14 +126,14 @@ class Processor {
popLocalFrame(Thread* t) = 0;
virtual object
invokeArray(Thread* t, object method, object this_, object arguments) = 0;
invokeArray(Thread* t, GcMethod* method, object this_, object arguments) = 0;
virtual object
invokeArray(Thread* t, object method, object this_, const jvalue* arguments)
invokeArray(Thread* t, GcMethod* method, object this_, const jvalue* arguments)
= 0;
virtual object
invokeList(Thread* t, object method, object this_, bool indirectObjects,
invokeList(Thread* t, GcMethod* method, object this_, bool indirectObjects,
va_list arguments) = 0;
virtual object
@ -153,7 +158,7 @@ class Processor {
virtual void
compileMethod(Thread* t, Zone* zone, object* constants, object* calls,
avian::codegen::DelayedPromise** addresses, object method,
avian::codegen::DelayedPromise** addresses, GcMethod* method,
OffsetResolver* resolver) = 0;
virtual void
@ -186,7 +191,7 @@ class Processor {
= 0;
object
invoke(Thread* t, object method, object this_, ...)
invoke(Thread* t, GcMethod* method, object this_, ...)
{
va_list a;
va_start(a, this_);

View File

@ -17,12 +17,12 @@
namespace vm {
object
hashMapFindNode(Thread* t, object map, object key,
hashMapFindNode(Thread* t, GcHashMap* map, object key,
uint32_t (*hash)(Thread*, object),
bool (*equal)(Thread*, object, object));
inline object
hashMapFind(Thread* t, object map, object key,
hashMapFind(Thread* t, GcHashMap* map, object key,
uint32_t (*hash)(Thread*, object),
bool (*equal)(Thread*, object, object))
{
@ -31,15 +31,15 @@ hashMapFind(Thread* t, object map, object key,
}
void
hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
hashMapResize(Thread* t, GcHashMap* map, uint32_t (*hash)(Thread*, object),
unsigned size);
void
hashMapInsert(Thread* t, object map, object key, object value,
hashMapInsert(Thread* t, GcHashMap* map, object key, object value,
uint32_t (*hash)(Thread*, object));
inline bool
hashMapInsertOrReplace(Thread* t, object map, object key, object value,
hashMapInsertOrReplace(Thread* t, GcHashMap* map, object key, object value,
uint32_t (*hash)(Thread*, object),
bool (*equal)(Thread*, object, object))
{
@ -54,7 +54,7 @@ hashMapInsertOrReplace(Thread* t, object map, object key, object value,
}
inline bool
hashMapInsertMaybe(Thread* t, object map, object key, object value,
hashMapInsertMaybe(Thread* t, GcHashMap* map, object key, object value,
uint32_t (*hash)(Thread*, object),
bool (*equal)(Thread*, object, object))
{
@ -68,12 +68,12 @@ hashMapInsertMaybe(Thread* t, object map, object key, object value,
}
object
hashMapRemove(Thread* t, object map, object key,
hashMapRemove(Thread* t, GcHashMap* map, object key,
uint32_t (*hash)(Thread*, object),
bool (*equal)(Thread*, object, object));
object
hashMapIterator(Thread* t, object map);
hashMapIterator(Thread* t, GcHashMap* map);
object
hashMapIteratorNext(Thread* t, object it);
@ -102,14 +102,14 @@ treeUpdate(Thread* t, object tree, intptr_t key, object value, object sentinal,
class HashMapIterator: public Thread::Protector {
public:
HashMapIterator(Thread* t, object map):
HashMapIterator(Thread* t, GcHashMap* map):
Protector(t), map(map), node(0), index(0)
{
find();
}
void find() {
object array = hashMapArray(t, map);
object array = map->array();
if (array) {
for (unsigned i = index; i < arrayLength(t, array); ++i) {
if (arrayBody(t, array, i)) {
@ -145,7 +145,7 @@ class HashMapIterator: public Thread::Protector {
v->visit(&node);
}
object map;
GcHashMap* map;
object node;
unsigned index;
};

View File

@ -21,37 +21,37 @@ namespace {
int64_t
search(Thread* t, object loader, object name,
object (*op)(Thread*, object, object), bool replaceDots)
GcClass* (*op)(Thread*, object, object), bool replaceDots)
{
if (LIKELY(name)) {
PROTECT(t, loader);
PROTECT(t, name);
object n = makeByteArray(t, stringLength(t, name) + 1);
object n = reinterpret_cast<object>(makeByteArray(t, stringLength(t, name) + 1));
char* s = reinterpret_cast<char*>(&byteArrayBody(t, n, 0));
stringChars(t, name, s);
if (replaceDots) {
replace('.', '/', s);
}
return reinterpret_cast<int64_t>(op(t, loader, n));
} else {
throwNew(t, Machine::NullPointerExceptionType);
throwNew(t, GcNullPointerException::Type);
}
}
object
GcClass*
resolveSystemClassThrow(Thread* t, object loader, object spec)
{
return resolveSystemClass
(t, loader, spec, true, Machine::ClassNotFoundExceptionType);
(t, loader, spec, true, GcClassNotFoundException::Type);
}
object
fieldForOffsetInClass(Thread* t, object c, unsigned offset)
fieldForOffsetInClass(Thread* t, GcClass* c, unsigned offset)
{
object super = classSuper(t, c);
GcClass* super = cast<GcClass>(t, c->super());
if (super) {
object field = fieldForOffsetInClass(t, super, offset);
if (field) {
@ -59,7 +59,7 @@ fieldForOffsetInClass(Thread* t, object c, unsigned offset)
}
}
object table = classFieldTable(t, c);
object table = c->fieldTable();
if (table) {
for (unsigned i = 0; i < objectArrayLength(t, table); ++i) {
object field = objectArrayBody(t, table, i);
@ -75,12 +75,12 @@ fieldForOffsetInClass(Thread* t, object c, unsigned offset)
}
object
fieldForOffset(Thread* t, object o, unsigned offset)
fieldForOffset(Thread* t, GcSingleton* o, unsigned offset)
{
object c = objectClass(t, o);
if (classVmFlags(t, c) & SingletonFlag) {
c = singletonObject(t, o, 0);
object table = classFieldTable(t, c);
GcClass* c = objectClass(t, o);
if (c->vmFlags() & SingletonFlag) {
c = cast<GcClass>(t, singletonObject(t, o, 0));
object table = c->fieldTable();
if (table) {
for (unsigned i = 0; i < objectArrayLength(t, table); ++i) {
object field = objectArrayBody(t, table, i);
@ -108,7 +108,7 @@ extern "C" AVIAN_EXPORT void JNICALL
Avian_avian_Classes_initialize
(Thread* t, object, uintptr_t* arguments)
{
object this_ = reinterpret_cast<object>(arguments[0]);
GcClass* this_ = cast<GcClass>(t, reinterpret_cast<object>(arguments[0]));
initClass(t, this_);
}
@ -135,7 +135,7 @@ Avian_avian_Classes_resolveVMClass
object spec = reinterpret_cast<object>(arguments[1]);
return reinterpret_cast<int64_t>
(resolveClass(t, loader, spec, true, Machine::ClassNotFoundExceptionType));
(resolveClass(t, loader, spec, true, GcClassNotFoundException::Type));
}
extern "C" AVIAN_EXPORT int64_t JNICALL
@ -149,7 +149,7 @@ Avian_avian_Classes_defineVMClass
uint8_t* buffer = static_cast<uint8_t*>
(t->m->heap->allocate(length));
THREAD_RESOURCE2(t, uint8_t*, buffer, int, length,
t->m->heap->free(buffer, length));
@ -202,7 +202,7 @@ Avian_avian_SystemClassLoader_resourceURLPrefix
return name ? reinterpret_cast<uintptr_t>(makeString(t, "%s", name)) : 0;
} else {
throwNew(t, Machine::NullPointerExceptionType);
throwNew(t, GcNullPointerException::Type);
}
}
@ -226,7 +226,7 @@ Avian_avian_SystemClassLoader_00024ResourceEnumeration_nextResourceURLPrefix
return name ? reinterpret_cast<uintptr_t>(makeString(t, "%s", name)) : 0;
} else {
throwNew(t, Machine::NullPointerExceptionType);
throwNew(t, GcNullPointerException::Type);
}
}
@ -235,7 +235,7 @@ Avian_avian_SystemClassLoader_getClass
(Thread* t, object, uintptr_t* arguments)
{
return reinterpret_cast<int64_t>
(getJClass(t, reinterpret_cast<object>(arguments[0])));
(getJClass(t, cast<GcClass>(t, reinterpret_cast<object>(arguments[0]))));
}
extern "C" AVIAN_EXPORT int64_t JNICALL
@ -256,7 +256,7 @@ Avian_avian_SystemClassLoader_getPackageSource
object key = makeByteArray(t, RUNTIME_ARRAY_BODY(chars));
object array = hashMapFind
(t, root(t, Machine::PackageMap), key, byteArrayHash, byteArrayEqual);
(t, cast<GcHashMap>(t, root(t, Machine::PackageMap)), key, byteArrayHash, byteArrayEqual);
if (array) {
return reinterpret_cast<uintptr_t>
@ -286,7 +286,7 @@ Avian_avian_Machine_dumpHeap
}
fclose(out);
} else {
throwNew(t, Machine::RuntimeExceptionType, "file not found: %s",
throwNew(t, GcRuntimeException::Type, "file not found: %s",
RUNTIME_ARRAY_BODY(n));
}
}
@ -357,7 +357,7 @@ Avian_avian_avianvmresource_Handler_00024ResourceInputStream_open
return reinterpret_cast<int64_t>(r);
} else {
throwNew(t, Machine::NullPointerExceptionType);
throwNew(t, GcNullPointerException::Type);
}
}
@ -398,7 +398,7 @@ Avian_avian_avianvmresource_Handler_00024ResourceInputStream_read__JI_3BII
int32_t length = arguments[5];
if (length == 0) return 0;
System::Region* region = reinterpret_cast<System::Region*>(peer);
if (length > static_cast<jint>(region->length()) - position) {
length = static_cast<jint>(region->length()) - position;
@ -469,7 +469,7 @@ Avian_avian_Singleton_getObject
(Thread* t, object, uintptr_t* arguments)
{
return reinterpret_cast<int64_t>
(singletonObject(t, reinterpret_cast<object>(arguments[0]), arguments[1]));
(singletonObject(t, cast<GcSingleton>(t, reinterpret_cast<object>(arguments[0])), arguments[1]));
}
extern "C" AVIAN_EXPORT int64_t JNICALL
@ -477,7 +477,7 @@ Avian_avian_Singleton_getInt
(Thread* t, object, uintptr_t* arguments)
{
return singletonValue
(t, reinterpret_cast<object>(arguments[0]), arguments[1]);
(t, cast<GcSingleton>(t, reinterpret_cast<object>(arguments[0])), arguments[1]);
}
extern "C" AVIAN_EXPORT int64_t JNICALL
@ -486,7 +486,7 @@ Avian_avian_Singleton_getLong
{
int64_t v;
memcpy(&v, &singletonValue
(t, reinterpret_cast<object>(arguments[0]), arguments[1]), 8);
(t, cast<GcSingleton>(t, reinterpret_cast<object>(arguments[0])), arguments[1]), 8);
return v;
}
@ -499,7 +499,7 @@ Avian_sun_misc_Unsafe_allocateMemory
if (p) {
return reinterpret_cast<int64_t>(p);
} else {
throwNew(t, Machine::OutOfMemoryErrorType);
throwNew(t, GcOutOfMemoryError::Type);
}
}
@ -711,19 +711,19 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_sun_misc_Unsafe_arrayIndexScale
(Thread* t, object, uintptr_t* arguments)
{
object c = jclassVmClass(t, reinterpret_cast<object>(arguments[1]));
GcClass* c = cast<GcClass>(t, jclassVmClass(t, reinterpret_cast<object>(arguments[1])));
if (c == type(t, Machine::BooleanArrayType)
|| c == type(t, Machine::ByteArrayType))
if (c == type(t, GcBooleanArray::Type)
|| c == type(t, GcByteArray::Type))
return 1;
else if (c == type(t, Machine::ShortArrayType)
|| c == type(t, Machine::CharArrayType))
else if (c == type(t, GcShortArray::Type)
|| c == type(t, GcCharArray::Type))
return 2;
else if (c == type(t, Machine::IntArrayType)
|| c == type(t, Machine::FloatArrayType))
else if (c == type(t, GcIntArray::Type)
|| c == type(t, GcFloatArray::Type))
return 4;
else if (c == type(t, Machine::LongArrayType)
|| c == type(t, Machine::DoubleArrayType))
else if (c == type(t, GcLongArray::Type)
|| c == type(t, GcDoubleArray::Type))
return 8;
else
return BytesPerWord;
@ -740,7 +740,7 @@ Avian_java_nio_FixedArrayByteBuffer_allocateFixed
object array = allocate3
(t, t->m->heap, Machine::FixedAllocation, ArrayBody + capacity, false);
setObjectClass(t, array, type(t, Machine::ByteArrayType));
setObjectClass(t, array, type(t, GcByteArray::Type));
byteArrayLength(t, array) = capacity;
longArrayBody(t, address, 0) = reinterpret_cast<intptr_t>(array) + ArrayBody;
@ -776,7 +776,7 @@ Avian_sun_misc_Unsafe_putObjectVolatile
object o = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8);
object value = reinterpret_cast<object>(arguments[4]);
storeStoreMemoryBarrier();
set(t, o, offset, reinterpret_cast<object>(value));
storeLoadMemoryBarrier();
@ -795,7 +795,7 @@ Avian_sun_misc_Unsafe_getObjectVolatile
{
object o = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8);
uintptr_t value = fieldAtOffset<uintptr_t>(o, offset);
loadMemoryBarrier();
return value;
@ -866,21 +866,21 @@ Avian_sun_misc_Unsafe_getLongVolatile
object lock;
if (BytesPerWord < 8) {
if (classArrayDimensions(t, objectClass(t, o))) {
lock = objectClass(t, o);
if (objectClass(t, o)->arrayDimensions()) {
lock = reinterpret_cast<object>(objectClass(t, o));
} else {
lock = fieldForOffset(t, o, offset);
lock = fieldForOffset(t, cast<GcSingleton>(t, o), offset);
}
PROTECT(t, o);
PROTECT(t, lock);
acquire(t, lock);
acquire(t, lock);
}
int64_t result = fieldAtOffset<int64_t>(o, offset);
if (BytesPerWord < 8) {
release(t, lock);
release(t, lock);
} else {
loadMemoryBarrier();
}
@ -898,15 +898,15 @@ Avian_sun_misc_Unsafe_putLongVolatile
object lock;
if (BytesPerWord < 8) {
if (classArrayDimensions(t, objectClass(t, o))) {
lock = objectClass(t, o);
if (objectClass(t, o)->arrayDimensions()) {
lock = reinterpret_cast<object>(objectClass(t, o));
} else {
lock = fieldForOffset(t, o, offset);
lock = fieldForOffset(t, cast<GcSingleton>(t, o), offset);
}
PROTECT(t, o);
PROTECT(t, lock);
acquire(t, lock);
acquire(t, lock);
} else {
storeStoreMemoryBarrier();
}
@ -934,7 +934,7 @@ Avian_sun_misc_Unsafe_unpark
(Thread* t, object, uintptr_t* arguments)
{
object thread = reinterpret_cast<object>(arguments[1]);
monitorAcquire(t, interruptLock(t, thread));
threadUnparked(t, thread) = true;
monitorNotify(t, interruptLock(t, thread));
@ -947,7 +947,7 @@ Avian_sun_misc_Unsafe_park
{
bool absolute = arguments[1];
int64_t time; memcpy(&time, arguments + 2, 8);
int64_t then = t->m->system->now();
if (absolute) {
@ -973,7 +973,7 @@ Avian_sun_misc_Unsafe_park
int64_t now = t->m->system->now();
time -= now - then;
then = now;
if (time == 0) {
break;
}
@ -992,7 +992,7 @@ Avian_sun_misc_Unsafe_putIntVolatile
object o = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8);
int32_t value = arguments[4];
storeStoreMemoryBarrier();
fieldAtOffset<int32_t>(o, offset) = value;
storeLoadMemoryBarrier();
@ -1024,7 +1024,7 @@ Avian_sun_misc_Unsafe_putByteVolatile
object o = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8);
int8_t value = arguments[4];
storeStoreMemoryBarrier();
fieldAtOffset<int8_t>(o, offset) = value;
storeLoadMemoryBarrier();
@ -1063,7 +1063,7 @@ Avian_sun_misc_Unsafe_putShortVolatile
object o = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8);
int16_t value = arguments[4];
storeStoreMemoryBarrier();
fieldAtOffset<int16_t>(o, offset) = value;
storeLoadMemoryBarrier();

View File

@ -25,7 +25,7 @@ extern "C" int JNI_OnLoad(JavaVM*, void*);
#include "avian/util.h"
#ifdef PLATFORM_WINDOWS
const char* getErrnoDescription(int err); // This function is defined in mingw-extensions.cpp
const char* getErrnoDescription(int err); // This function is defined in mingw-extensions.cpp
#endif
using namespace vm;
@ -93,7 +93,7 @@ defineClass(Thread* t, object method, uintptr_t* arguments)
if (v) {
return reinterpret_cast<uintptr_t>
(getJClass(t, reinterpret_cast<object>(v)));
(getJClass(t, cast<GcClass>(t, reinterpret_cast<object>(v))));
} else {
return 0;
}
@ -103,7 +103,7 @@ int64_t JNICALL
mapData(Thread*, object, uintptr_t*);
void JNICALL
closeMemoryMappedFile(Thread*, object, uintptr_t*);
closeMemoryMappedFile(Thread*, GcMethod*, uintptr_t*);
object
makeMethodOrConstructor(Thread* t, object c, unsigned index)
@ -131,8 +131,8 @@ makeMethodOrConstructor(Thread* t, object c, unsigned index)
(t, classLoader(t, methodClass(t, method)), methodAddendum(t, method));
if (byteArrayBody(t, methodName(t, method), 0) == '<') {
return makeJconstructor
(t, 0, c, parameterTypes, exceptionTypes, 0, 0, 0, 0, index);
return reinterpret_cast<object>(makeJconstructor
(t, 0, c, parameterTypes, exceptionTypes, 0, 0, 0, 0, index));
} else {
PROTECT(t, exceptionTypes);
@ -140,9 +140,9 @@ makeMethodOrConstructor(Thread* t, object c, unsigned index)
(t, methodName(t, method), 0,
byteArrayLength(t, methodName(t, method)) - 1);
return makeJmethod
return reinterpret_cast<object>(makeJmethod
(t, 0, index, c, name, parameterTypes, exceptionTypes, returnType, 0, 0,
0, 0, 0);
0, 0, 0));
}
}
@ -168,7 +168,7 @@ makeField(Thread* t, object c, unsigned index)
(t, fieldName(t, field), 0,
byteArrayLength(t, fieldName(t, field)) - 1);
return makeJfield(t, 0, c, type, 0, 0, name, index);
return reinterpret_cast<object>(makeJfield(t, 0, c, type, 0, 0, name, index));
}
void initVmThread(Thread* t, object thread, unsigned offset)
@ -176,14 +176,14 @@ void initVmThread(Thread* t, object thread, unsigned offset)
PROTECT(t, thread);
if (fieldAtOffset<object>(thread, offset) == 0) {
object c = resolveClass
GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "java/lang/VMThread");
PROTECT(t, c);
object instance = makeNew(t, c);
PROTECT(t, instance);
object constructor = resolveMethod
GcMethod* constructor = resolveMethod
(t, c, "<init>", "(Ljava/lang/Thread;)V");
t->m->processor->invoke(t, constructor, instance, thread);
@ -235,13 +235,13 @@ class MyClasspath : public Classpath {
{ }
virtual object
makeJclass(Thread* t, object class_)
makeJclass(Thread* t, GcClass* class_)
{
PROTECT(t, class_);
object c = allocate(t, FixedSizeOfJclass, true);
setObjectClass(t, c, type(t, Machine::JclassType));
set(t, c, JclassVmClass, class_);
object c = allocate(t, GcJclass::FixedSize, true);
setObjectClass(t, c, type(t, GcJclass::Type));
set(t, c, JclassVmClass, reinterpret_cast<object>(class_));
return c;
}
@ -249,10 +249,10 @@ class MyClasspath : public Classpath {
virtual object
makeString(Thread* t, object array, int32_t offset, int32_t length)
{
if (objectClass(t, array) == type(t, Machine::ByteArrayType)) {
if (objectClass(t, array) == type(t, GcByteArray::Type)) {
PROTECT(t, array);
object charArray = makeCharArray(t, length);
object charArray = reinterpret_cast<object>(makeCharArray(t, length));
for (int i = 0; i < length; ++i) {
expect(t, (byteArrayBody(t, array, offset + i) & 0x80) == 0);
@ -261,10 +261,10 @@ class MyClasspath : public Classpath {
array = charArray;
} else {
expect(t, objectClass(t, array) == type(t, Machine::CharArrayType));
expect(t, objectClass(t, array) == type(t, GcCharArray::Type));
}
return vm::makeString(t, array, offset, length, 0);
return reinterpret_cast<object>(vm::makeString(t, array, offset, length, 0));
}
virtual object
@ -279,25 +279,25 @@ class MyClasspath : public Classpath {
} else {
resolveSystemClass
(t, root(t, Machine::BootLoader),
className(t, type(t, Machine::ThreadGroupType)), false);
type(t, GcThreadGroup::Type)->name(), false);
group = makeNew(t, type(t, Machine::ThreadGroupType));
group = makeNew(t, type(t, GcThreadGroup::Type));
object constructor = resolveMethod
(t, type(t, Machine::ThreadGroupType), "<init>", "()V");
GcMethod* constructor = resolveMethod
(t, type(t, GcThreadGroup::Type), "<init>", "()V");
t->m->processor->invoke(t, constructor, group);
}
resolveSystemClass
(t, root(t, Machine::BootLoader),
className(t, type(t, Machine::ThreadType)), false);
type(t, GcThread::Type)->name(), false);
object thread = makeNew(t, type(t, Machine::ThreadType));
object thread = makeNew(t, type(t, GcThread::Type));
PROTECT(t, thread);
object constructor = resolveMethod
(t, type(t, Machine::ThreadType), "<init>",
GcMethod* constructor = resolveMethod
(t, type(t, GcThread::Type), "<init>",
"(Ljava/lang/ThreadGroup;Ljava/lang/String;IZ)V");
t->m->processor->invoke
@ -311,13 +311,13 @@ class MyClasspath : public Classpath {
}
virtual object
makeJMethod(Thread* t, object vmMethod)
makeJMethod(Thread* t, GcMethod* vmMethod)
{
object table = classMethodTable(t, methodClass(t, vmMethod));
object table = classMethodTable(t, vmMethod->class_());
for (unsigned i = 0; i < arrayLength(t, table); ++i) {
if (vmMethod == arrayBody(t, table, i)) {
if (reinterpret_cast<object>(vmMethod) == arrayBody(t, table, i)) {
return makeMethodOrConstructor
(t, getJClass(t, methodClass(t, vmMethod)), i);
(t, getJClass(t, cast<GcClass>(t, vmMethod->class_())), i);
}
}
abort(t);
@ -326,7 +326,7 @@ class MyClasspath : public Classpath {
virtual object
getVMMethod(Thread* t, object jmethod)
{
return objectClass(t, jmethod) == type(t, Machine::JmethodType)
return objectClass(t, jmethod) == type(t, GcJmethod::Type)
? arrayBody
(t, classMethodTable
(t, jclassVmClass(t, jmethodDeclaringClass(t, jmethod))),
@ -343,7 +343,7 @@ class MyClasspath : public Classpath {
object table = classFieldTable(t, fieldClass(t, vmField));
for (unsigned i = 0; i < arrayLength(t, table); ++i) {
if (vmField == arrayBody(t, table, i)) {
return makeField(t, getJClass(t, fieldClass(t, vmField)), i);
return makeField(t, getJClass(t, cast<GcClass>(t, fieldClass(t, vmField))), i);
}
}
abort(t);
@ -394,14 +394,14 @@ class MyClasspath : public Classpath {
initVmThread(t, t->javaThread, offset);
object method = resolveMethod
GcMethod* method = resolveMethod
(t, root(t, Machine::BootLoader), "java/lang/Thread", "run", "()V");
t->m->processor->invoke(t, method, t->javaThread);
}
virtual void
resolveNative(Thread* t, object method)
resolveNative(Thread* t, GcMethod* method)
{
vm::resolveNative(t, method);
}
@ -409,7 +409,7 @@ class MyClasspath : public Classpath {
void
interceptMethods(Thread* t, bool updateRuntimeData)
{
{ object c = resolveClass
{ GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "java/lang/Runtime", false);
if (c) {
@ -421,7 +421,7 @@ class MyClasspath : public Classpath {
}
}
{ object c = resolveClass
{ GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "java/lang/ref/FinalizerReference",
false);
@ -433,7 +433,7 @@ class MyClasspath : public Classpath {
}
}
{ object c = resolveClass
{ GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "java/lang/ClassLoader", false);
if (c) {
@ -448,7 +448,7 @@ class MyClasspath : public Classpath {
}
}
{ object c = resolveClass
{ GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "libcore/util/ZoneInfoDB", false);
if (c) {
@ -459,7 +459,7 @@ class MyClasspath : public Classpath {
}
}
{ object c = resolveClass
{ GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "libcore/io/MemoryMappedFile",
false);
@ -506,11 +506,11 @@ class MyClasspath : public Classpath {
virtual void
boot(Thread* t)
{
object c = resolveClass
GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "java/lang/ClassLoader");
PROTECT(t, c);
object constructor = resolveMethod
GcMethod* constructor = resolveMethod
(t, c, "<init>", "(Ljava/lang/ClassLoader;Z)V");
PROTECT(t, constructor);
@ -531,14 +531,14 @@ class MyClasspath : public Classpath {
virtual object
makeDirectByteBuffer(Thread* t, void* p, jlong capacity)
{
object c = resolveClass
GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "java/nio/DirectByteBuffer");
PROTECT(t, c);
object instance = makeNew(t, c);
PROTECT(t, instance);
object constructor = resolveMethod(t, c, "<init>", "(JI)V");
GcMethod* constructor = resolveMethod(t, c, "<init>", "(JI)V");
t->m->processor->invoke
(t, constructor, instance, reinterpret_cast<int64_t>(p),
@ -565,20 +565,20 @@ class MyClasspath : public Classpath {
}
virtual bool
canTailCall(Thread*, object, object, object, object)
canTailCall(Thread*, GcMethod*, object, object, object)
{
return true;
}
virtual object libraryClassLoader(Thread* t, object caller)
virtual object libraryClassLoader(Thread* t, GcMethod* caller)
{
return strcmp(
"java/lang/Runtime",
reinterpret_cast<char*>(
&byteArrayBody(t, className(t, methodClass(t, caller)), 0)))
&byteArrayBody(t, className(t, caller->class_()), 0)))
== 0
? t->libraryLoadStack->classLoader
: classLoader(t, methodClass(t, caller));
: classLoader(t, caller->class_());
}
virtual void
@ -604,14 +604,14 @@ class MyClasspath : public Classpath {
int64_t JNICALL
mapData(Thread* t, object, uintptr_t*)
{
object c = resolveClass
GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "libcore/io/MemoryMappedFile");
PROTECT(t, c);
object instance = makeNew(t, c);
PROTECT(t, instance);
object constructor = resolveMethod(t, c, "<init>", "(JJ)V");
GcMethod* constructor = resolveMethod(t, c, "<init>", "(JJ)V");
const char* jar = "javahomeJar";
Finder* finder = getFinder(t, jar, strlen(jar));
@ -632,11 +632,11 @@ mapData(Thread* t, object, uintptr_t*)
}
}
throwNew(t, Machine::RuntimeExceptionType);
throwNew(t, GcRuntimeException::Type);
}
void JNICALL
closeMemoryMappedFile(Thread* t, object method, uintptr_t* arguments)
closeMemoryMappedFile(Thread* t, GcMethod* method, uintptr_t* arguments)
{
object file = reinterpret_cast<object>(arguments[0]);
PROTECT(t, file);
@ -658,8 +658,8 @@ closeMemoryMappedFile(Thread* t, object method, uintptr_t* arguments)
}
t->m->processor->invoke
(t, nativeInterceptOriginal
(t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
(t, cast<GcMethod>(t, nativeInterceptOriginal
(t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method)))),
file);
}
@ -668,28 +668,28 @@ matchType(Thread* t, object field, object o)
{
switch (fieldCode(t, field)) {
case ByteField:
return objectClass(t, o) == type(t, Machine::ByteType);
return objectClass(t, o) == type(t, GcByte::Type);
case BooleanField:
return objectClass(t, o) == type(t, Machine::BooleanType);
return objectClass(t, o) == type(t, GcBoolean::Type);
case CharField:
return objectClass(t, o) == type(t, Machine::CharType);
return objectClass(t, o) == type(t, GcChar::Type);
case ShortField:
return objectClass(t, o) == type(t, Machine::ShortType);
return objectClass(t, o) == type(t, GcShort::Type);
case IntField:
return objectClass(t, o) == type(t, Machine::IntType);
return objectClass(t, o) == type(t, GcInt::Type);
case LongField:
return objectClass(t, o) == type(t, Machine::LongType);
return objectClass(t, o) == type(t, GcLong::Type);
case FloatField:
return objectClass(t, o) == type(t, Machine::FloatType);
return objectClass(t, o) == type(t, GcFloat::Type);
case DoubleField:
return objectClass(t, o) == type(t, Machine::DoubleType);
return objectClass(t, o) == type(t, GcDouble::Type);
case ObjectField:
if (o == 0) {
@ -701,7 +701,7 @@ matchType(Thread* t, object field, object o)
if (byteArrayBody(t, fieldSpec(t, field), 0) == '[') {
spec = fieldSpec(t, field);;
} else {
spec = makeByteArray(t, byteArrayLength(t, fieldSpec(t, field)) - 2);
spec = reinterpret_cast<object>(makeByteArray(t, byteArrayLength(t, fieldSpec(t, field)) - 2));
memcpy(&byteArrayBody(t, spec, 0),
&byteArrayBody(t, fieldSpec(t, field), 1),
@ -725,42 +725,42 @@ getField(Thread* t, object field, object instance)
PROTECT(t, field);
PROTECT(t, instance);
initClass(t, fieldClass(t, field));
initClass(t, cast<GcClass>(t, fieldClass(t, field)));
object target;
if (fieldFlags(t, field) & ACC_STATIC) {
target = classStaticTable(t, fieldClass(t, field));
} else if (instanceOf(t, fieldClass(t, field), instance)){
} else if (instanceOf(t, cast<GcClass>(t, fieldClass(t, field)), instance)){
target = instance;
} else {
throwNew(t, Machine::IllegalArgumentExceptionType);
throwNew(t, GcIllegalArgumentException::Type);
}
unsigned offset = fieldOffset(t, field);
switch (fieldCode(t, field)) {
case ByteField:
return makeByte(t, fieldAtOffset<int8_t>(target, offset));
return reinterpret_cast<object>(makeByte(t, fieldAtOffset<int8_t>(target, offset)));
case BooleanField:
return makeBoolean(t, fieldAtOffset<int8_t>(target, offset));
return reinterpret_cast<object>(makeBoolean(t, fieldAtOffset<int8_t>(target, offset)));
case CharField:
return makeChar(t, fieldAtOffset<int16_t>(target, offset));
return reinterpret_cast<object>(makeChar(t, fieldAtOffset<int16_t>(target, offset)));
case ShortField:
return makeShort(t, fieldAtOffset<int16_t>(target, offset));
return reinterpret_cast<object>(makeShort(t, fieldAtOffset<int16_t>(target, offset)));
case IntField:
return makeInt(t, fieldAtOffset<int32_t>(target, offset));
return reinterpret_cast<object>(makeInt(t, fieldAtOffset<int32_t>(target, offset)));
case LongField:
return makeLong(t, fieldAtOffset<int64_t>(target, offset));
return reinterpret_cast<object>(makeLong(t, fieldAtOffset<int64_t>(target, offset)));
case FloatField:
return makeFloat(t, fieldAtOffset<int32_t>(target, offset));
return reinterpret_cast<object>(makeFloat(t, fieldAtOffset<int32_t>(target, offset)));
case DoubleField:
return makeDouble(t, fieldAtOffset<int64_t>(target, offset));
return reinterpret_cast<object>(makeDouble(t, fieldAtOffset<int64_t>(target, offset)));
case ObjectField:
return fieldAtOffset<object>(target, offset);
@ -777,20 +777,20 @@ setField(Thread* t, object field, object instance, object value)
PROTECT(t, value);
if (not matchType(t, field, value)) {
throwNew(t, Machine::IllegalArgumentExceptionType);
throwNew(t, GcIllegalArgumentException::Type);
}
object target;
if ((fieldFlags(t, field) & ACC_STATIC) != 0) {
target = classStaticTable(t, fieldClass(t, field));
} else if (instanceOf(t, fieldClass(t, field), instance)){
} else if (instanceOf(t, cast<GcClass>(t, fieldClass(t, field)), instance)){
target = instance;
} else {
throwNew(t, Machine::IllegalArgumentExceptionType);
throwNew(t, GcIllegalArgumentException::Type);
}
PROTECT(t, target);
initClass(t, fieldClass(t, field));
initClass(t, cast<GcClass>(t, fieldClass(t, field)));
unsigned offset = fieldOffset(t, field);
switch (fieldCode(t, field)) {
@ -1100,7 +1100,7 @@ Avian_java_lang_Class_getInterfaces
PROTECT(t, array);
for (unsigned i = 0; i < arrayLength(t, table); ++i) {
object c = getJClass(t, arrayBody(t, table, i));
object c = getJClass(t, cast<GcClass>(t, arrayBody(t, table, i)));
set(t, array, ArrayBody + (i * BytesPerWord), c);
}
@ -1109,7 +1109,7 @@ Avian_java_lang_Class_getInterfaces
}
return reinterpret_cast<uintptr_t>
(makeObjectArray(t, type(t, Machine::JclassType), 0));
(makeObjectArray(t, type(t, GcJclass::Type), 0));
}
extern "C" AVIAN_EXPORT int64_t JNICALL
@ -1151,11 +1151,17 @@ Avian_java_lang_Class_getEnclosingMethod
if (enclosingMethod) {
PROTECT(t, enclosingMethod);
return reinterpret_cast<uintptr_t>
(t->m->classpath->makeJMethod
(t, findMethodInClass
(t, enclosingClass, pairFirst(t, enclosingMethod),
pairSecond(t, enclosingMethod))));
abort(t);
// TODO: the following violates type safety; enclosingClass at this
// point is a GcJclass (having come from "getJClass()") - but the method
// expects a GcClass.
// Figure it out.
// return reinterpret_cast<uintptr_t>
// (t->m->classpath->makeJMethod
// (t, findMethodInClass
// (t, cast<GcClass>(t, enclosingClass), pairFirst(t, enclosingMethod),
// pairSecond(t, enclosingMethod))));
}
}
}
@ -1173,9 +1179,9 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_Class_newInstanceImpl
(Thread* t, object, uintptr_t* arguments)
{
object c = jclassVmClass(t, reinterpret_cast<object>(arguments[0]));
GcClass* c = cast<GcClass>(t, jclassVmClass(t, reinterpret_cast<object>(arguments[0])));
object method = resolveMethod(t, c, "<init>", "()V");
GcMethod* method = resolveMethod(t, c, "<init>", "()V");
PROTECT(t, method);
object instance = makeNew(t, c);
@ -1199,7 +1205,7 @@ Avian_java_lang_Class_getComponentType
(getJClass(t, primitiveClass(t, n)));
} else {
return reinterpret_cast<uintptr_t>
(getJClass(t, classStaticTable(t, jclassVmClass(t, c))));
(getJClass(t, cast<GcClass>(t, classStaticTable(t, jclassVmClass(t, c)))));
}
} else {
return 0;
@ -1216,7 +1222,7 @@ Avian_java_lang_Class_classForName
object loader = reinterpret_cast<object>(arguments[2]);
PROTECT(t, loader);
object method = resolveMethod
GcMethod* method = resolveMethod
(t, root(t, Machine::BootLoader), "avian/Classes", "forName",
"(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;");
@ -1235,7 +1241,7 @@ Avian_java_lang_Class_getDeclaredField
object name = reinterpret_cast<object>(arguments[1]);
PROTECT(t, name);
object method = resolveMethod
GcMethod* method = resolveMethod
(t, root(t, Machine::BootLoader), "avian/Classes", "findField",
"(Lavian/VMClass;Ljava/lang/String;)I");
@ -1263,7 +1269,7 @@ Avian_java_lang_Class_getDeclaredConstructorOrMethod
object parameterTypes = reinterpret_cast<object>(arguments[2]);
PROTECT(t, parameterTypes);
object method = resolveMethod
GcMethod* method = resolveMethod
(t, root(t, Machine::BootLoader), "avian/Classes", "findMethod",
"(Lavian/VMClass;Ljava/lang/String;[Ljava/lang/Class;)I");
@ -1292,7 +1298,7 @@ Avian_java_lang_VMClassLoader_findLoadedClass
if (v) {
return reinterpret_cast<uintptr_t>
(getJClass(t, reinterpret_cast<object>(v)));
(getJClass(t, cast<GcClass>(t, reinterpret_cast<object>(v))));
} else {
return 0;
}
@ -1309,7 +1315,7 @@ Avian_java_lang_VMClassLoader_defineClass__Ljava_lang_ClassLoader_2Ljava_lang_St
if (v) {
return reinterpret_cast<uintptr_t>
(getJClass(t, reinterpret_cast<object>(v)));
(getJClass(t, cast<GcClass>(t, reinterpret_cast<object>(v))));
} else {
return 0;
}
@ -1341,7 +1347,7 @@ Avian_dalvik_system_VMRuntime_properties
(Thread* t, object, uintptr_t*)
{
object array = makeObjectArray(
t, type(t, Machine::StringType), t->m->propertyCount + 1);
t, type(t, GcString::Type), t->m->propertyCount + 1);
PROTECT(t, array);
unsigned i;
@ -1477,7 +1483,7 @@ Avian_java_lang_VMThread_sleep
if (milliseconds <= 0) milliseconds = 1;
if (threadSleepLock(t, t->javaThread) == 0) {
object lock = makeJobject(t);
object lock = reinterpret_cast<object>(makeJobject(t));
set(t, t->javaThread, ThreadSleepLock, lock);
}
@ -1514,7 +1520,7 @@ Avian_dalvik_system_VMStack_getCallingClassLoader
if (counter--) {
return true;
} else {
this->loader = classLoader(t, methodClass(t, walker->method()));
this->loader = classLoader(t, walker->method()->class_());
return false;
}
}
@ -1545,10 +1551,10 @@ Avian_dalvik_system_VMStack_getClasses
} else {
if (array == 0) {
array = makeObjectArray
(t, type(t, Machine::JclassType), walker->count());
(t, type(t, GcJclass::Type), walker->count());
}
object c = getJClass(t, methodClass(t, walker->method()));
object c = getJClass(t, cast<GcClass>(t, walker->method()->class_()));
assert(t, counter - 2 < objectArrayLength(t, array));
@ -1570,7 +1576,7 @@ Avian_dalvik_system_VMStack_getClasses
t->m->processor->walkStack(t, &v);
return reinterpret_cast<uintptr_t>
(v.array ? v.array : makeObjectArray(t, type(t, Machine::JclassType), 0));
(v.array ? v.array : makeObjectArray(t, type(t, GcJclass::Type), 0));
}
extern "C" AVIAN_EXPORT int64_t JNICALL
@ -1718,7 +1724,7 @@ Avian_java_lang_Class_getSuperclass
if (classFlags(t, c) & ACC_INTERFACE) {
return 0;
} else {
object s = classSuper(t, c);
GcClass* s = cast<GcClass>(t, classSuper(t, c));
return s ? reinterpret_cast<uintptr_t>(getJClass(t, s)) : 0;
}
}
@ -1798,9 +1804,9 @@ Avian_java_lang_Class_isAssignableFrom
if (LIKELY(that)) {
return isAssignableFrom
(t, jclassVmClass(t, this_), jclassVmClass(t, that));
(t, cast<GcClass>(t, jclassVmClass(t, this_)), cast<GcClass>(t, jclassVmClass(t, that)));
} else {
throwNew(t, Machine::NullPointerExceptionType);
throwNew(t, GcNullPointerException::Type);
}
}
@ -1812,7 +1818,7 @@ Avian_java_lang_Class_isInstance
object o = reinterpret_cast<object>(arguments[1]);
if (o) {
return instanceOf(t, jclassVmClass(t, this_), o);
return instanceOf(t, cast<GcClass>(t, jclassVmClass(t, this_)), o);
} else {
return 0;
}
@ -1827,7 +1833,7 @@ Avian_java_lang_Class_getDeclaredMethods
bool publicOnly = arguments[1];
object get = resolveMethod
GcMethod* get = resolveMethod
(t, root(t, Machine::BootLoader), "avian/Classes", "getMethods",
"(Lavian/VMClass;Z)[Ljava/lang/reflect/Method;");
@ -1844,7 +1850,7 @@ Avian_java_lang_Class_getDeclaredFields
bool publicOnly = arguments[1];
object get = resolveMethod
GcMethod* get = resolveMethod
(t, root(t, Machine::BootLoader), "avian/Classes", "getFields",
"(Lavian/VMClass;Z)[Ljava/lang/reflect/Field;");
@ -1858,10 +1864,10 @@ Avian_java_lang_reflect_Method_invokeNative
{
object instance = reinterpret_cast<object>(arguments[1]);
object args = reinterpret_cast<object>(arguments[2]);
object method = arrayBody
GcMethod* method = cast<GcMethod>(t, arrayBody
(t, classMethodTable
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[3]))),
arguments[6]);
arguments[6]));
return reinterpret_cast<uintptr_t>(invoke(t, method, instance, args));
}
@ -1923,7 +1929,7 @@ Avian_java_lang_reflect_Method_getAnnotation
PROTECT(t, method);
PROTECT(t, table);
object get = resolveMethod
GcMethod* get = resolveMethod
(t, root(t, Machine::BootLoader), "avian/Classes", "getAnnotation",
"(Ljava/lang/ClassLoader;[Ljava/lang/Object;)"
"Ljava/lang/annotation/Annotation;");
@ -1962,7 +1968,7 @@ Avian_java_lang_reflect_Method_getDeclaredAnnotations
objectArrayLength(t, table));
PROTECT(t, array);
object get = resolveMethod
GcMethod* get = resolveMethod
(t, root(t, Machine::BootLoader), "avian/Classes", "getAnnotation",
"(Ljava/lang/ClassLoader;[Ljava/lang/Object;)"
"Ljava/lang/annotation/Annotation;");
@ -2013,7 +2019,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
objectArrayLength(t, table));
PROTECT(t, array);
object get = resolveMethod(t,
GcMethod* get = resolveMethod(t,
root(t, Machine::BootLoader),
"avian/Classes",
"getAnnotation",
@ -2054,7 +2060,7 @@ Avian_java_lang_reflect_Method_getDefaultValue
object addendum = methodAddendum(t, method);
if (addendum) {
object get = resolveMethod
GcMethod* get = resolveMethod
(t, root(t, Machine::BootLoader), "avian/Classes",
"getAnnotationDefaultValue",
"(Ljava/lang/ClassLoader;Lavian/MethodAddendum;)"
@ -2075,12 +2081,12 @@ Avian_java_lang_reflect_Constructor_constructNative
object args = reinterpret_cast<object>(arguments[1]);
PROTECT(t, args);
object c = jclassVmClass(t, reinterpret_cast<object>(arguments[2]));
GcClass* c = cast<GcClass>(t, jclassVmClass(t, reinterpret_cast<object>(arguments[2])));
PROTECT(t, c);
initClass(t, c);
object method = arrayBody(t, classMethodTable(t, c), arguments[4]);
GcMethod* method = cast<GcMethod>(t, arrayBody(t, c->methodTable(), arguments[4]));
PROTECT(t, method);
object instance = makeNew(t, c);
@ -2174,7 +2180,7 @@ Avian_java_lang_reflect_Field_setIField
object instance = reinterpret_cast<object>(arguments[1]);
PROTECT(t, instance);
object value = makeInt(t, arguments[7]);
object value = reinterpret_cast<object>(makeInt(t, arguments[7]));
local::setField(t, field, instance, value);
}
@ -2210,7 +2216,7 @@ Avian_java_lang_reflect_Field_getAnnotation
PROTECT(t, field);
PROTECT(t, table);
object get = resolveMethod
GcMethod* get = resolveMethod
(t, root(t, Machine::BootLoader), "avian/Classes", "getAnnotation",
"(Ljava/lang/ClassLoader;[Ljava/lang/Object;)"
"Ljava/lang/annotation/Annotation;");
@ -2294,7 +2300,7 @@ Avian_java_lang_reflect_Array_createObjectArray
{
return reinterpret_cast<uintptr_t>
(makeObjectArray
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[0])),
(t, cast<GcClass>(t, jclassVmClass(t, reinterpret_cast<object>(arguments[0]))),
arguments[1]));
}
@ -2309,14 +2315,14 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_dalvik_system_VMRuntime_newNonMovableArray
(Thread* t, object, uintptr_t* arguments)
{
if (jclassVmClass(t, reinterpret_cast<object>(arguments[1]))
== type(t, Machine::JbyteType))
if (cast<GcClass>(t, jclassVmClass(t, reinterpret_cast<object>(arguments[1])))
== type(t, GcJbyte::Type))
{
object array = allocate3
(t, t->m->heap, Machine::FixedAllocation,
ArrayBody + arguments[2], false);
setObjectClass(t, array, type(t, Machine::ByteArrayType));
setObjectClass(t, array, type(t, GcByteArray::Type));
byteArrayLength(t, array) = arguments[2];
return reinterpret_cast<intptr_t>(array);
@ -2492,7 +2498,7 @@ Avian_libcore_io_Posix_getenv(Thread* t, object, uintptr_t* arguments)
extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_libcore_io_Posix_uname(Thread* t, object, uintptr_t*)
{
object c = resolveClass
GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "libcore/io/StructUtsname");
PROTECT(t, c);
@ -2540,7 +2546,7 @@ Avian_libcore_io_Posix_writeBytes(Thread* t, object, uintptr_t* arguments)
int d = jniGetFDFromFileDescriptor(t, &fd);
int r;
if (objectClass(t, buffer) == type(t, Machine::ByteArrayType)) {
if (objectClass(t, buffer) == type(t, GcByteArray::Type)) {
void* tmp = t->m->heap->allocate(count);
memcpy(tmp, &byteArrayBody(t, buffer, offset), count);
{ ENTER(t, Thread::IdleState);
@ -2556,7 +2562,7 @@ Avian_libcore_io_Posix_writeBytes(Thread* t, object, uintptr_t* arguments)
if (r < 0) {
THREAD_RUNTIME_ARRAY(t, char, message, 256);
throwNew(t, Machine::RuntimeExceptionType, "writeBytes %d: %s", d,
throwNew(t, GcRuntimeException::Type, "writeBytes %d: %s", d,
jniStrError(errno, RUNTIME_ARRAY_BODY(message), 0));
} else {
return r;

View File

@ -27,15 +27,15 @@ class MyClasspath : public Classpath {
{ }
virtual object
makeJclass(Thread* t, object class_)
makeJclass(Thread* t, GcClass* class_)
{
return vm::makeJclass(t, class_);
return reinterpret_cast<object>(vm::makeJclass(t, reinterpret_cast<object>(class_)));
}
virtual object
makeString(Thread* t, object array, int32_t offset, int32_t length)
{
return vm::makeString(t, array, offset, length, 0);
return reinterpret_cast<object>(vm::makeString(t, array, offset, length, 0));
}
virtual object
@ -45,32 +45,32 @@ class MyClasspath : public Classpath {
if (parent) {
group = threadGroup(t, parent->javaThread);
} else {
group = makeThreadGroup(t, 0, 0, 0);
group = reinterpret_cast<object>(makeThreadGroup(t, 0, 0, 0));
}
const unsigned NewState = 0;
const unsigned NormalPriority = 5;
return vm::makeThread
return reinterpret_cast<object>(vm::makeThread
(t, 0, 0, 0, 0, 0, NewState, NormalPriority, 0, 0, 0,
root(t, Machine::AppLoader), 0, 0, group, 0);
root(t, Machine::AppLoader), 0, 0, group, 0));
}
virtual object
makeJMethod(Thread* t, object vmMethod)
makeJMethod(Thread* t, GcMethod* vmMethod)
{
PROTECT(t, vmMethod);
object jmethod = makeJmethod(t, vmMethod, false);
object jmethod = reinterpret_cast<object>(makeJmethod(t, reinterpret_cast<object>(vmMethod), false));
return byteArrayBody(t, methodName(t, vmMethod), 0) == '<'
? makeJconstructor(t, jmethod) : jmethod;
return byteArrayBody(t, vmMethod->name(), 0) == '<'
? reinterpret_cast<object>(makeJconstructor(t, jmethod)) : jmethod;
}
virtual object
getVMMethod(Thread* t, object jmethod)
{
return objectClass(t, jmethod) == type(t, Machine::JmethodType)
return objectClass(t, jmethod) == type(t, GcJmethod::Type)
? jmethodVmMethod(t, jmethod)
: jmethodVmMethod(t, jconstructorMethod(t, jmethod));
}
@ -78,7 +78,7 @@ class MyClasspath : public Classpath {
virtual object
makeJField(Thread* t, object vmField)
{
return makeJfield(t, vmField, false);
return reinterpret_cast<object>(makeJfield(t, vmField, false));
}
virtual object
@ -96,7 +96,7 @@ class MyClasspath : public Classpath {
virtual void
runThread(Thread* t)
{
object method = resolveMethod
GcMethod* method = resolveMethod
(t, root(t, Machine::BootLoader), "java/lang/Thread", "run",
"(Ljava/lang/Thread;)V");
@ -104,7 +104,7 @@ class MyClasspath : public Classpath {
}
virtual void
resolveNative(Thread* t, object method)
resolveNative(Thread* t, GcMethod* method)
{
vm::resolveNative(t, method);
}
@ -141,14 +141,14 @@ class MyClasspath : public Classpath {
virtual object
makeDirectByteBuffer(Thread* t, void* p, jlong capacity)
{
object c = resolveClass
GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "java/nio/DirectByteBuffer");
PROTECT(t, c);
object instance = makeNew(t, c);
PROTECT(t, instance);
object constructor = resolveMethod(t, c, "<init>", "(JI)V");
GcMethod* constructor = resolveMethod(t, c, "<init>", "(JI)V");
t->m->processor->invoke
(t, constructor, instance, reinterpret_cast<int64_t>(p),
@ -180,7 +180,7 @@ class MyClasspath : public Classpath {
}
virtual bool canTailCall(Thread* t,
object,
GcMethod*,
object calleeClassName,
object calleeMethodName,
object)
@ -204,12 +204,12 @@ class MyClasspath : public Classpath {
&byteArrayBody(t, calleeClassName, 0)))));
}
virtual object libraryClassLoader(Thread* t, object caller)
virtual object libraryClassLoader(Thread* t, GcMethod* caller)
{
return (methodClass(t, caller) == type(t, Machine::ClassLoaderType)
return (caller->class_() == reinterpret_cast<object>(type(t, Gc::ClassLoaderType))
and t->libraryLoadStack)
? t->libraryLoadStack->classLoader
: classLoader(t, methodClass(t, caller));
: classLoader(t, caller->class_());
}
virtual void
@ -265,7 +265,7 @@ Avian_java_lang_Object_toString
unsigned hash = objectHash(t, this_);
object s = makeString
(t, "%s@0x%x",
&byteArrayBody(t, className(t, objectClass(t, this_)), 0),
&byteArrayBody(t, objectClass(t, this_)->name(), 0),
hash);
return reinterpret_cast<int64_t>(s);
@ -328,7 +328,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_io_ObjectInputStream_makeInstance
(Thread* t, object, uintptr_t* arguments)
{
object c = reinterpret_cast<object>(arguments[0]);
GcClass* c = cast<GcClass>(t, reinterpret_cast<object>(arguments[0]));
return reinterpret_cast<int64_t>(make(t, c));
}
@ -434,7 +434,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_reflect_Constructor_make
(Thread* t, object, uintptr_t* arguments)
{
object c = reinterpret_cast<object>(arguments[0]);
GcClass* c = cast<GcClass>(t, reinterpret_cast<object>(arguments[0]));
return reinterpret_cast<int64_t>(make(t, c));
}
@ -450,7 +450,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_reflect_Method_invoke
(Thread* t, object, uintptr_t* arguments)
{
object method = reinterpret_cast<object>(arguments[0]);
GcMethod* method = cast<GcMethod>(t, reinterpret_cast<object>(arguments[0]));
object instance = reinterpret_cast<object>(arguments[1]);
object args = reinterpret_cast<object>(arguments[2]);
@ -458,11 +458,11 @@ Avian_java_lang_reflect_Method_invoke
if (t->exception) {
object exception = t->exception;
t->exception = makeThrowable
(t, Machine::InvocationTargetExceptionType, 0, 0, exception);
(t, GcInvocationTargetException::Type, 0, 0, exception);
}
});
unsigned returnCode = methodReturnCode(t, method);
unsigned returnCode = method->returnCode();
return reinterpret_cast<int64_t>
(translateInvokeResult
@ -476,15 +476,15 @@ Avian_java_lang_reflect_Array_getLength
object array = reinterpret_cast<object>(arguments[0]);
if (LIKELY(array)) {
unsigned elementSize = classArrayElementSize(t, objectClass(t, array));
unsigned elementSize = objectClass(t, array)->arrayElementSize();
if (LIKELY(elementSize)) {
return fieldAtOffset<uintptr_t>(array, BytesPerWord);
} else {
throwNew(t, Machine::IllegalArgumentExceptionType);
throwNew(t, GcIllegalArgumentException::Type);
}
} else {
throwNew(t, Machine::NullPointerExceptionType);
throwNew(t, GcNullPointerException::Type);
}
}
@ -496,7 +496,7 @@ Avian_java_lang_reflect_Array_makeObjectArray
int length = arguments[1];
return reinterpret_cast<int64_t>
(makeObjectArray(t, jclassVmClass(t, elementType), length));
(makeObjectArray(t, cast<GcClass>(t, jclassVmClass(t, elementType)), length));
}
extern "C" AVIAN_EXPORT int64_t JNICALL
@ -542,7 +542,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_System_getVMProperties(Thread* t, object, uintptr_t*)
{
object array
= makeObjectArray(t, type(t, Machine::StringType), t->m->propertyCount);
= makeObjectArray(t, type(t, GcString::Type), t->m->propertyCount);
PROTECT(t, array);
for (unsigned i = 0; i < t->m->propertyCount; ++i) {
@ -573,7 +573,7 @@ Avian_java_lang_System_identityHashCode
if (LIKELY(o)) {
return objectHash(t, o);
} else {
throwNew(t, Machine::NullPointerExceptionType);
throwNew(t, GcNullPointerException::Type);
}
}
@ -581,7 +581,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_java_lang_ClassLoader_getCaller(Thread* t, object, uintptr_t*)
{
return reinterpret_cast<int64_t>(
getJClass(t, methodClass(t, getCaller(t, 2))));
getJClass(t, cast<GcClass>(t, getCaller(t, 2)->class_())));
}
extern "C" AVIAN_EXPORT void JNICALL
@ -619,7 +619,7 @@ Avian_java_lang_Runtime_addShutdownHook
ACQUIRE(t, t->m->shutdownLock);
setRoot(t, Machine::ShutdownHooks,
makePair(t, hook, root(t, Machine::ShutdownHooks)));
reinterpret_cast<object>(makePair(t, hook, root(t, Machine::ShutdownHooks))));
}
extern "C" AVIAN_EXPORT int64_t JNICALL
@ -637,7 +637,7 @@ Avian_java_lang_Throwable_resolveTrace
PROTECT(t, trace);
unsigned length = objectArrayLength(t, trace);
object elementType = type(t, Machine::StackTraceElementType);
GcClass* elementType = type(t, GcStackTraceElement::Type);
object array = makeObjectArray(t, elementType, length);
PROTECT(t, array);
@ -764,13 +764,13 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_avian_Classes_isAssignableFrom
(Thread* t, object, uintptr_t* arguments)
{
object this_ = reinterpret_cast<object>(arguments[0]);
object that = reinterpret_cast<object>(arguments[1]);
GcClass* this_ = cast<GcClass>(t, reinterpret_cast<object>(arguments[0]));
GcClass* that = cast<GcClass>(t, reinterpret_cast<object>(arguments[1]));
if (LIKELY(that)) {
return vm::isAssignableFrom(t, this_, that);
} else {
throwNew(t, Machine::NullPointerExceptionType);
throwNew(t, GcNullPointerException::Type);
}
}
@ -792,14 +792,14 @@ Avian_avian_Classes_makeMethod
arguments[1]);
PROTECT(t, method);
object c = resolveClass
GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "java/lang/reflect/Method");
PROTECT(t, c);
object instance = makeNew(t, c);
PROTECT(t, instance);
object constructor = resolveMethod(t, c, "<init>", "(Lavian/VMMethod;)V");
GcMethod* constructor = resolveMethod(t, c, "<init>", "(Lavian/VMMethod;)V");
t->m->processor->invoke(t, constructor, instance, method);
@ -811,7 +811,7 @@ Avian_avian_Classes_makeMethod
object instance = makeNew(t, c);
object constructor = resolveMethod
GcMethod* constructor = resolveMethod
(t, c, "<init>", "(Ljava/lang/Method;)V");
t->m->processor->invoke(t, constructor, instance, method);

File diff suppressed because it is too large Load Diff

View File

@ -223,4 +223,4 @@ void release(Context* c, Resource* resource, Value* value UNUSED, Site* site UNU
} // namespace compiler
} // namespace codegen
} // namespace avian
} // namespace avian

File diff suppressed because it is too large Load Diff

View File

@ -80,7 +80,7 @@ dumpHeap(Thread* t, FILE* out)
local::write1(out, local::Size);
local::write4(out, local::objectSize(t, p));
if (objectClass(t, p) == type(t, Machine::ClassType)) {
if (objectClass(t, p) == type(t, GcClass::Type)) {
object name = className(t, p);
if (name) {
local::write1(out, local::ClassName);

File diff suppressed because it is too large Load Diff

View File

@ -186,9 +186,9 @@ GetStringCritical(Thread* t, jstring s, jboolean* isCopy)
if (isCopy) {
*isCopy = true;
}
object data = stringData(t, *s);
if (objectClass(t, data) == type(t, Machine::ByteArrayType)) {
if (objectClass(t, data) == type(t, GcByteArray::Type)) {
return GetStringChars(t, s, isCopy);
} else {
return &charArrayBody(t, data, stringOffset(t, *s));
@ -198,7 +198,7 @@ GetStringCritical(Thread* t, jstring s, jboolean* isCopy)
void JNICALL
ReleaseStringCritical(Thread* t, jstring s, const jchar* chars)
{
if (objectClass(t, stringData(t, *s)) == type(t, Machine::ByteArrayType)) {
if (objectClass(t, stringData(t, *s)) == type(t, GcByteArray::Type)) {
ReleaseStringChars(t, s, chars);
}
@ -260,7 +260,7 @@ newString(Thread* t, uintptr_t* arguments)
const jchar* chars = reinterpret_cast<const jchar*>(arguments[0]);
jsize size = arguments[1];
object a = makeCharArray(t, size);
object a = reinterpret_cast<object>(makeCharArray(t, size));
if (size) {
memcpy(&charArrayBody(t, a, 0), chars, size * sizeof(jchar));
}
@ -321,11 +321,13 @@ defineClass(Thread* t, uintptr_t* arguments)
const uint8_t* buffer = reinterpret_cast<const uint8_t*>(arguments[1]);
jsize length = arguments[2];
return reinterpret_cast<uint64_t>
(makeLocalReference
(t, getJClass
(t, defineClass
(t, loader ? *loader : root(t, Machine::BootLoader), buffer, length))));
return reinterpret_cast<uint64_t>(makeLocalReference(
t,
getJClass(t,
cast<GcClass>(t, defineClass(t,
loader ? *loader : root(t, Machine::BootLoader),
buffer,
length)))));
}
jclass JNICALL
@ -344,16 +346,15 @@ findClass(Thread* t, uintptr_t* arguments)
{
const char* name = reinterpret_cast<const char*>(arguments[0]);
object n = makeByteArray(t, strlen(name) + 1);
object n = reinterpret_cast<object>(makeByteArray(t, strlen(name) + 1));
replace('.', '/', name, &byteArrayBody(t, n, 0));
object caller = getCaller(t, 0);
GcMethod* caller = getCaller(t, 0);
object c
= resolveClass(t,
caller ? t->m->classpath->libraryClassLoader(t, caller)
: root(t, Machine::AppLoader),
n);
GcClass* c = resolveClass(t,
caller ? t->m->classpath->libraryClassLoader(t, caller)
: root(t, Machine::AppLoader),
n);
if (t->m->classpath->mayInitClasses()) {
PROTECT(t, c);
@ -388,7 +389,7 @@ throwNew(Thread* t, uintptr_t* arguments)
object trace = makeTrace(t);
PROTECT(t, trace);
t->exception = make(t, jclassVmClass(t, *c));
t->exception = make(t, cast<GcClass>(t, jclassVmClass(t, *c)));
set(t, t->exception, ThrowableMessage, m);
set(t, t->exception, ThrowableTrace, trace);
@ -416,7 +417,7 @@ Throw(Thread* t, jthrowable throwable)
}
ENTER(t, Thread::ActiveState);
t->exception = *throwable;
return 0;
@ -424,7 +425,7 @@ Throw(Thread* t, jthrowable throwable)
jobject JNICALL
NewLocalRef(Thread* t, jobject o)
{
{
ENTER(t, Thread::ActiveState);
return makeLocalReference(t, *o);
@ -449,8 +450,8 @@ getObjectClass(Thread* t, uintptr_t* arguments)
{
jobject o = reinterpret_cast<jclass>(arguments[0]);
return reinterpret_cast<uint64_t>
(makeLocalReference(t, getJClass(t, objectClass(t, *o))));
return reinterpret_cast<uint64_t>(makeLocalReference(
t, getJClass(t, objectClass(t, *o))));
}
jclass JNICALL
@ -470,7 +471,7 @@ getSuperclass(Thread* t, uintptr_t* arguments)
} else {
object super = classSuper(t, class_);
return super ? reinterpret_cast<uint64_t>
(makeLocalReference(t, getJClass(t, super))) : 0;
(makeLocalReference(t, getJClass(t, cast<GcClass>(t, super)))) : 0;
}
}
@ -488,7 +489,7 @@ isInstanceOf(Thread* t, uintptr_t* arguments)
jobject o = reinterpret_cast<jobject>(arguments[0]);
jclass c = reinterpret_cast<jclass>(arguments[1]);
return instanceOf(t, jclassVmClass(t, *c), *o);
return instanceOf(t, cast<GcClass>(t, jclassVmClass(t, *c)), *o);
}
jboolean JNICALL
@ -506,7 +507,7 @@ isAssignableFrom(Thread* t, uintptr_t* arguments)
jclass b = reinterpret_cast<jclass>(arguments[0]);
jclass a = reinterpret_cast<jclass>(arguments[1]);
return isAssignableFrom(t, jclassVmClass(t, *a), jclassVmClass(t, *b));
return isAssignableFrom(t, cast<GcClass>(t, jclassVmClass(t, *a)), cast<GcClass>(t, jclassVmClass(t, *b)));
}
jboolean JNICALL
@ -518,20 +519,20 @@ IsAssignableFrom(Thread* t, jclass b, jclass a)
return run(t, isAssignableFrom, arguments);
}
object
GcMethod*
findMethod(Thread* t, jclass c, const char* name, const char* spec)
{
object n = makeByteArray(t, "%s", name);
PROTECT(t, n);
object s = makeByteArray(t, "%s", spec);
return vm::findMethod(t, jclassVmClass(t, *c), n, s);
return vm::findMethod(t, cast<GcClass>(t, jclassVmClass(t, *c)), n, s);
}
jint
methodID(Thread* t, object method)
methodID(Thread* t, GcMethod* method)
{
int id = methodNativeID(t, method);
int id = method->nativeID();
loadMemoryBarrier();
@ -539,19 +540,19 @@ methodID(Thread* t, object method)
PROTECT(t, method);
ACQUIRE(t, t->m->referenceLock);
if (methodNativeID(t, method) == 0) {
if (method->nativeID() == 0) {
setRoot(t, Machine::JNIMethodTable, vectorAppend
(t, root(t, Machine::JNIMethodTable), method));
(t, root(t, Machine::JNIMethodTable), reinterpret_cast<object>(method)));
storeStoreMemoryBarrier();
methodNativeID(t, method) = vectorSize
method->nativeID() = vectorSize
(t, root(t, Machine::JNIMethodTable));
}
}
return methodNativeID(t, method);
return method->nativeID();
}
uint64_t
@ -561,11 +562,11 @@ getMethodID(Thread* t, uintptr_t* arguments)
const char* name = reinterpret_cast<const char*>(arguments[1]);
const char* spec = reinterpret_cast<const char*>(arguments[2]);
object method = findMethod(t, c, name, spec);
GcMethod* method = findMethod(t, c, name, spec);
assert(t, (methodFlags(t, method) & ACC_STATIC) == 0);
assert(t, (method->flags() & ACC_STATIC) == 0);
return methodID(t, method);
return methodID(t, method);
}
jmethodID JNICALL
@ -585,9 +586,9 @@ getStaticMethodID(Thread* t, uintptr_t* arguments)
const char* name = reinterpret_cast<const char*>(arguments[1]);
const char* spec = reinterpret_cast<const char*>(arguments[2]);
object method = findMethod(t, c, name, spec);
GcMethod* method = findMethod(t, c, name, spec);
assert(t, methodFlags(t, method) & ACC_STATIC);
assert(t, method->flags() & ACC_STATIC);
return methodID(t, method);
}
@ -602,14 +603,14 @@ GetStaticMethodID(Thread* t, jclass c, const char* name, const char* spec)
return run(t, getStaticMethodID, arguments);
}
object
GcMethod*
getMethod(Thread* t, jmethodID m)
{
assert(t, m);
object method = vectorBody(t, root(t, Machine::JNIMethodTable), m - 1);
GcMethod* method = cast<GcMethod>(t, vectorBody(t, root(t, Machine::JNIMethodTable), m - 1));
assert(t, (methodFlags(t, method) & ACC_STATIC) == 0);
assert(t, (method->flags() & ACC_STATIC) == 0);
return method;
}
@ -621,7 +622,7 @@ newObjectV(Thread* t, uintptr_t* arguments)
jmethodID m = arguments[1];
va_list* a = reinterpret_cast<va_list*>(arguments[2]);
object o = make(t, jclassVmClass(t, *c));
object o = make(t, cast<GcClass>(t, jclassVmClass(t, *c)));
PROTECT(t, o);
t->m->processor->invokeList(t, getMethod(t, m), o, true, *a);
@ -659,7 +660,7 @@ newObjectA(Thread* t, uintptr_t* arguments)
jmethodID m = arguments[1];
const jvalue* a = reinterpret_cast<const jvalue*>(arguments[2]);
object o = make(t, jclassVmClass(t, *c));
object o = make(t, cast<GcClass>(t, jclassVmClass(t, *c)));
PROTECT(t, o);
t->m->processor->invokeArray(t, getMethod(t, m), o, a);
@ -1097,14 +1098,14 @@ CallVoidMethodA(Thread* t, jobject o, jmethodID m, const jvalue* a)
run(t, callVoidMethodA, arguments);
}
object
GcMethod*
getStaticMethod(Thread* t, jmethodID m)
{
assert(t, m);
object method = vectorBody(t, root(t, Machine::JNIMethodTable), m - 1);
GcMethod* method = cast<GcMethod>(t, vectorBody(t, root(t, Machine::JNIMethodTable), m - 1));
assert(t, methodFlags(t, method) & ACC_STATIC);
assert(t, method->flags() & ACC_STATIC);
return method;
}
@ -1492,7 +1493,7 @@ fieldID(Thread* t, object field)
PROTECT(t, field);
ACQUIRE(t, t->m->referenceLock);
if (fieldNativeID(t, field) == 0) {
setRoot(t, Machine::JNIFieldTable, vectorAppend
(t, root(t, Machine::JNIFieldTable), field));
@ -1513,7 +1514,7 @@ getFieldID(Thread* t, uintptr_t* arguments)
const char* name = reinterpret_cast<const char*>(arguments[1]);
const char* spec = reinterpret_cast<const char*>(arguments[2]);
return fieldID(t, resolveField(t, jclassVmClass(t, *c), name, spec));
return fieldID(t, resolveField(t, cast<GcClass>(t, jclassVmClass(t, *c)), name, spec));
}
jfieldID JNICALL
@ -1744,12 +1745,12 @@ setObjectField(Thread* t, uintptr_t* arguments)
jobject o = reinterpret_cast<jobject>(arguments[0]);
object field = getField(t, arguments[1]);
jobject v = reinterpret_cast<jobject>(arguments[2]);
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
set(t, *o, fieldOffset(t, field), (v ? *v : 0));
return 1;
}
@ -1769,12 +1770,12 @@ setBooleanField(Thread* t, uintptr_t* arguments)
jobject o = reinterpret_cast<jobject>(arguments[0]);
object field = getField(t, arguments[1]);
jboolean v = arguments[2];
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jboolean>(*o, fieldOffset(t, field)) = v;
return 1;
}
@ -1797,9 +1798,9 @@ setByteField(Thread* t, uintptr_t* arguments)
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jbyte>(*o, fieldOffset(t, field)) = v;
return 1;
}
@ -1822,9 +1823,9 @@ setCharField(Thread* t, uintptr_t* arguments)
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jchar>(*o, fieldOffset(t, field)) = v;
return 1;
}
@ -1847,9 +1848,9 @@ setShortField(Thread* t, uintptr_t* arguments)
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jshort>(*o, fieldOffset(t, field)) = v;
return 1;
}
@ -1872,9 +1873,9 @@ setIntField(Thread* t, uintptr_t* arguments)
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jint>(*o, fieldOffset(t, field)) = v;
return 1;
}
@ -1897,9 +1898,9 @@ setLongField(Thread* t, uintptr_t* arguments)
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jlong>(*o, fieldOffset(t, field)) = v;
return 1;
}
@ -1923,9 +1924,9 @@ setFloatField(Thread* t, uintptr_t* arguments)
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jfloat>(*o, fieldOffset(t, field)) = v;
return 1;
}
@ -1948,9 +1949,9 @@ setDoubleField(Thread* t, uintptr_t* arguments)
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jdouble>(*o, fieldOffset(t, field)) = v;
return 1;
}
@ -1982,7 +1983,7 @@ getStaticObjectField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
@ -2009,7 +2010,7 @@ getStaticBooleanField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
@ -2034,7 +2035,7 @@ getStaticByteField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
@ -2059,7 +2060,7 @@ getStaticCharField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
@ -2084,7 +2085,7 @@ getStaticShortField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
@ -2109,7 +2110,7 @@ getStaticIntField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
@ -2134,7 +2135,7 @@ getStaticLongField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
@ -2159,7 +2160,7 @@ getStaticFloatField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
@ -2185,7 +2186,7 @@ getStaticDoubleField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
@ -2211,17 +2212,17 @@ setStaticObjectField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
jobject v = reinterpret_cast<jobject>(arguments[2]);
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
set(t, classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field),
(v ? *v : 0));
return 1;
}
@ -2240,17 +2241,17 @@ setStaticBooleanField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
jboolean v = arguments[2];
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jboolean>
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
return 1;
}
@ -2269,17 +2270,17 @@ setStaticByteField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
jbyte v = arguments[2];
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jbyte>
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
return 1;
}
@ -2298,17 +2299,17 @@ setStaticCharField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
jchar v = arguments[2];
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jchar>
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
return 1;
}
@ -2327,17 +2328,17 @@ setStaticShortField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
jshort v = arguments[2];
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jshort>
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
return 1;
}
@ -2356,17 +2357,17 @@ setStaticIntField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
jint v = arguments[2];
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jint>
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
return 1;
}
@ -2385,17 +2386,17 @@ setStaticLongField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
jlong v; memcpy(&v, arguments + 2, sizeof(jlong));
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jlong>
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
return 1;
}
@ -2415,17 +2416,17 @@ setStaticFloatField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
jfloat v = bitsToFloat(arguments[2]);
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jfloat>
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
return 1;
}
@ -2444,17 +2445,17 @@ setStaticDoubleField(Thread* t, uintptr_t* arguments)
{
jobject c = reinterpret_cast<jobject>(arguments[0]);
initClass(t, jclassVmClass(t, *c));
initClass(t, cast<GcClass>(t, jclassVmClass(t, *c)));
object field = getStaticField(t, arguments[1]);
jdouble v; memcpy(&v, arguments + 2, sizeof(jdouble));
PROTECT(t, field);
ACQUIRE_FIELD_FOR_WRITE(t, field);
fieldAtOffset<jdouble>
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
return 1;
}
@ -2475,7 +2476,7 @@ newGlobalRef(Thread* t, jobject o, bool weak)
ENTER(t, Thread::ActiveState);
ACQUIRE(t, t->m->referenceLock);
if (o) {
for (Reference* r = t->m->jniReferences; r; r = r->next) {
if (r->target == *o and r->weak == weak) {
@ -2508,7 +2509,7 @@ DeleteGlobalRef(Thread* t, jobject r)
ENTER(t, Thread::ActiveState);
ACQUIRE(t, t->m->referenceLock);
if (r) {
release(t, reinterpret_cast<Reference*>(r));
}
@ -2563,7 +2564,7 @@ newObjectArray(Thread* t, uintptr_t* arguments)
jclass class_ = reinterpret_cast<jclass>(arguments[1]);
jobject init = reinterpret_cast<jobject>(arguments[2]);
object a = makeObjectArray(t, jclassVmClass(t, *class_), length);
object a = makeObjectArray(t, cast<GcClass>(t, jclassVmClass(t, *class_)), length);
object value = (init ? *init : 0);
for (jsize i = 0; i < length; ++i) {
set(t, a, ArrayBody + (i * BytesPerWord), value);
@ -2623,7 +2624,7 @@ NewBooleanArray(Thread* t, jsize length)
object
makeByteArray0(Thread* t, unsigned length)
{
return makeByteArray(t, length);
return reinterpret_cast<object>(makeByteArray(t, length));
}
jbyteArray JNICALL
@ -2845,7 +2846,7 @@ ReleaseBooleanArrayElements(Thread* t, jbooleanArray array, jboolean* p,
jint mode)
{
ENTER(t, Thread::ActiveState);
unsigned size = booleanArrayLength(t, *array) * sizeof(jboolean);
if (mode == 0 or mode == AVIAN_JNI_COMMIT) {
@ -2863,7 +2864,7 @@ void JNICALL
ReleaseByteArrayElements(Thread* t, jbyteArray array, jbyte* p, jint mode)
{
ENTER(t, Thread::ActiveState);
unsigned size = byteArrayLength(t, *array) * sizeof(jbyte);
if (mode == 0 or mode == AVIAN_JNI_COMMIT) {
@ -2884,7 +2885,7 @@ ReleaseCharArrayElements(Thread* t, jcharArray array, jchar* p, jint mode)
unsigned size = charArrayLength(t, *array) * sizeof(jchar);
if (mode == 0 or mode == AVIAN_JNI_COMMIT) {
if (mode == 0 or mode == AVIAN_JNI_COMMIT) {
if (size) {
memcpy(&charArrayBody(t, *array, 0), p, size);
}
@ -2898,7 +2899,7 @@ ReleaseCharArrayElements(Thread* t, jcharArray array, jchar* p, jint mode)
void JNICALL
ReleaseShortArrayElements(Thread* t, jshortArray array, jshort* p, jint mode)
{
ENTER(t, Thread::ActiveState);
ENTER(t, Thread::ActiveState);
unsigned size = shortArrayLength(t, *array) * sizeof(jshort);
@ -2917,7 +2918,7 @@ void JNICALL
ReleaseIntArrayElements(Thread* t, jintArray array, jint* p, jint mode)
{
ENTER(t, Thread::ActiveState);
unsigned size = intArrayLength(t, *array) * sizeof(jint);
if (mode == 0 or mode == AVIAN_JNI_COMMIT) {
@ -2935,7 +2936,7 @@ void JNICALL
ReleaseLongArrayElements(Thread* t, jlongArray array, jlong* p, jint mode)
{
ENTER(t, Thread::ActiveState);
unsigned size = longArrayLength(t, *array) * sizeof(jlong);
if (mode == 0 or mode == AVIAN_JNI_COMMIT) {
@ -2953,7 +2954,7 @@ void JNICALL
ReleaseFloatArrayElements(Thread* t, jfloatArray array, jfloat* p, jint mode)
{
ENTER(t, Thread::ActiveState);
unsigned size = floatArrayLength(t, *array) * sizeof(jfloat);
if (mode == 0 or mode == AVIAN_JNI_COMMIT) {
@ -2972,7 +2973,7 @@ ReleaseDoubleArrayElements(Thread* t, jdoubleArray array, jdouble* p,
jint mode)
{
ENTER(t, Thread::ActiveState);
unsigned size = doubleArrayLength(t, *array) * sizeof(jdouble);
if (mode == 0 or mode == AVIAN_JNI_COMMIT) {
@ -3172,7 +3173,7 @@ GetPrimitiveArrayCritical(Thread* t, jarray array, jboolean* isCopy)
}
++ t->criticalLevel;
if (isCopy) {
*isCopy = true;
}
@ -3195,7 +3196,7 @@ fromReflectedMethod(Thread* t, uintptr_t* arguments)
{
jobject m = reinterpret_cast<jobject>(arguments[0]);
return methodID(t, t->m->classpath->getVMMethod(t, *m));
return methodID(t, cast<GcMethod>(t, t->m->classpath->getVMMethod(t, *m)));
}
jmethodID JNICALL
@ -3281,10 +3282,10 @@ registerNatives(Thread* t, uintptr_t* arguments)
const char* sig = methods[i].signature;
if (*sig == '!') ++ sig;
object method = findMethodOrNull
(t, jclassVmClass(t, *c), methods[i].name, sig);
GcMethod* method = findMethodOrNull
(t, cast<GcClass>(t, jclassVmClass(t, *c)), methods[i].name, sig);
if (method == 0 or (methodFlags(t, method) & ACC_NATIVE) == 0) {
if (method == 0 or (method->flags() & ACC_NATIVE) == 0) {
// The JNI spec says we must throw a NoSuchMethodError in this
// case, but that would prevent using a code shrinker like
// ProGuard effectively. Instead, we just ignore it.
@ -3297,7 +3298,7 @@ registerNatives(Thread* t, uintptr_t* arguments)
}
}
return 1;
return 1;
}
jint JNICALL
@ -3328,7 +3329,7 @@ monitorOp(Thread* t, uintptr_t* arguments)
= reinterpret_cast<void (*)(Thread*, object)>(arguments[0]);
jobject o = reinterpret_cast<jobject>(arguments[1]);
op(t, *o);
return 1;
@ -3530,18 +3531,18 @@ uint64_t
boot(Thread* t, uintptr_t*)
{
setRoot(t, Machine::NullPointerException, makeThrowable
(t, Machine::NullPointerExceptionType));
(t, GcNullPointerException::Type));
setRoot(t, Machine::ArithmeticException,
makeThrowable(t, Machine::ArithmeticExceptionType));
makeThrowable(t, GcArithmeticException::Type));
setRoot(t, Machine::ArrayIndexOutOfBoundsException,
makeThrowable(t, Machine::ArrayIndexOutOfBoundsExceptionType));
makeThrowable(t, GcArrayIndexOutOfBoundsException::Type));
setRoot(t, Machine::OutOfMemoryError,
makeThrowable(t, Machine::OutOfMemoryErrorType));
makeThrowable(t, GcOutOfMemoryError::Type));
setRoot(t, Machine::Shutdown, makeThrowable(t, Machine::ThrowableType));
setRoot(t, Machine::Shutdown, makeThrowable(t, GcThrowable::Type));
t->m->classpath->preBoot(t);
@ -3560,7 +3561,7 @@ boot(Thread* t, uintptr_t*)
object host = makeString(t, "0.0.0.0");
PROTECT(t, host);
object method = resolveMethod
GcMethod* method = resolveMethod
(t, root(t, Machine::BootLoader), "avian/Traces", "startTraceListener",
"(Ljava/lang/String;I)V");

File diff suppressed because it is too large Load Diff

View File

@ -67,18 +67,18 @@ mangle(int8_t c, char* dst)
}
unsigned
jniNameLength(Thread* t, object method, bool decorate)
jniNameLength(Thread* t, GcMethod* method, bool decorate)
{
unsigned size = 0;
object className = ::className(t, methodClass(t, method));
object className = ::className(t, method->class_());
for (unsigned i = 0; i < byteArrayLength(t, className) - 1; ++i) {
size += mangledSize(byteArrayBody(t, className, i));
}
++ size;
object methodName = ::methodName(t, method);
object methodName = method->name();
for (unsigned i = 0; i < byteArrayLength(t, methodName) - 1; ++i) {
size += mangledSize(byteArrayBody(t, methodName, i));
}
@ -86,7 +86,7 @@ jniNameLength(Thread* t, object method, bool decorate)
if (decorate) {
size += 2;
object methodSpec = ::methodSpec(t, method);
object methodSpec = method->spec();
for (unsigned i = 1; i < byteArrayLength(t, methodSpec) - 1
and byteArrayBody(t, methodSpec, i) != ')'; ++i)
{
@ -99,19 +99,19 @@ jniNameLength(Thread* t, object method, bool decorate)
void
makeJNIName(Thread* t, const char* prefix, unsigned prefixLength, char* name,
object method, bool decorate)
GcMethod* method, bool decorate)
{
memcpy(name, prefix, prefixLength);
name += prefixLength;
object className = ::className(t, methodClass(t, method));
object className = ::className(t, method->class_());
for (unsigned i = 0; i < byteArrayLength(t, className) - 1; ++i) {
name += mangle(byteArrayBody(t, className, i), name);
}
*(name++) = '_';
object methodName = ::methodName(t, method);
object methodName = method->name();
for (unsigned i = 0; i < byteArrayLength(t, methodName) - 1; ++i) {
name += mangle(byteArrayBody(t, methodName, i), name);
}
@ -120,7 +120,7 @@ makeJNIName(Thread* t, const char* prefix, unsigned prefixLength, char* name,
*(name++) = '_';
*(name++) = '_';
object methodSpec = ::methodSpec(t, method);
object methodSpec = method->spec();
for (unsigned i = 1; i < byteArrayLength(t, methodSpec) - 1
and byteArrayBody(t, methodSpec, i) != ')'; ++i)
{
@ -150,7 +150,7 @@ resolveNativeMethod(Thread* t, const char* undecorated, const char* decorated)
}
void*
resolveNativeMethod(Thread* t, object method, const char* prefix,
resolveNativeMethod(Thread* t, GcMethod* method, const char* prefix,
unsigned prefixLength, int footprint UNUSED)
{
unsigned undecoratedSize = prefixLength + jniNameLength(t, method, false);
@ -175,7 +175,7 @@ resolveNativeMethod(Thread* t, object method, const char* prefix,
// on windows, we also try the _%s@%d and %s@%d variants
if (footprint == -1) {
footprint = methodParameterFootprint(t, method) + 1;
if (methodFlags(t, method) & ACC_STATIC) {
if (method->flags() & ACC_STATIC) {
++ footprint;
}
}
@ -206,16 +206,16 @@ resolveNativeMethod(Thread* t, object method, const char* prefix,
}
object
resolveNativeMethod(Thread* t, object method)
resolveNativeMethod(Thread* t, GcMethod* method)
{
void* p = resolveNativeMethod(t, method, "Avian_", 6, 3);
if (p) {
return makeNative(t, p, true);
return reinterpret_cast<object>(makeNative(t, p, true));
}
p = resolveNativeMethod(t, method, "Java_", 5, -1);
if (p) {
return makeNative(t, p, false);
return reinterpret_cast<object>(makeNative(t, p, false));
}
return 0;
@ -226,21 +226,21 @@ resolveNativeMethod(Thread* t, object method)
namespace vm {
void
resolveNative(Thread* t, object method)
resolveNative(Thread* t, GcMethod* method)
{
PROTECT(t, method);
assert(t, methodFlags(t, method) & ACC_NATIVE);
assert(t, method->flags() & ACC_NATIVE);
initClass(t, methodClass(t, method));
initClass(t, cast<GcClass>(t, method->class_()));
if (methodRuntimeDataNative(t, getMethodRuntimeData(t, method)) == 0) {
object native = resolveNativeMethod(t, method);
if (UNLIKELY(native == 0)) {
throwNew(t, Machine::UnsatisfiedLinkErrorType, "%s.%s%s",
&byteArrayBody(t, className(t, methodClass(t, method)), 0),
&byteArrayBody(t, methodName(t, method), 0),
&byteArrayBody(t, methodSpec(t, method), 0));
throwNew(t, GcUnsatisfiedLinkError::Type, "%s.%s%s",
&byteArrayBody(t, className(t, method->class_()), 0),
&byteArrayBody(t, method->name(), 0),
&byteArrayBody(t, method->spec(), 0));
}
PROTECT(t, native);
@ -256,9 +256,9 @@ resolveNative(Thread* t, object method)
}
int
findLineNumber(Thread* t, object method, unsigned ip)
findLineNumber(Thread* t, GcMethod* method, unsigned ip)
{
if (methodFlags(t, method) & ACC_NATIVE) {
if (method->flags() & ACC_NATIVE) {
return NativeLine;
}
@ -266,7 +266,7 @@ findLineNumber(Thread* t, object method, unsigned ip)
// about, so we back up first:
-- ip;
object code = methodCode(t, method);
object code = method->code();
object lnt = codeLineNumberTable(t, code);
if (lnt) {
unsigned bottom = 0;

View File

@ -176,7 +176,7 @@ endsWith(const char* suffix, const char* s, unsigned length)
}
object
getNonStaticFields(Thread* t, object typeMaps, object c, object fields,
getNonStaticFields(Thread* t, GcHashMap* typeMaps, object c, object fields,
unsigned* count, object* array)
{
PROTECT(t, typeMaps);
@ -210,12 +210,12 @@ getNonStaticFields(Thread* t, object typeMaps, object c, object fields,
}
object
allFields(Thread* t, object typeMaps, object c, unsigned* count, object* array)
allFields(Thread* t, GcHashMap* typeMaps, object c, unsigned* count, object* array)
{
PROTECT(t, typeMaps);
PROTECT(t, c);
object fields = makeVector(t, 0, 0);
object fields = reinterpret_cast<object>(makeVector(t, 0, 0));
PROTECT(t, fields);
*array = hashMapFind(t, typeMaps, c, objectHash, objectEqual);
@ -248,7 +248,7 @@ allFields(Thread* t, object typeMaps, object c, unsigned* count, object* array)
}
TypeMap*
classTypeMap(Thread* t, object typeMaps, object p)
classTypeMap(Thread* t, GcHashMap* typeMaps, object p)
{
return reinterpret_cast<TypeMap*>
(&byteArrayBody
@ -256,18 +256,18 @@ classTypeMap(Thread* t, object typeMaps, object p)
}
TypeMap*
typeMap(Thread* t, object typeMaps, object p)
typeMap(Thread* t, GcHashMap* typeMaps, object p)
{
return reinterpret_cast<TypeMap*>
(&byteArrayBody
(t, objectClass(t, p) == type(t, Machine::SingletonType)
(t, objectClass(t, p) == type(t, GcSingleton::Type)
? hashMapFind(t, typeMaps, p, objectHash, objectEqual)
: hashMapFind(t, typeMaps, objectClass(t, p), objectHash, objectEqual),
: hashMapFind(t, typeMaps, reinterpret_cast<object>(objectClass(t, p)), objectHash, objectEqual),
0));
}
unsigned
targetFieldOffset(Thread* t, object typeMaps, object field)
targetFieldOffset(Thread* t, GcHashMap* typeMaps, object field)
{
// if (strcmp(reinterpret_cast<const char*>
// (&byteArrayBody(t, className(t, fieldClass(t, field)), 0)),
@ -282,7 +282,7 @@ targetFieldOffset(Thread* t, object typeMaps, object field)
object
makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
const char* className, const char* methodName,
const char* methodSpec, object typeMaps)
const char* methodSpec, GcHashMap* typeMaps)
{
PROTECT(t, typeMaps);
@ -301,13 +301,13 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
class MyOffsetResolver: public OffsetResolver {
public:
MyOffsetResolver(object* typeMaps): typeMaps(typeMaps) { }
MyOffsetResolver(GcHashMap** typeMaps): typeMaps(typeMaps) { }
virtual unsigned fieldOffset(Thread* t, object field) {
return targetFieldOffset(t, *typeMaps, field);
}
object* typeMaps;
GcHashMap** typeMaps;
} resolver(&typeMaps);
Finder* finder = static_cast<Finder*>
@ -321,9 +321,9 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
and (className == 0 or strncmp(name, className, nameSize - 6) == 0))
{
// fprintf(stderr, "pass 1 %.*s\n", nameSize - 6, name);
object c = resolveSystemClass
object c = reinterpret_cast<object>(resolveSystemClass
(t, root(t, Machine::BootLoader),
makeByteArray(t, "%.*s", nameSize - 6, name), true);
makeByteArray(t, "%.*s", nameSize - 6, name), true));
PROTECT(t, c);
@ -399,8 +399,8 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
}
}
object array = makeByteArray
(t, TypeMap::sizeInBytes(count + 2, count + 2));
object array = reinterpret_cast<object>(makeByteArray
(t, TypeMap::sizeInBytes(count + 2, count + 2)));
TypeMap* map = new (&byteArrayBody(t, array, 0)) TypeMap
(count + 2, count + 2, count + 2, TypeMap::PoolKind);
@ -417,8 +417,8 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
}
hashMapInsert
(t, typeMaps, hashMapFind
(t, root(t, Machine::PoolMap), c, objectHash, objectEqual), array,
(t, typeMaps, reinterpret_cast<object>(hashMapFind
(t, cast<GcHashMap>(t, root(t, Machine::PoolMap)), c, objectHash, objectEqual)), array,
objectHash);
}
}
@ -548,9 +548,9 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
}
if (hashMapFind(t, typeMaps, c, objectHash, objectEqual) == 0) {
object array = makeByteArray
object array = reinterpret_cast<object>(makeByteArray
(t, TypeMap::sizeInBytes
(ceilingDivide(classFixedSize(t, c), BytesPerWord), memberIndex));
(ceilingDivide(classFixedSize(t, c), BytesPerWord), memberIndex)));
TypeMap* map = new (&byteArrayBody(t, array, 0)) TypeMap
(ceilingDivide(classFixedSize(t, c), BytesPerWord),
@ -571,12 +571,12 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
}
if (classStaticTable(t, c)) {
object array = makeByteArray
object array = reinterpret_cast<object>(makeByteArray
(t, TypeMap::sizeInBytes
(singletonCount(t, classStaticTable(t, c)) + 2, staticIndex));
(singletonCount(t, cast<GcSingleton>(t, classStaticTable(t, c))) + 2, staticIndex)));
TypeMap* map = new (&byteArrayBody(t, array, 0)) TypeMap
(singletonCount(t, classStaticTable(t, c)) + 2,
(singletonCount(t, cast<GcSingleton>(t, classStaticTable(t, c))) + 2,
ceilingDivide(targetStaticOffset, TargetBytesPerWord), staticIndex,
TypeMap::SingletonKind);
@ -606,41 +606,41 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
and (className == 0 or strncmp(name, className, nameSize - 6) == 0))
{
// fprintf(stderr, "pass 2 %.*s\n", nameSize - 6, name);
object c = resolveSystemClass
object c = reinterpret_cast<object>(resolveSystemClass
(t, root(t, Machine::BootLoader),
makeByteArray(t, "%.*s", nameSize - 6, name), true);
makeByteArray(t, "%.*s", nameSize - 6, name), true));
PROTECT(t, c);
if (classMethodTable(t, c)) {
for (unsigned i = 0; i < arrayLength(t, classMethodTable(t, c)); ++i) {
object method = arrayBody(t, classMethodTable(t, c), i);
GcMethod* method = cast<GcMethod>(t, arrayBody(t, classMethodTable(t, c), i));
if (((methodName == 0
or ::strcmp
(reinterpret_cast<char*>
(&byteArrayBody
(t, vm::methodName(t, method), 0)), methodName) == 0)
(t, method->name(), 0)), methodName) == 0)
and (methodSpec == 0
or ::strcmp
(reinterpret_cast<char*>
(&byteArrayBody
(t, vm::methodSpec(t, method), 0)), methodSpec)
(t, method->spec(), 0)), methodSpec)
== 0)))
{
if (methodCode(t, method)
or (methodFlags(t, method) & ACC_NATIVE))
if (method->code()
or (method->flags() & ACC_NATIVE))
{
PROTECT(t, method);
t->m->processor->compileMethod
(t, zone, &constants, &calls, &addresses, method, &resolver);
if (methodCode(t, method)) {
methods = makePair(t, method, methods);
if (method->code()) {
methods = reinterpret_cast<object>(makePair(t, reinterpret_cast<object>(method), methods));
}
}
object addendum = methodAddendum(t, method);
object addendum = method->addendum();
if (addendum and methodAddendumExceptionTable(t, addendum)) {
PROTECT(t, addendum);
@ -653,11 +653,11 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
(t, methodAddendumExceptionTable(t, addendum), i) - 1;
object o = singletonObject
(t, addendumPool(t, addendum), index);
(t, cast<GcSingleton>(t, addendumPool(t, addendum)), index);
if (objectClass(t, o) == type(t, Machine::ReferenceType)) {
o = resolveClass
(t, root(t, Machine::BootLoader), referenceName(t, o));
if (objectClass(t, o) == type(t, GcReference::Type)) {
o = reinterpret_cast<object>(resolveClass
(t, root(t, Machine::BootLoader), referenceName(t, o)));
set(t, addendumPool(t, addendum),
SingletonBody + (index * BytesPerWord), o);
@ -671,12 +671,12 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
}
for (; calls; calls = tripleThird(t, calls)) {
object method = tripleFirst(t, calls);
GcMethod* method = cast<GcMethod>(t, tripleFirst(t, calls));
uintptr_t address;
if (methodFlags(t, method) & ACC_NATIVE) {
if (method->flags() & ACC_NATIVE) {
address = reinterpret_cast<uintptr_t>(code + image->thunks.native.start);
} else {
address = codeCompiled(t, methodCode(t, method));
address = codeCompiled(t, method->code());
}
static_cast<ListenPromise*>(pointerValue(t, tripleSecond(t, calls)))
@ -706,7 +706,7 @@ visitRoots(Thread* t, BootImage* image, HeapWalker* w, object constants)
{
Machine* m = t->m;
for (HashMapIterator it(t, classLoaderMap(t, root(t, Machine::BootLoader)));
for (HashMapIterator it(t, cast<GcHashMap>(t, classLoaderMap(t, root(t, Machine::BootLoader))));
it.hasMore();)
{
w->visitRoot(tripleSecond(t, it.next()));
@ -724,7 +724,7 @@ visitRoots(Thread* t, BootImage* image, HeapWalker* w, object constants)
}
unsigned
targetOffset(Thread* t, object typeMaps, object p, unsigned offset)
targetOffset(Thread* t, GcHashMap* typeMaps, object p, unsigned offset)
{
TypeMap* map = typeMap(t, typeMaps, p);
@ -741,7 +741,7 @@ targetOffset(Thread* t, object typeMaps, object p, unsigned offset)
}
unsigned
targetSize(Thread* t, object typeMaps, object p)
targetSize(Thread* t, GcHashMap* typeMaps, object p)
{
TypeMap* map = typeMap(t, typeMaps, p);
@ -786,11 +786,11 @@ objectMaskCount(TypeMap* map)
}
unsigned
targetSize(Thread* t, object typeMaps, object referer, unsigned refererOffset,
targetSize(Thread* t, GcHashMap* typeMaps, object referer, unsigned refererOffset,
object p)
{
if (referer
and objectClass(t, referer) == type(t, Machine::ClassType)
and objectClass(t, referer) == type(t, GcClass::Type)
and (refererOffset * BytesPerWord) == ClassObjectMask)
{
return (TargetBytesPerWord * 2)
@ -913,7 +913,7 @@ nonObjectsEqual(TypeMap* map, uint8_t* src, uint8_t* dst)
}
void
copy(Thread* t, object typeMaps, object p, uint8_t* dst)
copy(Thread* t, GcHashMap* typeMaps, object p, uint8_t* dst)
{
TypeMap* map = typeMap(t, typeMaps, p);
@ -935,7 +935,7 @@ copy(Thread* t, object typeMaps, object p, uint8_t* dst)
+ (i * map->targetArrayElementSizeInBytes), map->arrayElementType);
}
if (objectClass(t, p) == type(t, Machine::ClassType)) {
if (objectClass(t, p) == type(t, GcClass::Type)) {
uint16_t fixedSize;
uint8_t arrayElementSize;
object array = hashMapFind(t, typeMaps, p, objectHash, objectEqual);
@ -971,7 +971,7 @@ copy(Thread* t, object typeMaps, object p, uint8_t* dst)
} else {
switch (map->kind) {
case TypeMap::NormalKind:
if (objectClass(t, p) == type(t, Machine::FieldType)) {
if (objectClass(t, p) == type(t, GcField::Type)) {
uint16_t offset = targetV2(targetFieldOffset(t, typeMaps, p));
memcpy(dst + TargetFieldOffset, &offset, 2);
}
@ -1066,11 +1066,11 @@ copy(Thread* t, object typeMaps, object p, uint8_t* dst)
}
void
copy(Thread* t, object typeMaps, object referer, unsigned refererOffset,
copy(Thread* t, GcHashMap* typeMaps, object referer, unsigned refererOffset,
object p, uint8_t* dst)
{
if (referer
and objectClass(t, referer) == type(t, Machine::ClassType)
and objectClass(t, referer) == type(t, GcClass::Type)
and (refererOffset * BytesPerWord) == ClassObjectMask)
{
TypeMap* map = classTypeMap(t, typeMaps, referer);
@ -1115,11 +1115,11 @@ copy(Thread* t, object typeMaps, object referer, unsigned refererOffset,
HeapWalker*
makeHeapImage(Thread* t, BootImage* image, target_uintptr_t* heap,
target_uintptr_t* map, unsigned capacity, object constants,
object typeMaps)
GcHashMap* typeMaps)
{
class Visitor: public HeapVisitor {
public:
Visitor(Thread* t, object typeMaps, target_uintptr_t* heap,
Visitor(Thread* t, GcHashMap* typeMaps, target_uintptr_t* heap,
target_uintptr_t* map, unsigned capacity):
t(t), typeMaps(typeMaps), currentObject(0), currentNumber(0),
currentOffset(0), heap(heap), map(map), position(0), capacity(capacity)
@ -1159,9 +1159,9 @@ makeHeapImage(Thread* t, BootImage* image, target_uintptr_t* heap,
unsigned number;
if ((currentObject
and objectClass(t, currentObject) == type(t, Machine::ClassType)
and objectClass(t, currentObject) == type(t, GcClass::Type)
and (currentOffset * BytesPerWord) == ClassStaticTable)
or instanceOf(t, type(t, Machine::SystemClassLoaderType), p))
or instanceOf(t, type(t, GcSystemClassLoader::Type), p))
{
// Static tables and system classloaders must be allocated
// as fixed objects in the heap image so that they can be
@ -1235,7 +1235,7 @@ makeHeapImage(Thread* t, BootImage* image, target_uintptr_t* heap,
}
Thread* t;
object typeMaps;
GcHashMap* typeMaps;
object currentObject;
unsigned currentNumber;
unsigned currentOffset;
@ -1285,7 +1285,7 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
bool useLZMA)
{
setRoot(t, Machine::OutOfMemoryError,
make(t, type(t, Machine::OutOfMemoryErrorType)));
make(t, type(t, GcOutOfMemoryError::Type)));
Zone zone(t->m->system, t->m->heap, 64 * 1024);
@ -1320,14 +1320,14 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
t->m->processor->addCompilationHandler(&compilationHandler);
object classPoolMap;
object typeMaps;
GcHashMap* classPoolMap;
GcHashMap* typeMaps;
object constants;
{ classPoolMap = makeHashMap(t, 0, 0);
PROTECT(t, classPoolMap);
setRoot(t, Machine::PoolMap, classPoolMap);
setRoot(t, Machine::PoolMap, reinterpret_cast<object>(classPoolMap));
typeMaps = makeHashMap(t, 0, 0);
PROTECT(t, typeMaps);
@ -1456,9 +1456,9 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
targetArrayElementSize = 0;
}
object array = makeByteArray
object array = reinterpret_cast<object>(makeByteArray
(t, TypeMap::sizeInBytes
(ceilingDivide(buildOffset, BytesPerWord), fixedFieldCount));
(ceilingDivide(buildOffset, BytesPerWord), fixedFieldCount)));
TypeMap* map = new (&byteArrayBody(t, array, 0)) TypeMap
(ceilingDivide(buildOffset, BytesPerWord),
@ -1478,7 +1478,7 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
}
hashMapInsert
(t, typeMaps, vm::type(t, static_cast<Machine::Type>(i)), array,
(t, typeMaps, reinterpret_cast<object>(vm::type(t, static_cast<Gc::Type>(i))), array,
objectHash);
}
@ -1490,62 +1490,62 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
// these roots will not be used when the bootimage is loaded, so
// there's no need to preserve them:
setRoot(t, Machine::PoolMap, 0);
setRoot(t, Machine::ByteArrayMap, makeWeakHashMap(t, 0, 0));
setRoot(t, Machine::ByteArrayMap, reinterpret_cast<object>(makeWeakHashMap(t, 0, 0)));
// name all primitive classes so we don't try to update immutable
// references at runtime:
{ object name = makeByteArray(t, "void");
set(t, type(t, Machine::JvoidType), ClassName, name);
{ object name = reinterpret_cast<object>(makeByteArray(t, "void"));
set(t, reinterpret_cast<object>(type(t, GcJvoid::Type)), ClassName, name);
name = makeByteArray(t, "boolean");
set(t, type(t, Machine::JbooleanType), ClassName, name);
name = reinterpret_cast<object>(makeByteArray(t, "boolean"));
set(t, reinterpret_cast<object>(type(t, GcJboolean::Type)), ClassName, name);
name = makeByteArray(t, "byte");
set(t, type(t, Machine::JbyteType), ClassName, name);
name = reinterpret_cast<object>(makeByteArray(t, "byte"));
set(t, reinterpret_cast<object>(type(t, GcJbyte::Type)), ClassName, name);
name = makeByteArray(t, "short");
set(t, type(t, Machine::JshortType), ClassName, name);
name = reinterpret_cast<object>(makeByteArray(t, "short"));
set(t, reinterpret_cast<object>(type(t, GcJshort::Type)), ClassName, name);
name = makeByteArray(t, "char");
set(t, type(t, Machine::JcharType), ClassName, name);
name = reinterpret_cast<object>(makeByteArray(t, "char"));
set(t, reinterpret_cast<object>(type(t, GcJchar::Type)), ClassName, name);
name = makeByteArray(t, "int");
set(t, type(t, Machine::JintType), ClassName, name);
name = reinterpret_cast<object>(makeByteArray(t, "int"));
set(t, reinterpret_cast<object>(type(t, GcJint::Type)), ClassName, name);
name = makeByteArray(t, "float");
set(t, type(t, Machine::JfloatType), ClassName, name);
name = reinterpret_cast<object>(makeByteArray(t, "float"));
set(t, reinterpret_cast<object>(type(t, GcJfloat::Type)), ClassName, name);
name = makeByteArray(t, "long");
set(t, type(t, Machine::JlongType), ClassName, name);
name = reinterpret_cast<object>(makeByteArray(t, "long"));
set(t, reinterpret_cast<object>(type(t, GcJlong::Type)), ClassName, name);
name = makeByteArray(t, "double");
set(t, type(t, Machine::JdoubleType), ClassName, name);
name = reinterpret_cast<object>(makeByteArray(t, "double"));
set(t, reinterpret_cast<object>(type(t, GcJdouble::Type)), ClassName, name);
}
// resolve primitive array classes in case they are needed at
// runtime:
{ object name = makeByteArray(t, "[B");
{ object name = reinterpret_cast<object>(makeByteArray(t, "[B"));
resolveSystemClass(t, root(t, Machine::BootLoader), name, true);
name = makeByteArray(t, "[Z");
name = reinterpret_cast<object>(makeByteArray(t, "[Z"));
resolveSystemClass(t, root(t, Machine::BootLoader), name, true);
name = makeByteArray(t, "[S");
name = reinterpret_cast<object>(makeByteArray(t, "[S"));
resolveSystemClass(t, root(t, Machine::BootLoader), name, true);
name = makeByteArray(t, "[C");
name = reinterpret_cast<object>(makeByteArray(t, "[C"));
resolveSystemClass(t, root(t, Machine::BootLoader), name, true);
name = makeByteArray(t, "[I");
name = reinterpret_cast<object>(makeByteArray(t, "[I"));
resolveSystemClass(t, root(t, Machine::BootLoader), name, true);
name = makeByteArray(t, "[J");
name = reinterpret_cast<object>(makeByteArray(t, "[J"));
resolveSystemClass(t, root(t, Machine::BootLoader), name, true);
name = makeByteArray(t, "[F");
name = reinterpret_cast<object>(makeByteArray(t, "[F"));
resolveSystemClass(t, root(t, Machine::BootLoader), name, true);
name = makeByteArray(t, "[D");
name = reinterpret_cast<object>(makeByteArray(t, "[D"));
resolveSystemClass(t, root(t, Machine::BootLoader), name, true);
}
}
@ -1570,7 +1570,7 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
{ unsigned i = 0;
for (HashMapIterator it
(t, classLoaderMap(t, root(t, Machine::BootLoader)));
(t, cast<GcHashMap>(t, classLoaderMap(t, root(t, Machine::BootLoader))));
it.hasMore();)
{
bootClassTable[i++] = targetVW
@ -1586,7 +1586,7 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
{ unsigned i = 0;
for (HashMapIterator it
(t, classLoaderMap(t, root(t, Machine::AppLoader)));
(t, cast<GcHashMap>(t, classLoaderMap(t, root(t, Machine::AppLoader))));
it.hasMore();)
{
appClassTable[i++] = targetVW
@ -1599,7 +1599,7 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
(t->m->heap->allocate(image->stringCount * sizeof(unsigned)));
{ unsigned i = 0;
for (HashMapIterator it(t, root(t, Machine::StringMap)); it.hasMore();) {
for (HashMapIterator it(t, cast<GcHashMap>(t, root(t, Machine::StringMap))); it.hasMore();) {
stringTable[i++] = targetVW
(heapWalker->map()->find
(jreferenceTarget(t, tripleFirst(t, it.next()))));

View File

@ -309,7 +309,7 @@ class Type : public Object {
o->methods.first = o->methods.last = 0;
o->overridesMethods = false;
return o;
}
}
};
const char*
@ -470,7 +470,7 @@ class String : public Object {
String* o = allocate<String>();
o->type = Object::String;
unsigned length = 0;
for (Object* p = s; p; p = cdr(p)) ++ length;
@ -506,7 +506,7 @@ endsWith(char c, const char* s)
{
assert(s);
if (*s == 0) return false;
while (*s) ++ s;
return (*(s - 1) == c);
}
@ -653,7 +653,7 @@ class MemberIterator {
padding_(0),
alignment_(BytesPerWord),
sawSuperclassBoundary(true)
{
{
while (skipSupers and hasMore() and this->type != type) next();
padding_ = 0;
alignment_ = BytesPerWord;
@ -701,7 +701,7 @@ class MemberIterator {
case Object::Scalar: {
size_ = memberSize(member);
padding_ = pad(size_, alignment_);
alignment_ = (alignment_ + size_ + padding_) % 8;
alignment_ = (alignment_ + size_ + padding_) % 8;
} break;
case Object::Array: {
@ -784,7 +784,7 @@ sizeOf(const char* type)
return BytesPerWord;
} else {
fprintf(stderr, "unexpected type: %s\n", type);
abort();
abort();
}
}
@ -980,7 +980,7 @@ parseJavaClass(Object* type, Stream* s, Object* declarations)
s->skip(interfaceCount * 2);
// for (unsigned i = 0; i < interfaceCount; ++i) {
// const char* name = reinterpret_cast<const char*>
// (pool[pool[s->read2() - 1] - 1]);
// (pool[pool[s->read2() - 1] - 1]);
// }
unsigned fieldCount = s->read2();
@ -1037,7 +1037,7 @@ parseJavaClass(Object* type, Stream* s, Object* declarations)
Object* method = Method::make(type, name, spec);
addMethod(type, method);
typeOverridesMethods(type) = true;
}
}
}
}
@ -1220,10 +1220,10 @@ writeAccessor(Output* out, Object* member, Object* offset, bool unsafe = false)
if (memberOwner(member)->type == Object::Type) {
if (not unsafe) {
out->write(" assert(t, t->m->unsafe or ");
out->write("instanceOf(t, arrayBodyUnsafe");
out->write("(t, t->m->types, Machine::");
out->write("instanceOf(t, reinterpret_cast<GcClass*>(arrayBodyUnsafe");
out->write("(t, t->m->types, Gc::");
out->write(capitalize(local::typeName(memberOwner(member))));
out->write("Type)");
out->write("Type))");
out->write(", o));\n");
if (member->type != Object::Scalar) {
@ -1435,9 +1435,9 @@ writeConstructorParameters(Output* out, Object* t)
out->write(" ");
out->write(obfuscate(memberName(m)));
} break;
default: break;
}
}
}
}
@ -1451,9 +1451,9 @@ writeConstructorArguments(Output* out, Object* t)
out->write(", ");
out->write(obfuscate(memberName(m)));
} break;
default: break;
}
}
}
}
@ -1472,7 +1472,59 @@ writeConstructorInitializations(Output* out, Object* t)
} break;
default: break;
}
}
}
}
void writeClassAccessors(Output* out, Object* t)
{
for (MemberIterator it(t); it.hasMore();) {
Object* m = it.next();
switch (m->type) {
case Object::Scalar: {
out->write(" ");
out->write(memberTypeName(m));
out->write("& ");
out->write(obfuscate(memberName(m)));
out->write("() { return field_at<");
out->write(memberTypeName(m));
out->write(">(");
out->write(capitalize(local::typeName(memberOwner(m))));
out->write(capitalize(memberName(m)));
out->write("); }\n");
} break;
default:
break;
}
}
}
void writeClassDeclarations(Output* out, Object* declarations)
{
for (Object* p = declarations; p; p = cdr(p)) {
Object* o = car(p);
switch (o->type) {
case Object::Type: {
out->write("class Gc");
out->write(capitalize(typeName(o)));
out->write(": public GcObject {\n");
out->write(" public:\n");
out->write(" static const Gc::Type Type = Gc::");
out->write(capitalize(typeName(o)));
out->write("Type;\n");
out->write(" static const size_t FixedSize = FixedSizeOf");
out->write(capitalize(typeName(o)));
out->write(";\n\n");
writeClassAccessors(out, o);
out->write("};\n\n");
} break;
default:
break;
}
}
}
@ -1486,7 +1538,7 @@ writeInitializerDeclarations(Output* out, Object* declarations)
out->write("void init");
out->write(capitalize(typeName(o)));
out->write("(Thread* t, object o");
writeConstructorParameters(out, o);
out->write(");\n\n");
@ -1504,10 +1556,12 @@ writeConstructorDeclarations(Output* out, Object* declarations)
Object* o = car(p);
switch (o->type) {
case Object::Type: {
out->write("object make");
out->write("Gc");
out->write(capitalize(typeName(o)));
out->write("* make");
out->write(capitalize(typeName(o)));
out->write("(Thread* t");
writeConstructorParameters(out, o);
out->write(");\n\n");
@ -1528,15 +1582,15 @@ writeInitializers(Output* out, Object* declarations)
out->write("void\ninit");
out->write(capitalize(typeName(o)));
out->write("(Thread* t, object o");
writeConstructorParameters(out, o);
out->write(")\n{\n");
out->write(" setObjectClass(t, o, ");
out->write("arrayBody(t, t->m->types, Machine::");
out->write("reinterpret_cast<GcClass*>(arrayBody(t, t->m->types, Gc::");
out->write(capitalize(typeName(o)));
out->write("Type));\n");
out->write("Type)));\n");
writeConstructorInitializations(out, o);
@ -1555,10 +1609,12 @@ writeConstructors(Output* out, Object* declarations)
Object* o = car(p);
switch (o->type) {
case Object::Type: {
out->write("object make");
out->write("Gc");
out->write(capitalize(typeName(o)));
out->write("* make");
out->write(capitalize(typeName(o)));
out->write("(Thread* t");
writeConstructorParameters(out, o);
out->write(")\n{\n");
@ -1598,7 +1654,9 @@ writeConstructors(Output* out, Object* declarations)
writeConstructorArguments(out, o);
out->write(");\n");
out->write(" return o;\n}\n\n");
out->write(" return reinterpret_cast<Gc");
out->write(capitalize(typeName(o)));
out->write("*>(o);\n}\n\n");
} break;
default: break;
@ -1629,7 +1687,7 @@ writeEnums(Output* out, Object* declarations)
if (wrote) {
out->write("\n");
}
}
}
unsigned
@ -1685,23 +1743,23 @@ typeObjectMask(Object* type)
void
writeInitialization(Output* out, Object* type)
{
out->write("bootClass(t, Machine::");
out->write("bootClass(t, Gc::");
out->write(capitalize(typeName(type)));
out->write("Type, ");
if (typeSuper(type)) {
out->write("Machine::");
out->write("Gc::");
out->write(capitalize(typeName(typeSuper(type))));
out->write("Type");
} else {
out->write("-1");
out->write("-1");
}
out->write(", ");
if (typeObjectMask(type) != 1) {
out->write(typeObjectMask(type));
} else {
out->write("0");
out->write("0");
}
out->write(", ");
@ -1769,16 +1827,16 @@ writeInitializations(Output* out, Object* declarations)
void
writeJavaInitialization(Output* out, Object* type)
{
out->write("bootJavaClass(t, Machine::");
out->write("bootJavaClass(t, Gc::");
out->write(capitalize(typeName(type)));
out->write("Type, ");
if (typeSuper(type)) {
out->write("Machine::");
out->write("Gc::");
out->write(capitalize(typeName(typeSuper(type))));
out->write("Type");
} else {
out->write("-1");
out->write("-1");
}
out->write(", \"");
@ -1807,7 +1865,7 @@ writeJavaInitializations(Output* out, Object* declarations)
void
writeNameInitialization(Output* out, Object* type)
{
out->write("nameClass(t, Machine::");
out->write("nameClass(t, Gc::");
out->write(capitalize(typeName(type)));
out->write("Type, \"");
if (equal(typeName(type), "jbyte")
@ -1820,7 +1878,7 @@ writeNameInitialization(Output* out, Object* type)
or equal(typeName(type), "jdouble")
or equal(typeName(type), "jvoid"))
{
out->write(typeName(type) + 1);
out->write(typeName(type) + 1);
} else {
out->write("vm::");
out->write(typeName(type));
@ -2012,6 +2070,7 @@ int main(int ac, char** av)
local::writeAccessors(&out, declarations);
local::writeSizes(&out, declarations);
local::writeClassDeclarations(&out, declarations);
local::writeInitializerDeclarations(&out, declarations);
local::writeConstructorDeclarations(&out, declarations);
} else if (local::equal(outputType.value, "constructors")) {

View File

@ -93,8 +93,8 @@ cloneTreeNode(Thread* t, object n)
{
PROTECT(t, n);
object newNode = makeTreeNode
(t, getTreeNodeValue(t, n), treeNodeLeft(t, n), treeNodeRight(t, n));
object newNode = reinterpret_cast<object>(makeTreeNode
(t, getTreeNodeValue(t, n), treeNodeLeft(t, n), treeNodeRight(t, n)));
setTreeNodeRed(t, newNode, treeNodeRed(t, n));
return newNode;
}
@ -315,13 +315,13 @@ treeAdd(Thread* t, TreeContext* c)
namespace vm {
object
hashMapFindNode(Thread* t, object map, object key,
hashMapFindNode(Thread* t, GcHashMap* map, object key,
uint32_t (*hash)(Thread*, object),
bool (*equal)(Thread*, object, object))
{
bool weak = objectClass(t, map) == type(t, Machine::WeakHashMapType);
bool weak = objectClass(t, map) == type(t, GcWeakHashMap::Type);
object array = hashMapArray(t, map);
object array = map->array();
if (array) {
unsigned index = hash(t, key) & (arrayLength(t, array) - 1);
for (object n = arrayBody(t, array, index); n; n = tripleThird(t, n)) {
@ -342,7 +342,7 @@ hashMapFindNode(Thread* t, object map, object key,
}
void
hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
hashMapResize(Thread* t, GcHashMap* map, uint32_t (*hash)(Thread*, object),
unsigned size)
{
PROTECT(t, map);
@ -350,7 +350,7 @@ hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
object newArray = 0;
if (size) {
object oldArray = hashMapArray(t, map);
object oldArray = map->array();
PROTECT(t, oldArray);
unsigned newLength = nextPowerOfTwo(size);
@ -358,16 +358,16 @@ hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
return;
}
newArray = makeArray(t, newLength);
newArray = reinterpret_cast<object>(makeArray(t, newLength));
if (oldArray != hashMapArray(t, map)) {
if (oldArray != map->array()) {
// a resize was performed during a GC via the makeArray call
// above; nothing left to do
return;
}
if (oldArray) {
bool weak = objectClass(t, map) == type(t, Machine::WeakHashMapType);
bool weak = objectClass(t, map) == type(t, GcWeakHashMap::Type);
for (unsigned i = 0; i < arrayLength(t, oldArray); ++i) {
object next;
for (object p = arrayBody(t, oldArray, i); p; p = next) {
@ -390,11 +390,11 @@ hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
}
}
set(t, map, HashMapArray, newArray);
set(t, reinterpret_cast<object>(map), HashMapArray, newArray);
}
void
hashMapInsert(Thread* t, object map, object key, object value,
hashMapInsert(Thread* t, GcHashMap* map, object key, object value,
uint32_t (*hash)(Thread*, object))
{
// note that we reinitialize the array variable whenever an
@ -405,19 +405,19 @@ hashMapInsert(Thread* t, object map, object key, object value,
uint32_t h = hash(t, key);
bool weak = objectClass(t, map) == type(t, Machine::WeakHashMapType);
bool weak = objectClass(t, map) == type(t, GcWeakHashMap::Type);
object array = hashMapArray(t, map);
object array = map->array();
++ hashMapSize(t, map);
++ map->size();
if (array == 0 or hashMapSize(t, map) >= arrayLength(t, array) * 2) {
if (array == 0 or map->size() >= arrayLength(t, array) * 2) {
PROTECT(t, key);
PROTECT(t, value);
hashMapResize(t, map, hash, array ? arrayLength(t, array) * 2 : 16);
array = hashMapArray(t, map);
array = map->array();
}
object k = key;
@ -426,25 +426,25 @@ hashMapInsert(Thread* t, object map, object key, object value,
PROTECT(t, key);
PROTECT(t, value);
object r = makeWeakReference(t, 0, 0, 0, 0);
object r = reinterpret_cast<object>(makeWeakReference(t, 0, 0, 0, 0));
jreferenceTarget(t, r) = key;
jreferenceVmNext(t, r) = t->m->weakReferences;
t->m->weakReferences = r;
k = r;
array = hashMapArray(t, map);
array = map->array();
}
object n = makeTriple(t, k, value, 0);
object n = reinterpret_cast<object>(makeTriple(t, k, value, 0));
array = hashMapArray(t, map);
array = map->array();
unsigned index = h & (arrayLength(t, array) - 1);
set(t, n, TripleThird, arrayBody(t, array, index));
set(t, array, ArrayBody + (index * BytesPerWord), n);
if (hashMapSize(t, map) <= arrayLength(t, array) / 3) {
if (map->size() <= arrayLength(t, array) / 3) {
// this might happen if nodes were removed during GC in which case
// we weren't able to resize at the time
hashMapResize(t, map, hash, arrayLength(t, array) / 2);
@ -452,26 +452,26 @@ hashMapInsert(Thread* t, object map, object key, object value,
}
object
hashMapRemoveNode(Thread* t, object map, unsigned index, object p, object n)
hashMapRemoveNode(Thread* t, GcHashMap* map, unsigned index, object p, object n)
{
if (p) {
set(t, p, TripleThird, tripleThird(t, n));
} else {
set(t, hashMapArray(t, map), ArrayBody + (index * BytesPerWord),
set(t, map->array(), ArrayBody + (index * BytesPerWord),
tripleThird(t, n));
}
-- hashMapSize(t, map);
-- map->size();
return n;
}
object
hashMapRemove(Thread* t, object map, object key,
hashMapRemove(Thread* t, GcHashMap* map, object key,
uint32_t (*hash)(Thread*, object),
bool (*equal)(Thread*, object, object))
{
bool weak = objectClass(t, map) == type(t, Machine::WeakHashMapType);
bool weak = objectClass(t, map) == type(t, GcWeakHashMap::Type);
object array = hashMapArray(t, map);
object array = map->array();
object o = 0;
if (array) {
unsigned index = hash(t, key) & (arrayLength(t, array) - 1);
@ -496,7 +496,7 @@ hashMapRemove(Thread* t, object map, object key,
}
if ((not t->m->collecting)
and hashMapSize(t, map) <= arrayLength(t, array) / 3)
and map->size() <= arrayLength(t, array) / 3)
{
PROTECT(t, o);
hashMapResize(t, map, hash, arrayLength(t, array) / 2);
@ -513,7 +513,7 @@ listAppend(Thread* t, object list, object value)
++ listSize(t, list);
object p = makePair(t, value, 0);
object p = reinterpret_cast<object>(makePair(t, value, 0));
if (listFront(t, list)) {
set(t, listRear(t, list), PairSecond, p);
} else {
@ -529,8 +529,8 @@ vectorAppend(Thread* t, object vector, object value)
PROTECT(t, vector);
PROTECT(t, value);
object newVector = makeVector
(t, vectorSize(t, vector), max(16, vectorSize(t, vector) * 2));
object newVector = reinterpret_cast<object>(makeVector
(t, vectorSize(t, vector), max(16, vectorSize(t, vector) * 2)));
if (vectorSize(t, vector)) {
memcpy(&vectorBody(t, newVector, 0),
@ -551,8 +551,8 @@ growArray(Thread* t, object array)
{
PROTECT(t, array);
object newArray = makeArray
(t, array == 0 ? 16 : (arrayLength(t, array) * 2));
object newArray = reinterpret_cast<object>(makeArray
(t, array == 0 ? 16 : (arrayLength(t, array) * 2)));
if (array) {
memcpy(&arrayBody(t, newArray, 0), &arrayBody(t, array, 0),
@ -578,7 +578,7 @@ treeInsert(Thread* t, Zone* zone, object tree, intptr_t key, object value,
PROTECT(t, tree);
PROTECT(t, sentinal);
object node = makeTreeNode(t, value, sentinal, sentinal);
object node = reinterpret_cast<object>(makeTreeNode(t, value, sentinal, sentinal));
TreeContext c(t, zone);
treeFind(t, &c, tree, key, node, sentinal, compare);