From 6e19f4dccadece16e6656f44a62e5024158a7725 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 14 Feb 2011 18:55:11 -0700 Subject: [PATCH] use vmRun to execute implementations of JVM_MonitorWait/Notify/NotifyAll These methods can all throw exceptions, so they must be run using vmRun to avoid unwinding past the JVM entry points. --- src/classpath-openjdk.cpp | 45 +++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 56782758db..69e4d67b68 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -1806,28 +1806,61 @@ EXPORT(JVM_IHashCode)(Thread* t, jobject o) return objectHash(t, *o); } +uint64_t +jvmWait(Thread* t, uintptr_t* arguments) +{ + jobject o = reinterpret_cast(arguments[0]); + jlong milliseconds; memcpy(&milliseconds, arguments + 1, sizeof(jlong)); + + vm::wait(t, *o, milliseconds); + + return 1; +} + extern "C" JNIEXPORT void JNICALL EXPORT(JVM_MonitorWait)(Thread* t, jobject o, jlong milliseconds) { - ENTER(t, Thread::ActiveState); + uintptr_t arguments[1 + (sizeof(jlong) / BytesPerWord)]; + arguments[0] = reinterpret_cast(o); + memcpy(arguments + 1, &milliseconds, sizeof(jlong)); - vm::wait(t, *o, milliseconds); + run(t, jvmWait, arguments); +} + +uint64_t +jvmNotify(Thread* t, uintptr_t* arguments) +{ + jobject o = reinterpret_cast(arguments[0]); + + notify(t, *o); + + return 1; } extern "C" JNIEXPORT void JNICALL EXPORT(JVM_MonitorNotify)(Thread* t, jobject o) { - ENTER(t, Thread::ActiveState); + uintptr_t arguments[] = { reinterpret_cast(o) }; - notify(t, *o); + run(t, jvmNotify, arguments); +} + +uint64_t +jvmNotifyAll(Thread* t, uintptr_t* arguments) +{ + jobject o = reinterpret_cast(arguments[0]); + + notifyAll(t, *o); + + return 1; } extern "C" JNIEXPORT void JNICALL EXPORT(JVM_MonitorNotifyAll)(Thread* t, jobject o) { - ENTER(t, Thread::ActiveState); + uintptr_t arguments[] = { reinterpret_cast(o) }; - notifyAll(t, *o); + run(t, jvmNotifyAll, arguments); } uint64_t