< prev index next >

src/hotspot/share/runtime/serviceThread.cpp

Print this page
rev 54996 : Checkpoint latest preliminary review patches for full OpenJDK review; merge with 8222295.patch.
rev 55000 : [mq]: dcubed.monitor_deflate_conc.v2.04

@@ -154,14 +154,17 @@
               (resolved_method_table_work = ResolvedMethodTable::has_work()) |
               (protection_domain_table_work = SystemDictionary::pd_cache_table()->has_work()) |
               (oopstorage_work = needs_oopstorage_cleanup(oopstorages,
                                                           oopstorages_cleanup,
                                                           oopstorage_count)) |
-              (deflate_idle_monitors = ObjectSynchronizer::gOmShouldDeflateIdleMonitors())
+              (deflate_idle_monitors = ObjectSynchronizer::is_async_deflation_needed())
              ) == 0) {
         // Wait until notified that there is some work to do.
-        ml.wait();
+        // If AsyncDeflateIdleMonitors, then we wait for
+        // GuaranteedSafepointInterval so that is_async_deflation_needed()
+        // is checked at the same interval.
+        ml.wait(AsyncDeflateIdleMonitors ? GuaranteedSafepointInterval : 0);
       }
 
       if (has_jvmti_events) {
         jvmti_event = JvmtiDeferredEventQueue::dequeue();
       }

@@ -203,13 +206,26 @@
       cleanup_oopstorages(oopstorages, oopstorages_cleanup, oopstorage_count);
     }
 
     if (deflate_idle_monitors) {
       // Deflate any global idle monitors.
+      ObjectSynchronizer::deflate_global_idle_monitors_using_JT();
+
       // deflate_per_thread_idle_monitors_using_JT() is called by
       // each JavaThread from ObjectSynchronizer::omAlloc() as needed.
-      ObjectSynchronizer::deflate_global_idle_monitors_using_JT();
+      int count = 0;
+      for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
+        if (jt->omInUseCount > 0) {
+          // This JavaThread is using monitors so mark it.
+          jt->omShouldDeflateIdleMonitors = true;
+          count++;
+        }
+      }
+      if (count > 0) {
+        log_debug(monitorinflation)("requesting async deflation of idle monitors for %d thread(s).", count);
+      }
+      ObjectSynchronizer::set_is_async_deflation_requested(false);  // async deflation has been requested
     }
   }
 }
 
 bool ServiceThread::is_service_thread(Thread* thread) {
< prev index next >