formalize Machine::roots in types.def

This commit is contained in:
Joshua Warner 2014-06-29 19:44:41 -06:00
parent 75f2dd013c
commit 052f2498aa
12 changed files with 436 additions and 372 deletions

View File

@ -642,7 +642,7 @@ getFinder(Thread* t, const char* name, unsigned nameLength)
{ {
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
for (GcFinder* p = cast<GcFinder>(t, root(t, Machine::VirtualFileFinders)); for (GcFinder* p = roots(t)->virtualFileFinders();
p; p = p->next()) p; p = p->next())
{ {
if (p->name()->length() == nameLength if (p->name()->length() == nameLength
@ -669,9 +669,9 @@ getFinder(Thread* t, const char* name, unsigned nameLength)
if (data) { if (data) {
Finder* f = makeFinder(t->m->system, t->m->heap, data, size); Finder* f = makeFinder(t->m->system, t->m->heap, data, size);
GcFinder* finder = makeFinder GcFinder* finder = makeFinder
(t, f, n, cast<GcFinder>(t, root(t, Machine::VirtualFileFinders))); (t, f, n, roots(t)->virtualFileFinders());
setRoot(t, Machine::VirtualFileFinders, reinterpret_cast<object>(finder)); set(t, roots(t), RootsVirtualFileFinders, finder);
return f; return f;
} }

View File

@ -1211,6 +1211,7 @@ class GcClassLoader;
class GcJreference; class GcJreference;
class GcArray; class GcArray;
class GcThrowable; class GcThrowable;
class GcRoots;
class Machine { class Machine {
public: public:
@ -1221,38 +1222,6 @@ class Machine {
ImmortalAllocation ImmortalAllocation
}; };
enum Root {
BootLoader,
AppLoader,
BootstrapClassMap,
PackageMap,
FindLoadedClassMethod,
LoadClassMethod,
MonitorMap,
StringMap,
ByteArrayMap,
PoolMap,
ClassRuntimeDataTable,
MethodRuntimeDataTable,
JNIMethodTable,
JNIFieldTable,
ShutdownHooks,
FinalizerThread,
ObjectsToFinalize,
ObjectsToClean,
NullPointerException,
ArithmeticException,
ArrayIndexOutOfBoundsException,
OutOfMemoryError,
Shutdown,
VirtualFileFinders,
VirtualFiles,
ArrayInterfaceTable,
ThreadTerminated
};
static const unsigned RootCount = ThreadTerminated + 1;
Machine(System* system, Heap* heap, Finder* bootFinder, Finder* appFinder, Machine(System* system, Heap* heap, Finder* bootFinder, Finder* appFinder,
Processor* processor, Classpath* classpath, const char** properties, Processor* processor, Classpath* classpath, const char** properties,
unsigned propertyCount, const char** arguments, unsigned propertyCount, const char** arguments,
@ -1296,7 +1265,7 @@ class Machine {
FILE* errorLog; FILE* errorLog;
BootImage* bootimage; BootImage* bootimage;
GcArray* types; GcArray* types;
GcArray* roots; GcRoots* roots;
GcFinalizer* finalizers; GcFinalizer* finalizers;
GcFinalizer* tenuredFinalizers; GcFinalizer* tenuredFinalizers;
GcFinalizer* finalizeQueue; GcFinalizer* finalizeQueue;
@ -1340,8 +1309,8 @@ run(Thread* t, uint64_t (*function)(Thread*, uintptr_t*),
void void
checkDaemon(Thread* t); checkDaemon(Thread* t);
object& GcRoots*
root(Thread* t, Machine::Root root); roots(Thread* t);
extern "C" uint64_t extern "C" uint64_t
vmRun(uint64_t (*function)(Thread*, uintptr_t*), uintptr_t* arguments, vmRun(uint64_t (*function)(Thread*, uintptr_t*), uintptr_t* arguments,
@ -1524,17 +1493,7 @@ class Thread {
t->systemThread = st; t->systemThread = st;
} }
virtual void run() { virtual void run();
enterActiveState(t);
vm::run(t, runThread, 0);
if (t->exception and reinterpret_cast<object>(t->exception) != root(t, Machine::Shutdown)) {
printTrace(t, t->exception);
}
t->exit();
}
virtual bool interrupted(); virtual bool interrupted();
@ -2011,6 +1970,18 @@ arrayBodyUnsafe(Thread*, GcArray* a, unsigned index)
return a->body()[index]; return a->body()[index];
} }
inline void Thread::Runnable::run() {
enterActiveState(t);
vm::run(t, runThread, 0);
if (t->exception and t->exception != roots(t)->shutdownInProgress()) {
printTrace(t, t->exception);
}
t->exit();
}
inline bool Thread::Runnable::interrupted() { inline bool Thread::Runnable::interrupted() {
return t->javaThread and t->javaThread->interrupted(); return t->javaThread and t->javaThread->interrupted();
} }
@ -2194,16 +2165,10 @@ attachThread(Machine* m, bool daemon)
} }
} }
inline object& inline GcRoots*
root(Thread* t, Machine::Root root) roots(Thread* t)
{ {
return t->m->roots->body()[root]; return t->m->roots;
}
inline void
setRoot(Thread* t, Machine::Root root, object value)
{
set(t, reinterpret_cast<object>(t->m->roots), ArrayBody + (root * BytesPerWord), value);
} }
inline GcClass* inline GcClass*
@ -3392,7 +3357,7 @@ wait(Thread* t, object o, int64_t milliseconds)
t->m->classpath->clearInterrupted(t); t->m->classpath->clearInterrupted(t);
throwNew(t, GcInterruptedException::Type); throwNew(t, GcInterruptedException::Type);
} else { } else {
throw_(t, cast<GcThrowable>(t, root(t, Machine::Shutdown))); throw_(t, roots(t)->shutdownInProgress());
} }
} }
} else { } else {
@ -3471,7 +3436,7 @@ inline bool
exceptionMatch(Thread* t, GcClass* type, GcThrowable* exception) exceptionMatch(Thread* t, GcClass* type, GcThrowable* exception)
{ {
return type == 0 return type == 0
or (reinterpret_cast<object>(exception) != root(t, Machine::Shutdown) or (exception != roots(t)->shutdownInProgress()
and instanceOf(t, type, reinterpret_cast<object>(t->exception))); and instanceOf(t, type, reinterpret_cast<object>(t->exception)));
} }
@ -3847,7 +3812,9 @@ inline GcClassRuntimeData*
getClassRuntimeDataIfExists(Thread* t, GcClass* c) getClassRuntimeDataIfExists(Thread* t, GcClass* c)
{ {
if (c->runtimeDataIndex()) { if (c->runtimeDataIndex()) {
return cast<GcClassRuntimeData>(t, cast<GcVector>(t, root(t, Machine::ClassRuntimeDataTable))->body()[c->runtimeDataIndex() - 1]); return cast<GcClassRuntimeData>(
t,
roots(t)->classRuntimeDataTable()->body()[c->runtimeDataIndex() - 1]);
} else { } else {
return 0; return 0;
} }
@ -3864,16 +3831,20 @@ getClassRuntimeData(Thread* t, GcClass* c)
if (c->runtimeDataIndex() == 0) { if (c->runtimeDataIndex() == 0) {
object runtimeData = reinterpret_cast<object>(makeClassRuntimeData(t, 0, 0, 0, 0)); object runtimeData = reinterpret_cast<object>(makeClassRuntimeData(t, 0, 0, 0, 0));
setRoot(t, Machine::ClassRuntimeDataTable, reinterpret_cast<object>(vectorAppend {
(t, cast<GcVector>(t, root(t, Machine::ClassRuntimeDataTable)), runtimeData))); GcVector* v
= vectorAppend(t, roots(t)->classRuntimeDataTable(), runtimeData);
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsClassRuntimeDataTable, v);
}
c->runtimeDataIndex() = cast<GcVector>(t, root(t, Machine::ClassRuntimeDataTable))->size(); c->runtimeDataIndex() = roots(t)->classRuntimeDataTable()->size();
} }
} }
return cast<GcClassRuntimeData>( return cast<GcClassRuntimeData>(
t, t,
cast<GcVector>(t, root(t, Machine::ClassRuntimeDataTable)) roots(t)->classRuntimeDataTable()
->body()[c->runtimeDataIndex() - 1]); ->body()[c->runtimeDataIndex() - 1]);
} }
@ -3892,18 +3863,22 @@ getMethodRuntimeData(Thread* t, GcMethod* method)
if (method->runtimeDataIndex() == 0) { if (method->runtimeDataIndex() == 0) {
object runtimeData = reinterpret_cast<object>(makeMethodRuntimeData(t, 0)); object runtimeData = reinterpret_cast<object>(makeMethodRuntimeData(t, 0));
setRoot(t, Machine::MethodRuntimeDataTable, reinterpret_cast<object>(vectorAppend {
(t, cast<GcVector>(t, root(t, Machine::MethodRuntimeDataTable)), runtimeData))); GcVector* v
= vectorAppend(t, roots(t)->methodRuntimeDataTable(), runtimeData);
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsMethodRuntimeDataTable, v);
}
storeStoreMemoryBarrier(); storeStoreMemoryBarrier();
method->runtimeDataIndex() = cast<GcVector>(t, root(t, Machine::MethodRuntimeDataTable))->size(); method->runtimeDataIndex() = roots(t)->methodRuntimeDataTable()->size();
} }
} }
return cast<GcMethodRuntimeData>( return cast<GcMethodRuntimeData>(
t, t,
cast<GcVector>(t, root(t, Machine::MethodRuntimeDataTable)) roots(t)->methodRuntimeDataTable()
->body()[method->runtimeDataIndex() - 1]); ->body()[method->runtimeDataIndex() - 1]);
} }

View File

