--- old/src/share/vm/gc/g1/g1MarkSweep.cpp 2016-03-09 17:39:42.817075461 +0100 +++ new/src/share/vm/gc/g1/g1MarkSweep.cpp 2016-03-09 17:39:42.673070619 +0100 @@ -220,12 +220,6 @@ } }; -class G1AlwaysTrueClosure: public BoolObjectClosure { -public: - bool do_object_b(oop p) { return true; } -}; -static G1AlwaysTrueClosure always_true; - void G1MarkSweep::mark_sweep_phase3() { G1CollectedHeap* g1h = G1CollectedHeap::heap(); @@ -248,7 +242,7 @@ // Now adjust pointers in remaining weak roots. (All of which should // have been cleared if they pointed to non-surviving objects.) - JNIHandles::weak_oops_do(&always_true, &GenMarkSweep::adjust_pointer_closure); + JNIHandles::weak_oops_do(&GenMarkSweep::adjust_pointer_closure); if (G1StringDedup::is_enabled()) { G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure); --- old/src/share/vm/gc/parallel/psMarkSweep.cpp 2016-03-09 17:39:43.081084340 +0100 +++ new/src/share/vm/gc/parallel/psMarkSweep.cpp 2016-03-09 17:39:42.925079092 +0100 @@ -570,13 +570,6 @@ old_gen->precompact(); } -// This should be moved to the shared markSweep code! -class PSAlwaysTrueClosure: public BoolObjectClosure { -public: - bool do_object_b(oop p) { return true; } -}; -static PSAlwaysTrueClosure always_true; - void PSMarkSweep::mark_sweep_phase3() { // Adjust the pointers to reflect the new locations GCTraceTime(Trace, gc) tm("Phase 3: Adjust pointers", _gc_timer); @@ -603,7 +596,7 @@ // Now adjust pointers in remaining weak roots. (All of which should // have been cleared if they pointed to non-surviving objects.) // Global (weak) JNI handles - JNIHandles::weak_oops_do(&always_true, adjust_pointer_closure()); + JNIHandles::weak_oops_do(adjust_pointer_closure()); CodeBlobToOopClosure adjust_from_blobs(adjust_pointer_closure(), CodeBlobToOopClosure::FixRelocations); CodeCache::blobs_do(&adjust_from_blobs); --- old/src/share/vm/gc/parallel/psParallelCompact.cpp 2016-03-09 17:39:43.353093494 +0100 +++ new/src/share/vm/gc/parallel/psParallelCompact.cpp 2016-03-09 17:39:43.197088244 +0100 @@ -2157,7 +2157,7 @@ // Now adjust pointers in remaining weak roots. (All of which should // have been cleared if they pointed to non-surviving objects.) // Global (weak) JNI handles - JNIHandles::weak_oops_do(&always_true, &oop_closure); + JNIHandles::weak_oops_do(&oop_closure); CodeBlobToOopClosure adjust_from_blobs(&oop_closure, CodeBlobToOopClosure::FixRelocations); CodeCache::blobs_do(&adjust_from_blobs); --- old/src/share/vm/gc/shared/genCollectedHeap.cpp 2016-03-09 17:39:43.645103321 +0100 +++ new/src/share/vm/gc/shared/genCollectedHeap.cpp 2016-03-09 17:39:43.501098475 +0100 @@ -684,15 +684,8 @@ _process_strong_tasks->all_tasks_completed(scope->n_threads()); } - -class AlwaysTrueClosure: public BoolObjectClosure { -public: - bool do_object_b(oop p) { return true; } -}; -static AlwaysTrueClosure always_true; - void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) { - JNIHandles::weak_oops_do(&always_true, root_closure); + JNIHandles::weak_oops_do(root_closure); _young_gen->ref_processor()->weak_oops_do(root_closure); _old_gen->ref_processor()->weak_oops_do(root_closure); } --- old/src/share/vm/gc/shared/referenceProcessor.cpp 2016-03-09 17:39:43.925112744 +0100 +++ new/src/share/vm/gc/shared/referenceProcessor.cpp 2016-03-09 17:39:43.773107629 +0100 @@ -281,8 +281,7 @@ size_t count() { return _count; } }; CountHandleClosure global_handle_count; - AlwaysAliveClosure always_alive; - JNIHandles::weak_oops_do(&always_alive, &global_handle_count); + JNIHandles::weak_oops_do(&global_handle_count); return global_handle_count.count(); } #endif --- old/src/share/vm/runtime/jniHandles.cpp 2016-03-09 17:39:44.193121763 +0100 +++ new/src/share/vm/runtime/jniHandles.cpp 2016-03-09 17:39:44.041116648 +0100 @@ -128,6 +128,17 @@ } +void JNIHandles::weak_oops_do(OopClosure* f) { + class AlwaysTrueClosure: public BoolObjectClosure { + public: + bool do_object_b(oop p) { return true; } + }; + static AlwaysTrueClosure always_true; + + weak_oops_do(&always_true, f); +} + + void JNIHandles::initialize() { _global_handles = JNIHandleBlock::allocate_block(); _weak_global_handles = JNIHandleBlock::allocate_block(); @@ -185,11 +196,6 @@ } -class AlwaysAliveClosure: public BoolObjectClosure { -public: - bool do_object_b(oop obj) { return true; } -}; - class CountHandleClosure: public OopClosure { private: int _count; @@ -211,9 +217,8 @@ "JNIHandles not initialized"); CountHandleClosure global_handle_count; - AlwaysAliveClosure always_alive; oops_do(&global_handle_count); - weak_oops_do(&always_alive, &global_handle_count); + weak_oops_do(&global_handle_count); st->print_cr("JNI global references: %d", global_handle_count.count()); st->cr(); @@ -230,10 +235,9 @@ void JNIHandles::verify() { VerifyHandleClosure verify_handle; - AlwaysAliveClosure always_alive; oops_do(&verify_handle); - weak_oops_do(&always_alive, &verify_handle); + weak_oops_do(&verify_handle); } --- old/src/share/vm/runtime/jniHandles.hpp 2016-03-09 17:39:44.417129302 +0100 +++ new/src/share/vm/runtime/jniHandles.hpp 2016-03-09 17:39:44.301125398 +0100 @@ -86,6 +86,8 @@ static void oops_do(OopClosure* f); // Traversal of weak global handles. Unreachable oops are cleared. static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f); + // Traversal of weak global handles. + static void weak_oops_do(OopClosure* f); };