OSDN Git Service

Fix 570-checker-osr test for non-debuggable mode.
authorVladimir Marko <vmarko@google.com>
Tue, 19 Apr 2016 16:26:54 +0000 (17:26 +0100)
committerVladimir Marko <vmarko@google.com>
Tue, 19 Apr 2016 17:35:37 +0000 (18:35 +0100)
For non-debuggable mode, we need to create profiling info.

Bug: 28210356

(cherry picked from commit b9d338b96c804a077dc2ed60b36b7ab64dc2c78c)

Change-Id: I5044e94bf78bd982007c8e7a3a9e5ee56f861e9c

test/570-checker-osr/osr.cc
test/570-checker-osr/src/Main.java

index ac2e0ce..2a5b2c9 100644 (file)
@@ -89,35 +89,41 @@ extern "C" JNIEXPORT jboolean JNICALL Java_Main_isInInterpreter(JNIEnv* env,
 
 class ProfilingInfoVisitor : public StackVisitor {
  public:
-  explicit ProfilingInfoVisitor(Thread* thread)
+  explicit ProfilingInfoVisitor(Thread* thread, const char* method_name)
       SHARED_REQUIRES(Locks::mutator_lock_)
-      : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames) {}
+      : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+        method_name_(method_name) {}
 
   bool VisitFrame() SHARED_REQUIRES(Locks::mutator_lock_) {
     ArtMethod* m = GetMethod();
     std::string m_name(m->GetName());
 
-    if ((m_name.compare("$noinline$inlineCache") == 0) ||
-        (m_name.compare("$noinline$stackOverflow") == 0)) {
+    if (m_name.compare(method_name_) == 0) {
       ProfilingInfo::Create(Thread::Current(), m, /* retry_allocation */ true);
       return false;
     }
     return true;
   }
+
+  const char* const method_name_;
 };
 
-extern "C" JNIEXPORT void JNICALL Java_Main_ensureHasProfilingInfo(JNIEnv*, jclass) {
+extern "C" JNIEXPORT void JNICALL Java_Main_ensureHasProfilingInfo(JNIEnv* env,
+                                                                   jclass,
+                                                                   jstring method_name) {
   if (!Runtime::Current()->UseJit()) {
     return;
   }
+  ScopedUtfChars chars(env, method_name);
+  CHECK(chars.c_str() != nullptr);
   ScopedObjectAccess soa(Thread::Current());
-  ProfilingInfoVisitor visitor(soa.Self());
+  ProfilingInfoVisitor visitor(soa.Self(), chars.c_str());
   visitor.WalkStack();
 }
 
 class OsrCheckVisitor : public StackVisitor {
  public:
-  OsrCheckVisitor(Thread* thread, const char* const method_name)
+  OsrCheckVisitor(Thread* thread, const char* method_name)
       SHARED_REQUIRES(Locks::mutator_lock_)
       : StackVisitor(thread, nullptr, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
         method_name_(method_name) {}
index f22a0c1..200b54a 100644 (file)
@@ -124,7 +124,7 @@ public class Main {
       return SubMain.class;
     }
 
-    ensureHasProfilingInfo();
+    ensureHasProfilingInfo("$noinline$inlineCache");
 
     // Ensure that we have OSR code to jump to.
     if (isSecondInvocation) {
@@ -167,7 +167,7 @@ public class Main {
     }
 
     // We need a ProfilingInfo object to populate the 'otherInlineCache' call.
-    ensureHasProfilingInfo();
+    ensureHasProfilingInfo("$noinline$stackOverflow");
 
     if (isSecondInvocation) {
       // Ensure we have an OSR code and we jump to it.
@@ -188,6 +188,7 @@ public class Main {
     assertIntEquals(12, $opt$inline$testRemoveSuspendCheck(12, 5));
     // Since we cannot have a loop directly in this method, we need to force the OSR
     // compilation from native code.
+    ensureHasProfilingInfo("$opt$noinline$testOsrInlineLoop");
     ensureHasOsrCode("$opt$noinline$testOsrInlineLoop");
   }
 
@@ -219,7 +220,7 @@ public class Main {
 
   public static native boolean isInOsrCode(String methodName);
   public static native boolean isInInterpreter(String methodName);
-  public static native void ensureHasProfilingInfo();
+  public static native void ensureHasProfilingInfo(String methodName);
   public static native void ensureHasOsrCode(String methodName);
 
   public static boolean doThrow = false;