// public static native boolean isInterpretedFunction(String smali);
staticbool IsMethodInterpreted(Thread* self, const ArtMethod* goal, constbool require_deoptable, /* out */ bool* method_is_interpreted)
REQUIRES_SHARED(Locks::mutator_lock_) {
*method_is_interpreted = true; bool method_found = false; bool prev_was_runtime = true;
StackVisitor::WalkStack(
[&](const art::StackVisitor* stack_visitor) REQUIRES_SHARED(Locks::mutator_lock_) { if (goal == stack_visitor->GetMethod()) { // We don't deoptimize beyond a runtime frame. So if we need the method to be // deoptimizeable we cannot allow the previous frame to be a runtime frame.
*method_is_interpreted =
(require_deoptable && prev_was_runtime) || stack_visitor->IsShadowFrame();
method_found = true; returnfalse;
}
prev_was_runtime = stack_visitor->GetMethod()->IsRuntimeMethod(); returntrue;
},
self, /* context= */ nullptr,
art::StackVisitor::StackWalkKind::kIncludeInlinedFrames); return method_found;
}
// TODO Remove 'require_deoptimizable' option once we have deoptimization through runtime frames. extern"C" JNIEXPORT jboolean JNICALL Java_Main_isInterpretedFunction(
JNIEnv* env, [[maybe_unused]] jclass klass, jobject method, jboolean require_deoptimizable) { // Return false if this seems to not be an ART runtime. if (Runtime::Current() == nullptr) { return JNI_FALSE;
} if (method == nullptr) {
env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "method is null!"); return JNI_FALSE;
}
jmethodID id = env->FromReflectedMethod(method); if (id == nullptr) {
env->ThrowNew(env->FindClass("java/lang/Error"), "Unable to interpret method argument!"); return JNI_FALSE;
}
{
ScopedObjectAccess soa(env);
ArtMethod* goal = jni::DecodeArtMethod(id); bool is_interpreted; if (!IsMethodInterpreted(soa.Self(), goal, require_deoptimizable, &is_interpreted)) {
env->ThrowNew(env->FindClass("java/lang/Error"), "Unable to find given method in stack!"); return JNI_FALSE;
} bool enters_interpreter = Runtime::Current()->GetClassLinker()->IsQuickToInterpreterBridge(
goal->GetEntryPointFromQuickCompiledCode()); return (is_interpreted || enters_interpreter);
}
}
// public static native void assertIsInterpreted();
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.