From 65190473420e9ec3f0ee378eb9494bc20157b70c Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 3 Sep 2009 09:06:04 -0600 Subject: [PATCH] fix bootimage build --- src/bootimage.cpp | 4 ++-- src/builtin.cpp | 4 ++-- src/compile.cpp | 5 ++--- src/gnu.cpp | 4 ++-- src/machine.cpp | 17 ++++++++++------- src/machine.h | 11 +++++++++++ 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 6df24a6ff3..944914c6a9 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -52,7 +52,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, and (className == 0 or strncmp(name, className, nameSize - 6) == 0)) { // fprintf(stderr, "%.*s\n", nameSize - 6, name); - object c = resolveClass + object c = resolveSystemClass (t, makeByteArray(t, "%.*s", nameSize - 6, name)); if (t->exception) return 0; @@ -399,7 +399,7 @@ main(int ac, const char** av) enter(t, Thread::ActiveState); enter(t, Thread::IdleState); - FILE* output = fopen(av[2], "wb"); + FILE* output = vm::fopen(av[2], "wb"); if (output == 0) { fprintf(stderr, "unable to open %s\n", av[2]); return -1; diff --git a/src/builtin.cpp b/src/builtin.cpp index ec5cbee7c4..5a44a6a260 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -186,13 +186,13 @@ Avian_java_lang_ClassLoader_defineClass t->m->heap->free(buffer, length); if (c) { - if (classLoaderMap(t, loader) == 0) { + if (getClassLoaderMap(t, loader) == 0) { PROTECT(t, c); object map = makeHashMap(t, 0, 0); set(t, loader, ClassLoaderMap, map); } - hashMapInsert(t, classLoaderMap(t, loader), className(t, c), c, + hashMapInsert(t, getClassLoaderMap(t, loader), className(t, c), c, byteArrayHash); } diff --git a/src/compile.cpp b/src/compile.cpp index 808cdf3157..a7e67b7e9a 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -7131,7 +7131,7 @@ fixupCode(Thread* t, uintptr_t* map, unsigned size, uint8_t* code, void fixupMethods(Thread* t, BootImage* image, uint8_t* code) { - for (HashMapIterator it(t, classLoaderMap(t, t->m->loader)); it.hasMore();) { + for (HashMapIterator it(t, t->m->classMap); it.hasMore();) { object c = tripleSecond(t, it.next()); if (classMethodTable(t, c)) { @@ -7261,8 +7261,7 @@ boot(MyThread* t, BootImage* image) syncInstructionCache(code, image->codeSize); - object classMap = makeClassMap(t, classTable, image->classCount, heap); - set(t, t->m->loader, ClassLoaderMap, classMap); + t->m->classMap = makeClassMap(t, classTable, image->classCount, heap); t->m->stringMap = makeStringMap(t, stringTable, image->stringCount, heap); diff --git a/src/gnu.cpp b/src/gnu.cpp index 289f159f4c..fcc5bc3b97 100644 --- a/src/gnu.cpp +++ b/src/gnu.cpp @@ -437,7 +437,7 @@ Avian_java_lang_VMClassLoader_findLoadedClass { object loader = reinterpret_cast(arguments[0]); - object map = classLoaderMap(t, loader); + object map = getClassLoaderMap(t, loader); if (map) { PROTECT(t, loader); @@ -452,7 +452,7 @@ Avian_java_lang_VMClassLoader_findLoadedClass return reinterpret_cast (hashMapFind - (t, classLoaderMap(t, loader), n, byteArrayHash, byteArrayEqual)); + (t, getClassLoaderMap(t, loader), n, byteArrayHash, byteArrayEqual)); } else { return 0; } diff --git a/src/machine.cpp b/src/machine.cpp index 34892a00d1..a0ce673f92 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1934,8 +1934,7 @@ boot(Thread* t) classVmFlags(t, arrayBody(t, m->types, Machine::JvoidType)) |= PrimitiveFlag; - object classMap = makeHashMap(t, 0, 0); - set(t, t->m->loader, ClassLoaderMap, classMap); + m->classMap = makeHashMap(t, 0, 0); m->bootstrapClassMap = makeHashMap(t, 0, 0); @@ -2070,6 +2069,7 @@ Machine::Machine(System* system, Heap* heap, Finder* finder, shutdownLock(0), libraries(0), loader(0), + classMap(0), loadClassMethod(0), bootstrapClassMap(0), monitorMap(0), @@ -2782,8 +2782,7 @@ findLoadedSystemClass(Thread* t, object spec) PROTECT(t, spec); ACQUIRE(t, t->m->classLock); - return hashMapFind(t, classLoaderMap(t, t->m->loader), spec, byteArrayHash, - byteArrayEqual); + return hashMapFind(t, t->m->classMap, spec, byteArrayHash, byteArrayEqual); } object @@ -2900,7 +2899,7 @@ resolveSystemClass(Thread* t, object spec) ACQUIRE(t, t->m->classLock); object class_ = hashMapFind - (t, classLoaderMap(t, t->m->loader), spec, byteArrayHash, byteArrayEqual); + (t, t->m->classMap, spec, byteArrayHash, byteArrayEqual); if (class_ == 0) { if (byteArrayBody(t, spec, 0) == '[') { @@ -2950,8 +2949,7 @@ resolveSystemClass(Thread* t, object spec) if (class_) { PROTECT(t, class_); - hashMapInsert(t, classLoaderMap(t, t->m->loader), spec, class_, - byteArrayHash); + hashMapInsert(t, t->m->classMap, spec, class_, byteArrayHash); } else if (t->exception == 0) { object message = makeString(t, "%s", &byteArrayBody(t, spec, 0)); t->exception = makeClassNotFoundException(t, message); @@ -3565,6 +3563,7 @@ void visitRoots(Machine* m, Heap::Visitor* v) { v->visit(&(m->loader)); + v->visit(&(m->classMap)); v->visit(&(m->loadClassMethod)); v->visit(&(m->bootstrapClassMap)); v->visit(&(m->monitorMap)); @@ -3699,6 +3698,8 @@ runJavaThread(Thread* t) void runFinalizeThread(Thread* t) { + fprintf(stderr, "run finalize thread\n"); + setDaemon(t, t->javaThread, true); object list = 0; @@ -3713,6 +3714,8 @@ runFinalizeThread(Thread* t) } if (t->m->finalizeThread == 0) { + fprintf(stderr, "exit finalize thread\n"); + return; } else { list = t->m->objectsToFinalize; diff --git a/src/machine.h b/src/machine.h index 2191dedfbe..60fecc3864 100644 --- a/src/machine.h +++ b/src/machine.h @@ -1189,6 +1189,7 @@ class Machine { System::Monitor* shutdownLock; System::Library* libraries; object loader; + object classMap; object loadClassMethod; object bootstrapClassMap; object monitorMap; @@ -1658,6 +1659,16 @@ instanceOf(Thread* t, object class_, object o); #include "type-declarations.cpp" +inline object +getClassLoaderMap(Thread* t, object loader) +{ + if (loader == t->m->loader) { + return t->m->classMap; + } else { + return classLoaderMap(t, loader); + } +} + inline bool objectFixed(Thread*, object o) {