--- old/src/share/vm/c1/c1_Runtime1.cpp 2017-07-24 16:40:34.796313923 +0200 +++ new/src/share/vm/c1/c1_Runtime1.cpp 2017-07-24 16:40:34.676313927 +0200 @@ -1223,11 +1223,6 @@ MutexLockerEx ml_code (CodeCache_lock, Mutex::_no_safepoint_check_flag); nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); guarantee(nm != NULL, "only nmethods can contain non-perm oops"); - if (!nm->on_scavenge_root_list() && - ((mirror.not_null() && mirror()->is_scavengable()) || - (appendix.not_null() && appendix->is_scavengable()))) { - CodeCache::add_scavenge_root_nmethod(nm); - } // Since we've patched some oops in the nmethod, // (re)register it with the heap. --- old/src/share/vm/code/codeCache.cpp 2017-07-24 16:40:35.568313896 +0200 +++ new/src/share/vm/code/codeCache.cpp 2017-07-24 16:40:35.408313901 +0200 @@ -683,8 +683,9 @@ if (cb->is_alive()) { f->do_code_blob(cb); #ifdef ASSERT - if (cb->is_nmethod()) - ((nmethod*)cb)->verify_scavenge_root_oops(); + if (cb->is_nmethod()) { + Universe::heap()->verify_nmethod_roots((nmethod*)cb); + } #endif //ASSERT } } @@ -695,10 +696,6 @@ void CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure* f) { assert_locked_or_safepoint(CodeCache_lock); - if (UseG1GC) { - return; - } - const bool fix_relocations = f->fix_relocations(); debug_only(mark_scavenge_root_nmethods()); @@ -738,10 +735,6 @@ void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { assert_locked_or_safepoint(CodeCache_lock); - if (UseG1GC) { - return; - } - nm->set_on_scavenge_root_list(); nm->set_scavenge_root_link(_scavenge_root_nmethods); set_scavenge_root_nmethods(nm); @@ -754,8 +747,6 @@ assert((prev == NULL && scavenge_root_nmethods() == nm) || (prev != NULL && prev->scavenge_root_link() == nm), "precondition"); - assert(!UseG1GC, "G1 does not use the scavenge_root_nmethods list"); - print_trace("unlink_scavenge_root", nm); if (prev == NULL) { set_scavenge_root_nmethods(nm->scavenge_root_link()); @@ -769,10 +760,6 @@ void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { assert_locked_or_safepoint(CodeCache_lock); - if (UseG1GC) { - return; - } - print_trace("drop_scavenge_root", nm); nmethod* prev = NULL; for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { @@ -788,10 +775,6 @@ void CodeCache::prune_scavenge_root_nmethods() { assert_locked_or_safepoint(CodeCache_lock); - if (UseG1GC) { - return; - } - debug_only(mark_scavenge_root_nmethods()); nmethod* last = NULL; @@ -820,10 +803,6 @@ #ifndef PRODUCT void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) { - if (UseG1GC) { - return; - } - // While we are here, verify the integrity of the list. mark_scavenge_root_nmethods(); for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { @@ -854,7 +833,7 @@ assert(nm->scavenge_root_not_marked(), "must be already processed"); if (nm->on_scavenge_root_list()) call_f = false; // don't show this one to the client - nm->verify_scavenge_root_oops(); + Universe::heap()->verify_nmethod_roots(nm); if (call_f) f_or_null->do_code_blob(nm); } } @@ -1640,4 +1619,3 @@ blob_count(), nmethod_count(), adapter_count(), unallocated_capacity()); } - --- old/src/share/vm/code/nmethod.cpp 2017-07-24 16:40:36.396313867 +0200 +++ new/src/share/vm/code/nmethod.cpp 2017-07-24 16:40:36.240313872 +0200 @@ -410,11 +410,8 @@ _oops_do_mark_link = NULL; _jmethod_id = NULL; _osr_link = NULL; - if (UseG1GC) { - _unloading_next = NULL; - } else { - _scavenge_root_link = NULL; - } + _unloading_next = NULL; + _scavenge_root_link = NULL; _scavenge_root_state = 0; #if INCLUDE_RTM_OPT _rtm_state = NoRTM; @@ -598,12 +595,9 @@ code_buffer->copy_code_and_locs_to(this); code_buffer->copy_values_to(this); if (ScavengeRootsInCode) { - if (detect_scavenge_root_oops()) { - CodeCache::add_scavenge_root_nmethod(this); - } Universe::heap()->register_nmethod(this); } - debug_only(verify_scavenge_root_oops()); + debug_only(Universe::heap()->verify_nmethod_roots(this)); CodeCache::commit(this); } @@ -753,12 +747,9 @@ debug_info->copy_to(this); dependencies->copy_to(this); if (ScavengeRootsInCode) { - if (detect_scavenge_root_oops()) { - CodeCache::add_scavenge_root_nmethod(this); - } Universe::heap()->register_nmethod(this); } - debug_only(verify_scavenge_root_oops()); + debug_only(Universe::heap()->verify_nmethod_roots(this)); CodeCache::commit(this); @@ -2135,7 +2126,7 @@ VerifyOopsClosure voc(this); oops_do(&voc); assert(voc.ok(), "embedded oops must be OK"); - verify_scavenge_root_oops(); + Universe::heap()->verify_nmethod_roots(this); verify_scopes(); } @@ -2228,10 +2219,6 @@ }; void nmethod::verify_scavenge_root_oops() { - if (UseG1GC) { - return; - } - if (!on_scavenge_root_list()) { // Actually look inside, to verify the claim that it's clean. DebugScavengeRoot debug_scavenge_root(this); --- old/src/share/vm/gc/g1/g1CollectedHeap.cpp 2017-07-24 16:40:37.200313839 +0200 +++ new/src/share/vm/gc/g1/g1CollectedHeap.cpp 2017-07-24 16:40:37.040313845 +0200 @@ -2458,6 +2458,10 @@ return _cmThread->request_concurrent_phase(phase); } +void G1CollectedHeap::verify_nmethod_roots(nmethod* nmethod) { + +} + class PrintRegionClosure: public HeapRegionClosure { outputStream* _st; public: @@ -5419,16 +5423,14 @@ }; void G1CollectedHeap::register_nmethod(nmethod* nm) { - CollectedHeap::register_nmethod(nm); - + assert_locked_or_safepoint(CodeCache_lock); guarantee(nm != NULL, "sanity"); RegisterNMethodOopClosure reg_cl(this, nm); nm->oops_do(®_cl); } void G1CollectedHeap::unregister_nmethod(nmethod* nm) { - CollectedHeap::unregister_nmethod(nm); - + assert_locked_or_safepoint(CodeCache_lock); guarantee(nm != NULL, "sanity"); UnregisterNMethodOopClosure reg_cl(this, nm); nm->oops_do(®_cl, true); --- old/src/share/vm/gc/g1/g1CollectedHeap.hpp 2017-07-24 16:40:38.036313810 +0200 +++ new/src/share/vm/gc/g1/g1CollectedHeap.hpp 2017-07-24 16:40:37.908313814 +0200 @@ -1436,6 +1436,8 @@ virtual const char* const* concurrent_phases() const; virtual bool request_concurrent_phase(const char* phase); + void verify_nmethod_roots(nmethod* nmethod); + // The methods below are here for convenience and dispatch the // appropriate method depending on value of the given VerifyOption // parameter. The values for that parameter, and their meanings, --- old/src/share/vm/gc/shared/collectedHeap.cpp 2017-07-24 16:40:38.788313784 +0200 +++ new/src/share/vm/gc/shared/collectedHeap.cpp 2017-07-24 16:40:38.664313788 +0200 @@ -137,6 +137,9 @@ void CollectedHeap::register_nmethod(nmethod* nm) { assert_locked_or_safepoint(CodeCache_lock); + if (!nm->on_scavenge_root_list() && nm->detect_scavenge_root_oops()) { + CodeCache::add_scavenge_root_nmethod(nm); + } } void CollectedHeap::unregister_nmethod(nmethod* nm) { @@ -618,3 +621,7 @@ _reserved.set_start(start); _reserved.set_end(end); } + +void CollectedHeap::verify_nmethod_roots(nmethod* nmethod) { + nmethod->verify_scavenge_root_oops(); +} --- old/src/share/vm/gc/shared/collectedHeap.hpp 2017-07-24 16:40:39.544313757 +0200 +++ new/src/share/vm/gc/shared/collectedHeap.hpp 2017-07-24 16:40:39.388313763 +0200 @@ -393,6 +393,8 @@ virtual size_t max_tlab_size() const; + virtual void verify_nmethod_roots(nmethod* nmethod); + // An estimate of the maximum allocation that could be performed // for thread-local allocation buffers without triggering any // collection or expansion activity.