// Walk the list of methods which might contain non-perm oops. void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) { assert_locked_or_safepoint(CodeCache_lock); debug_only(mark_scavenge_root_nmethods()); for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { debug_only(cur->clear_scavenge_root_marked()); assert(cur->scavenge_root_not_marked(), ""); assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); bool is_live = (!cur->is_zombie() && !cur->is_unloaded()); #ifndef PRODUCT if (TraceScavenge) { cur->print_on(tty, is_live ? "scavenge root" : "dead scavenge root"); tty->cr(); } #endif //PRODUCT if (is_live) { // Perform cur->oops_do(f), maybe just once per nmethod. f->do_code_blob(cur); cur->fix_oop_relocations(); } } // Check for stray marks. debug_only(verify_perm_nmethods(NULL)); }
void CodeCache::prune_scavenge_root_nmethods() { assert_locked_or_safepoint(CodeCache_lock); debug_only(mark_scavenge_root_nmethods()); nmethod* last = NULL; nmethod* cur = scavenge_root_nmethods(); while (cur != NULL) { nmethod* next = cur->scavenge_root_link(); debug_only(cur->clear_scavenge_root_marked()); assert(cur->scavenge_root_not_marked(), ""); assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); if (!cur->is_zombie() && !cur->is_unloaded() && cur->detect_scavenge_root_oops()) { // Keep it. Advance 'last' to prevent deletion. last = cur; } else { // Prune it from the list, so we don't have to look at it any more. print_trace("prune_scavenge_root", cur); cur->set_scavenge_root_link(NULL); cur->clear_on_scavenge_root_list(); if (last != NULL) last->set_scavenge_root_link(next); else set_scavenge_root_nmethods(next); } cur = next; } // Check for stray marks. debug_only(verify_perm_nmethods(NULL)); }
void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { assert_locked_or_safepoint(CodeCache_lock); if (UseG1GC) { return; } print_trace("drop_scavenge_root", nm); nmethod* last = NULL; nmethod* cur = scavenge_root_nmethods(); while (cur != NULL) { nmethod* next = cur->scavenge_root_link(); if (cur == nm) { if (last != NULL) last->set_scavenge_root_link(next); else set_scavenge_root_nmethods(next); nm->set_scavenge_root_link(NULL); nm->clear_on_scavenge_root_list(); return; } last = cur; cur = next; } assert(false, "should have been on list"); }
void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) { // 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()) { assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); cur->clear_scavenge_root_marked(); } verify_perm_nmethods(f); }