blob: 39ce2cd5053b2748199ef2924e091d5ba98ca167 [file] [log] [blame]
Ian Rogersdf20fe02011-07-20 20:34:16 -07001// 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 Carlstrom578bbdc2011-07-21 14:07:47 -07007
8#include "assembler.h"
9#include "macros.h"
Ian Rogersdf20fe02011-07-20 20:34:16 -070010
11namespace art {
12
Elliott Hughes40ef99e2011-08-11 17:44:34 -070013class Thread;
Ian Rogersdf20fe02011-07-20 20:34:16 -070014
Elliott Hughes40ef99e2011-08-11 17:44:34 -070015JNIEnv* CreateJNIEnv();
Ian Rogersdf20fe02011-07-20 20:34:16 -070016
Elliott Hughes40ef99e2011-08-11 17:44:34 -070017struct JNIEnvExt {
18 const struct JNINativeInterface* fns; // Must be first.
Ian Rogersdf20fe02011-07-20 20:34:16 -070019
Elliott Hughes40ef99e2011-08-11 17:44:34 -070020 Thread* self;
Carl Shapiroea4dca82011-08-01 13:45:38 -070021
Elliott Hughes40ef99e2011-08-11 17:44:34 -070022 // Are we in a "critical" JNI call?
23 bool critical;
Carl Shapiro2ed144c2011-07-26 16:52:08 -070024
Elliott Hughes40ef99e2011-08-11 17:44:34 -070025 // 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 Shapiroea4dca82011-08-01 13:45:38 -070029};
30
31class 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 Rogersdf20fe02011-07-20 20:34:16 -070046};
47
48} // namespace art
Carl Shapiroea4dca82011-08-01 13:45:38 -070049
Ian Rogersdf20fe02011-07-20 20:34:16 -070050#endif // ART_SRC_JNI_INTERNAL_H_