< prev index next >

src/hotspot/share/runtime/sweeper.cpp


681       SWEEP(cm);                                                                                                                     
682     }                                                                                                                                
683     return result;                                                                                                                   
684   }                                                                                                                                  
685 
686   if (cm->is_zombie()) {                                                                                                             
687     // All inline caches that referred to this nmethod were cleaned in the                                                           
688     // previous sweeper cycle. Now flush the nmethod from the code cache.                                                            
689     assert(!cm->is_locked_by_vm(), "must not flush locked Compiled Methods");                                                        
690     cm->flush();                                                                                                                     
691     assert(result == None, "sanity");                                                                                                
692     result = Flushed;                                                                                                                
693   } else if (cm->is_not_entrant()) {                                                                                                 
694     // If there are no current activations of this method on the                                                                     
695     // stack we can safely convert it to a zombie method                                                                             
696     OrderAccess::loadload(); // _stack_traversal_mark and _state                                                                     
697     if (cm->can_convert_to_zombie()) {                                                                                               
698       // Code cache state change is tracked in make_zombie()                                                                         
699       cm->make_zombie();                                                                                                             
700       SWEEP(cm);                                                                                                                     
701       // The nmethod may have been locked by JVMTI after being made zombie (see                                                      
702       // JvmtiDeferredEvent::compiled_method_unload_event()). If so, we cannot                                                       
703       // flush the osr nmethod directly but have to wait for a later sweeper cycle.                                                  
704       if (cm->is_osr_method() && !cm->is_locked_by_vm()) {                                                                           
705         // No inline caches will ever point to osr methods, so we can just remove it.                                                
706         // Make sure that we unregistered the nmethod with the heap and flushed all                                                  
707         // dependencies before removing the nmethod (done in make_zombie()).                                                         
708         assert(cm->is_zombie(), "nmethod must be unregistered");                                                                     
709         cm->flush();                                                                                                                 
710         assert(result == None, "sanity");                                                                                            
711         result = Flushed;                                                                                                            
712       } else {                                                                                                                       
713         assert(result == None, "sanity");                                                                                            
714         result = MadeZombie;                                                                                                         
715         assert(cm->is_zombie(), "nmethod must be zombie");                                                                           
716       }                                                                                                                              
717     } else {                                                                                                                         
718       // Still alive, clean up its inline caches                                                                                     
719       cm->cleanup_inline_caches(false);                                                                                              
720       SWEEP(cm);                                                                                                                     
721     }                                                                                                                                
722   } else if (cm->is_unloaded()) {                                                                                                    
723     // Code is unloaded, so there are no activations on the stack.                                                                   
724     // Convert the nmethod to zombie or flush it directly in the OSR case.                                                           
725     if (cm->is_osr_method()) {                                                                                                       
726       SWEEP(cm);                                                                                                                     
727       // No inline caches will ever point to osr methods, so we can just remove it                                                   
728       cm->flush();                                                                                                                   
729       assert(result == None, "sanity");                                                                                              
730       result = Flushed;                                                                                                              
731     } else {                                                                                                                         
732       // Code cache state change is tracked in make_zombie()                                                                         
733       cm->make_zombie();                                                                                                             
734       SWEEP(cm);                                                                                                                     
735       assert(result == None, "sanity");                                                                                              
736       result = MadeZombie;                                                                                                           
737     }                                                                                                                                
738   } else {                                                                                                                           
739     if (cm->is_nmethod()) {                                                                                                          
740       possibly_flush((nmethod*)cm);                                                                                                  
741     }                                                                                                                                
742     // Clean inline caches that point to zombie/non-entrant/unloaded nmethods                                                        
743     cm->cleanup_inline_caches(false);                                                                                                
744     SWEEP(cm);                                                                                                                       
745   }                                                                                                                                  
746   return result;                                                                                                                     
747 }                                                                                                                                    
748 
749 
750 void NMethodSweeper::possibly_flush(nmethod* nm) {                                                                                   
751   if (UseCodeCacheFlushing) {                                                                                                        
752     if (!nm->is_locked_by_vm() && !nm->is_native_method() && !nm->is_not_installed() && !nm->is_unloading()) {                       
753       bool make_not_entrant = false;                                                                                                 
754 
755       // Do not make native methods not-entrant                                                                                      
756       nm->dec_hotness_counter();                                                                                                     

681       SWEEP(cm);
682     }
683     return result;
684   }
685 
686   if (cm->is_zombie()) {
687     // All inline caches that referred to this nmethod were cleaned in the
688     // previous sweeper cycle. Now flush the nmethod from the code cache.
689     assert(!cm->is_locked_by_vm(), "must not flush locked Compiled Methods");
690     cm->flush();
691     assert(result == None, "sanity");
692     result = Flushed;
693   } else if (cm->is_not_entrant()) {
694     // If there are no current activations of this method on the
695     // stack we can safely convert it to a zombie method
696     OrderAccess::loadload(); // _stack_traversal_mark and _state
697     if (cm->can_convert_to_zombie()) {
698       // Code cache state change is tracked in make_zombie()
699       cm->make_zombie();
700       SWEEP(cm);
701       assert(result == None, "sanity");
702       result = MadeZombie;
703       assert(cm->is_zombie(), "nmethod must be zombie");













704     } else {
705       // Still alive, clean up its inline caches
706       cm->cleanup_inline_caches(false);
707       SWEEP(cm);
708     }
709   } else if (cm->is_unloaded()) {
710     // Code is unloaded, so there are no activations on the stack.
711     // Convert the nmethod to zombie.
712     // Code cache state change is tracked in make_zombie()
713     cm->make_zombie();
714     SWEEP(cm);
715     assert(result == None, "sanity");
716     result = MadeZombie;








717   } else {
718     if (cm->is_nmethod()) {
719       possibly_flush((nmethod*)cm);
720     }
721     // Clean inline caches that point to zombie/non-entrant/unloaded nmethods
722     cm->cleanup_inline_caches(false);
723     SWEEP(cm);
724   }
725   return result;
726 }
727 
728 
729 void NMethodSweeper::possibly_flush(nmethod* nm) {
730   if (UseCodeCacheFlushing) {
731     if (!nm->is_locked_by_vm() && !nm->is_native_method() && !nm->is_not_installed() && !nm->is_unloading()) {
732       bool make_not_entrant = false;
733 
734       // Do not make native methods not-entrant
735       nm->dec_hotness_counter();
< prev index next >