1330 if (!Universe::heap()->is_gc_active()) |
1330 if (!Universe::heap()->is_gc_active()) |
1331 cause->klass()->print_on(log); |
1331 cause->klass()->print_on(log); |
1332 } |
1332 } |
1333 // Unlink the osr method, so we do not look this up again |
1333 // Unlink the osr method, so we do not look this up again |
1334 if (is_osr_method()) { |
1334 if (is_osr_method()) { |
1335 invalidate_osr_method(); |
1335 // Invalidate the osr nmethod only once |
1336 } |
1336 if (is_in_use()) { |
|
1337 invalidate_osr_method(); |
|
1338 } |
|
1339 #ifdef ASSERT |
|
1340 if (method() != NULL) { |
|
1341 // Make sure osr nmethod is invalidated, i.e. not on the list |
|
1342 bool found = method()->method_holder()->remove_osr_nmethod(this); |
|
1343 assert(!found, "osr nmethod should have been invalidated"); |
|
1344 } |
|
1345 #endif |
|
1346 } |
|
1347 |
1337 // If _method is already NULL the Method* is about to be unloaded, |
1348 // If _method is already NULL the Method* is about to be unloaded, |
1338 // so we don't have to break the cycle. Note that it is possible to |
1349 // so we don't have to break the cycle. Note that it is possible to |
1339 // have the Method* live here, in case we unload the nmethod because |
1350 // have the Method* live here, in case we unload the nmethod because |
1340 // it is pointing to some oop (other than the Method*) being unloaded. |
1351 // it is pointing to some oop (other than the Method*) being unloaded. |
1341 if (_method != NULL) { |
1352 if (_method != NULL) { |
1384 NMethodSweeper::report_state_change(this); |
1395 NMethodSweeper::report_state_change(this); |
1385 } |
1396 } |
1386 |
1397 |
1387 void nmethod::invalidate_osr_method() { |
1398 void nmethod::invalidate_osr_method() { |
1388 assert(_entry_bci != InvocationEntryBci, "wrong kind of nmethod"); |
1399 assert(_entry_bci != InvocationEntryBci, "wrong kind of nmethod"); |
1389 #ifndef ASSERT |
|
1390 // Make sure osr nmethod is invalidated only once |
|
1391 if (!is_in_use()) { |
|
1392 return; |
|
1393 } |
|
1394 #endif |
|
1395 // Remove from list of active nmethods |
1400 // Remove from list of active nmethods |
1396 if (method() != NULL) { |
1401 if (method() != NULL) { |
1397 bool removed = method()->method_holder()->remove_osr_nmethod(this); |
1402 method()->method_holder()->remove_osr_nmethod(this); |
1398 assert(!removed || is_in_use(), "unused osr nmethod should be invalidated"); |
|
1399 } |
1403 } |
1400 } |
1404 } |
1401 |
1405 |
1402 void nmethod::log_state_change() const { |
1406 void nmethod::log_state_change() const { |
1403 if (LogCompilation) { |
1407 if (LogCompilation) { |
1442 |
1446 |
1443 { |
1447 { |
1444 // invalidate osr nmethod before acquiring the patching lock since |
1448 // invalidate osr nmethod before acquiring the patching lock since |
1445 // they both acquire leaf locks and we don't want a deadlock. |
1449 // they both acquire leaf locks and we don't want a deadlock. |
1446 // This logic is equivalent to the logic below for patching the |
1450 // This logic is equivalent to the logic below for patching the |
1447 // verified entry point of regular methods. |
1451 // verified entry point of regular methods. We check that the |
1448 if (is_osr_method()) { |
1452 // nmethod is in use to ensure that it is invalidated only once. |
|
1453 if (is_osr_method() && is_in_use()) { |
1449 // this effectively makes the osr nmethod not entrant |
1454 // this effectively makes the osr nmethod not entrant |
1450 invalidate_osr_method(); |
1455 invalidate_osr_method(); |
1451 } |
1456 } |
1452 |
1457 |
1453 // Enter critical section. Does not block for safepoint. |
1458 // Enter critical section. Does not block for safepoint. |
1508 method()->from_compiled_entry() == verified_entry_point())) { |
1513 method()->from_compiled_entry() == verified_entry_point())) { |
1509 HandleMark hm; |
1514 HandleMark hm; |
1510 method()->clear_code(); |
1515 method()->clear_code(); |
1511 } |
1516 } |
1512 } // leave critical region under Patching_lock |
1517 } // leave critical region under Patching_lock |
|
1518 |
|
1519 #ifdef ASSERT |
|
1520 if (is_osr_method() && method() != NULL) { |
|
1521 // Make sure osr nmethod is invalidated, i.e. not on the list |
|
1522 bool found = method()->method_holder()->remove_osr_nmethod(this); |
|
1523 assert(!found, "osr nmethod should have been invalidated"); |
|
1524 } |
|
1525 #endif |
1513 |
1526 |
1514 // When the nmethod becomes zombie it is no longer alive so the |
1527 // When the nmethod becomes zombie it is no longer alive so the |
1515 // dependencies must be flushed. nmethods in the not_entrant |
1528 // dependencies must be flushed. nmethods in the not_entrant |
1516 // state will be flushed later when the transition to zombie |
1529 // state will be flushed later when the transition to zombie |
1517 // happens or they get unloaded. |
1530 // happens or they get unloaded. |