diff options
author | 2020-08-06 15:25:19 +0100 | |
---|---|---|
committer | 2020-08-07 09:26:23 +0000 | |
commit | 2c71e26d4fa5cd8f4dbf5c60291a7242725e43d2 (patch) | |
tree | a9eb90df557000c8f5fed8ff4f5e5b400e3eb5a7 | |
parent | a996425197a7946eae02d218f70610a853f2fe9a (diff) |
Make 566-polymorphic-inlining more robust.
And make it pass on jit-at-first-use.
Test: 566-polymorphic-inlining
Bug: 152392499
Change-Id: I965dece8eaf3176e7082daf786af4d7d915ce27d
-rw-r--r-- | test/566-polymorphic-inlining/polymorphic_inline.cc | 38 | ||||
-rw-r--r-- | test/566-polymorphic-inlining/src/Main.java | 13 |
2 files changed, 37 insertions, 14 deletions
diff --git a/test/566-polymorphic-inlining/polymorphic_inline.cc b/test/566-polymorphic-inlining/polymorphic_inline.cc index 191a9427aa..34ec3ff86f 100644 --- a/test/566-polymorphic-inlining/polymorphic_inline.cc +++ b/test/566-polymorphic-inlining/polymorphic_inline.cc @@ -20,24 +20,25 @@ #include "jit/jit_code_cache.h" #include "jit/profiling_info.h" #include "mirror/class.h" +#include "nativehelper/ScopedUtfChars.h" #include "oat_quick_method_header.h" #include "scoped_thread_state_change-inl.h" #include "stack_map.h" namespace art { -static void do_checks(jclass cls, const char* method_name) { - ScopedObjectAccess soa(Thread::Current()); - ObjPtr<mirror::Class> klass = soa.Decode<mirror::Class>(cls); +static bool do_checks(ArtMethod* method, ScopedObjectAccess& soa) + REQUIRES_SHARED(Locks::mutator_lock_) { jit::Jit* jit = Runtime::Current()->GetJit(); jit::JitCodeCache* code_cache = jit->GetCodeCache(); - ArtMethod* method = klass->FindDeclaredDirectMethodByName(method_name, kRuntimePointerSize); OatQuickMethodHeader* header = nullptr; // Infinite loop... Test harness will have its own timeout. while (true) { const void* pc = method->GetEntryPointFromQuickCompiledCode(); - if (code_cache->ContainsPc(pc)) { + if (code_cache->ContainsPc(pc) && + !CodeInfo::IsBaseline( + OatQuickMethodHeader::FromEntryPoint(pc)->GetOptimizedCodeInfoPtr())) { header = OatQuickMethodHeader::FromEntryPoint(pc); break; } else { @@ -50,19 +51,32 @@ static void do_checks(jclass cls, const char* method_name) { } CodeInfo info(header); - CHECK(info.HasInlineInfo()) << method->PrettyMethod(); + return info.HasInlineInfo(); } -extern "C" JNIEXPORT void JNICALL Java_Main_ensureJittedAndPolymorphicInline566(JNIEnv*, jclass cls) { +extern "C" JNIEXPORT bool JNICALL Java_Main_ensureJittedAndPolymorphicInline566(JNIEnv* env, + jclass cls, + jstring method_name) { jit::Jit* jit = Runtime::Current()->GetJit(); if (jit == nullptr) { - return; + return true; + } + + // The test only works when we use tiered JIT. + if (jit->JitAtFirstUse()) { + return true; + } + + ScopedObjectAccess soa(Thread::Current()); + ScopedUtfChars chars(env, method_name); + ArtMethod* method = soa.Decode<mirror::Class>(cls)->FindDeclaredDirectMethodByName( + chars.c_str(), kRuntimePointerSize); + + if (method == nullptr) { + return false; } - do_checks(cls, "$noinline$testInvokeVirtual"); - do_checks(cls, "$noinline$testInvokeInterface"); - do_checks(cls, "$noinline$testInvokeInterface2"); - do_checks(cls, "$noinline$testInlineToSameTarget"); + return do_checks(method, soa); } } // namespace art diff --git a/test/566-polymorphic-inlining/src/Main.java b/test/566-polymorphic-inlining/src/Main.java index 340a269f5e..595a0567c1 100644 --- a/test/566-polymorphic-inlining/src/Main.java +++ b/test/566-polymorphic-inlining/src/Main.java @@ -55,7 +55,10 @@ public class Main implements Itf { $noinline$testInlineToSameTarget(mains[1]); } - ensureJittedAndPolymorphicInline566(); + ensureJittedAndPolymorphicInline("$noinline$testInvokeVirtual"); + ensureJittedAndPolymorphicInline("$noinline$testInvokeInterface"); + ensureJittedAndPolymorphicInline("$noinline$testInvokeInterface2"); + ensureJittedAndPolymorphicInline("$noinline$testInlineToSameTarget"); // At this point, the JIT should have compiled both methods, and inline // sameInvokeVirtual and sameInvokeInterface. @@ -121,7 +124,13 @@ public class Main implements Itf { public Object field = new Object(); - public static native void ensureJittedAndPolymorphicInline566(); + public static void ensureJittedAndPolymorphicInline(String methodName) { + if (!ensureJittedAndPolymorphicInline566(methodName)) { + throw new Error("Didn't find an inlined method in " + methodName); + } + } + + public static native boolean ensureJittedAndPolymorphicInline566(String methodName); public void increment() { field.getClass(); // null check to ensure we get an inlined frame in the CodeInfo |