< prev index next >

src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

Print this page
rev 6875 : 8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
Reviewed-by: mgerdin, coleenp, bdelsart

@@ -25,10 +25,11 @@
 #if !defined(__clang_major__) && defined(__GNUC__)
 #define ATTRIBUTE_PRINTF(x,y) // FIXME, formats are a mess.
 #endif
 
 #include "precompiled.hpp"
+#include "classfile/metadataOnStackMark.hpp"
 #include "code/codeCache.hpp"
 #include "code/icBuffer.hpp"
 #include "gc_implementation/g1/bufferingOopClosure.hpp"
 #include "gc_implementation/g1/concurrentG1Refine.hpp"
 #include "gc_implementation/g1/concurrentG1RefineThread.hpp"

@@ -5131,10 +5132,14 @@
 
       for (int i = 0; i < num_claimed_nmethods; i++) {
         clean_nmethod(claimed_nmethods[i]);
       }
     }
+
+    // The nmethod cleaning helps out and does the CodeCache part of MetadataOnStackMark.
+    // Need to retire the buffers now that this thread has stopped cleaning nmethods.
+    MetadataOnStackMark::retire_buffer_for_thread(Thread::current());
   }
 
   void work_second_pass(uint worker_id) {
     nmethod* nm;
     // Take care of postponed nmethods.

@@ -5183,10 +5188,13 @@
     ik->clean_method_data(_is_alive);
 
     // G1 specific cleanup work that has
     // been moved here to be done in parallel.
     ik->clean_dependent_nmethods();
+    if (JvmtiExport::has_redefined_a_class()) {
+      InstanceKlass::purge_previous_versions(ik);
+    }
   }
 
   void work() {
     ResourceMark rm;
 

@@ -5217,12 +5225,22 @@
       _string_symbol_task(is_alive, process_strings, process_symbols),
       _code_cache_task(num_workers, is_alive, unloading_occurred),
       _klass_cleaning_task(is_alive) {
   }
 
+  void pre_work_verification() {
+    assert(!MetadataOnStackMark::has_buffer_for_thread(Thread::current()), "Should be empty");
+  }
+
+  void post_work_verification() {
+    assert(!MetadataOnStackMark::has_buffer_for_thread(Thread::current()), "Should be empty");
+  }
+
   // The parallel work done by all worker threads.
   void work(uint worker_id) {
+    pre_work_verification();
+
     // Do first pass of code cache cleaning.
     _code_cache_task.work_first_pass(worker_id);
 
     // Let the threads mark that the first pass is done.
     _code_cache_task.barrier_mark(worker_id);

@@ -5237,10 +5255,12 @@
     // the liveness information gathered during the first pass.
     _code_cache_task.work_second_pass(worker_id);
 
     // Clean all klasses that were not unloaded.
     _klass_cleaning_task.work();
+
+    post_work_verification();
   }
 };
 
 
 void G1CollectedHeap::parallel_cleaning(BoolObjectClosure* is_alive,
< prev index next >