OSDN Git Service

Fix interaction between instrumentation and jit lock.
authorNicolas Geoffray <ngeoffray@google.com>
Mon, 18 Apr 2016 11:09:30 +0000 (12:09 +0100)
committerNicolas Geoffray <ngeoffray@google.com>
Mon, 18 Apr 2016 11:32:44 +0000 (12:32 +0100)
The jit lock needs to have higher priority than the
deoptimized methods lock.

bug:28236735

Change-Id: I82862b8bfc82a5641156290926c04c80b1371534

runtime/base/mutex.h
runtime/jit/jit.cc
runtime/jit/jit_code_cache.cc

index 17e0339..3dca12a 100644 (file)
@@ -76,7 +76,6 @@ enum LockLevel {
   kReferenceQueueClearedReferencesLock,
   kReferenceProcessorLock,
   kJitDebugInterfaceLock,
-  kJitCodeCacheLock,
   kAllocSpaceLock,
   kBumpPointerSpaceBlockLock,
   kArenaPoolLock,
@@ -89,6 +88,7 @@ enum LockLevel {
   kTracingUniqueMethodsLock,
   kTracingStreamingLock,
   kDeoptimizedMethodsLock,
+  kJitCodeCacheLock,
   kClassLoaderClassesLock,
   kDefaultMutexLevel,
   kMarkSweepLargeObjectLock,
index 0a6da2c..2a66847 100644 (file)
@@ -635,12 +635,9 @@ void Jit::MethodEntered(Thread* thread, ArtMethod* method) {
   ProfilingInfo* profiling_info = method->GetProfilingInfo(sizeof(void*));
   // Update the entrypoint if the ProfilingInfo has one. The interpreter will call it
   // instead of interpreting the method.
-  // We avoid doing this if exit stubs are installed to not mess with the instrumentation.
-  // TODO(ngeoffray): Clean up instrumentation and code cache interactions.
-  if ((profiling_info != nullptr) &&
-      (profiling_info->GetSavedEntryPoint() != nullptr) &&
-      !Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled()) {
-    method->SetEntryPointFromQuickCompiledCode(profiling_info->GetSavedEntryPoint());
+  if ((profiling_info != nullptr) && (profiling_info->GetSavedEntryPoint() != nullptr)) {
+    Runtime::Current()->GetInstrumentation()->UpdateMethodsCode(
+        method, profiling_info->GetSavedEntryPoint());
   } else {
     AddSamples(thread, method, 1, /* with_backedges */false);
   }
index 1f3e08b..752d4ba 100644 (file)
@@ -354,8 +354,7 @@ uint8_t* JitCodeCache::CommitCodeInternal(Thread* self,
     if (osr) {
       number_of_osr_compilations_++;
       osr_code_map_.Put(method, code_ptr);
-    } else if (!Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled()) {
-      // TODO(ngeoffray): Clean up instrumentation and code cache interactions.
+    } else {
       Runtime::Current()->GetInstrumentation()->UpdateMethodsCode(
           method, method_header->GetEntryPoint());
     }
@@ -634,10 +633,7 @@ void JitCodeCache::GarbageCollectCache(Thread* self) {
       bool next_collection_will_be_full = ShouldDoFullCollection();
 
       // Start polling the liveness of compiled code to prepare for the next full collection.
-      // We avoid doing this if exit stubs are installed to not mess with the instrumentation.
-      // TODO(ngeoffray): Clean up instrumentation and code cache interactions.
-      if (!Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled() &&
-          next_collection_will_be_full) {
+      if (next_collection_will_be_full) {
         // Save the entry point of methods we have compiled, and update the entry
         // point of those methods to the interpreter. If the method is invoked, the
         // interpreter will update its entry point to the compiled code and call it.
@@ -645,7 +641,8 @@ void JitCodeCache::GarbageCollectCache(Thread* self) {
           const void* entry_point = info->GetMethod()->GetEntryPointFromQuickCompiledCode();
           if (ContainsPc(entry_point)) {
             info->SetSavedEntryPoint(entry_point);
-            info->GetMethod()->SetEntryPointFromQuickCompiledCode(GetQuickToInterpreterBridge());
+            Runtime::Current()->GetInstrumentation()->UpdateMethodsCode(
+                info->GetMethod(), GetQuickToInterpreterBridge());
           }
         }