1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu Nov 06 09:15:23 2014 -0800 1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Nov 19 12:52:56 2014 -0800 1.3 @@ -27,6 +27,7 @@ 1.4 #endif 1.5 1.6 #include "precompiled.hpp" 1.7 +#include "classfile/metadataOnStackMark.hpp" 1.8 #include "code/codeCache.hpp" 1.9 #include "code/icBuffer.hpp" 1.10 #include "gc_implementation/g1/bufferingOopClosure.hpp" 1.11 @@ -5133,6 +5134,10 @@ 1.12 clean_nmethod(claimed_nmethods[i]); 1.13 } 1.14 } 1.15 + 1.16 + // The nmethod cleaning helps out and does the CodeCache part of MetadataOnStackMark. 1.17 + // Need to retire the buffers now that this thread has stopped cleaning nmethods. 1.18 + MetadataOnStackMark::retire_buffer_for_thread(Thread::current()); 1.19 } 1.20 1.21 void work_second_pass(uint worker_id) { 1.22 @@ -5185,6 +5190,9 @@ 1.23 // G1 specific cleanup work that has 1.24 // been moved here to be done in parallel. 1.25 ik->clean_dependent_nmethods(); 1.26 + if (JvmtiExport::has_redefined_a_class()) { 1.27 + InstanceKlass::purge_previous_versions(ik); 1.28 + } 1.29 } 1.30 1.31 void work() { 1.32 @@ -5219,8 +5227,18 @@ 1.33 _klass_cleaning_task(is_alive) { 1.34 } 1.35 1.36 + void pre_work_verification() { 1.37 + assert(!MetadataOnStackMark::has_buffer_for_thread(Thread::current()), "Should be empty"); 1.38 + } 1.39 + 1.40 + void post_work_verification() { 1.41 + assert(!MetadataOnStackMark::has_buffer_for_thread(Thread::current()), "Should be empty"); 1.42 + } 1.43 + 1.44 // The parallel work done by all worker threads. 1.45 void work(uint worker_id) { 1.46 + pre_work_verification(); 1.47 + 1.48 // Do first pass of code cache cleaning. 1.49 _code_cache_task.work_first_pass(worker_id); 1.50 1.51 @@ -5239,6 +5257,8 @@ 1.52 1.53 // Clean all klasses that were not unloaded. 1.54 _klass_cleaning_task.work(); 1.55 + 1.56 + post_work_verification(); 1.57 } 1.58 }; 1.59