< prev index next >

src/hotspot/share/code/nmethod.cpp


1354     return NULL;                                                                                                                     
1355   }                                                                                                                                  
1356   return NativeAccess<AS_NO_KEEPALIVE>::oop_load(oop_addr_at(index));                                                                
1357 }                                                                                                                                    
1358 
1359 //                                                                                                                                   
1360 // Notify all classes this nmethod is dependent on that it is no                                                                     
1361 // longer dependent. This should only be called in two situations.                                                                   
1362 // First, when a nmethod transitions to a zombie all dependents need                                                                 
1363 // to be clear.  Since zombification happens at a safepoint there's no                                                               
1364 // synchronization issues.  The second place is a little more tricky.                                                                
1365 // During phase 1 of mark sweep class unloading may happen and as a                                                                  
1366 // result some nmethods may get unloaded.  In this case the flushing                                                                 
1367 // of dependencies must happen during phase 1 since after GC any                                                                     
1368 // dependencies in the unloaded nmethod won't be updated, so                                                                         
1369 // traversing the dependency information in unsafe.  In that case this                                                               
1370 // function is called with a boolean argument and this function only                                                                 
1371 // notifies instanceKlasses that are reachable                                                                                       
1372 
1373 void nmethod::flush_dependencies(bool delete_immediately) {                                                                          
1374   assert_locked_or_safepoint(CodeCache_lock);                                                                                        
1375   assert(Universe::heap()->is_gc_active() != delete_immediately,                                                                     
1376   "delete_immediately is false if and only if we are called during GC");                                                             
1377   if (!has_flushed_dependencies()) {                                                                                                 
1378     set_has_flushed_dependencies();                                                                                                  
1379     for (Dependencies::DepStream deps(this); deps.next(); ) {                                                                        
1380       if (deps.type() == Dependencies::call_site_target_value) {                                                                     
1381         // CallSite dependencies are managed on per-CallSite instance basis.                                                         
1382         oop call_site = deps.argument_oop(0);                                                                                        
1383         MethodHandles::remove_dependent_nmethod(call_site, this);                                                                    
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
1384       } else {                                                                                                                       
1385         Klass* klass = deps.context_type();                                                                                          
1386         if (klass == NULL) {                                                                                                         
1387           continue;  // ignore things like evol_method                                                                               
1388         }                                                                                                                            
1389         // During GC delete_immediately is false, and liveness                                                                       
1390         // of dependee determines class that needs to be updated.                                                                    
1391         if (delete_immediately || klass->is_loader_alive()) {                                                                        
1392           // The GC defers deletion of this entry, since there might be multiple threads                                             
1393           // iterating over the _dependencies graph. Other call paths are single-threaded                                            
1394           // and may delete it immediately.                                                                                          
1395           InstanceKlass::cast(klass)->remove_dependent_nmethod(this, delete_immediately);                                            
                                                                                                                                     
1396         }                                                                                                                            
1397       }                                                                                                                              
1398     }                                                                                                                                
1399   }                                                                                                                                  
1400 }                                                                                                                                    
1401 
1402 // ------------------------------------------------------------------                                                                
1403 // post_compiled_method_load_event                                                                                                   
1404 // new method for install_code() path                                                                                                
1405 // Transfer information from compilation to jvmti                                                                                    
1406 void nmethod::post_compiled_method_load_event() {                                                                                    
1407 
1408   Method* moop = method();                                                                                                           
1409   HOTSPOT_COMPILED_METHOD_LOAD(                                                                                                      
1410       (char *) moop->klass_name()->bytes(),                                                                                          
1411       moop->klass_name()->utf8_length(),                                                                                             
1412       (char *) moop->name()->bytes(),                                                                                                
1413       moop->name()->utf8_length(),                                                                                                   
1414       (char *) moop->signature()->bytes(),                                                                                           

1354     return NULL;
1355   }
1356   return NativeAccess<AS_NO_KEEPALIVE>::oop_load(oop_addr_at(index));
1357 }
1358 
1359 //
1360 // Notify all classes this nmethod is dependent on that it is no
1361 // longer dependent. This should only be called in two situations.
1362 // First, when a nmethod transitions to a zombie all dependents need
1363 // to be clear.  Since zombification happens at a safepoint there's no
1364 // synchronization issues.  The second place is a little more tricky.
1365 // During phase 1 of mark sweep class unloading may happen and as a
1366 // result some nmethods may get unloaded.  In this case the flushing
1367 // of dependencies must happen during phase 1 since after GC any
1368 // dependencies in the unloaded nmethod won't be updated, so
1369 // traversing the dependency information in unsafe.  In that case this
1370 // function is called with a boolean argument and this function only
1371 // notifies instanceKlasses that are reachable
1372 
1373 void nmethod::flush_dependencies(bool delete_immediately) {
1374   DEBUG_ONLY(bool called_by_gc = Universe::heap()->is_gc_active() || Thread::current()->is_ConcurrentGC_thread();)
1375   assert(called_by_gc != delete_immediately,
1376   "delete_immediately is false if and only if we are called during GC");
1377   if (!has_flushed_dependencies()) {
1378     set_has_flushed_dependencies();
1379     for (Dependencies::DepStream deps(this); deps.next(); ) {
1380       if (deps.type() == Dependencies::call_site_target_value) {
1381         // CallSite dependencies are managed on per-CallSite instance basis.
1382         oop call_site = deps.argument_oop(0);
1383         if (delete_immediately) {
1384           assert_locked_or_safepoint(CodeCache_lock);
1385           MethodHandles::remove_dependent_nmethod(call_site, this);
1386         } else {
1387           MethodHandles::clean_dependency_context(call_site);
1388         }
1389       } else {
1390         Klass* klass = deps.context_type();
1391         if (klass == NULL) {
1392           continue;  // ignore things like evol_method
1393         }
1394         // During GC delete_immediately is false, and liveness
1395         // of dependee determines class that needs to be updated.
1396         if (delete_immediately) {
1397           assert_locked_or_safepoint(CodeCache_lock);
1398           InstanceKlass::cast(klass)->remove_dependent_nmethod(this);
1399         } else if (klass->is_loader_alive()) {
1400           // The GC may clean dependency contexts concurrently and in parallel.
1401           InstanceKlass::cast(klass)->clean_dependency_context();
1402         }
1403       }
1404     }
1405   }
1406 }
1407 
1408 // ------------------------------------------------------------------
1409 // post_compiled_method_load_event
1410 // new method for install_code() path
1411 // Transfer information from compilation to jvmti
1412 void nmethod::post_compiled_method_load_event() {
1413 
1414   Method* moop = method();
1415   HOTSPOT_COMPILED_METHOD_LOAD(
1416       (char *) moop->klass_name()->bytes(),
1417       moop->klass_name()->utf8_length(),
1418       (char *) moop->name()->bytes(),
1419       moop->name()->utf8_length(),
1420       (char *) moop->signature()->bytes(),
< prev index next >