void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { assert_locked_or_safepoint(CodeCache_lock); nm->set_on_scavenge_root_list(); nm->set_scavenge_root_link(_scavenge_root_nmethods); set_scavenge_root_nmethods(nm); print_trace("add_scavenge_root", nm); }
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"); }