From 01dcb1661bf5e558e1b27c0c9a69afa3ac2286ff Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 18 Aug 2009 15:27:21 -0600 Subject: [PATCH 1/4] don't resolve all constant pool entries in linkClass - just the field and method specs --- src/machine.cpp | 41 +++-------------------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/src/machine.cpp b/src/machine.cpp index 122c3c77ad..1fa9791397 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2943,48 +2943,13 @@ linkClass(Thread* t, object loader, object class_) } if (classMethodTable(t, class_)) { - bool resolvedPool = false; for (unsigned i = 0; i < arrayLength(t, classMethodTable(t, class_)); ++i) { - object method = arrayBody(t, classMethodTable(t, class_), i); - PROTECT(t, method); - - object code = methodCode(t, method); - if ((not resolvedPool) - and code - and codePool(t, code) - and objectClass(t, codePool(t, code)) - == arrayBody(t, t->m->types, Machine::SingletonType)) - { - object pool = codePool(t, code); - PROTECT(t, pool); - unsigned count = singletonCount(t, pool); - for (unsigned j = 0; j < count; ++j) { - if (singletonIsObject(t, pool, j)) { - object entry = singletonObject(t, pool, j); - if (objectClass(t, entry) - == arrayBody(t, t->m->types, Machine::ReferenceType)) - { - if (referenceSpec(t, entry) == 0) { - resolveClassInPool(t, loader, method, j); - } else if (byteArrayBody(t, referenceSpec(t, entry), 0) == '(') - { - resolveMethod(t, loader, method, j); - } else { - resolveField(t, loader, method, j); - } - - if (UNLIKELY(t->exception)) return; - } - } - } - - resolvedPool = true; - } - - object spec = methodSpec(t, method); + object spec = methodSpec + (t, arrayBody(t, classMethodTable(t, class_), i)); PROTECT(t, spec); + for (unsigned j = 1; j < byteArrayLength(t, spec);) { j = resolveSpec(t, loader, spec, j); if (UNLIKELY(t->exception)) return; From 0eba1eeaf28a1d2c2e258c633965bf82092e1155 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 18 Aug 2009 15:29:25 -0600 Subject: [PATCH 2/4] leave thread in JoinedState instead of ZombieState in DetachCurrentThread --- src/jnienv.cpp | 11 ++++++++++- src/posix.cpp | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 7bda0458ad..0b1b34760e 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -77,8 +77,17 @@ DetachCurrentThread(Machine* m) { Thread* t = static_cast(m->localThread->get()); if (t) { + expect(t, t != m->rootThread); + m->localThread->set(0); - t->exit(); + + ACQUIRE_RAW(t, t->m->stateLock); + + enter(t, Thread::ActiveState); + enter(t, Thread::ZombieState); + + t->state = Thread::JoinedState; + return 0; } else { return -1; diff --git a/src/posix.cpp b/src/posix.cpp index 5f2fbf11c4..48096dac52 100644 --- a/src/posix.cpp +++ b/src/posix.cpp @@ -129,7 +129,7 @@ class MySystem: public System { virtual void join() { int rv UNUSED = pthread_join(thread, 0); - //expect(s, rv == 0); + expect(s, rv == 0); } virtual void dispose() { From 0a2e611baa94f16e8eed9bcb1bac9d6b547a270f Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 18 Aug 2009 15:47:08 -0600 Subject: [PATCH 3/4] handle case of null thread local in SegFaultHandler::handleSignal --- src/compile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compile.cpp b/src/compile.cpp index 97fe3fb21e..e045bb04b6 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -6328,7 +6328,7 @@ class SegFaultHandler: public System::SignalHandler { void** thread) { MyThread* t = static_cast(m->localThread->get()); - if (t->state == Thread::ActiveState) { + if (t and t->state == Thread::ActiveState) { object node = methodForIp(t, *ip); if (node) { void* oldIp = t->ip; From df3baeb83b92a110f25e142a687fc20a61c4173d Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 19 Aug 2009 07:36:52 -0600 Subject: [PATCH 4/4] handle null value properly in SetObjectArrayElement --- src/jnienv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 0b1b34760e..5195057e4a 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -1245,7 +1245,7 @@ SetObjectArrayElement(Thread* t, jobjectArray array, jsize index, { ENTER(t, Thread::ActiveState); - set(t, *array, ArrayBody + (index * BytesPerWord), *value); + set(t, *array, ArrayBody + (index * BytesPerWord), (value ? *value : 0)); } jbooleanArray JNICALL