1340 |
1340 |
1341 // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload event |
1341 // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload event |
1342 // and it hasn't already been reported for this nmethod then report it now. |
1342 // and it hasn't already been reported for this nmethod then report it now. |
1343 // (the event may have been reported earilier if the GC marked it for unloading). |
1343 // (the event may have been reported earilier if the GC marked it for unloading). |
1344 if (state == zombie) { |
1344 if (state == zombie) { |
1345 |
1345 post_compiled_method_unload(); |
1346 DTRACE_METHOD_UNLOAD_PROBE(method()); |
|
1347 |
|
1348 if (JvmtiExport::should_post_compiled_method_unload() && |
|
1349 !unload_reported()) { |
|
1350 assert(method() != NULL, "checking"); |
|
1351 { |
|
1352 HandleMark hm; |
|
1353 JvmtiExport::post_compiled_method_unload_at_safepoint( |
|
1354 method()->jmethod_id(), code_begin()); |
|
1355 } |
|
1356 set_unload_reported(); |
|
1357 } |
|
1358 } |
1346 } |
1359 |
1347 |
1360 |
1348 |
1361 // Zombie only stuff |
1349 // Zombie only stuff |
1362 if (state == zombie) { |
1350 if (state == zombie) { |
1504 JvmtiExport::post_compiled_method_load(this); |
1492 JvmtiExport::post_compiled_method_load(this); |
1505 } |
1493 } |
1506 } |
1494 } |
1507 |
1495 |
1508 void nmethod::post_compiled_method_unload() { |
1496 void nmethod::post_compiled_method_unload() { |
|
1497 if (unload_reported()) { |
|
1498 // During unloading we transition to unloaded and then to zombie |
|
1499 // and the unloading is reported during the first transition. |
|
1500 return; |
|
1501 } |
|
1502 |
1509 assert(_method != NULL && !is_unloaded(), "just checking"); |
1503 assert(_method != NULL && !is_unloaded(), "just checking"); |
1510 DTRACE_METHOD_UNLOAD_PROBE(method()); |
1504 DTRACE_METHOD_UNLOAD_PROBE(method()); |
1511 |
1505 |
1512 // If a JVMTI agent has enabled the CompiledMethodUnload event then |
1506 // If a JVMTI agent has enabled the CompiledMethodUnload event then |
1513 // post the event. Sometime later this nmethod will be made a zombie by |
1507 // post the event. Sometime later this nmethod will be made a zombie by |
1514 // the sweeper but the methodOop will not be valid at that point. |
1508 // the sweeper but the methodOop will not be valid at that point. |
1515 if (JvmtiExport::should_post_compiled_method_unload()) { |
1509 if (JvmtiExport::should_post_compiled_method_unload()) { |
1516 assert(!unload_reported(), "already unloaded"); |
1510 assert(!unload_reported(), "already unloaded"); |
1517 HandleMark hm; |
1511 HandleMark hm; |
1518 JvmtiExport::post_compiled_method_unload_at_safepoint( |
1512 JvmtiExport::post_compiled_method_unload(method()->jmethod_id(), code_begin()); |
1519 method()->jmethod_id(), code_begin()); |
|
1520 } |
1513 } |
1521 |
1514 |
1522 // The JVMTI CompiledMethodUnload event can be enabled or disabled at |
1515 // The JVMTI CompiledMethodUnload event can be enabled or disabled at |
1523 // any time. As the nmethod is being unloaded now we mark it has |
1516 // any time. As the nmethod is being unloaded now we mark it has |
1524 // having the unload event reported - this will ensure that we don't |
1517 // having the unload event reported - this will ensure that we don't |