1602 // result some nmethods may get unloaded. In this case the flushing
1603 // of dependencies must happen during phase 1 since after GC any
1604 // dependencies in the unloaded nmethod won't be updated, so
1605 // traversing the dependency information in unsafe. In that case this
1606 // function is called with a non-NULL argument and this function only
1607 // notifies instanceKlasses that are reachable
1608
1609 void nmethod::flush_dependencies(BoolObjectClosure* is_alive) {
1610 assert_locked_or_safepoint(CodeCache_lock);
1611 assert(Universe::heap()->is_gc_active() == (is_alive != NULL),
1612 "is_alive is non-NULL if and only if we are called during GC");
1613 if (!has_flushed_dependencies()) {
1614 set_has_flushed_dependencies();
1615 for (Dependencies::DepStream deps(this); deps.next(); ) {
1616 Klass* klass = deps.context_type();
1617 if (klass == NULL) continue; // ignore things like evol_method
1618
1619 // During GC the is_alive closure is non-NULL, and is used to
1620 // determine liveness of dependees that need to be updated.
1621 if (is_alive == NULL || klass->is_loader_alive(is_alive)) {
1622 InstanceKlass::cast(klass)->remove_dependent_nmethod(this);
1623 }
1624 }
1625 }
1626 }
1627
1628
1629 // If this oop is not live, the nmethod can be unloaded.
1630 bool nmethod::can_unload(BoolObjectClosure* is_alive, oop* root, bool unloading_occurred) {
1631 assert(root != NULL, "just checking");
1632 oop obj = *root;
1633 if (obj == NULL || is_alive->do_object_b(obj)) {
1634 return false;
1635 }
1636
1637 // If ScavengeRootsInCode is true, an nmethod might be unloaded
1638 // simply because one of its constant oops has gone dead.
1639 // No actual classes need to be unloaded in order for this to occur.
1640 assert(unloading_occurred || ScavengeRootsInCode, "Inconsistency in unloading");
1641 make_unloaded(is_alive, obj);
1642 return true;
|
1602 // result some nmethods may get unloaded. In this case the flushing
1603 // of dependencies must happen during phase 1 since after GC any
1604 // dependencies in the unloaded nmethod won't be updated, so
1605 // traversing the dependency information in unsafe. In that case this
1606 // function is called with a non-NULL argument and this function only
1607 // notifies instanceKlasses that are reachable
1608
1609 void nmethod::flush_dependencies(BoolObjectClosure* is_alive) {
1610 assert_locked_or_safepoint(CodeCache_lock);
1611 assert(Universe::heap()->is_gc_active() == (is_alive != NULL),
1612 "is_alive is non-NULL if and only if we are called during GC");
1613 if (!has_flushed_dependencies()) {
1614 set_has_flushed_dependencies();
1615 for (Dependencies::DepStream deps(this); deps.next(); ) {
1616 Klass* klass = deps.context_type();
1617 if (klass == NULL) continue; // ignore things like evol_method
1618
1619 // During GC the is_alive closure is non-NULL, and is used to
1620 // determine liveness of dependees that need to be updated.
1621 if (is_alive == NULL || klass->is_loader_alive(is_alive)) {
1622 // The GC defers deletion of this entry, since there might be multiple threads
1623 // iterating over the _dependencies graph. Other call paths are single-threaded
1624 // and may delete it immediately.
1625 bool delete_immediately = is_alive == NULL;
1626 InstanceKlass::cast(klass)->remove_dependent_nmethod(this, delete_immediately);
1627 }
1628 }
1629 }
1630 }
1631
1632
1633 // If this oop is not live, the nmethod can be unloaded.
1634 bool nmethod::can_unload(BoolObjectClosure* is_alive, oop* root, bool unloading_occurred) {
1635 assert(root != NULL, "just checking");
1636 oop obj = *root;
1637 if (obj == NULL || is_alive->do_object_b(obj)) {
1638 return false;
1639 }
1640
1641 // If ScavengeRootsInCode is true, an nmethod might be unloaded
1642 // simply because one of its constant oops has gone dead.
1643 // No actual classes need to be unloaded in order for this to occur.
1644 assert(unloading_occurred || ScavengeRootsInCode, "Inconsistency in unloading");
1645 make_unloaded(is_alive, obj);
1646 return true;
|