diff options
author | jgu21 <jinghui.gu@intel.com> | 2014-09-10 06:57:17 -0400 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-09-23 20:11:31 -0700 |
commit | a6da74e941d7cee498ac3880018a1d8dc953c6eb (patch) | |
tree | bb36d90e914f8a842abd7dd854ba168f9441e8db /runtime/native_bridge_art_interface.cc | |
parent | a20b7b3ecf90bb761d7085403782721f2fb474c5 (diff) | |
download | art-a6da74e941d7cee498ac3880018a1d8dc953c6eb.tar.gz art-a6da74e941d7cee498ac3880018a1d8dc953c6eb.tar.bz2 art-a6da74e941d7cee498ac3880018a1d8dc953c6eb.zip |
ART: Update for split native bridge initialization
Change-Id: I0b93da93251c6b4638de786bf98cf99df07c3fc2
Diffstat (limited to 'runtime/native_bridge_art_interface.cc')
-rw-r--r-- | runtime/native_bridge_art_interface.cc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/runtime/native_bridge_art_interface.cc b/runtime/native_bridge_art_interface.cc index 453c92f495..fcd11ed442 100644 --- a/runtime/native_bridge_art_interface.cc +++ b/runtime/native_bridge_art_interface.cc @@ -16,6 +16,9 @@ #include "native_bridge_art_interface.h" +#include "nativebridge/native_bridge.h" + +#include "base/logging.h" #include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "scoped_thread_state_change.h" @@ -91,4 +94,40 @@ uint32_t GetNativeMethods(JNIEnv* env, jclass clazz, JNINativeMethod* methods, return count; } +// Native bridge library runtime callbacks. They represent the runtime interface to native bridge. +// +// The interface is expected to expose the following methods: +// getMethodShorty(): in the case of native method calling JNI native function CallXXXXMethodY(), +// native bridge calls back to VM for the shorty of the method so that it can prepare based on +// host calling convention. +// getNativeMethodCount() and getNativeMethods(): in case of JNI function UnregisterNatives(), +// native bridge can call back to get all native methods of specified class so that all +// corresponding trampolines can be destroyed. +static android::NativeBridgeRuntimeCallbacks native_bridge_art_callbacks_ { + GetMethodShorty, GetNativeMethodCount, GetNativeMethods +}; + +void LoadNativeBridge(std::string& native_bridge_library_filename) { + android::LoadNativeBridge(native_bridge_library_filename.c_str(), &native_bridge_art_callbacks_); + VLOG(startup) << "Runtime::Setup native bridge library: " + << (native_bridge_library_filename.empty() ? "(empty)" : native_bridge_library_filename); +} + +void PreInitializeNativeBridge(std::string dir) { + VLOG(startup) << "Runtime::Pre-initialize native bridge"; + if (unshare(CLONE_NEWNS) == -1) { + LOG(WARNING) << "Could not create mount namespace."; + return; + } + android::PreInitializeNativeBridge(dir.c_str(), GetInstructionSetString(kRuntimeISA)); +} + +void InitializeNativeBridge(JNIEnv* env, const char* instruction_set) { + android::InitializeNativeBridge(env, instruction_set); +} + +void UnloadNativeBridge() { + android::UnloadNativeBridge(); +} + }; // namespace art |