@ -255,7 +255,7 @@ Avian_avian_SystemClassLoader_getPackageSource
GcByteArray* key = makeByteArray(t, RUNTIME_ARRAY_BODY(chars)); GcByteArray* key = makeByteArray(t, RUNTIME_ARRAY_BODY(chars));
GcByteArray* array = cast<GcByteArray>(t, hashMapFind GcByteArray* array = cast<GcByteArray>(t, hashMapFind
(t, cast<GcHashMap>(t, root(t, Machine::PackageMap)), reinterpret_cast<object>(key), byteArrayHash, byteArrayEqual)); (t, roots(t)->packageMap(), reinterpret_cast<object>(key), byteArrayHash, byteArrayEqual));
if (array) { if (array) {
return reinterpret_cast<uintptr_t>(makeLocalReference( return reinterpret_cast<uintptr_t>(makeLocalReference(

View File

@ -81,7 +81,7 @@ finalizeAllEnqueued(Thread*, object, uintptr_t*)
int64_t JNICALL int64_t JNICALL
appLoader(Thread* t, object, uintptr_t*) appLoader(Thread* t, object, uintptr_t*)
{ {
return reinterpret_cast<uintptr_t>(root(t, Machine::AppLoader)); return reinterpret_cast<uintptr_t>(roots(t)->appLoader());
} }
int64_t JNICALL int64_t JNICALL
@ -177,7 +177,7 @@ void initVmThread(Thread* t, GcThread* thread, unsigned offset)
if (fieldAtOffset<object>(thread, offset) == 0) { if (fieldAtOffset<object>(thread, offset) == 0) {
GcClass* c = resolveClass GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/VMThread"); (t, roots(t)->bootLoader(), "java/lang/VMThread");
PROTECT(t, c); PROTECT(t, c);
object instance = makeNew(t, c); object instance = makeNew(t, c);
@ -213,7 +213,7 @@ translateStackTrace(Thread* t, object raw)
object array = makeObjectArray object array = makeObjectArray
(t, resolveClass (t, resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/StackTraceElement"), (t, roots(t)->bootLoader(), "java/lang/StackTraceElement"),
objectArrayLength(t, raw)); objectArrayLength(t, raw));
PROTECT(t, array); PROTECT(t, array);
@ -278,7 +278,7 @@ class MyClasspath : public Classpath {
group = parent->javaThread->group(); group = parent->javaThread->group();
} else { } else {
resolveSystemClass resolveSystemClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), (t, roots(t)->bootLoader(),
type(t, GcThreadGroup::Type)->name(), false); type(t, GcThreadGroup::Type)->name(), false);
group = cast<GcThreadGroup>(t, makeNew(t, type(t, GcThreadGroup::Type))); group = cast<GcThreadGroup>(t, makeNew(t, type(t, GcThreadGroup::Type)));
@ -290,7 +290,7 @@ class MyClasspath : public Classpath {
} }
resolveSystemClass resolveSystemClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), (t, roots(t)->bootLoader(),
type(t, GcThread::Type)->name(), false); type(t, GcThread::Type)->name(), false);
GcThread* thread = cast<GcThread>(t, makeNew(t, type(t, GcThread::Type))); GcThread* thread = cast<GcThread>(t, makeNew(t, type(t, GcThread::Type)));
@ -303,7 +303,7 @@ class MyClasspath : public Classpath {
t->m->processor->invoke t->m->processor->invoke
(t, constructor, reinterpret_cast<object>(thread), group, 0, NormalPriority, false); (t, constructor, reinterpret_cast<object>(thread), group, 0, NormalPriority, false);
set(t, reinterpret_cast<object>(thread), ThreadContextClassLoader, root(t, Machine::AppLoader)); set(t, thread, ThreadContextClassLoader, roots(t)->appLoader());
initVmThread(t, thread); initVmThread(t, thread);
@ -392,7 +392,7 @@ class MyClasspath : public Classpath {
initVmThread(t, t->javaThread, offset); initVmThread(t, t->javaThread, offset);
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/Thread", "run", "()V"); (t, roots(t)->bootLoader(), "java/lang/Thread", "run", "()V");
t->m->processor->invoke(t, method, reinterpret_cast<object>(t->javaThread)); t->m->processor->invoke(t, method, reinterpret_cast<object>(t->javaThread));
} }
@ -407,7 +407,7 @@ class MyClasspath : public Classpath {
interceptMethods(Thread* t, bool updateRuntimeData) interceptMethods(Thread* t, bool updateRuntimeData)
{ {
{ GcClass* c = resolveClass { GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/Runtime", false); (t, roots(t)->bootLoader(), "java/lang/Runtime", false);
if (c) { if (c) {
PROTECT(t, c); PROTECT(t, c);
@ -419,7 +419,7 @@ class MyClasspath : public Classpath {
} }
{ GcClass* c = resolveClass { GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/ref/FinalizerReference", (t, roots(t)->bootLoader(), "java/lang/ref/FinalizerReference",
false); false);
if (c) { if (c) {
@ -431,7 +431,7 @@ class MyClasspath : public Classpath {
} }
{ GcClass* c = resolveClass { GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/ClassLoader", false); (t, roots(t)->bootLoader(), "java/lang/ClassLoader", false);
if (c) { if (c) {
PROTECT(t, c); PROTECT(t, c);
@ -446,7 +446,7 @@ class MyClasspath : public Classpath {
} }
{ GcClass* c = resolveClass { GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "libcore/util/ZoneInfoDB", false); (t, roots(t)->bootLoader(), "libcore/util/ZoneInfoDB", false);
if (c) { if (c) {
PROTECT(t, c); PROTECT(t, c);
@ -457,7 +457,7 @@ class MyClasspath : public Classpath {
} }
{ GcClass* c = resolveClass { GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "libcore/io/MemoryMappedFile", (t, roots(t)->bootLoader(), "libcore/io/MemoryMappedFile",
false); false);
if (c) { if (c) {
@ -504,7 +504,7 @@ class MyClasspath : public Classpath {
boot(Thread* t) boot(Thread* t)
{ {
GcClass* c = resolveClass GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/ClassLoader"); (t, roots(t)->bootLoader(), "java/lang/ClassLoader");
PROTECT(t, c); PROTECT(t, c);
GcMethod* constructor = resolveMethod GcMethod* constructor = resolveMethod
@ -512,11 +512,11 @@ class MyClasspath : public Classpath {
PROTECT(t, constructor); PROTECT(t, constructor);
t->m->processor->invoke t->m->processor->invoke
(t, constructor, root(t, Machine::BootLoader), 0, true); (t, constructor, reinterpret_cast<object>(roots(t)->bootLoader()), 0, true);
t->m->processor->invoke t->m->processor->invoke
(t, constructor, root(t, Machine::AppLoader), (t, constructor, reinterpret_cast<object>(roots(t)->appLoader()),
root(t, Machine::BootLoader), false); roots(t)->bootLoader(), false);
} }
virtual const char* virtual const char*
@ -529,7 +529,7 @@ class MyClasspath : public Classpath {
makeDirectByteBuffer(Thread* t, void* p, jlong capacity) makeDirectByteBuffer(Thread* t, void* p, jlong capacity)
{ {
GcClass* c = resolveClass GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/nio/DirectByteBuffer"); (t, roots(t)->bootLoader(), "java/nio/DirectByteBuffer");
PROTECT(t, c); PROTECT(t, c);
object instance = makeNew(t, c); object instance = makeNew(t, c);
@ -602,7 +602,7 @@ int64_t JNICALL
mapData(Thread* t, object, uintptr_t*) mapData(Thread* t, object, uintptr_t*)
{ {
GcClass* c = resolveClass GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "libcore/io/MemoryMappedFile"); (t, roots(t)->bootLoader(), "libcore/io/MemoryMappedFile");
PROTECT(t, c); PROTECT(t, c);
object instance = makeNew(t, c); object instance = makeNew(t, c);
@ -1219,7 +1219,7 @@ Avian_java_lang_Class_classForName
PROTECT(t, loader); PROTECT(t, loader);
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "forName", (t, roots(t)->bootLoader(), "avian/Classes", "forName",
"(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;"); "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;");
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
@ -1238,7 +1238,7 @@ Avian_java_lang_Class_getDeclaredField
PROTECT(t, name); PROTECT(t, name);
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "findField", (t, roots(t)->bootLoader(), "avian/Classes", "findField",
"(Lavian/VMClass;Ljava/lang/String;)I"); "(Lavian/VMClass;Ljava/lang/String;)I");
int index = cast<GcInt> int index = cast<GcInt>
@ -1266,7 +1266,7 @@ Avian_java_lang_Class_getDeclaredConstructorOrMethod
PROTECT(t, parameterTypes); PROTECT(t, parameterTypes);
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "findMethod", (t, roots(t)->bootLoader(), "avian/Classes", "findMethod",
"(Lavian/VMClass;Ljava/lang/String;[Ljava/lang/Class;)I"); "(Lavian/VMClass;Ljava/lang/String;[Ljava/lang/Class;)I");
int index = cast<GcInt> int index = cast<GcInt>
@ -1321,14 +1321,14 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_dalvik_system_VMRuntime_bootClassPath Avian_dalvik_system_VMRuntime_bootClassPath
(Thread* t, object, uintptr_t*) (Thread* t, object, uintptr_t*)
{ {
return reinterpret_cast<uintptr_t>(root(t, Machine::BootLoader)); return reinterpret_cast<uintptr_t>(roots(t)->bootLoader());
} }
extern "C" AVIAN_EXPORT int64_t JNICALL extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_dalvik_system_VMRuntime_classPath Avian_dalvik_system_VMRuntime_classPath
(Thread* t, object, uintptr_t*) (Thread* t, object, uintptr_t*)
{ {
return reinterpret_cast<uintptr_t>(root(t, Machine::AppLoader)); return reinterpret_cast<uintptr_t>(roots(t)->appLoader());
} }
extern "C" AVIAN_EXPORT int64_t JNICALL extern "C" AVIAN_EXPORT int64_t JNICALL
@ -1823,7 +1823,7 @@ Avian_java_lang_Class_getDeclaredMethods
bool publicOnly = arguments[1]; bool publicOnly = arguments[1];
GcMethod* get = resolveMethod GcMethod* get = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "getMethods", (t, roots(t)->bootLoader(), "avian/Classes", "getMethods",
"(Lavian/VMClass;Z)[Ljava/lang/reflect/Method;"); "(Lavian/VMClass;Z)[Ljava/lang/reflect/Method;");
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
@ -1840,7 +1840,7 @@ Avian_java_lang_Class_getDeclaredFields
bool publicOnly = arguments[1]; bool publicOnly = arguments[1];
GcMethod* get = resolveMethod GcMethod* get = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "getFields", (t, roots(t)->bootLoader(), "avian/Classes", "getFields",
"(Lavian/VMClass;Z)[Ljava/lang/reflect/Field;"); "(Lavian/VMClass;Z)[Ljava/lang/reflect/Field;");
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
@ -1915,7 +1915,7 @@ Avian_java_lang_reflect_Method_getAnnotation
PROTECT(t, table); PROTECT(t, table);
GcMethod* get = resolveMethod GcMethod* get = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "getAnnotation", (t, roots(t)->bootLoader(), "avian/Classes", "getAnnotation",
"(Ljava/lang/ClassLoader;[Ljava/lang/Object;)" "(Ljava/lang/ClassLoader;[Ljava/lang/Object;)"
"Ljava/lang/annotation/Annotation;"); "Ljava/lang/annotation/Annotation;");
@ -1948,12 +1948,12 @@ Avian_java_lang_reflect_Method_getDeclaredAnnotations
object array = makeObjectArray object array = makeObjectArray
(t, resolveClass (t, resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/annotation/Annotation"), (t, roots(t)->bootLoader(), "java/lang/annotation/Annotation"),
objectArrayLength(t, table)); objectArrayLength(t, table));
PROTECT(t, array); PROTECT(t, array);
GcMethod* get = resolveMethod GcMethod* get = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "getAnnotation", (t, roots(t)->bootLoader(), "avian/Classes", "getAnnotation",
"(Ljava/lang/ClassLoader;[Ljava/lang/Object;)" "(Ljava/lang/ClassLoader;[Ljava/lang/Object;)"
"Ljava/lang/annotation/Annotation;"); "Ljava/lang/annotation/Annotation;");
PROTECT(t, get); PROTECT(t, get);
@ -1973,7 +1973,7 @@ Avian_java_lang_reflect_Method_getDeclaredAnnotations
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
(makeObjectArray (makeObjectArray
(t, resolveClass (t, resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/annotation/Annotation"), (t, roots(t)->bootLoader(), "java/lang/annotation/Annotation"),
0)); 0));
} }
@ -1997,13 +1997,13 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
object array object array
= makeObjectArray(t, = makeObjectArray(t,
resolveClass(t, resolveClass(t,
cast<GcClassLoader>(t, root(t, Machine::BootLoader)), roots(t)->bootLoader(),
"java/lang/annotation/Annotation"), "java/lang/annotation/Annotation"),
objectArrayLength(t, table)); objectArrayLength(t, table));
PROTECT(t, array); PROTECT(t, array);
GcMethod* get = resolveMethod(t, GcMethod* get = resolveMethod(t,
cast<GcClassLoader>(t, root(t, Machine::BootLoader)), roots(t)->bootLoader(),
"avian/Classes", "avian/Classes",
"getAnnotation", "getAnnotation",
"(Ljava/lang/ClassLoader;[Ljava/lang/Object;)" "(Ljava/lang/ClassLoader;[Ljava/lang/Object;)"
@ -2028,7 +2028,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
return reinterpret_cast<uintptr_t>(makeObjectArray( return reinterpret_cast<uintptr_t>(makeObjectArray(
t, t,
resolveClass( resolveClass(
t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/annotation/Annotation"), t, roots(t)->bootLoader(), "java/lang/annotation/Annotation"),
0)); 0));
} }
@ -2043,7 +2043,7 @@ Avian_java_lang_reflect_Method_getDefaultValue
GcMethodAddendum* addendum = method->addendum(); GcMethodAddendum* addendum = method->addendum();
if (addendum) { if (addendum) {
GcMethod* get = resolveMethod GcMethod* get = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", (t, roots(t)->bootLoader(), "avian/Classes",
"getAnnotationDefaultValue", "getAnnotationDefaultValue",
"(Ljava/lang/ClassLoader;Lavian/MethodAddendum;)" "(Ljava/lang/ClassLoader;Lavian/MethodAddendum;)"
"Ljava/lang/Object;"); "Ljava/lang/Object;");
@ -2192,7 +2192,7 @@ Avian_java_lang_reflect_Field_getAnnotation
PROTECT(t, table); PROTECT(t, table);
GcMethod* get = resolveMethod GcMethod* get = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "getAnnotation", (t, roots(t)->bootLoader(), "avian/Classes", "getAnnotation",
"(Ljava/lang/ClassLoader;[Ljava/lang/Object;)" "(Ljava/lang/ClassLoader;[Ljava/lang/Object;)"
"Ljava/lang/annotation/Annotation;"); "Ljava/lang/annotation/Annotation;");
@ -2473,7 +2473,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_libcore_io_Posix_uname(Thread* t, object, uintptr_t*) Avian_libcore_io_Posix_uname(Thread* t, object, uintptr_t*)
{ {
GcClass* c = resolveClass GcClass* c = resolveClass
(t, root(t, Machine::BootLoader), "libcore/io/StructUtsname"); (t, roots(t)->bootLoader(), "libcore/io/StructUtsname");
PROTECT(t, c); PROTECT(t, c);
object instance = makeNew(t, c); object instance = makeNew(t, c);

View File

@ -53,7 +53,7 @@ class MyClasspath : public Classpath {
return vm::makeThread return vm::makeThread
(t, 0, 0, 0, 0, 0, NewState, NormalPriority, 0, 0, 0, (t, 0, 0, 0, 0, 0, NewState, NormalPriority, 0, 0, 0,
cast<GcClassLoader>(t, root(t, Machine::AppLoader)), 0, 0, group, 0); roots(t)->appLoader(), 0, 0, group, 0);
} }
virtual object virtual object
@ -97,7 +97,7 @@ class MyClasspath : public Classpath {
runThread(Thread* t) runThread(Thread* t)
{ {
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/Thread", "run", (t, roots(t)->bootLoader(), "java/lang/Thread", "run",
"(Ljava/lang/Thread;)V"); "(Ljava/lang/Thread;)V");
t->m->processor->invoke(t, method, 0, t->javaThread); t->m->processor->invoke(t, method, 0, t->javaThread);
@ -142,7 +142,7 @@ class MyClasspath : public Classpath {
makeDirectByteBuffer(Thread* t, void* p, jlong capacity) makeDirectByteBuffer(Thread* t, void* p, jlong capacity)
{ {
GcClass* c = resolveClass GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/nio/DirectByteBuffer"); (t, roots(t)->bootLoader(), "java/nio/DirectByteBuffer");
PROTECT(t, c); PROTECT(t, c);
object instance = makeNew(t, c); object instance = makeNew(t, c);
@ -618,8 +618,8 @@ Avian_java_lang_Runtime_addShutdownHook
ACQUIRE(t, t->m->shutdownLock); ACQUIRE(t, t->m->shutdownLock);
setRoot(t, Machine::ShutdownHooks, GcPair* p = makePair(t, hook, reinterpret_cast<object>(roots(t)->shutdownHooks()));
reinterpret_cast<object>(makePair(t, hook, root(t, Machine::ShutdownHooks)))); set(t, roots(t), RootsShutdownHooks, p);
} }
extern "C" AVIAN_EXPORT int64_t JNICALL extern "C" AVIAN_EXPORT int64_t JNICALL
@ -793,7 +793,7 @@ Avian_avian_Classes_makeMethod
PROTECT(t, method); PROTECT(t, method);
GcClass* c = resolveClass GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/reflect/Method"); (t, roots(t)->bootLoader(), "java/lang/reflect/Method");
PROTECT(t, c); PROTECT(t, c);
object instance = makeNew(t, c); object instance = makeNew(t, c);
@ -807,7 +807,7 @@ Avian_avian_Classes_makeMethod
object oldInstance = instance; object oldInstance = instance;
c = resolveClass c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/reflect/Constructor"); (t, roots(t)->bootLoader(), "java/lang/reflect/Constructor");
object instance = makeNew(t, c); object instance = makeNew(t, c);

View File

@ -560,7 +560,7 @@ class MyClasspath : public Classpath {
thread->group() = group; thread->group() = group;
// TODO: use set / write barrier? // TODO: use set / write barrier?
thread->contextClassLoader() = cast<GcClassLoader>(t, root(t, Machine::AppLoader)); thread->contextClassLoader() = roots(t)->appLoader();
PROTECT(t, thread); PROTECT(t, thread);
@ -649,14 +649,14 @@ class MyClasspath : public Classpath {
t->exception = 0; t->exception = 0;
t->m->processor->invoke t->m->processor->invoke
(t, cast<GcMethod>(t, root(t, Machine::ThreadTerminated)), (t, cast<GcMethod>(t, roots(t)->threadTerminated()),
reinterpret_cast<object>(t->javaThread->group()), t->javaThread); reinterpret_cast<object>(t->javaThread->group()), t->javaThread);
t->exception = e; t->exception = e;
}); });
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/Thread", "run", "()V"); (t, roots(t)->bootLoader(), "java/lang/Thread", "run", "()V");
t->m->processor->invoke(t, method, reinterpret_cast<object>(t->javaThread)); t->m->processor->invoke(t, method, reinterpret_cast<object>(t->javaThread));
} }
@ -703,12 +703,14 @@ class MyClasspath : public Classpath {
{ {
globalMachine = t->m; globalMachine = t->m;
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), resolveSystemClass(t, roots(t)->bootLoader(),
type(t, GcClassLoader::Type)->name()); type(t, GcClassLoader::Type)->name());
setRoot(t, Machine::ThreadTerminated, reinterpret_cast<object>(resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/ThreadGroup", (t, roots(t)->bootLoader(), "java/lang/ThreadGroup",
"threadTerminated", "(Ljava/lang/Thread;)V"))); "threadTerminated", "(Ljava/lang/Thread;)V");
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsThreadTerminated, method);
#ifdef AVIAN_OPENJDK_SRC #ifdef AVIAN_OPENJDK_SRC
interceptFileOperations(t, true); interceptFileOperations(t, true);
@ -721,12 +723,12 @@ class MyClasspath : public Classpath {
(t, type(t, GcClassLoader::Type), "assertionLock", (t, type(t, GcClassLoader::Type), "assertionLock",
"Ljava/lang/Object;"); "Ljava/lang/Object;");
set(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), assertionLock->offset(), set(t, roots(t)->bootLoader(), assertionLock->offset(),
cast<GcClassLoader>(t, root(t, Machine::BootLoader))); roots(t)->bootLoader());
} }
{ GcClass* class_ = resolveClass { GcClass* class_ = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/util/Properties", true, (t, roots(t)->bootLoader(), "java/util/Properties", true,
GcNoClassDefFoundError::Type); GcNoClassDefFoundError::Type);
PROTECT(t, class_); PROTECT(t, class_);
@ -740,7 +742,7 @@ class MyClasspath : public Classpath {
t->m->processor->invoke(t, constructor, instance); t->m->processor->invoke(t, constructor, instance);
t->m->processor->invoke t->m->processor->invoke
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/System", (t, roots(t)->bootLoader(), "java/lang/System",
"setProperties", "(Ljava/util/Properties;)V", 0, instance); "setProperties", "(Ljava/util/Properties;)V", 0, instance);
} }
@ -750,11 +752,11 @@ class MyClasspath : public Classpath {
PROTECT(t, constructor); PROTECT(t, constructor);
t->m->processor->invoke(t, constructor, root(t, Machine::BootLoader), 0); t->m->processor->invoke(t, constructor, reinterpret_cast<object>(roots(t)->bootLoader()), 0);
t->m->processor->invoke t->m->processor->invoke
(t, constructor, root(t, Machine::AppLoader), (t, constructor, reinterpret_cast<object>(roots(t)->appLoader()),
cast<GcClassLoader>(t, root(t, Machine::BootLoader))); roots(t)->bootLoader());
} }
{ GcField* scl = resolveField { GcField* scl = resolveField
@ -766,23 +768,23 @@ class MyClasspath : public Classpath {
GcField* sclSet = resolveField GcField* sclSet = resolveField
(t, type(t, GcClassLoader::Type), "sclSet", "Z"); (t, type(t, GcClassLoader::Type), "sclSet", "Z");
set(t, reinterpret_cast<object>(type(t, GcClassLoader::Type)->staticTable()), set(t, type(t, GcClassLoader::Type)->staticTable(),
scl->offset(), root(t, Machine::AppLoader)); scl->offset(), roots(t)->appLoader());
fieldAtOffset<uint8_t>(type(t, GcClassLoader::Type)->staticTable(), fieldAtOffset<uint8_t>(type(t, GcClassLoader::Type)->staticTable(),
sclSet->offset()) = true; sclSet->offset()) = true;
} }
t->m->processor->invoke t->m->processor->invoke
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/System", (t, roots(t)->bootLoader(), "java/lang/System",
"initializeSystemClass", "()V", 0); "initializeSystemClass", "()V", 0);
t->m->processor->invoke t->m->processor->invoke
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "sun/misc/Launcher", (t, roots(t)->bootLoader(), "sun/misc/Launcher",
"getLauncher", "()Lsun/misc/Launcher;", 0); "getLauncher", "()Lsun/misc/Launcher;", 0);
set(t, reinterpret_cast<object>(t->javaThread), ThreadContextClassLoader, set(t, t->javaThread, ThreadContextClassLoader,
root(t, Machine::AppLoader)); roots(t)->appLoader());
} }
virtual const char* virtual const char*
@ -795,7 +797,7 @@ class MyClasspath : public Classpath {
makeDirectByteBuffer(Thread* t, void* p, jlong capacity) makeDirectByteBuffer(Thread* t, void* p, jlong capacity)
{ {
GcClass* c = resolveClass GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/nio/DirectByteBuffer"); (t, roots(t)->bootLoader(), "java/nio/DirectByteBuffer");
PROTECT(t, c); PROTECT(t, c);
object instance = makeNew(t, c); object instance = makeNew(t, c);
@ -884,7 +886,7 @@ class MyClasspath : public Classpath {
shutDown(Thread* t) shutDown(Thread* t)
{ {
GcClass* c = resolveClass GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/Shutdown", false); (t, roots(t)->bootLoader(), "java/lang/Shutdown", false);
if (c) { if (c) {
GcMethod* m = findMethodOrNull(t, c, "shutdown", "()V"); GcMethod* m = findMethodOrNull(t, c, "shutdown", "()V");
@ -1168,24 +1170,24 @@ openFile(Thread* t, object method, uintptr_t* arguments)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
int index = -1; int index = -1;
unsigned oldLength = root(t, Machine::VirtualFiles) unsigned oldLength = roots(t)->virtualFiles()
? arrayLength(t, root(t, Machine::VirtualFiles)) : 0; ? arrayLength(t, roots(t)->virtualFiles()) : 0;
for (unsigned i = 0; i < oldLength; ++i) { for (unsigned i = 0; i < oldLength; ++i) {
if (arrayBody(t, root(t, Machine::VirtualFiles), i) == 0) { if (arrayBody(t, roots(t)->virtualFiles(), i) == 0) {
index = i; index = i;
break; break;
} }
} }
if (index == -1) { if (index == -1) {
object newArray = growArray(t, root(t, Machine::VirtualFiles)); object newArray = growArray(t, roots(t)->virtualFiles());
setRoot(t, Machine::VirtualFiles, newArray); setRoot(t, Machine::VirtualFiles, newArray);
index = oldLength; index = oldLength;
} }
object region = makeRegion(t, r, 0); object region = makeRegion(t, r, 0);
set(t, root(t, Machine::VirtualFiles), ArrayBody + (index * BytesPerWord), set(t, roots(t)->virtualFiles(), ArrayBody + (index * BytesPerWord),
region); region);
fieldAtOffset<int32_t> fieldAtOffset<int32_t>
@ -1215,7 +1217,7 @@ readByteFromFile(Thread* t, object method, uintptr_t* arguments)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
object region = arrayBody object region = arrayBody
(t, root(t, Machine::VirtualFiles), fd - VirtualFileBase); (t, roots(t)->virtualFiles(), fd - VirtualFileBase);
if (region) { if (region) {
System::Region* r = static_cast<System::Region*> System::Region* r = static_cast<System::Region*>
@ -1258,7 +1260,7 @@ readBytesFromFile(Thread* t, object method, uintptr_t* arguments)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
object region = arrayBody object region = arrayBody
(t, root(t, Machine::VirtualFiles), fd - VirtualFileBase); (t, roots(t)->virtualFiles(), fd - VirtualFileBase);
if (region) { if (region) {
System::Region* r = static_cast<System::Region*> System::Region* r = static_cast<System::Region*>
@ -1308,7 +1310,7 @@ skipBytesInFile(Thread* t, object method, uintptr_t* arguments)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
object region = arrayBody object region = arrayBody
(t, root(t, Machine::VirtualFiles), fd - VirtualFileBase); (t, roots(t)->virtualFiles(), fd - VirtualFileBase);
if (region) { if (region) {
System::Region* r = static_cast<System::Region*> System::Region* r = static_cast<System::Region*>
@ -1349,7 +1351,7 @@ availableBytesInFile(Thread* t, object method, uintptr_t* arguments)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
object region = arrayBody object region = arrayBody
(t, root(t, Machine::VirtualFiles), fd - VirtualFileBase); (t, roots(t)->virtualFiles(), fd - VirtualFileBase);
if (region) { if (region) {
return static_cast<System::Region*>(regionRegion(t, region))->length() return static_cast<System::Region*>(regionRegion(t, region))->length()
@ -1382,13 +1384,13 @@ closeFile(Thread* t, object method, uintptr_t* arguments)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
int index = fd - VirtualFileBase; int index = fd - VirtualFileBase;
object region = arrayBody(t, root(t, Machine::VirtualFiles), index); object region = arrayBody(t, roots(t)->virtualFiles(), index);
if (region) { if (region) {
static_cast<System::Region*>(regionRegion(t, region))->dispose(); static_cast<System::Region*>(regionRegion(t, region))->dispose();
} }
set(t, root(t, Machine::VirtualFiles), ArrayBody + (index * BytesPerWord), set(t, roots(t)->virtualFiles(), ArrayBody + (index * BytesPerWord),
0); 0);
} else { } else {
t->m->processor->invoke t->m->processor->invoke
@ -1848,7 +1850,7 @@ getBootstrapResource(Thread* t, object, uintptr_t* arguments)
if (m) { if (m) {
return reinterpret_cast<int64_t> return reinterpret_cast<int64_t>
(t->m->processor->invoke(t, m, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name)); (t->m->processor->invoke(t, m, roots(t)->bootLoader(), name));
} else { } else {
return 0; return 0;
} }
@ -1866,7 +1868,7 @@ getBootstrapResources(Thread* t, object, uintptr_t* arguments)
if (m) { if (m) {
return reinterpret_cast<int64_t> return reinterpret_cast<int64_t>
(t->m->processor->invoke(t, m, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name)); (t->m->processor->invoke(t, m, roots(t)->bootLoader(), name));
} else { } else {
return 0; return 0;
} }
@ -1944,7 +1946,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData)
MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath); MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
{ object fileClass = resolveClass { object fileClass = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/io/File", false); (t, roots(t)->bootLoader(), "java/io/File", false);
if (fileClass) { if (fileClass) {
object filePathField = findFieldInClass2 object filePathField = findFieldInClass2
@ -1957,7 +1959,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData)
} }
{ object fileDescriptorClass = resolveClass { object fileDescriptorClass = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/io/FileDescriptor", false); (t, roots(t)->bootLoader(), "java/io/FileDescriptor", false);
if (fileDescriptorClass) { if (fileDescriptorClass) {
object fileDescriptorFdField = findFieldInClass2 object fileDescriptorFdField = findFieldInClass2
@ -1970,7 +1972,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData)
} }
{ object fileInputStreamClass = resolveClass { object fileInputStreamClass = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/io/FileInputStream", false); (t, roots(t)->bootLoader(), "java/io/FileInputStream", false);
if (fileInputStreamClass) { if (fileInputStreamClass) {
PROTECT(t, fileInputStreamClass); PROTECT(t, fileInputStreamClass);
@ -2008,7 +2010,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData)
} }
{ object zipFileClass = resolveClass { object zipFileClass = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/util/zip/ZipFile", false); (t, roots(t)->bootLoader(), "java/util/zip/ZipFile", false);
if (zipFileClass) { if (zipFileClass) {
PROTECT(t, zipFileClass); PROTECT(t, zipFileClass);
@ -2061,7 +2063,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData)
} }
{ object jarFileClass = resolveClass { object jarFileClass = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/util/jar/JarFile", false); (t, roots(t)->bootLoader(), "java/util/jar/JarFile", false);
if (jarFileClass) { if (jarFileClass) {
intercept(t, jarFileClass, "getMetaInfEntryNames", intercept(t, jarFileClass, "getMetaInfEntryNames",
@ -2080,7 +2082,7 @@ interceptFileOperations(Thread* t, bool updateRuntimeData)
#endif #endif
object fsClass = resolveClass object fsClass = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), fsClassName, false); (t, roots(t)->bootLoader(), fsClassName, false);
if (fsClass) { if (fsClass) {
PROTECT(t, fsClass); PROTECT(t, fsClass);
@ -2550,7 +2552,7 @@ Avian_sun_misc_Perf_createLong
return reinterpret_cast<int64_t> return reinterpret_cast<int64_t>
(t->m->processor->invoke (t->m->processor->invoke
(t, resolveMethod (t, resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/nio/ByteBuffer", "allocate", (t, roots(t)->bootLoader(), "java/nio/ByteBuffer", "allocate",
"(I)Ljava/nio/ByteBuffer;"), 0, 8)); "(I)Ljava/nio/ByteBuffer;"), 0, 8));
} }
@ -2956,7 +2958,7 @@ jvmInitProperties(Thread* t, uintptr_t* arguments)
jobject properties = reinterpret_cast<jobject>(arguments[0]); jobject properties = reinterpret_cast<jobject>(arguments[0]);
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/util/Properties", "setProperty", (t, roots(t)->bootLoader(), "java/util/Properties", "setProperty",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;"); "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;");
PROTECT(t, method); PROTECT(t, method);
@ -3024,7 +3026,7 @@ jvmInitProperties(Thread* t, uintptr_t* arguments)
local::setProperty local::setProperty
(t, method, *properties, "sun.boot.class.path", (t, method, *properties, "sun.boot.class.path",
static_cast<Finder*> static_cast<Finder*>
(cast<GcSystemClassLoader>(t, root(t, Machine::BootLoader))->finder())->path()); (roots(t)->bootLoader()->as<GcSystemClassLoader>(t)->finder())->path());
local::setProperty(t, method, *properties, "file.encoding", "UTF-8"); local::setProperty(t, method, *properties, "file.encoding", "UTF-8");
#ifdef ARCH_x86_32 #ifdef ARCH_x86_32
@ -3526,7 +3528,7 @@ jvmGetSystemPackage(Thread* t, uintptr_t* arguments)
object key = reinterpret_cast<object>(makeByteArray(t, RUNTIME_ARRAY_BODY(chars))); object key = reinterpret_cast<object>(makeByteArray(t, RUNTIME_ARRAY_BODY(chars)));
GcByteArray* array = cast<GcByteArray>(t, hashMapFind GcByteArray* array = cast<GcByteArray>(t, hashMapFind
(t, cast<GcHashMap>(t, root(t, Machine::PackageMap)), key, byteArrayHash, byteArrayEqual)); (t, roots(t)->packageMap(), key, byteArrayHash, byteArrayEqual));
if (array) { if (array) {
return reinterpret_cast<uintptr_t> return reinterpret_cast<uintptr_t>
@ -3554,7 +3556,7 @@ jvmGetSystemPackages(Thread* t, uintptr_t*)
makeObjectArray( makeObjectArray(
t, t,
resolveClass( resolveClass(
t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/Package"), t, roots(t)->bootLoader(), "java/lang/Package"),
0))); 0)));
} }
@ -3586,7 +3588,7 @@ EXPORT(JVM_LatestUserDefinedLoader)(Thread* t)
virtual bool visit(Processor::StackWalker* walker) { virtual bool visit(Processor::StackWalker* walker) {
GcClassLoader* loader = walker->method()->class_()->loader(); GcClassLoader* loader = walker->method()->class_()->loader();
if (loader if (loader
and loader != cast<GcClassLoader>(t, root(t, Machine::BootLoader)) and loader != roots(t)->bootLoader()
and strcmp and strcmp
(objectClass(t, loader)->name()->body().begin(), (objectClass(t, loader)->name()->body().begin(),
reinterpret_cast<const int8_t*> reinterpret_cast<const int8_t*>
@ -3865,7 +3867,7 @@ jvmResolveClass(Thread* t, uintptr_t* arguments)
jclass c = reinterpret_cast<jclass>(arguments[0]); jclass c = reinterpret_cast<jclass>(arguments[0]);
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "link", (t, roots(t)->bootLoader(), "avian/Classes", "link",
"(Lavian/VMClass;)V"); "(Lavian/VMClass;)V");
t->m->processor->invoke(t, method, 0, (*c)->vmClass()); t->m->processor->invoke(t, method, 0, (*c)->vmClass());
@ -3890,7 +3892,7 @@ jvmFindClassFromClassLoader(Thread* t, uintptr_t* arguments)
jboolean throwError = arguments[3]; jboolean throwError = arguments[3];
GcClass* c = resolveClass GcClass* c = resolveClass
(t, cast<GcClassLoader>(t, loader ? *loader : root(t, Machine::BootLoader)), name, true, (t, loader ? cast<GcClassLoader>(t, *loader) : roots(t)->bootLoader(), name, true,
throwError ? static_cast<Gc::Type>(GcNoClassDefFoundError::Type) throwError ? static_cast<Gc::Type>(GcNoClassDefFoundError::Type)
: static_cast<Gc::Type>(GcClassNotFoundException::Type)); : static_cast<Gc::Type>(GcClassNotFoundException::Type));
@ -4046,7 +4048,7 @@ EXPORT(JVM_GetClassLoader)(Thread* t, jclass c)
GcClassLoader* loader = (*c)->vmClass()->loader(); GcClassLoader* loader = (*c)->vmClass()->loader();
if (loader == cast<GcClassLoader>(t, root(t, Machine::BootLoader))) { if (loader == roots(t)->bootLoader()) {
// sun.misc.Unsafe.getUnsafe expects a null result if the class // sun.misc.Unsafe.getUnsafe expects a null result if the class
// loader is the boot classloader and will throw a // loader is the boot classloader and will throw a
// SecurityException otherwise. // SecurityException otherwise.
@ -4058,7 +4060,7 @@ EXPORT(JVM_GetClassLoader)(Thread* t, jclass c)
{ {
return 0; return 0;
} else { } else {
return makeLocalReference(t, root(t, Machine::BootLoader)); return makeLocalReference(t, reinterpret_cast<object>(roots(t)->bootLoader()));
} }
} else { } else {
return makeLocalReference(t, reinterpret_cast<object>(loader)); return makeLocalReference(t, reinterpret_cast<object>(loader));
@ -4118,7 +4120,7 @@ jvmGetProtectionDomain(Thread* t, uintptr_t* arguments)
jclass c = reinterpret_cast<jclass>(arguments[0]); jclass c = reinterpret_cast<jclass>(arguments[0]);
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Classes", "getProtectionDomain", (t, roots(t)->bootLoader(), "avian/Classes", "getProtectionDomain",
"(Lavian/VMClass;)Ljava/security/ProtectionDomain;"); "(Lavian/VMClass;)Ljava/security/ProtectionDomain;");
return reinterpret_cast<uint64_t> return reinterpret_cast<uint64_t>
@ -4631,7 +4633,7 @@ maybeWrap(Thread* t, bool wrapException)
PROTECT(t, exception); PROTECT(t, exception);
GcClass* paeClass = resolveClass GcClass* paeClass = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), (t, roots(t)->bootLoader(),
"java/security/PrivilegedActionException"); "java/security/PrivilegedActionException");
PROTECT(t, paeClass); PROTECT(t, paeClass);
@ -4658,7 +4660,7 @@ jvmDoPrivileged(Thread* t, uintptr_t* arguments)
// object: // object:
GcClass* privilegedAction = resolveClass GcClass* privilegedAction = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/security/PrivilegedAction"); (t, roots(t)->bootLoader(), "java/security/PrivilegedAction");
GcMethod* method; GcMethod* method;
if (instanceOf(t, privilegedAction, *action)) { if (instanceOf(t, privilegedAction, *action)) {
@ -4666,7 +4668,7 @@ jvmDoPrivileged(Thread* t, uintptr_t* arguments)
(t, privilegedAction, "run", "()Ljava/lang/Object;"); (t, privilegedAction, "run", "()Ljava/lang/Object;");
} else { } else {
GcClass* privilegedExceptionAction = resolveClass GcClass* privilegedExceptionAction = resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), (t, roots(t)->bootLoader(),
"java/security/PrivilegedExceptionAction"); "java/security/PrivilegedExceptionAction");
method = resolveMethod method = resolveMethod
@ -5196,7 +5198,7 @@ getMemoryManagers(Thread* t, uintptr_t*)
t, t,
makeObjectArray(t, makeObjectArray(t,
resolveClass(t, resolveClass(t,
cast<GcClassLoader>(t, root(t, Machine::BootLoader)), roots(t)->bootLoader(),
"java/lang/management/MemoryManagerMXBean"), "java/lang/management/MemoryManagerMXBean"),
0))); 0)));
} }
@ -5214,7 +5216,7 @@ getMemoryPools(Thread* t, uintptr_t*)
t, t,
makeObjectArray(t, makeObjectArray(t,
resolveClass(t, resolveClass(t,
cast<GcClassLoader>(t, root(t, Machine::BootLoader)), roots(t)->bootLoader(),
"java/lang/management/MemoryPoolMXBean"), "java/lang/management/MemoryPoolMXBean"),
0))); 0)));
} }

View File

@ -336,7 +336,7 @@ resolveTarget(MyThread* t, void* stack, GcMethod* method)
PROTECT(t, method); PROTECT(t, method);
PROTECT(t, class_); PROTECT(t, class_);
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), class_->name()); resolveSystemClass(t, roots(t)->bootLoader(), class_->name());
} }
if (method->class_()->flags() & ACC_INTERFACE) { if (method->class_()->flags() & ACC_INTERFACE) {
@ -352,7 +352,7 @@ resolveTarget(MyThread* t, GcClass* class_, unsigned index)
if (class_->vmFlags() & BootstrapFlag) { if (class_->vmFlags() & BootstrapFlag) {
PROTECT(t, class_); PROTECT(t, class_);
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), class_->name()); resolveSystemClass(t, roots(t)->bootLoader(), class_->name());
} }
return cast<GcMethod>(t, cast<GcArray>(t, class_->virtualTable())->body()[index]); return cast<GcMethod>(t, cast<GcArray>(t, class_->virtualTable())->body()[index]);
@ -2460,7 +2460,7 @@ throwArithmetic(MyThread* t)
} else { } else {
// not enough memory available for a new exception and stack trace // not enough memory available for a new exception and stack trace
// -- use a preallocated instance instead // -- use a preallocated instance instead
throw_(t, cast<GcThrowable>(t, root(t, Machine::ArithmeticException))); throw_(t, roots(t)->arithmeticException());
} }
} }
@ -2671,7 +2671,7 @@ throwArrayIndexOutOfBounds(MyThread* t)
} else { } else {
// not enough memory available for a new exception and stack trace // not enough memory available for a new exception and stack trace
// -- use a preallocated instance instead // -- use a preallocated instance instead
throw_(t, cast<GcThrowable>(t, root(t, Machine::ArrayIndexOutOfBoundsException))); throw_(t, roots(t)->arrayIndexOutOfBoundsException());
} }
} }
@ -7726,7 +7726,7 @@ callContinuation(MyThread* t, GcContinuation* continuation, object result,
PROTECT(t, nextContinuation); PROTECT(t, nextContinuation);
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Continuations", "rewind", (t, roots(t)->bootLoader(), "avian/Continuations", "rewind",
"(Ljava/lang/Runnable;Lavian/Callback;Ljava/lang/Object;" "(Ljava/lang/Runnable;Lavian/Callback;Ljava/lang/Object;"
"Ljava/lang/Throwable;)V"); "Ljava/lang/Throwable;)V");
@ -7786,7 +7786,7 @@ callWithCurrentContinuation(MyThread* t, object receiver)
if (root(t, ReceiveMethod) == 0) { if (root(t, ReceiveMethod) == 0) {
GcMethod* m = resolveMethod GcMethod* m = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Function", "call", (t, roots(t)->bootLoader(), "avian/Function", "call",
"(Ljava/lang/Object;)Ljava/lang/Object;"); "(Ljava/lang/Object;)Ljava/lang/Object;");
if (m) { if (m) {
@ -7796,7 +7796,7 @@ callWithCurrentContinuation(MyThread* t, object receiver)
if (continuationClass->vmFlags() & BootstrapFlag) { if (continuationClass->vmFlags() & BootstrapFlag) {
resolveSystemClass( resolveSystemClass(
t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), continuationClass->name()); t, roots(t)->bootLoader(), continuationClass->name());
} }
} }
} }
@ -7825,7 +7825,7 @@ dynamicWind(MyThread* t, object before, object thunk, object after)
if (root(t, WindMethod) == 0) { if (root(t, WindMethod) == 0) {
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Continuations", "wind", (t, roots(t)->bootLoader(), "avian/Continuations", "wind",
"(Ljava/lang/Runnable;Ljava/util/concurrent/Callable;" "(Ljava/lang/Runnable;Ljava/util/concurrent/Callable;"
"Ljava/lang/Runnable;)Lavian/Continuations$UnwindResult;"); "Ljava/lang/Runnable;)Lavian/Continuations$UnwindResult;");
@ -8032,7 +8032,7 @@ invoke(Thread* thread, GcMethod* method, ArgumentList* arguments)
compile(t, local::codeAllocator(static_cast<MyThread*>(t)), 0, compile(t, local::codeAllocator(static_cast<MyThread*>(t)), 0,
resolveMethod resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::AppLoader)), (t, roots(t)->appLoader(),
"foo/ClassName", "foo/ClassName",
"methodName", "methodName",
"()V")); "()V"));
@ -8113,8 +8113,9 @@ invoke(Thread* thread, GcMethod* method, ArgumentList* arguments)
class SignalHandler: public SignalRegistrar::Handler { class SignalHandler: public SignalRegistrar::Handler {
public: public:
SignalHandler(Gc::Type type, Machine::Root root, unsigned fixedSize): typedef GcThrowable*& (GcRoots::*ExceptionGetter)();
m(0), type(type), root(root), fixedSize(fixedSize) { } SignalHandler(Gc::Type type, ExceptionGetter exc, unsigned fixedSize):
m(0), type(type), exc(exc), fixedSize(fixedSize) { }
virtual bool handleSignal(void** ip, void** frame, void** stack, virtual bool handleSignal(void** ip, void** frame, void** stack,
void** thread) void** thread)
@ -8137,7 +8138,7 @@ class SignalHandler: public SignalRegistrar::Handler {
} else { } else {
// not enough memory available for a new exception and stack // not enough memory available for a new exception and stack
// trace -- use a preallocated instance instead // trace -- use a preallocated instance instead
t->exception = cast<GcThrowable>(t, vm::root(t, root)); t->exception = (vm::roots(t)->*exc)();
} }
// printTrace(t, t->exception); // printTrace(t, t->exception);
@ -8162,7 +8163,7 @@ class SignalHandler: public SignalRegistrar::Handler {
Machine* m; Machine* m;
Gc::Type type; Gc::Type type;
Machine::Root root; ExceptionGetter exc;
unsigned fixedSize; unsigned fixedSize;
}; };
@ -8258,10 +8259,10 @@ class MyProcessor: public Processor {
codeImage(0), codeImage(0),
codeImageSize(0), codeImageSize(0),
segFaultHandler(GcNullPointerException::Type, segFaultHandler(GcNullPointerException::Type,
Machine::NullPointerException, &GcRoots::nullPointerException,
GcNullPointerException::FixedSize), GcNullPointerException::FixedSize),
divideByZeroHandler(GcArithmeticException::Type, divideByZeroHandler(GcArithmeticException::Type,
Machine::ArithmeticException, &GcRoots::arithmeticException,
GcArithmeticException::FixedSize), GcArithmeticException::FixedSize),
codeAllocator(s, Slice<uint8_t>(0, 0)), codeAllocator(s, Slice<uint8_t>(0, 0)),
callTableSize(0), callTableSize(0),
@ -9530,10 +9531,10 @@ boot(MyThread* t, BootImage* image, uint8_t* code)
t->m->types = reinterpret_cast<GcArray*>(bootObject(heap, image->types)); t->m->types = reinterpret_cast<GcArray*>(bootObject(heap, image->types));
t->m->roots = makeArray(t, Machine::RootCount); t->m->roots = makeRoots(t, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);;
setRoot(t, Machine::BootLoader, bootObject(heap, image->bootLoader)); set(t, reinterpret_cast<object>(roots(t)), RootsBootLoader, bootObject(heap, image->bootLoader));
setRoot(t, Machine::AppLoader, bootObject(heap, image->appLoader)); set(t, reinterpret_cast<object>(roots(t)), RootsAppLoader, bootObject(heap, image->appLoader));
p->roots = makeArray(t, RootCount); p->roots = makeArray(t, RootCount);
@ -9542,20 +9543,24 @@ boot(MyThread* t, BootImage* image, uint8_t* code)
setRoot(t, VirtualThunks, bootObject(heap, image->virtualThunks)); setRoot(t, VirtualThunks, bootObject(heap, image->virtualThunks));
{ object map = reinterpret_cast<object>(makeClassMap(t, bootClassTable, image->bootClassCount, heap)); {
set(t, root(t, Machine::BootLoader), ClassLoaderMap, map); GcHashMap* map = makeClassMap(t, bootClassTable, image->bootClassCount, heap);
// sequence point, for gc (don't recombine statements)
set(t, roots(t)->bootLoader(), ClassLoaderMap, map);
} }
cast<GcSystemClassLoader>(t, root(t, Machine::BootLoader))->finder() = t->m->bootFinder; roots(t)->bootLoader()->as<GcSystemClassLoader>(t)->finder() = t->m->bootFinder;
{ object map = reinterpret_cast<object>(makeClassMap(t, appClassTable, image->appClassCount, heap)); {
set(t, root(t, Machine::AppLoader), ClassLoaderMap, map); GcHashMap* map = makeClassMap(t, appClassTable, image->appClassCount, heap);
// sequence point, for gc (don't recombine statements)
set(t, roots(t)->appLoader(), ClassLoaderMap, map);
} }
cast<GcSystemClassLoader>(t, root(t, Machine::AppLoader))->finder() = t->m->appFinder; roots(t)->appLoader()->as<GcSystemClassLoader>(t)->finder() = t->m->appFinder;
setRoot(t, Machine::StringMap, reinterpret_cast<object>(makeStringMap set(t, roots(t), RootsStringMap, makeStringMap
(t, stringTable, image->stringCount, heap))); (t, stringTable, image->stringCount, heap));
p->callTableSize = image->callCount; p->callTableSize = image->callCount;
@ -9571,11 +9576,11 @@ boot(MyThread* t, BootImage* image, uint8_t* code)
if (image->initialized) { if (image->initialized) {
resetRuntimeState resetRuntimeState
(t, cast<GcHashMap>(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader))->map()), heap, (t, cast<GcHashMap>(t, roots(t)->bootLoader()->map()), heap,
image->heapSize); image->heapSize);
resetRuntimeState resetRuntimeState
(t, cast<GcHashMap>(t, cast<GcClassLoader>(t, root(t, Machine::AppLoader))->map()), heap, (t, cast<GcHashMap>(t, roots(t)->appLoader()->map()), heap,
image->heapSize); image->heapSize);
for (unsigned i = 0; i < t->m->types->length(); ++i) { for (unsigned i = 0; i < t->m->types->length(); ++i) {
@ -9586,15 +9591,17 @@ boot(MyThread* t, BootImage* image, uint8_t* code)
fixupVirtualThunks(t, code); fixupVirtualThunks(t, code);
fixupMethods fixupMethods
(t, cast<GcHashMap>(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader))->map()), image, code); (t, cast<GcHashMap>(t, roots(t)->bootLoader()->map()), image, code);
fixupMethods fixupMethods
(t, cast<GcHashMap>(t, cast<GcClassLoader>(t, root(t, Machine::AppLoader))->map()), image, code); (t, cast<GcHashMap>(t, roots(t)->appLoader()->map()), image, code);
} }
image->initialized = true; image->initialized = true;
setRoot(t, Machine::BootstrapClassMap, reinterpret_cast<object>(makeHashMap(t, 0, 0))); GcHashMap* map = makeHashMap(t, 0, 0);
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsBootstrapClassMap, map);
} }
intptr_t intptr_t

