Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #ifndef ART_SRC_JNI_INTERNAL_H_ |
| 4 | #define ART_SRC_JNI_INTERNAL_H_ |
| 5 | |
| 6 | #include "jni.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 7 | |
| 8 | #include "assembler.h" |
| 9 | #include "macros.h" |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 10 | |
| 11 | namespace art { |
| 12 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame^] | 13 | class Thread; |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 14 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame^] | 15 | JNIEnv* CreateJNIEnv(); |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 16 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame^] | 17 | struct JNIEnvExt { |
| 18 | const struct JNINativeInterface* fns; // Must be first. |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 19 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame^] | 20 | Thread* self; |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 21 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame^] | 22 | // Are we in a "critical" JNI call? |
| 23 | bool critical; |
Carl Shapiro | 2ed144c | 2011-07-26 16:52:08 -0700 | [diff] [blame] | 24 | |
Elliott Hughes | 40ef99e | 2011-08-11 17:44:34 -0700 | [diff] [blame^] | 25 | // Used to help call synchronized native methods. |
| 26 | // TODO: make jni_compiler.cc do the indirection itself. |
| 27 | void (*MonitorEnterHelper)(JNIEnv*, jobject); |
| 28 | void (*MonitorExitHelper)(JNIEnv*, jobject); |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | class JniInvokeInterface { |
| 32 | public: |
| 33 | static struct JNIInvokeInterface* GetInterface() { |
| 34 | return &invoke_interface_; |
| 35 | } |
| 36 | private: |
| 37 | static jint DestroyJavaVM(JavaVM* vm); |
| 38 | static jint AttachCurrentThread(JavaVM* vm, JNIEnv** penv, void* thr_args); |
| 39 | static jint DetachCurrentThread(JavaVM* vm); |
| 40 | static jint GetEnv(JavaVM* vm, void** penv, int version); |
| 41 | static jint AttachCurrentThreadAsDaemon(JavaVM* vm, |
| 42 | JNIEnv** penv, |
| 43 | void* thr_args); |
| 44 | static struct JNIInvokeInterface invoke_interface_; |
| 45 | DISALLOW_IMPLICIT_CONSTRUCTORS(JniInvokeInterface); |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | } // namespace art |
Carl Shapiro | ea4dca8 | 2011-08-01 13:45:38 -0700 | [diff] [blame] | 49 | |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 50 | #endif // ART_SRC_JNI_INTERNAL_H_ |