< prev index next >

src/share/vm/runtime/synchronizer.cpp

Print this page
rev 13387 : [mq]: parallel_sp_cleaning.patch

@@ -1684,34 +1684,40 @@
     }
   }
   return deflated_count;
 }
 
-void ObjectSynchronizer::deflate_idle_monitors() {
+void ObjectSynchronizer::deflate_idle_monitors(bool deflate_thread_local_monitors) {
   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
   int nInuse = 0;              // currently associated with objects
   int nInCirculation = 0;      // extant
   int nScavenged = 0;          // reclaimed
   bool deflated = false;
 
   ObjectMonitor * freeHeadp = NULL;  // Local SLL of scavenged monitors
   ObjectMonitor * freeTailp = NULL;
 
   TEVENT(deflate_idle_monitors);
-  if (MonitorInUseLists) {
-    if (! Universe::heap()->supports_per_thread_monitor_deflation() ||
-        ForceMonitorScavenge == 1) {
-      Universe::heap()->deflate_idle_monitors_all_threads();
-    }
-  }
-
   // Prevent omFlush from changing mids in Thread dtor's during deflation
   // And in case the vm thread is acquiring a lock during a safepoint
   // See e.g. 6320749
   Thread::muxAcquire(&gListLock, "scavenge - return");
 
   if (MonitorInUseLists) {
+    if (deflate_thread_local_monitors) {
+      for (JavaThread* cur = Threads::first(); cur != NULL; cur = cur->next()) {
+        nInCirculation+= cur->omInUseCount;
+        int deflated_count = deflate_monitor_list(cur->omInUseList_addr(), &freeHeadp, &freeTailp);
+        cur->omInUseCount-= deflated_count;
+        if (ObjectMonitor::Knob_VerifyInUse) {
+          verifyInUse(cur);
+        }
+        nScavenged += deflated_count;
+        nInuse += cur->omInUseCount;
+      }
+    }
+
     // For moribund threads, scan gOmInUseList
     if (gOmInUseList) {
       nInCirculation += gOmInUseCount;
       int deflated_count = deflate_monitor_list((ObjectMonitor **)&gOmInUseList, &freeHeadp, &freeTailp);
       gOmInUseCount-= deflated_count;

@@ -1784,12 +1790,10 @@
 }
 
 void ObjectSynchronizer::deflate_idle_monitors_and_oops_do(Thread* thread, OopClosure* cl) {
   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
   if (! MonitorInUseLists) return;
-  if (ForceMonitorScavenge == 1) return;
-  assert(Universe::heap()->supports_per_thread_monitor_deflation(), "only call this when supported by GC");
 
   ObjectMonitor * freeHeadp = NULL;  // Local SLL of scavenged monitors
   ObjectMonitor * freeTailp = NULL;
 
   int deflated_count = deflate_monitor_list(thread->omInUseList_addr(), &freeHeadp, &freeTailp, cl);
< prev index next >