diff options
author | 2016-06-16 14:09:03 +0100 | |
---|---|---|
committer | 2016-06-16 14:09:03 +0100 | |
commit | 2fa1137715ff3aad9359c55810de0e93f89741f0 (patch) | |
tree | 50250697d9f8016bb84e7815714583f07e34656e | |
parent | 61b370e4559a84910fe5bf0b2b1d7216ce805315 (diff) |
Ensure we get a ProfilingInfo object before compiling.
Otherwise, the compiler could decide not to JIT compile
the method.
Change-Id: I6e92224748861317c5ac629395ea180df4e51f8b
-rw-r--r-- | test/566-polymorphic-inlining/polymorphic_inline.cc | 27 | ||||
-rw-r--r-- | test/566-polymorphic-inlining/src/Main.java | 12 |
2 files changed, 32 insertions, 7 deletions
diff --git a/test/566-polymorphic-inlining/polymorphic_inline.cc b/test/566-polymorphic-inlining/polymorphic_inline.cc index 7b2c6cbcd5..c0d93dd8a1 100644 --- a/test/566-polymorphic-inlining/polymorphic_inline.cc +++ b/test/566-polymorphic-inlining/polymorphic_inline.cc @@ -17,6 +17,7 @@ #include "art_method.h" #include "jit/jit.h" #include "jit/jit_code_cache.h" +#include "jit/profiling_info.h" #include "oat_quick_method_header.h" #include "scoped_thread_state_change.h" #include "stack_map.h" @@ -37,8 +38,10 @@ static void do_checks(jclass cls, const char* method_name) { if (code_cache->ContainsPc(header->GetCode())) { break; } else { - // sleep one second to give time to the JIT compiler. - sleep(1); + // Sleep to yield to the compiler thread. + usleep(1000); + // Will either ensure it's compiled or do the compilation itself. + jit->CompileMethod(method, soa.Self(), /* osr */ false); } } @@ -47,7 +50,25 @@ static void do_checks(jclass cls, const char* method_name) { CHECK(info.HasInlineInfo(encoding)); } -extern "C" JNIEXPORT void JNICALL Java_Main_ensureJittedAndPolymorphicInline(JNIEnv*, jclass cls) { +static void allocate_profiling_info(jclass cls, const char* method_name) { + ScopedObjectAccess soa(Thread::Current()); + mirror::Class* klass = soa.Decode<mirror::Class*>(cls); + ArtMethod* method = klass->FindDeclaredDirectMethodByName(method_name, sizeof(void*)); + ProfilingInfo::Create(soa.Self(), method, /* retry_allocation */ true); +} + +extern "C" JNIEXPORT void JNICALL Java_Main_ensureProfilingInfo566(JNIEnv*, jclass cls) { + jit::Jit* jit = Runtime::Current()->GetJit(); + if (jit == nullptr) { + return; + } + + allocate_profiling_info(cls, "testInvokeVirtual"); + allocate_profiling_info(cls, "testInvokeInterface"); + allocate_profiling_info(cls, "$noinline$testInlineToSameTarget"); +} + +extern "C" JNIEXPORT void JNICALL Java_Main_ensureJittedAndPolymorphicInline566(JNIEnv*, jclass cls) { jit::Jit* jit = Runtime::Current()->GetJit(); if (jit == nullptr) { return; diff --git a/test/566-polymorphic-inlining/src/Main.java b/test/566-polymorphic-inlining/src/Main.java index a59ce5b344..d39e6ed57b 100644 --- a/test/566-polymorphic-inlining/src/Main.java +++ b/test/566-polymorphic-inlining/src/Main.java @@ -39,6 +39,9 @@ public class Main implements Itf { itfs[1] = mains[1] = new Subclass(); itfs[2] = mains[2] = new OtherSubclass(); + // Create the profiling info eagerly to make sure they are filled. + ensureProfilingInfo566(); + // Make testInvokeVirtual and testInvokeInterface hot to get them jitted. // We pass Main and Subclass to get polymorphic inlining based on calling // the same method. @@ -51,7 +54,7 @@ public class Main implements Itf { $noinline$testInlineToSameTarget(mains[1]); } - ensureJittedAndPolymorphicInline(); + ensureJittedAndPolymorphicInline566(); // At this point, the JIT should have compiled both methods, and inline // sameInvokeVirtual and sameInvokeInterface. @@ -71,12 +74,12 @@ public class Main implements Itf { } public Class sameInvokeVirtual() { - field.getClass(); // null check to ensure we get an inlined frame in the CodeInfo + field.getClass(); // null check to ensure we get an inlined frame in the CodeInfo. return Main.class; } public Class sameInvokeInterface() { - field.getClass(); // null check to ensure we get an inlined frame in the CodeInfo + field.getClass(); // null check to ensure we get an inlined frame in the CodeInfo. return Itf.class; } @@ -95,7 +98,8 @@ public class Main implements Itf { public Object field = new Object(); - public static native void ensureJittedAndPolymorphicInline(); + public static native void ensureJittedAndPolymorphicInline566(); + public static native void ensureProfilingInfo566(); public void increment() { field.getClass(); // null check to ensure we get an inlined frame in the CodeInfo |