From 542888a1d39b56f6e2d78df25e4b1775dcf88f15 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 12 Sep 2007 21:15:16 -0600 Subject: [PATCH] bugfixes --- src/heap.cpp | 2 +- src/jnienv.cpp | 58 ++++++++++++++++++++++++++++++++++--------------- src/machine.cpp | 6 +++-- src/machine.h | 7 +++--- src/run.cpp | 18 +++++++++++---- 5 files changed, 64 insertions(+), 27 deletions(-) diff --git a/src/heap.cpp b/src/heap.cpp index 240df45044..73e9a9c42e 100644 --- a/src/heap.cpp +++ b/src/heap.cpp @@ -14,7 +14,7 @@ const unsigned Top = ~static_cast(0); const unsigned InitialGen2CapacityInBytes = 4 * 1024 * 1024; -const bool Verbose = true; +const bool Verbose = false; const bool Verbose2 = false; const bool Debug = false; diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 7b4a089f7d..fa933fedb9 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -235,7 +235,8 @@ CallBooleanMethodV(Thread* t, jobject o, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return booleanValue(t, run(t, getMethod(t, *o, m), *o, true, a)); + object r = run(t, getMethod(t, *o, m), *o, true, a); + return (t->exception ? 0 : booleanValue(t, r)); } jboolean JNICALL @@ -256,7 +257,8 @@ CallByteMethodV(Thread* t, jobject o, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return byteValue(t, run(t, getMethod(t, *o, m), *o, true, a)); + object r = run(t, getMethod(t, *o, m), *o, true, a); + return (t->exception ? 0 : byteValue(t, r)); } jbyte JNICALL @@ -277,7 +279,8 @@ CallCharMethodV(Thread* t, jobject o, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return charValue(t, run(t, getMethod(t, *o, m), *o, true, a)); + object r = run(t, getMethod(t, *o, m), *o, true, a); + return (t->exception ? 0 : charValue(t, r)); } jchar JNICALL @@ -298,7 +301,8 @@ CallShortMethodV(Thread* t, jobject o, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return shortValue(t, run(t, getMethod(t, *o, m), *o, true, a)); + object r = run(t, getMethod(t, *o, m), *o, true, a); + return (t->exception ? 0 : shortValue(t, r)); } jshort JNICALL @@ -319,7 +323,8 @@ CallIntMethodV(Thread* t, jobject o, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return intValue(t, run(t, getMethod(t, *o, m), *o, true, a)); + object r = run(t, getMethod(t, *o, m), *o, true, a); + return (t->exception ? 0 : intValue(t, r)); } jint JNICALL @@ -340,7 +345,8 @@ CallLongMethodV(Thread* t, jobject o, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return longValue(t, run(t, getMethod(t, *o, m), *o, true, a)); + object r = run(t, getMethod(t, *o, m), *o, true, a); + return (t->exception ? 0 : longValue(t, r)); } jlong JNICALL @@ -361,7 +367,10 @@ CallFloatMethodV(Thread* t, jobject o, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return floatValue(t, run(t, getMethod(t, *o, m), *o, true, a)); + object r = run(t, getMethod(t, *o, m), *o, true, a); + jint i = (t->exception ? 0 : floatValue(t, r)); + jfloat f; memcpy(&f, &i, 4); + return f; } jfloat JNICALL @@ -382,7 +391,10 @@ CallDoubleMethodV(Thread* t, jobject o, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return doubleValue(t, run(t, getMethod(t, *o, m), *o, true, a)); + object r = run(t, getMethod(t, *o, m), *o, true, a); + jlong i = (t->exception ? 0 : doubleValue(t, r)); + jdouble f; memcpy(&f, &i, 4); + return f; } jdouble JNICALL @@ -420,7 +432,7 @@ CallVoidMethod(Thread* t, jobject o, jmethodID m, ...) inline object getStaticMethod(Thread* t, object class_, jmethodID m) { - return arrayBody(t, classMethodTable(t, class_), m); + return arrayBody(t, classMethodTable(t, class_), m - 1); } jobject JNICALL @@ -449,7 +461,8 @@ CallStaticBooleanMethodV(Thread* t, jclass c, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return booleanValue(t, run(t, getStaticMethod(t, *c, m), 0, true, a)); + object r = run(t, getStaticMethod(t, *c, m), 0, true, a); + return (t->exception ? 0 : booleanValue(t, r)); } jboolean JNICALL @@ -470,7 +483,8 @@ CallStaticByteMethodV(Thread* t, jclass c, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return byteValue(t, run(t, getStaticMethod(t, *c, m), 0, true, a)); + object r = run(t, getStaticMethod(t, *c, m), 0, true, a); + return (t->exception ? 0 : byteValue(t, r)); } jbyte JNICALL @@ -491,7 +505,8 @@ CallStaticCharMethodV(Thread* t, jclass c, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return charValue(t, run(t, getStaticMethod(t, *c, m), 0, true, a)); + object r = run(t, getStaticMethod(t, *c, m), 0, true, a); + return (t->exception ? 0 : charValue(t, r)); } jchar JNICALL @@ -512,7 +527,8 @@ CallStaticShortMethodV(Thread* t, jclass c, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return shortValue(t, run(t, getStaticMethod(t, *c, m), 0, true, a)); + object r = run(t, getStaticMethod(t, *c, m), 0, true, a); + return (t->exception ? 0 : shortValue(t, r)); } jshort JNICALL @@ -533,7 +549,8 @@ CallStaticIntMethodV(Thread* t, jclass c, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return intValue(t, run(t, getStaticMethod(t, *c, m), 0, true, a)); + object r = run(t, getStaticMethod(t, *c, m), 0, true, a); + return (t->exception ? 0 : intValue(t, r)); } jint JNICALL @@ -554,7 +571,8 @@ CallStaticLongMethodV(Thread* t, jclass c, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return longValue(t, run(t, getStaticMethod(t, *c, m), 0, true, a)); + object r = run(t, getStaticMethod(t, *c, m), 0, true, a); + return (t->exception ? 0 : longValue(t, r)); } jlong JNICALL @@ -575,7 +593,10 @@ CallStaticFloatMethodV(Thread* t, jclass c, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return floatValue(t, run(t, getStaticMethod(t, *c, m), 0, true, a)); + object r = run(t, getStaticMethod(t, *c, m), 0, true, a); + jint i = (t->exception ? 0 : floatValue(t, r)); + jfloat f; memcpy(&f, &i, 4); + return f; } jfloat JNICALL @@ -596,7 +617,10 @@ CallStaticDoubleMethodV(Thread* t, jclass c, jmethodID m, va_list a) { ENTER(t, Thread::ActiveState); - return doubleValue(t, run(t, getStaticMethod(t, *c, m), 0, true, a)); + object r = run(t, getStaticMethod(t, *c, m), 0, true, a); + jlong i = (t->exception ? 0 : doubleValue(t, r)); + jdouble f; memcpy(&f, &i, 4); + return f; } jdouble JNICALL diff --git a/src/machine.cpp b/src/machine.cpp index bf9a33ef9d..3c25c0998a 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -361,7 +361,7 @@ postCollect(Thread* t) { #ifdef VM_STRESS t->vm->system->free(t->defaultHeap); - t->defaultHeap = static_cast + t->defaultHeap = static_cast (t->vm->system->allocate(Thread::HeapSizeInBytes)); #endif @@ -996,6 +996,8 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool) PROTECT(t, method); if (flags & ACC_STATIC) { + methodOffset(t, method) = i; + if (strcmp(reinterpret_cast(""), &byteArrayBody(t, methodName(t, method), 0)) == 0) { @@ -1352,7 +1354,7 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent): runnable(this) #ifdef VM_STRESS , stress(false), - defaultHeap(static_cast(m->system->allocate(HeapSizeInBytes))) + defaultHeap(static_cast(m->system->allocate(HeapSizeInBytes))) #endif // VM_STRESS , heap(defaultHeap) { diff --git a/src/machine.h b/src/machine.h index 2b48d10a4d..fc1476ec9c 100644 --- a/src/machine.h +++ b/src/machine.h @@ -1097,9 +1097,9 @@ class Reference { class Machine { public: - enum { + enum Type { #include "type-enums.cpp" - } Type; + }; Machine(System* system, Heap* heap, Finder* finder); @@ -1246,11 +1246,12 @@ class Thread { unsigned heapOffset; Protector* protector; Runnable runnable; - uintptr_t* heap; #ifdef VM_STRESS bool stress; uintptr_t* defaultHeap; + uintptr_t* heap; #else // not VM_STRESS + uintptr_t* heap; uintptr_t defaultHeap[HeapSizeInWords]; #endif // not VM_STRESS uintptr_t stack[StackSizeInWords]; diff --git a/src/run.cpp b/src/run.cpp index c4c9d236fa..6a5c29ea8b 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -2450,8 +2450,13 @@ pushArguments(Thread* t, object this_, const char* spec, bool indirectObjects, case 'L': while (*s and *s != ';') ++ s; ++ s; - pushObject - (t, (indirectObjects ? va_arg(a, object) : *va_arg(a, object*))); + + if (indirectObjects) { + object* v = va_arg(a, object*); + pushObject(t, v ? *v : 0); + } else { + pushObject(t, va_arg(a, object)); + } break; case '[': @@ -2466,8 +2471,13 @@ pushArguments(Thread* t, object this_, const char* spec, bool indirectObjects, ++ s; break; } - pushObject - (t, (indirectObjects ? va_arg(a, object) : *va_arg(a, object*))); + + if (indirectObjects) { + object* v = va_arg(a, object*); + pushObject(t, v ? *v : 0); + } else { + pushObject(t, va_arg(a, object)); + } break; case 'J':