View File

@ -2909,7 +2909,7 @@ invoke(Thread* t, GcMethod* method)
class_ = objectClass(t, peekObject(t, t->sp - parameterFootprint)); class_ = objectClass(t, peekObject(t, t->sp - parameterFootprint));
if (class_->vmFlags() & BootstrapFlag) { if (class_->vmFlags() & BootstrapFlag) {
resolveClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), class_->name()); resolveClass(t, roots(t)->bootLoader(), class_->name());
} }
if (method->class_()->flags() & ACC_INTERFACE) { if (method->class_()->flags() & ACC_INTERFACE) {

View File

@ -330,8 +330,7 @@ defineClass(Thread* t, uintptr_t* arguments)
t, t,
defineClass(t, defineClass(t,
loader ? cast<GcClassLoader>(t, *loader) loader ? cast<GcClassLoader>(t, *loader)
: cast<GcClassLoader>( : roots(t)->bootLoader(),
t, root(t, Machine::BootLoader)),
buffer, buffer,
length)))))); length))))));
} }
@ -357,11 +356,11 @@ findClass(Thread* t, uintptr_t* arguments)
GcMethod* caller = getCaller(t, 0); GcMethod* caller = getCaller(t, 0);
GcClass* c = resolveClass( GcClass* c
t, = resolveClass(t,
caller ? t->m->classpath->libraryClassLoader(t, caller) : cast caller ? t->m->classpath->libraryClassLoader(t, caller)
<GcClassLoader>(t, root(t, Machine::AppLoader)), : roots(t)->appLoader(),
n); n);
if (t->m->classpath->mayInitClasses()) { if (t->m->classpath->mayInitClasses()) {
PROTECT(t, c); PROTECT(t, c);
@ -549,13 +548,14 @@ methodID(Thread* t, GcMethod* method)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
if (method->nativeID() == 0) { if (method->nativeID() == 0) {
setRoot(t, Machine::JNIMethodTable, reinterpret_cast<object>(vectorAppend GcVector* v = vectorAppend(
(t, cast<GcVector>(t, root(t, Machine::JNIMethodTable)), reinterpret_cast<object>(method)))); t, roots(t)->jNIMethodTable(), reinterpret_cast<object>(method));
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsJNIMethodTable, v);
storeStoreMemoryBarrier(); storeStoreMemoryBarrier();
method->nativeID() = cast<GcVector> method->nativeID() = roots(t)->jNIMethodTable()->size();
(t, root(t, Machine::JNIMethodTable))->size();
} }
} }
@ -615,7 +615,7 @@ getMethod(Thread* t, jmethodID m)
{ {
assertT(t, m); assertT(t, m);
GcMethod* method = cast<GcMethod>(t, cast<GcVector>(t, root(t, Machine::JNIMethodTable))->body()[m - 1]); GcMethod* method = cast<GcMethod>(t, roots(t)->jNIMethodTable()->body()[m - 1]);
assertT(t, (method->flags() & ACC_STATIC) == 0); assertT(t, (method->flags() & ACC_STATIC) == 0);
@ -1110,7 +1110,7 @@ getStaticMethod(Thread* t, jmethodID m)
{ {
assertT(t, m); assertT(t, m);
GcMethod* method = cast<GcMethod>(t, cast<GcVector>(t, root(t, Machine::JNIMethodTable))->body()[m - 1]); GcMethod* method = cast<GcMethod>(t, roots(t)->jNIMethodTable()->body()[m - 1]);
assertT(t, method->flags() & ACC_STATIC); assertT(t, method->flags() & ACC_STATIC);
@ -1502,12 +1502,14 @@ fieldID(Thread* t, GcField* field)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
if (field->nativeID() == 0) { if (field->nativeID() == 0) {
setRoot(t, Machine::JNIFieldTable, reinterpret_cast<object>(vectorAppend GcVector* v = vectorAppend(
(t, cast<GcVector>(t, root(t, Machine::JNIFieldTable)), reinterpret_cast<object>(field)))); t, roots(t)->jNIFieldTable(), reinterpret_cast<object>(field));
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsJNIFieldTable, v);
storeStoreMemoryBarrier(); storeStoreMemoryBarrier();
field->nativeID() = cast<GcVector>(t, root(t, Machine::JNIFieldTable))->size(); field->nativeID() = roots(t)->jNIFieldTable()->size();
} }
} }
@ -1549,7 +1551,7 @@ getField(Thread* t, jfieldID f)
{ {
assertT(t, f); assertT(t, f);
GcField* field = cast<GcField>(t, cast<GcVector>(t, root(t, Machine::JNIFieldTable))->body()[f - 1]); GcField* field = cast<GcField>(t, roots(t)->jNIFieldTable()->body()[f - 1]);
assertT(t, (field->flags() & ACC_STATIC) == 0); assertT(t, (field->flags() & ACC_STATIC) == 0);
@ -1978,7 +1980,7 @@ getStaticField(Thread* t, jfieldID f)
{ {
assertT(t, f); assertT(t, f);
GcField* field = cast<GcField>(t, cast<GcVector>(t, root(t, Machine::JNIFieldTable))->body()[f - 1]); GcField* field = cast<GcField>(t, roots(t)->jNIFieldTable()->body()[f - 1]);
assertT(t, field->flags() & ACC_STATIC); assertT(t, field->flags() & ACC_STATIC);
@ -3399,7 +3401,7 @@ pushLocalFrame(Thread* t, uintptr_t* arguments)
if (t->m->processor->pushLocalFrame(t, arguments[0])) { if (t->m->processor->pushLocalFrame(t, arguments[0])) {
return 1; return 1;
} else { } else {
throw_(t, cast<GcThrowable>(t, root(t, Machine::OutOfMemoryError))); throw_(t, roots(t)->outOfMemoryError());
} }
} }
@ -3537,22 +3539,25 @@ append(char** p, const char* value, unsigned length, char tail)
uint64_t uint64_t
boot(Thread* t, uintptr_t*) boot(Thread* t, uintptr_t*)
{ {
setRoot(t, GcThrowable* throwable = makeThrowable(t, GcNullPointerException::Type);
Machine::NullPointerException, // sequence point, for gc (don't recombine statements)
reinterpret_cast<object>(makeThrowable(t, GcNullPointerException::Type))); set(t, roots(t), RootsNullPointerException, throwable);
setRoot(t, throwable = makeThrowable(t, GcArithmeticException::Type);
Machine::ArithmeticException, // sequence point, for gc (don't recombine statements)
reinterpret_cast<object>(makeThrowable(t, GcArithmeticException::Type))); set(t, roots(t), RootsArithmeticException, throwable);
setRoot(t, throwable = makeThrowable(t, GcArrayIndexOutOfBoundsException::Type);
Machine::ArrayIndexOutOfBoundsException, // sequence point, for gc (don't recombine statements)
reinterpret_cast<object>(makeThrowable(t, GcArrayIndexOutOfBoundsException::Type))); set(t, roots(t), RootsArrayIndexOutOfBoundsException, throwable);
setRoot( throwable = makeThrowable(t, GcOutOfMemoryError::Type);
t, Machine::OutOfMemoryError, reinterpret_cast<object>(makeThrowable(t, GcOutOfMemoryError::Type))); // sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsOutOfMemoryError, throwable);
setRoot(t, Machine::Shutdown, reinterpret_cast<object>(makeThrowable(t, GcThrowable::Type))); throwable = makeThrowable(t, GcThrowable::Type);
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsShutdownInProgress, throwable);
t->m->classpath->preBoot(t); t->m->classpath->preBoot(t);
@ -3560,9 +3565,11 @@ boot(Thread* t, uintptr_t*)
t->javaThread->peer() = reinterpret_cast<jlong>(t); t->javaThread->peer() = reinterpret_cast<jlong>(t);
setRoot(t, Machine::FinalizerThread, reinterpret_cast<object>(t->m->classpath->makeThread(t, t))); GcThread* jthread = t->m->classpath->makeThread(t, t);
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsFinalizerThread, jthread);
cast<GcThread>(t, root(t, Machine::FinalizerThread))->daemon() = true; roots(t)->finalizerThread()->daemon() = true;
t->m->classpath->boot(t); t->m->classpath->boot(t);
@ -3572,7 +3579,7 @@ boot(Thread* t, uintptr_t*)
PROTECT(t, host); PROTECT(t, host);
GcMethod* method = resolveMethod GcMethod* method = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "avian/Traces", "startTraceListener", (t, roots(t)->bootLoader(), "avian/Traces", "startTraceListener",
"(Ljava/lang/String;I)V"); "(Ljava/lang/String;I)V");
t->m->processor->invoke(t, method, 0, host, atoi(port)); t->m->processor->invoke(t, method, 0, host, atoi(port));

View File

@ -215,7 +215,7 @@ turnOffTheLights(Thread* t)
} }
} }
if (GcArray* files = cast<GcArray>(t, root(t, Machine::VirtualFiles))) { if (GcArray* files = roots(t)->virtualFiles()) {
PROTECT(t, files); PROTECT(t, files);
for (unsigned i = 0; i < files->length(); for (unsigned i = 0; i < files->length();
++i) ++i)
@ -227,7 +227,7 @@ turnOffTheLights(Thread* t)
} }
} }
for (GcFinder* p = cast<GcFinder>(t, root(t, Machine::VirtualFileFinders)); for (GcFinder* p = roots(t)->virtualFileFinders();
p; p = p->next()) p; p = p->next())
{ {
static_cast<Finder*>(p->finder())->dispose(); static_cast<Finder*>(p->finder())->dispose();
@ -402,8 +402,8 @@ finalizerTargetUnreachable(Thread* t, Heap::Visitor* v, GcFinalizer** p)
t->m->finalizeQueue = finalizer; t->m->finalizeQueue = finalizer;
} else { } else {
set(t, reinterpret_cast<object>(finalizer), FinalizerQueueTarget, finalizer->target()); set(t, reinterpret_cast<object>(finalizer), FinalizerQueueTarget, finalizer->target());
set(t, reinterpret_cast<object>(finalizer), FinalizerQueueNext, root(t, Machine::ObjectsToFinalize)); set(t, finalizer, FinalizerQueueNext, roots(t)->objectsToFinalize());
setRoot(t, Machine::ObjectsToFinalize, reinterpret_cast<object>(finalizer)); set(t, roots(t), RootsObjectsToFinalize, finalizer);
} }
} }
@ -422,8 +422,8 @@ referenceTargetUnreachable(Thread* t, Heap::Visitor* v, GcJreference** p)
GcJreference* reference = *p; GcJreference* reference = *p;
*p = cast<GcJreference>(t, reference->vmNext()); *p = cast<GcJreference>(t, reference->vmNext());
set(t, reinterpret_cast<object>(reference), CleanerQueueNext, root(t, Machine::ObjectsToClean)); set(t, reference, CleanerQueueNext, roots(t)->objectsToClean());
setRoot(t, Machine::ObjectsToClean, reinterpret_cast<object>(reference)); set(t, roots(t), RootsObjectsToClean, reference);
} else { } else {
if ((*p)->queue() if ((*p)->queue()
and t->m->heap->status((*p)->queue()) != Heap::Unreachable) and t->m->heap->status((*p)->queue()) != Heap::Unreachable)
@ -437,9 +437,9 @@ referenceTargetUnreachable(Thread* t, Heap::Visitor* v, GcJreference** p)
if (q->front()) { if (q->front()) {
set(t, reinterpret_cast<object>(*p), JreferenceJNext, reinterpret_cast<object>(q->front())); set(t, reinterpret_cast<object>(*p), JreferenceJNext, reinterpret_cast<object>(q->front()));
} else { } else {
set(t, reinterpret_cast<object>(*p), JreferenceJNext, reinterpret_cast<object>(*p)); set(t, *p, JreferenceJNext, *p);
} }
set(t, reinterpret_cast<object>(q), ReferenceQueueFront, reinterpret_cast<object>(*p)); set(t, q, ReferenceQueueFront, *p);
(*p)->queue() = 0; (*p)->queue() = 0;
} }
@ -880,7 +880,7 @@ void
removeByteArray(Thread* t, object o) removeByteArray(Thread* t, object o)
{ {
hashMapRemove(t, hashMapRemove(t,
cast<GcHashMap>(t, root(t, Machine::ByteArrayMap)), roots(t)->byteArrayMap(),
o, o,
byteArrayHash, byteArrayHash,
objectEqual); objectEqual);
@ -894,11 +894,11 @@ internByteArray(Thread* t, GcByteArray* array)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
GcTriple* n = hashMapFindNode GcTriple* n = hashMapFindNode
(t, cast<GcHashMap>(t, root(t, Machine::ByteArrayMap)), reinterpret_cast<object>(array), byteArrayHash, byteArrayEqual); (t, roots(t)->byteArrayMap(), reinterpret_cast<object>(array), byteArrayHash, byteArrayEqual);
if (n) { if (n) {
return cast<GcByteArray>(t, cast<GcJreference>(t, n->first())->target()); return cast<GcByteArray>(t, cast<GcJreference>(t, n->first())->target());
} else { } else {
hashMapInsert(t, cast<GcHashMap>(t, root(t, Machine::ByteArrayMap)), reinterpret_cast<object>(array), 0, byteArrayHash); hashMapInsert(t, roots(t)->byteArrayMap(), reinterpret_cast<object>(array), 0, byteArrayHash);
addFinalizer(t, reinterpret_cast<object>(array), removeByteArray); addFinalizer(t, reinterpret_cast<object>(array), removeByteArray);
return array; return array;
} }
@ -2546,7 +2546,7 @@ makeArrayClass(Thread* t, GcClassLoader* loader, unsigned dimensions, GcByteArra
// avoid infinite recursion due to trying to create an array to // avoid infinite recursion due to trying to create an array to
// make a stack trace for a ClassNotFoundException. // make a stack trace for a ClassNotFoundException.
resolveSystemClass resolveSystemClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), (t, roots(t)->bootLoader(),
type(t, GcJobject::Type)->name(), false); type(t, GcJobject::Type)->name(), false);
} }
@ -2564,7 +2564,7 @@ makeArrayClass(Thread* t, GcClassLoader* loader, unsigned dimensions, GcByteArra
spec, spec,
0, 0,
type(t, GcJobject::Type), type(t, GcJobject::Type),
root(t, Machine::ArrayInterfaceTable), reinterpret_cast<object>(roots(t)->arrayInterfaceTable()),
reinterpret_cast<object>(vtable), reinterpret_cast<object>(vtable),
0, 0,
0, 0,
@ -2647,7 +2647,7 @@ makeArrayClass(Thread* t, GcClassLoader* loader, GcByteArray* spec, bool throw_,
} }
GcClass* elementClass = cast<GcClass>(t, hashMapFind GcClass* elementClass = cast<GcClass>(t, hashMapFind
(t, cast<GcHashMap>(t, root(t, Machine::BootstrapClassMap)), reinterpret_cast<object>(elementSpec), byteArrayHash, (t, roots(t)->bootstrapClassMap(), reinterpret_cast<object>(elementSpec), byteArrayHash,
byteArrayEqual)); byteArrayEqual));
if (elementClass == 0) { if (elementClass == 0) {
@ -2680,7 +2680,7 @@ resolveArrayClass(Thread* t, GcClassLoader* loader, GcByteArray* spec, bool thro
{ {
GcClass* c = cast<GcClass>(t, GcClass* c = cast<GcClass>(t,
hashMapFind(t, hashMapFind(t,
cast<GcHashMap>(t, root(t, Machine::BootstrapClassMap)), roots(t)->bootstrapClassMap(),
reinterpret_cast<object>(spec), reinterpret_cast<object>(spec),
byteArrayHash, byteArrayHash,
byteArrayEqual)); byteArrayEqual));
@ -2694,7 +2694,7 @@ resolveArrayClass(Thread* t, GcClassLoader* loader, GcByteArray* spec, bool thro
PROTECT(t, loader); PROTECT(t, loader);
PROTECT(t, spec); PROTECT(t, spec);
c = findLoadedClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), spec); c = findLoadedClass(t, roots(t)->bootLoader(), spec);
if (c) { if (c) {
return c; return c;
@ -2713,7 +2713,7 @@ removeMonitor(Thread* t, object o)
} }
object m = hashMapRemove object m = hashMapRemove
(t, cast<GcHashMap>(t, root(t, Machine::MonitorMap)), o, objectHash, objectEqual); (t, roots(t)->monitorMap(), o, objectHash, objectEqual);
if (DebugMonitors) { if (DebugMonitors) {
fprintf(stderr, "dispose monitor %p for object %x\n", m, hash); fprintf(stderr, "dispose monitor %p for object %x\n", m, hash);
@ -2723,7 +2723,7 @@ removeMonitor(Thread* t, object o)
void void
removeString(Thread* t, object o) removeString(Thread* t, object o)
{ {
hashMapRemove(t, cast<GcHashMap>(t, root(t, Machine::StringMap)), o, stringHash, objectEqual); hashMapRemove(t, roots(t)->stringMap(), o, stringHash, objectEqual);
} }
void void
@ -2755,7 +2755,7 @@ bootClass(Thread* t, Gc::Type type, int superType, uint32_t objectMask,
GcClass* class_ = t->m->processor->makeClass GcClass* class_ = t->m->processor->makeClass
(t, 0, BootstrapFlag, fixedSize, arrayElementSize, (t, 0, BootstrapFlag, fixedSize, arrayElementSize,
arrayElementSize ? 1 : 0, 0, mask, 0, 0, super, 0, 0, 0, 0, 0, 0, arrayElementSize ? 1 : 0, 0, mask, 0, 0, super, 0, 0, 0, 0, 0, 0,
cast<GcClassLoader>(t, root(t, Machine::BootLoader)), vtableLength); roots(t)->bootLoader(), vtableLength);
setType(t, type, class_); setType(t, type, class_);
} }
@ -2789,7 +2789,7 @@ bootJavaClass(Thread* t, Gc::Type type, int superType, const char* name,
t->m->processor->initVtable(t, class_); t->m->processor->initVtable(t, class_);
hashMapInsert hashMapInsert
(t, cast<GcHashMap>(t, root(t, Machine::BootstrapClassMap)), reinterpret_cast<object>(n), reinterpret_cast<object>(class_), byteArrayHash); (t, roots(t)->bootstrapClassMap(), reinterpret_cast<object>(n), reinterpret_cast<object>(class_), byteArrayHash);
} }
void void
@ -2810,7 +2810,7 @@ makeArrayInterfaceTable(Thread* t)
set(t, interfaceTable, ArrayBody + (2 * BytesPerWord), set(t, interfaceTable, ArrayBody + (2 * BytesPerWord),
type(t, GcCloneable::Type)); type(t, GcCloneable::Type));
setRoot(t, Machine::ArrayInterfaceTable, reinterpret_cast<object>(interfaceTable)); set(t, roots(t), RootsArrayInterfaceTable, interfaceTable);
} }
void void
@ -2820,14 +2820,15 @@ boot(Thread* t)
m->unsafe = true; m->unsafe = true;
m->roots = reinterpret_cast<GcArray*>(allocate(t, pad((Machine::RootCount + 2) * BytesPerWord), true)); m->roots = reinterpret_cast<GcRoots*>(allocate(t, GcRoots::FixedSize, true));
m->roots->length() = Machine::RootCount;
setRoot(t, Machine::BootLoader, object classLoader = allocate(t, GcSystemClassLoader::FixedSize, true);
allocate(t, GcSystemClassLoader::FixedSize, true)); // sequence point, for gc (don't recombine statements)
set(t, reinterpret_cast<object>(roots(t)), RootsBootLoader, classLoader);
setRoot(t, Machine::AppLoader, classLoader = allocate(t, GcSystemClassLoader::FixedSize, true);
allocate(t, GcSystemClassLoader::FixedSize, true)); // sequence point, for gc (don't recombine statements)
set(t, reinterpret_cast<object>(roots(t)), RootsAppLoader, classLoader);
m->types = reinterpret_cast<GcArray*>(allocate(t, pad((TypeCount + 2) * BytesPerWord), true)); m->types = reinterpret_cast<GcArray*>(allocate(t, pad((TypeCount + 2) * BytesPerWord), true));
m->types->length() = TypeCount; m->types->length() = TypeCount;
@ -2836,21 +2837,23 @@ boot(Thread* t)
GcClass* arrayClass = type(t, GcArray::Type); GcClass* arrayClass = type(t, GcArray::Type);
set(t, m->types, 0, arrayClass); set(t, m->types, 0, arrayClass);
set(t, m->roots, 0, arrayClass);
GcClass* rootsClass = type(t, GcRoots::Type);
set(t, m->roots, 0, rootsClass);
GcClass* loaderClass = type(t, GcSystemClassLoader::Type); GcClass* loaderClass = type(t, GcSystemClassLoader::Type);
set(t, root(t, Machine::BootLoader), 0, reinterpret_cast<object>(loaderClass)); set(t, roots(t)->bootLoader(), 0, loaderClass);
set(t, root(t, Machine::AppLoader), 0, reinterpret_cast<object>(loaderClass)); set(t, roots(t)->appLoader(), 0, loaderClass);
GcClass* objectClass = type(t, GcJobject::Type); GcClass* objectClass = type(t, GcJobject::Type);
GcClass* classClass = type(t, GcClass::Type); GcClass* classClass = type(t, GcClass::Type);
set(t, reinterpret_cast<object>(classClass), 0, reinterpret_cast<object>(classClass)); set(t, classClass, 0, classClass);
set(t, reinterpret_cast<object>(classClass), ClassSuper, reinterpret_cast<object>(objectClass)); set(t, classClass, ClassSuper, objectClass);
GcClass* intArrayClass = type(t, GcIntArray::Type); GcClass* intArrayClass = type(t, GcIntArray::Type);
set(t, reinterpret_cast<object>(intArrayClass), 0, reinterpret_cast<object>(classClass)); set(t, intArrayClass, 0, classClass);
set(t, reinterpret_cast<object>(intArrayClass), ClassSuper, reinterpret_cast<object>(objectClass)); set(t, intArrayClass, ClassSuper, objectClass);
m->unsafe = false; m->unsafe = false;
@ -2888,60 +2891,68 @@ boot(Thread* t)
type(t, GcJvoid::Type)->vmFlags() type(t, GcJvoid::Type)->vmFlags()
|= PrimitiveFlag; |= PrimitiveFlag;
set(t, reinterpret_cast<object>(type(t, GcBooleanArray::Type)), ClassArrayElementClass, set(t, type(t, GcBooleanArray::Type), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJboolean::Type))); type(t, GcJboolean::Type));
set(t, reinterpret_cast<object>(type(t, GcByteArray::Type)), ClassArrayElementClass, set(t, type(t, GcByteArray::Type), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJbyte::Type))); type(t, GcJbyte::Type));
set(t, reinterpret_cast<object>(type(t, GcCharArray::Type)), ClassArrayElementClass, set(t, type(t, GcCharArray::Type), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJchar::Type))); type(t, GcJchar::Type));
set(t, reinterpret_cast<object>(type(t, GcShortArray::Type)), ClassArrayElementClass, set(t, type(t, GcShortArray::Type), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJshort::Type))); type(t, GcJshort::Type));
set(t, reinterpret_cast<object>(type(t, GcIntArray::Type)), ClassArrayElementClass, set(t, type(t, GcIntArray::Type), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJint::Type))); type(t, GcJint::Type));
set(t, reinterpret_cast<object>(type(t, GcLongArray::Type)), ClassArrayElementClass, set(t, type(t, GcLongArray::Type), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJlong::Type))); type(t, GcJlong::Type));
set(t, reinterpret_cast<object>(type(t, GcFloatArray::Type)), ClassArrayElementClass, set(t, type(t, GcFloatArray::Type), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJfloat::Type))); type(t, GcJfloat::Type));
set(t, reinterpret_cast<object>(type(t, GcDoubleArray::Type)), ClassArrayElementClass, set(t, type(t, GcDoubleArray::Type), ClassArrayElementClass,
reinterpret_cast<object>(type(t, GcJdouble::Type))); type(t, GcJdouble::Type));
{ GcHashMap* map = makeHashMap(t, 0, 0); { GcHashMap* map = makeHashMap(t, 0, 0);
set(t, root(t, Machine::BootLoader), ClassLoaderMap, reinterpret_cast<object>(map)); set(t, roots(t)->bootLoader(), ClassLoaderMap, map);
} }
cast<GcSystemClassLoader>(t, root(t, Machine::BootLoader))->finder() = m->bootFinder; roots(t)->bootLoader()->as<GcSystemClassLoader>(t)->finder() = m->bootFinder;
{ GcHashMap* map = makeHashMap(t, 0, 0); { GcHashMap* map = makeHashMap(t, 0, 0);
set(t, root(t, Machine::AppLoader), ClassLoaderMap, reinterpret_cast<object>(map)); set(t, roots(t)->appLoader(), ClassLoaderMap, map);
} }
cast<GcSystemClassLoader>(t, root(t, Machine::AppLoader))->finder() = m->appFinder; roots(t)->appLoader()->as<GcSystemClassLoader>(t)->finder() = m->appFinder;
set(t, root(t, Machine::AppLoader), ClassLoaderParent, set(t, roots(t)->appLoader(), ClassLoaderParent,
root(t, Machine::BootLoader)); roots(t)->bootLoader());
setRoot(t, Machine::BootstrapClassMap, reinterpret_cast<object>(makeHashMap(t, 0, 0))); {
GcHashMap* map = makeHashMap(t, 0, 0);
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsBootstrapClassMap, map);
}
setRoot(t, Machine::StringMap, reinterpret_cast<object>(makeWeakHashMap(t, 0, 0))); {
GcWeakHashMap* map = makeWeakHashMap(t, 0, 0);
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsStringMap, map);
}
makeArrayInterfaceTable(t); makeArrayInterfaceTable(t);
set(t, reinterpret_cast<object>(type(t, GcBooleanArray::Type)), ClassInterfaceTable, set(t, type(t, GcBooleanArray::Type), ClassInterfaceTable,
root(t, Machine::ArrayInterfaceTable)); roots(t)->arrayInterfaceTable());
set(t, reinterpret_cast<object>(type(t, GcByteArray::Type)), ClassInterfaceTable, set(t, type(t, GcByteArray::Type), ClassInterfaceTable,
root(t, Machine::ArrayInterfaceTable)); roots(t)->arrayInterfaceTable());
set(t, reinterpret_cast<object>(type(t, GcCharArray::Type)), ClassInterfaceTable, set(t, type(t, GcCharArray::Type), ClassInterfaceTable,
root(t, Machine::ArrayInterfaceTable)); roots(t)->arrayInterfaceTable());
set(t, reinterpret_cast<object>(type(t, GcShortArray::Type)), ClassInterfaceTable, set(t, type(t, GcShortArray::Type), ClassInterfaceTable,
root(t, Machine::ArrayInterfaceTable)); roots(t)->arrayInterfaceTable());
set(t, reinterpret_cast<object>(type(t, GcIntArray::Type)), ClassInterfaceTable, set(t, type(t, GcIntArray::Type), ClassInterfaceTable,
root(t, Machine::ArrayInterfaceTable)); roots(t)->arrayInterfaceTable());
set(t, reinterpret_cast<object>(type(t, GcLongArray::Type)), ClassInterfaceTable, set(t, type(t, GcLongArray::Type), ClassInterfaceTable,
root(t, Machine::ArrayInterfaceTable)); roots(t)->arrayInterfaceTable());
set(t, reinterpret_cast<object>(type(t, GcFloatArray::Type)), ClassInterfaceTable, set(t, type(t, GcFloatArray::Type), ClassInterfaceTable,
root(t, Machine::ArrayInterfaceTable)); roots(t)->arrayInterfaceTable());
set(t, reinterpret_cast<object>(type(t, GcDoubleArray::Type)), ClassInterfaceTable, set(t, type(t, GcDoubleArray::Type), ClassInterfaceTable,
root(t, Machine::ArrayInterfaceTable)); roots(t)->arrayInterfaceTable());
m->processor->boot(t, 0, 0); m->processor->boot(t, 0, 0);
@ -3090,12 +3101,12 @@ doCollect(Thread* t, Heap::CollectionType type, int pendingAllocation)
function(t, finalizeQueue->target()); function(t, finalizeQueue->target());
} }
if ((root(t, Machine::ObjectsToFinalize) or root(t, Machine::ObjectsToClean)) if ((roots(t)->objectsToFinalize() or roots(t)->objectsToClean())
and m->finalizeThread == 0 and m->finalizeThread == 0
and t->state != Thread::ExitState) and t->state != Thread::ExitState)
{ {
m->finalizeThread = m->processor->makeThread m->finalizeThread = m->processor->makeThread
(m, cast<GcThread>(t, root(t, Machine::FinalizerThread)), m->rootThread); (m, roots(t)->finalizerThread(), m->rootThread);
addThread(t, m->finalizeThread); addThread(t, m->finalizeThread);
@ -3165,8 +3176,10 @@ updatePackageMap(Thread* t, GcClass* class_)
{ {
PROTECT(t, class_); PROTECT(t, class_);
if (root(t, Machine::PackageMap) == 0) { if (roots(t)->packageMap() == 0) {
setRoot(t, Machine::PackageMap, reinterpret_cast<object>(makeHashMap(t, 0, 0))); GcHashMap* map = makeHashMap(t, 0, 0);
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsPackageMap, map);
} }
GcByteArray* className = class_->name(); GcByteArray* className = class_->name();
@ -3189,7 +3202,7 @@ updatePackageMap(Thread* t, GcClass* class_)
PROTECT(t, key); PROTECT(t, key);
hashMapRemove hashMapRemove
(t, cast<GcHashMap>(t, root(t, Machine::PackageMap)), reinterpret_cast<object>(key), byteArrayHash, (t, roots(t)->packageMap(), reinterpret_cast<object>(key), byteArrayHash,
byteArrayEqual); byteArrayEqual);
GcByteArray* source = class_->source(); GcByteArray* source = class_->source();
@ -3210,7 +3223,7 @@ updatePackageMap(Thread* t, GcClass* class_)
} }
hashMapInsert hashMapInsert
(t, cast<GcHashMap>(t, root(t, Machine::PackageMap)), reinterpret_cast<object>(key), reinterpret_cast<object>(source), byteArrayHash); (t, roots(t)->packageMap(), reinterpret_cast<object>(key), reinterpret_cast<object>(source), byteArrayHash);
} }
} }
} }
@ -3453,13 +3466,29 @@ Thread::init()
boot(this); boot(this);
} }
setRoot(this, Machine::ByteArrayMap, reinterpret_cast<object>(makeWeakHashMap(this, 0, 0))); GcWeakHashMap* map = makeWeakHashMap(this, 0, 0);
setRoot(this, Machine::MonitorMap, reinterpret_cast<object>(makeWeakHashMap(this, 0, 0))); // sequence point, for gc (don't recombine statements)
set(this, roots(this), RootsByteArrayMap, map);
setRoot(this, Machine::ClassRuntimeDataTable, reinterpret_cast<object>(makeVector(this, 0, 0))); map = makeWeakHashMap(this, 0, 0);
setRoot(this, Machine::MethodRuntimeDataTable, reinterpret_cast<object>(makeVector(this, 0, 0))); // sequence point, for gc (don't recombine statements)
setRoot(this, Machine::JNIMethodTable, reinterpret_cast<object>(makeVector(this, 0, 0))); set(this, roots(this), RootsMonitorMap, map);
setRoot(this, Machine::JNIFieldTable, reinterpret_cast<object>(makeVector(this, 0, 0)));
GcVector* v = makeVector(this, 0, 0);
// sequence point, for gc (don't recombine statements)
set(this, roots(this), RootsClassRuntimeDataTable, v);
v = makeVector(this, 0, 0);
// sequence point, for gc (don't recombine statements)
set(this, roots(this), RootsMethodRuntimeDataTable, v);
v = makeVector(this, 0, 0);
// sequence point, for gc (don't recombine statements)
set(this, roots(this), RootsJNIMethodTable, v);
v = makeVector(this, 0, 0);
// sequence point, for gc (don't recombine statements)
set(this, roots(this), RootsJNIFieldTable, v);
m->localThread->set(this); m->localThread->set(this);
} }
@ -3508,10 +3537,10 @@ shutDown(Thread* t)
{ {
ACQUIRE(t, t->m->shutdownLock); ACQUIRE(t, t->m->shutdownLock);
GcPair* hooks = cast<GcPair>(t, root(t, Machine::ShutdownHooks)); GcPair* hooks = roots(t)->shutdownHooks();
PROTECT(t, hooks); PROTECT(t, hooks);
setRoot(t, Machine::ShutdownHooks, 0); set(t, roots(t), RootsShutdownHooks, 0);
GcPair* h = hooks; GcPair* h = hooks;
PROTECT(t, h); PROTECT(t, h);
@ -3835,7 +3864,7 @@ allocate3(Thread* t, Allocator* allocator, Machine::AllocationType type,
} }
if (t->m->heap->limitExceeded(pendingAllocation)) { if (t->m->heap->limitExceeded(pendingAllocation)) {
throw_(t, cast<GcThrowable>(t, root(t, Machine::OutOfMemoryError))); throw_(t, roots(t)->outOfMemoryError());
} }
} while (type == Machine::MovableAllocation } while (type == Machine::MovableAllocation
and t->heapIndex + ceilingDivide(sizeInBytes, BytesPerWord) and t->heapIndex + ceilingDivide(sizeInBytes, BytesPerWord)
@ -4093,7 +4122,7 @@ resolveBootstrap(Thread* t, uintptr_t* arguments)
{ {
GcByteArray* name = cast<GcByteArray>(t, reinterpret_cast<object>(arguments[0])); GcByteArray* name = cast<GcByteArray>(t, reinterpret_cast<object>(arguments[0]));
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name); resolveSystemClass(t, roots(t)->bootLoader(), name);
return 1; return 1;
} }
@ -4363,14 +4392,14 @@ parseClass(Thread* t, GcClassLoader* loader, const uint8_t* data, unsigned size,
updateClassTables(t, real, class_); updateClassTables(t, real, class_);
if (root(t, Machine::PoolMap)) { if (roots(t)->poolMap()) {
object bootstrapClass = hashMapFind object bootstrapClass = hashMapFind
(t, cast<GcHashMap>(t, root(t, Machine::BootstrapClassMap)), reinterpret_cast<object>(class_->name()), (t, roots(t)->bootstrapClassMap(), reinterpret_cast<object>(class_->name()),
byteArrayHash, byteArrayEqual); byteArrayHash, byteArrayEqual);
hashMapInsert( hashMapInsert(
t, t,
cast<GcHashMap>(t, root(t, Machine::PoolMap)), roots(t)->poolMap(),
bootstrapClass ? bootstrapClass : reinterpret_cast<object>(real), bootstrapClass ? bootstrapClass : reinterpret_cast<object>(real),
reinterpret_cast<object>(pool), reinterpret_cast<object>(pool),
objectHash); objectHash);
@ -4479,7 +4508,7 @@ resolveSystemClass(Thread* t, GcClassLoader* loader, GcByteArray* spec, bool thr
} }
GcClass* bootstrapClass = cast<GcClass>(t, hashMapFind GcClass* bootstrapClass = cast<GcClass>(t, hashMapFind
(t, cast<GcHashMap>(t, root(t, Machine::BootstrapClassMap)), reinterpret_cast<object>(spec), byteArrayHash, (t, roots(t)->bootstrapClassMap(), reinterpret_cast<object>(spec), byteArrayHash,
byteArrayEqual)); byteArrayEqual));
if (bootstrapClass) { if (bootstrapClass) {
@ -4533,26 +4562,26 @@ resolveClass(Thread* t, GcClassLoader* loader, GcByteArray* spec, bool throw_,
if (spec->body()[0] == '[') { if (spec->body()[0] == '[') {
c = resolveArrayClass(t, loader, spec, throw_, throwType); c = resolveArrayClass(t, loader, spec, throw_, throwType);
} else { } else {
if (root(t, Machine::LoadClassMethod) == 0) { if (roots(t)->loadClassMethod() == 0) {
GcMethod* m = resolveMethod GcMethod* m = resolveMethod
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/ClassLoader", (t, roots(t)->bootLoader(), "java/lang/ClassLoader",
"loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"); "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
if (m) { if (m) {
setRoot(t, Machine::LoadClassMethod, reinterpret_cast<object>(m)); set(t, roots(t), RootsLoadClassMethod, m);
GcClass* classLoaderClass = type(t, GcClassLoader::Type); GcClass* classLoaderClass = type(t, GcClassLoader::Type);
if (classLoaderClass->vmFlags() & BootstrapFlag) { if (classLoaderClass->vmFlags() & BootstrapFlag) {
resolveSystemClass resolveSystemClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), (t, roots(t)->bootLoader(),
classLoaderClass->name()); classLoaderClass->name());
} }
} }
} }
GcMethod* method = findVirtualMethod GcMethod* method = findVirtualMethod
(t, cast<GcMethod>(t, root(t, Machine::LoadClassMethod)), objectClass(t, loader)); (t, roots(t)->loadClassMethod(), objectClass(t, loader));
PROTECT(t, method); PROTECT(t, method);
@ -4912,7 +4941,7 @@ objectMonitor(Thread* t, object o, bool createNew)
assertT(t, t->state == Thread::ActiveState); assertT(t, t->state == Thread::ActiveState);
object m = hashMapFind object m = hashMapFind
(t, cast<GcHashMap>(t, root(t, Machine::MonitorMap)), o, objectHash, objectEqual); (t, roots(t)->monitorMap(), o, objectHash, objectEqual);
if (m) { if (m) {
if (DebugMonitors) { if (DebugMonitors) {
@ -4927,7 +4956,7 @@ objectMonitor(Thread* t, object o, bool createNew)
{ ENTER(t, Thread::ExclusiveState); { ENTER(t, Thread::ExclusiveState);
m = hashMapFind m = hashMapFind
(t, cast<GcHashMap>(t, root(t, Machine::MonitorMap)), o, objectHash, objectEqual); (t, roots(t)->monitorMap(), o, objectHash, objectEqual);
if (m) { if (m) {
if (DebugMonitors) { if (DebugMonitors) {
@ -4946,7 +4975,7 @@ objectMonitor(Thread* t, object o, bool createNew)
objectHash(t, o)); objectHash(t, o));
} }
hashMapInsert(t, cast<GcHashMap>(t, root(t, Machine::MonitorMap)), o, m, objectHash); hashMapInsert(t, roots(t)->monitorMap(), o, m, objectHash);
addFinalizer(t, o, removeMonitor); addFinalizer(t, o, removeMonitor);
} }
@ -4965,12 +4994,12 @@ intern(Thread* t, object s)
ACQUIRE(t, t->m->referenceLock); ACQUIRE(t, t->m->referenceLock);
GcTriple* n = hashMapFindNode GcTriple* n = hashMapFindNode
(t, cast<GcHashMap>(t, root(t, Machine::StringMap)), s, stringHash, stringEqual); (t, roots(t)->stringMap(), s, stringHash, stringEqual);
if (n) { if (n) {
return reinterpret_cast<object>(cast<GcJreference>(t, n->first())->target()); return reinterpret_cast<object>(cast<GcJreference>(t, n->first())->target());
} else { } else {
hashMapInsert(t, cast<GcHashMap>(t, root(t, Machine::StringMap)), s, 0, stringHash); hashMapInsert(t, roots(t)->stringMap(), s, 0, stringHash);
addFinalizer(t, s, removeString); addFinalizer(t, s, removeString);
return s; return s;
} }
@ -5196,8 +5225,8 @@ runFinalizeThread(Thread* t)
{ ACQUIRE(t, t->m->stateLock); { ACQUIRE(t, t->m->stateLock);
while (t->m->finalizeThread while (t->m->finalizeThread
and root(t, Machine::ObjectsToFinalize) == 0 and roots(t)->objectsToFinalize() == 0
and root(t, Machine::ObjectsToClean) == 0) and roots(t)->objectsToClean() == 0)
{ {
ENTER(t, Thread::IdleState); ENTER(t, Thread::IdleState);
t->m->stateLock->wait(t->systemThread, 0); t->m->stateLock->wait(t->systemThread, 0);
@ -5206,11 +5235,11 @@ runFinalizeThread(Thread* t)
if (t->m->finalizeThread == 0) { if (t->m->finalizeThread == 0) {
return; return;
} else { } else {
finalizeList = cast<GcFinalizer>(t, root(t, Machine::ObjectsToFinalize)); finalizeList = roots(t)->objectsToFinalize();
setRoot(t, Machine::ObjectsToFinalize, 0); set(t, roots(t), RootsObjectsToFinalize, 0);
cleanList = cast<GcCleaner>(t, root(t, Machine::ObjectsToClean)); cleanList = roots(t)->objectsToClean();
setRoot(t, Machine::ObjectsToClean, 0); set(t, roots(t), RootsObjectsToClean, 0);
} }
} }

View File

@ -312,7 +312,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
} resolver(&typeMaps); } resolver(&typeMaps);
Finder* finder = static_cast<Finder*> Finder* finder = static_cast<Finder*>
(cast<GcSystemClassLoader>(t, root(t, Machine::BootLoader))->finder()); (roots(t)->bootLoader()->as<GcSystemClassLoader>(t)->finder());
for (Finder::Iterator it(finder); it.hasMore();) { for (Finder::Iterator it(finder); it.hasMore();) {
unsigned nameSize = 0; unsigned nameSize = 0;
@ -323,7 +323,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
{ {
// fprintf(stderr, "pass 1 %.*s\n", nameSize - 6, name); // fprintf(stderr, "pass 1 %.*s\n", nameSize - 6, name);
GcClass* c = resolveSystemClass GcClass* c = resolveSystemClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), (t, roots(t)->bootLoader(),
makeByteArray(t, "%.*s", nameSize - 6, name), true); makeByteArray(t, "%.*s", nameSize - 6, name), true);
PROTECT(t, c); PROTECT(t, c);
@ -419,7 +419,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
hashMapInsert hashMapInsert
(t, typeMaps, reinterpret_cast<object>(hashMapFind (t, typeMaps, reinterpret_cast<object>(hashMapFind
(t, cast<GcHashMap>(t, root(t, Machine::PoolMap)), reinterpret_cast<object>(c), objectHash, objectEqual)), reinterpret_cast<object>(array), (t, roots(t)->poolMap(), reinterpret_cast<object>(c), objectHash, objectEqual)), reinterpret_cast<object>(array),
objectHash); objectHash);
} }
} }
@ -611,7 +611,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
PROTECT(t, c); PROTECT(t, c);
c = resolveSystemClass c = resolveSystemClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), (t, roots(t)->bootLoader(),
makeByteArray(t, "%.*s", nameSize - 6, name), true); makeByteArray(t, "%.*s", nameSize - 6, name), true);
if (GcArray* mtable = cast<GcArray>(t, c->methodTable())) { if (GcArray* mtable = cast<GcArray>(t, c->methodTable())) {
@ -657,7 +657,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
if (objectClass(t, o) == type(t, GcReference::Type)) { if (objectClass(t, o) == type(t, GcReference::Type)) {
o = reinterpret_cast<object>(resolveClass o = reinterpret_cast<object>(resolveClass
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), cast<GcReference>(t, o)->name())); (t, roots(t)->bootLoader(), cast<GcReference>(t, o)->name()));
set(t, reinterpret_cast<object>(addendum->pool()), set(t, reinterpret_cast<object>(addendum->pool()),
SingletonBody + (index * BytesPerWord), o); SingletonBody + (index * BytesPerWord), o);
@ -706,14 +706,14 @@ visitRoots(Thread* t, BootImage* image, HeapWalker* w, GcTriple* constants)
{ {
Machine* m = t->m; Machine* m = t->m;
for (HashMapIterator it(t, cast<GcHashMap>(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader))->map())); for (HashMapIterator it(t, cast<GcHashMap>(t, roots(t)->bootLoader()->map()));
it.hasMore();) it.hasMore();)
{ {
w->visitRoot(it.next()->second()); w->visitRoot(it.next()->second());
} }
image->bootLoader = w->visitRoot(root(t, Machine::BootLoader)); image->bootLoader = w->visitRoot(reinterpret_cast<object>(roots(t)->bootLoader()));
image->appLoader = w->visitRoot(root(t, Machine::AppLoader)); image->appLoader = w->visitRoot(reinterpret_cast<object>(roots(t)->appLoader()));
image->types = w->visitRoot(reinterpret_cast<object>(m->types)); image->types = w->visitRoot(reinterpret_cast<object>(m->types));
m->processor->visitRoots(t, w); m->processor->visitRoots(t, w);
@ -1288,8 +1288,9 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
const char* codeimageStart, const char* codeimageEnd, const char* codeimageStart, const char* codeimageEnd,
bool useLZMA) bool useLZMA)
{ {
setRoot(t, Machine::OutOfMemoryError, GcThrowable* throwable = cast<GcThrowable>(t, make(t, type(t, GcOutOfMemoryError::Type)));
make(t, type(t, GcOutOfMemoryError::Type))); // sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsOutOfMemoryError, throwable);
Zone zone(t->m->system, t->m->heap, 64 * 1024); Zone zone(t->m->system, t->m->heap, 64 * 1024);
@ -1331,7 +1332,7 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
{ classPoolMap = makeHashMap(t, 0, 0); { classPoolMap = makeHashMap(t, 0, 0);
PROTECT(t, classPoolMap); PROTECT(t, classPoolMap);
setRoot(t, Machine::PoolMap, reinterpret_cast<object>(classPoolMap)); set(t, roots(t), RootsPoolMap, classPoolMap);
typeMaps = makeHashMap(t, 0, 0); typeMaps = makeHashMap(t, 0, 0);
PROTECT(t, typeMaps); PROTECT(t, typeMaps);
@ -1493,8 +1494,11 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
// these roots will not be used when the bootimage is loaded, so // these roots will not be used when the bootimage is loaded, so
// there's no need to preserve them: // there's no need to preserve them:
setRoot(t, Machine::PoolMap, 0); set(t, roots(t), RootsPoolMap, 0);
setRoot(t, Machine::ByteArrayMap, reinterpret_cast<object>(makeWeakHashMap(t, 0, 0)));
GcWeakHashMap* map = makeWeakHashMap(t, 0, 0);
// sequence point, for gc (don't recombine statements)
set(t, roots(t), RootsByteArrayMap, map);
// name all primitive classes so we don't try to update immutable // name all primitive classes so we don't try to update immutable
// references at runtime: // references at runtime:
@ -1529,28 +1533,28 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
// resolve primitive array classes in case they are needed at // resolve primitive array classes in case they are needed at
// runtime: // runtime:
{ GcByteArray* name = makeByteArray(t, "[B"); { GcByteArray* name = makeByteArray(t, "[B");
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true); resolveSystemClass(t, roots(t)->bootLoader(), name, true);
name = makeByteArray(t, "[Z"); name = makeByteArray(t, "[Z");
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true); resolveSystemClass(t, roots(t)->bootLoader(), name, true);
name = makeByteArray(t, "[S"); name = makeByteArray(t, "[S");
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true); resolveSystemClass(t, roots(t)->bootLoader(), name, true);
name = makeByteArray(t, "[C"); name = makeByteArray(t, "[C");
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true); resolveSystemClass(t, roots(t)->bootLoader(), name, true);
name = makeByteArray(t, "[I"); name = makeByteArray(t, "[I");
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true); resolveSystemClass(t, roots(t)->bootLoader(), name, true);
name = makeByteArray(t, "[J"); name = makeByteArray(t, "[J");
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true); resolveSystemClass(t, roots(t)->bootLoader(), name, true);
name = makeByteArray(t, "[F"); name = makeByteArray(t, "[F");
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true); resolveSystemClass(t, roots(t)->bootLoader(), name, true);
name = makeByteArray(t, "[D"); name = makeByteArray(t, "[D");
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true); resolveSystemClass(t, roots(t)->bootLoader(), name, true);
} }
} }
@ -1567,14 +1571,14 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
updateConstants(t, constants, heapWalker->map()); updateConstants(t, constants, heapWalker->map());
image->bootClassCount = cast<GcHashMap> image->bootClassCount = cast<GcHashMap>
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader))->map())->size(); (t, roots(t)->bootLoader()->map())->size();
unsigned* bootClassTable = static_cast<unsigned*> unsigned* bootClassTable = static_cast<unsigned*>
(t->m->heap->allocate(image->bootClassCount * sizeof(unsigned))); (t->m->heap->allocate(image->bootClassCount * sizeof(unsigned)));
{ unsigned i = 0; { unsigned i = 0;
for (HashMapIterator it for (HashMapIterator it
(t, cast<GcHashMap>(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader))->map())); (t, cast<GcHashMap>(t, roots(t)->bootLoader()->map()));
it.hasMore();) it.hasMore();)
{ {
bootClassTable[i++] = targetVW bootClassTable[i++] = targetVW
@ -1583,14 +1587,14 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
} }
image->appClassCount = cast<GcHashMap> image->appClassCount = cast<GcHashMap>
(t, cast<GcClassLoader>(t, root(t, Machine::AppLoader))->map())->size(); (t, roots(t)->appLoader()->map())->size();
unsigned* appClassTable = static_cast<unsigned*> unsigned* appClassTable = static_cast<unsigned*>
(t->m->heap->allocate(image->appClassCount * sizeof(unsigned))); (t->m->heap->allocate(image->appClassCount * sizeof(unsigned)));
{ unsigned i = 0; { unsigned i = 0;
for (HashMapIterator it for (HashMapIterator it
(t, cast<GcHashMap>(t, cast<GcClassLoader>(t, root(t, Machine::AppLoader))->map())); (t, cast<GcHashMap>(t, roots(t)->appLoader()->map()));
it.hasMore();) it.hasMore();)
{ {
appClassTable[i++] = targetVW appClassTable[i++] = targetVW
@ -1598,12 +1602,12 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
} }
} }
image->stringCount = cast<GcHashMap>(t, root(t, Machine::StringMap))->size(); image->stringCount = roots(t)->stringMap()->size();
unsigned* stringTable = static_cast<unsigned*> unsigned* stringTable = static_cast<unsigned*>
(t->m->heap->allocate(image->stringCount * sizeof(unsigned))); (t->m->heap->allocate(image->stringCount * sizeof(unsigned)));
{ unsigned i = 0; { unsigned i = 0;
for (HashMapIterator it(t, cast<GcHashMap>(t, root(t, Machine::StringMap))); it.hasMore();) { for (HashMapIterator it(t, roots(t)->stringMap()); it.hasMore();) {
stringTable[i++] = targetVW stringTable[i++] = targetVW
(heapWalker->map()->find (heapWalker->map()->find
(reinterpret_cast<object>(cast<GcJreference>(t, it.next()->first())->target()))); (reinterpret_cast<object>(cast<GcJreference>(t, it.next()->first())->target())));

View File

@ -376,3 +376,43 @@
(type jvoid (type jvoid
(extends jobject)) (extends jobject))
(type roots
(classLoader bootLoader)
(classLoader appLoader)
(hashMap bootstrapClassMap)
(hashMap packageMap)
(method findLoadedClassMethod)
(method loadClassMethod)
(hashMap monitorMap)
(hashMap stringMap)
(hashMap byteArrayMap)
(hashMap poolMap)
(vector classRuntimeDataTable)
(vector methodRuntimeDataTable)
(vector jNIMethodTable)
(vector jNIFieldTable)
(pair shutdownHooks)
(thread finalizerThread)
(finalizer objectsToFinalize)
(cleaner objectsToClean)
(throwable nullPointerException)
(throwable arithmeticException)
(throwable arrayIndexOutOfBoundsException)
(throwable outOfMemoryError)
(throwable shutdownInProgress)
(finder virtualFileFinders)
(field array virtualFiles)
(field array arrayInterfaceTable)
(object threadTerminated))
(type compileRoots
(field array callTable)
(treeNode methodTree)
(treeNode methodTreeSentinal)
(object objectPools)
(object staticTableArray)
(wordArray virtualThunks)
(method receiveMethod)
(method windMethod)
(method rewindMethod))