uint32_t count = 0; for (auto& m : c->GetMethods(kRuntimePointerSize)) { if (m.IsNative()) { if (count < method_count) {
methods[count].name = m.GetName();
methods[count].signature = m.GetShorty();
methods[count].fnPtr = m.GetEntryPointFromJni();
count++;
} else {
LOG(WARNING) << "Output native method array too small. Skipping "
<< m.PrettyMethod();
}
}
} 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 PreInitializeNativeBridge(const std::string& dir) {
VLOG(startup) << "Runtime::Pre-initialize native bridge"; #ifndef __APPLE__ // Mac OS does not support CLONE_NEWNS. if (unshare(CLONE_NEWNS) == -1) {
LOG(WARNING) << "Could not create mount namespace.";
}
android::PreInitializeNativeBridge(dir.c_str(), GetInstructionSetString(kRuntimeISA)); #else
UNUSED(dir); #endif
}
void InitializeNativeBridge(JNIEnv* env, constchar* instruction_set) { if (android::NativeBridgeInitialized()) { // This happens in apps forked from app-zygote, since native bridge // is initialized in the zygote. return;
} if (android::InitializeNativeBridge(env, instruction_set)) { if (android::NativeBridgeGetVersion() >= 2U) { #ifdef _NSIG // Undefined on Apple, but we don't support running on Mac, anyways. // Managed signal handling support added in version 2. for (int signal = 0; signal < _NSIG; ++signal) {
android::NativeBridgeSignalHandlerFn fn = android::NativeBridgeGetSignalHandler(signal); if (fn != nullptr) {
sigset_t mask;
sigfillset(&mask);
SigchainAction sa = {
.sc_sigaction = fn,
.sc_mask = mask, // The native bridge signal might not return back to sigchain's handler.
.sc_flags = SIGCHAIN_ALLOW_NORETURN,
};
AddSpecialSignalHandlerFn(signal, &sa);
}
} #endif
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.