Support for synchronized native methods.
This change adds support for synchronized native methods by using
calls to MonitorEnter and MonitorExit on the JNIEnv*. There is
some tidying of the assembler and a straw man JNIEnv implementation.
The JNIEnv implementation just warns when MonitorEnter/Exit are called
and doesn't adhere to the correct JNIEnv layout.
Change-Id: I90ed6ec8f85f5b01b929f16e0dbdecadd0b01359
diff --git a/src/thread.h b/src/thread.h
index ab0bacc..3f962d5 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -9,6 +9,7 @@
#include "src/globals.h"
#include "src/heap.h"
+#include "src/jni_internal.h"
#include "src/logging.h"
#include "src/macros.h"
#include "src/runtime.h"
@@ -179,7 +180,7 @@
}
// JNI methods
- JNIEnv* GetJniEnv() const {
+ JniEnvironment* GetJniEnv() const {
return jni_env_;
}
@@ -204,10 +205,12 @@
private:
Thread() :
- thread_id_(1234), top_shb_(NULL),
- jni_env_(reinterpret_cast<JNIEnv*>(0xEBADC0DE)), exception_(NULL) {
+ thread_id_(1234), top_shb_(NULL), exception_(NULL) {
+ jni_env_ = new JniEnvironment();
}
- ~Thread() {}
+ ~Thread() {
+ delete jni_env_;
+ }
void InitCpu();
@@ -224,7 +227,7 @@
StackHandleBlock* top_shb_;
// Every thread may have an associated JNI environment
- JNIEnv* jni_env_;
+ JniEnvironment* jni_env_;
State state_;