src/hotspot/share/gc/shared/scavengableNMethods.cpp
changeset 54177 b4779a44476b
parent 54122 4b1426ed1c44
child 54178 98e21d4da074
equal deleted inserted replaced
54176:2786541e4f91 54177:b4779a44476b
    63 
    63 
    64   CodeCache::print_trace("register_nmethod", nm);
    64   CodeCache::print_trace("register_nmethod", nm);
    65 }
    65 }
    66 
    66 
    67 void ScavengableNMethods::unregister_nmethod(nmethod* nm) {
    67 void ScavengableNMethods::unregister_nmethod(nmethod* nm) {
    68   // Do nothing. Unlinking is currently delayed until the purge phase.
    68   assert_locked_or_safepoint(CodeCache_lock);
       
    69 
       
    70   if (gc_data(nm).on_list()) {
       
    71     nmethod* prev = NULL;
       
    72     for (nmethod* cur = _head; cur != NULL; cur = gc_data(cur).next()) {
       
    73       if (cur == nm) {
       
    74         CodeCache::print_trace("unregister_nmethod", nm);
       
    75         unlist_nmethod(cur, prev);
       
    76         return;
       
    77       }
       
    78       prev = cur;
       
    79     }
       
    80   }
    69 }
    81 }
    70 
    82 
    71 #ifndef PRODUCT
    83 #ifndef PRODUCT
    72 
    84 
    73 class DebugScavengableOops: public OopClosure {
    85 class DebugScavengableOops: public OopClosure {
   108     if (!cl.ok())
   120     if (!cl.ok())
   109       fatal("found an unadvertised bad scavengable oop in the code cache");
   121       fatal("found an unadvertised bad scavengable oop in the code cache");
   110   }
   122   }
   111   assert(gc_data(nm).not_marked(), "");
   123   assert(gc_data(nm).not_marked(), "");
   112 #endif // PRODUCT
   124 #endif // PRODUCT
   113 }
       
   114 
       
   115 void ScavengableNMethods::flush_nmethod(nmethod* nm) {
       
   116   assert_locked_or_safepoint(CodeCache_lock);
       
   117 
       
   118   // TODO: Should be done in unregister_nmethod, during the "unlink" phase.
       
   119   if (gc_data(nm).on_list()) {
       
   120     CodeCache::print_trace("flush_nmethod", nm);
       
   121     nmethod* prev = NULL;
       
   122     for (nmethod* cur = _head; cur != NULL; cur = gc_data(cur).next()) {
       
   123       if (cur == nm) {
       
   124         unlist_nmethod(cur, prev);
       
   125         return;
       
   126       }
       
   127       prev = cur;
       
   128     }
       
   129   }
       
   130 }
   125 }
   131 
   126 
   132 class HasScavengableOops: public OopClosure {
   127 class HasScavengableOops: public OopClosure {
   133   BoolObjectClosure* _is_scavengable;
   128   BoolObjectClosure* _is_scavengable;
   134   bool               _found;
   129   bool               _found;