< prev index next >

src/hotspot/share/runtime/interfaceSupport.cpp

Print this page
rev 56101 : 8227745: Enable Escape Analysis for better performance when debugging
Reviewed-by: ???

@@ -28,10 +28,11 @@
 #include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "memory/universe.hpp"
 #include "runtime/atomic.hpp"
 #include "runtime/frame.inline.hpp"
+#include "runtime/deoptimization.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/init.hpp"
 #include "runtime/interfaceSupport.inline.hpp"
 #include "runtime/orderAccess.hpp"
 #include "runtime/os.inline.hpp"

@@ -65,10 +66,13 @@
     InterfaceSupport::deoptimizeAll();
   }
   if (ZombieALot) {
     InterfaceSupport::zombieAll();
   }
+  if (DeoptimizeObjectsALot == 1) {
+    InterfaceSupport::deoptimizeAllObjects();
+  }
   // do verification AFTER potential deoptimization
   if (VerifyStack) {
     InterfaceSupport::verify_stack();
   }
 }

@@ -197,10 +201,11 @@
 }
 
 // invocation counter for InterfaceSupport::deoptimizeAll/zombieAll functions
 int deoptimizeAllCounter = 0;
 int zombieAllCounter = 0;
+int deoptimizeAllObjectsCounter = 0;
 
 void InterfaceSupport::zombieAll() {
   // This method is called by all threads when a thread make
   // transition to VM state (for example, runtime calls).
   // Divide number of calls by number of threads to avoid

@@ -231,10 +236,27 @@
     }
   }
   deoptimizeAllCounter++;
 }
 
+void InterfaceSupport::deoptimizeAllObjects() {
+  // This method is called by all threads when a thread makes
+  // transition to VM state (for example, runtime calls).
+  // Divide number of calls by number of threads to avoid
+  // dependence of DeoptimizeObjectsALot events frequency on number of threads.
+  int value = deoptimizeAllObjectsCounter / Threads::number_of_threads();
+  if (is_init_completed() && value > DeoptimizeObjectsALotInterval) {
+    // Revert optimizations based on escape analysis for all compiled frames of all Java threads as
+    // if objects local to a frame or a thread were escaping.
+    deoptimizeAllObjectsCounter = 0;
+    JavaThread* ct = JavaThread::current();
+    JVMTIEscapeBarrier eb(ct, true);
+    eb.deoptimize_objects_all_threads();
+  }
+  deoptimizeAllObjectsCounter++;
+}
+
 
 void InterfaceSupport::stress_derived_pointers() {
 #ifdef COMPILER2
   JavaThread *thread = JavaThread::current();
   if (!is_init_completed()) return;
< prev index next >