Re-enable test 566-polymorphic-inlining.

- Can not rely on debug builds.
- Need to wait for the method to be compiled.

Change-Id: I26ce89075075da8555fd59ade56bd04bec23f4ce
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index c6e7fef..b0e5fde 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -738,15 +738,8 @@
     return false;
   }
 
-  // Compiling requires a profiling info object to notify compilation. Create
-  // one if it hasn't been done before.
-  ProfilingInfo* info = method->GetProfilingInfo(sizeof(void*));
-  if (info == nullptr) {
-    ProfilingInfo::Create(self, method, /* retry_allocation */ true);
-  }
-
   MutexLock mu(self, lock_);
-  info = method->GetProfilingInfo(sizeof(void*));
+  ProfilingInfo* info = method->GetProfilingInfo(sizeof(void*));
   if (info == nullptr || info->IsMethodBeingCompiled()) {
     return false;
   }
diff --git a/test/566-polymorphic-inlining/polymorphic_inline.cc b/test/566-polymorphic-inlining/polymorphic_inline.cc
index 55eac5c..b2934ed 100644
--- a/test/566-polymorphic-inlining/polymorphic_inline.cc
+++ b/test/566-polymorphic-inlining/polymorphic_inline.cc
@@ -29,11 +29,18 @@
   jit::Jit* jit = Runtime::Current()->GetJit();
   jit::JitCodeCache* code_cache = jit->GetCodeCache();
   ArtMethod* method = klass->FindDeclaredDirectMethodByName(method_name, sizeof(void*));
-  jit->CompileMethod(method, soa.Self());
 
-  OatQuickMethodHeader* header = OatQuickMethodHeader::FromEntryPoint(
-      method->GetEntryPointFromQuickCompiledCode());
-  CHECK(code_cache->ContainsPc(header->GetCode()));
+  OatQuickMethodHeader* header = nullptr;
+  // Infinite loop... Test harness will have its own timeout.
+  while (true) {
+    header = OatQuickMethodHeader::FromEntryPoint(method->GetEntryPointFromQuickCompiledCode());
+    if (code_cache->ContainsPc(header->GetCode())) {
+      break;
+    } else {
+      // sleep one second to give time to the JIT compiler.
+      sleep(1);
+    }
+  }
 
   CodeInfo info = header->GetOptimizedCodeInfo();
   CHECK(info.HasInlineInfo());
@@ -45,6 +52,11 @@
     return;
   }
 
+  if (kIsDebugBuild) {
+    // A debug build might often compile the methods without profiling informations filled.
+    return;
+  }
+
   do_checks(cls, "testInvokeVirtual");
   do_checks(cls, "testInvokeInterface");
 }
diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk
index bc60c3f..d6c2983 100644
--- a/test/Android.run-test.mk
+++ b/test/Android.run-test.mk
@@ -445,7 +445,6 @@
 # CFI unwinding expects managed frames, and the test does not iterate enough to even compile. JIT
 # also uses Generic JNI instead of the JNI compiler.
 TEST_ART_BROKEN_JIT_RUN_TESTS := \
-  566-polymorphic-inlining \
   137-cfi
 
 ifneq (,$(filter jit,$(COMPILER_TYPES)))