1465
1466 void nmethod::flush_dependencies(BoolObjectClosure* is_alive) {
1467 assert_locked_or_safepoint(CodeCache_lock);
1468 assert(Universe::heap()->is_gc_active() == (is_alive != NULL),
1469 "is_alive is non-NULL if and only if we are called during GC");
1470 if (!has_flushed_dependencies()) {
1471 set_has_flushed_dependencies();
1472 for (Dependencies::DepStream deps(this); deps.next(); ) {
1473 if (deps.type() == Dependencies::call_site_target_value) {
1474 // CallSite dependencies are managed on per-CallSite instance basis.
1475 oop call_site = deps.argument_oop(0);
1476 MethodHandles::remove_dependent_nmethod(call_site, this);
1477 } else {
1478 Klass* klass = deps.context_type();
1479 if (klass == NULL) {
1480 continue; // ignore things like evol_method
1481 }
1482 // During GC the is_alive closure is non-NULL, and is used to
1483 // determine liveness of dependees that need to be updated.
1484 if (is_alive == NULL || klass->is_loader_alive(is_alive)) {
1485 InstanceKlass::cast(klass)->remove_dependent_nmethod(this);
1486 }
1487 }
1488 }
1489 }
1490 }
1491
1492
1493 // If this oop is not live, the nmethod can be unloaded.
1494 bool nmethod::can_unload(BoolObjectClosure* is_alive, oop* root, bool unloading_occurred) {
1495 assert(root != NULL, "just checking");
1496 oop obj = *root;
1497 if (obj == NULL || is_alive->do_object_b(obj)) {
1498 return false;
1499 }
1500
1501 // If ScavengeRootsInCode is true, an nmethod might be unloaded
1502 // simply because one of its constant oops has gone dead.
1503 // No actual classes need to be unloaded in order for this to occur.
1504 assert(unloading_occurred || ScavengeRootsInCode, "Inconsistency in unloading");
1505 make_unloaded(is_alive, obj);
|
1465
1466 void nmethod::flush_dependencies(BoolObjectClosure* is_alive) {
1467 assert_locked_or_safepoint(CodeCache_lock);
1468 assert(Universe::heap()->is_gc_active() == (is_alive != NULL),
1469 "is_alive is non-NULL if and only if we are called during GC");
1470 if (!has_flushed_dependencies()) {
1471 set_has_flushed_dependencies();
1472 for (Dependencies::DepStream deps(this); deps.next(); ) {
1473 if (deps.type() == Dependencies::call_site_target_value) {
1474 // CallSite dependencies are managed on per-CallSite instance basis.
1475 oop call_site = deps.argument_oop(0);
1476 MethodHandles::remove_dependent_nmethod(call_site, this);
1477 } else {
1478 Klass* klass = deps.context_type();
1479 if (klass == NULL) {
1480 continue; // ignore things like evol_method
1481 }
1482 // During GC the is_alive closure is non-NULL, and is used to
1483 // determine liveness of dependees that need to be updated.
1484 if (is_alive == NULL || klass->is_loader_alive(is_alive)) {
1485 // The GC defers deletion of this entry, since there might be multiple threads
1486 // iterating over the _dependencies graph. Other call paths are single-threaded
1487 // and may delete it immediately.
1488 bool delete_immediately = is_alive == NULL;
1489 InstanceKlass::cast(klass)->remove_dependent_nmethod(this, delete_immediately);
1490 }
1491 }
1492 }
1493 }
1494 }
1495
1496
1497 // If this oop is not live, the nmethod can be unloaded.
1498 bool nmethod::can_unload(BoolObjectClosure* is_alive, oop* root, bool unloading_occurred) {
1499 assert(root != NULL, "just checking");
1500 oop obj = *root;
1501 if (obj == NULL || is_alive->do_object_b(obj)) {
1502 return false;
1503 }
1504
1505 // If ScavengeRootsInCode is true, an nmethod might be unloaded
1506 // simply because one of its constant oops has gone dead.
1507 // No actual classes need to be unloaded in order for this to occur.
1508 assert(unloading_occurred || ScavengeRootsInCode, "Inconsistency in unloading");
1509 make_unloaded(is_alive, obj);
|