src/share/vm/classfile/systemDictionary.cpp

Print this page




1595   // Now flush all code that depended on old class hierarchy.
1596   // Note: must be done *after* linking k into the hierarchy (was bug 12/9/97)
1597   // Also, first reinitialize vtable because it may have gotten out of synch
1598   // while the new class wasn't connected to the class hierarchy.
1599   Universe::flush_dependents_on(k);
1600 }
1601 
1602 
1603 // ----------------------------------------------------------------------------
1604 // GC support
1605 
1606 // Following roots during mark-sweep is separated in two phases.
1607 //
1608 // The first phase follows preloaded classes and all other system
1609 // classes, since these will never get unloaded anyway.
1610 //
1611 // The second phase removes (unloads) unreachable classes from the
1612 // system dictionary and follows the remaining classes' contents.
1613 
1614 void SystemDictionary::always_strong_oops_do(OopClosure* blk) {
1615   blk->do_oop(&_java_system_loader);
1616   blk->do_oop(&_system_loader_lock_obj);
1617 
1618   dictionary()->always_strong_oops_do(blk);
1619 
1620   // Visit extra methods
1621   invoke_method_table()->oops_do(blk);
1622 }
1623 
1624 void SystemDictionary::always_strong_classes_do(KlassClosure* closure) {
1625   // Follow all system classes and temporary placeholders in dictionary
1626   dictionary()->always_strong_classes_do(closure);
1627 
1628   // Placeholders. These represent classes we're actively loading.
1629   placeholders()->classes_do(closure);
1630 }
1631 
1632 // Calculate a "good" systemdictionary size based
1633 // on predicted or current loaded classes count
1634 int SystemDictionary::calculate_systemdictionary_size(int classcount) {
1635   int newsize = _old_default_sdsize;
1636   if ((classcount > 0)  && !DumpSharedSpaces) {
1637     int desiredsize = classcount/_average_depth_goal;
1638     for (newsize = _primelist[_sdgeneration]; _sdgeneration < _prime_array_size -1;
1639          newsize = _primelist[++_sdgeneration]) {
1640       if (desiredsize <=  newsize) {
1641         break;


1666 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
1667 // Note: anonymous classes are not in the SD.
1668 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) {
1669   // First, mark for unload all ClassLoaderData referencing a dead class loader.
1670   bool has_dead_loaders = ClassLoaderDataGraph::do_unloading(is_alive);
1671   bool unloading_occurred = false;
1672   if (has_dead_loaders) {
1673     unloading_occurred = dictionary()->do_unloading();
1674     constraints()->purge_loader_constraints();
1675     resolution_errors()->purge_resolution_errors();
1676   }
1677   // Oops referenced by the system dictionary may get unreachable independently
1678   // of the class loader (eg. cached protection domain oops). So we need to
1679   // explicitly unlink them here instead of in Dictionary::do_unloading.
1680   dictionary()->unlink(is_alive);
1681 #ifdef ASSERT
1682   VerifySDReachableAndLiveClosure cl(is_alive);
1683   dictionary()->oops_do(&cl);
1684 #endif
1685   return unloading_occurred;











1686 }
1687 
1688 void SystemDictionary::oops_do(OopClosure* f) {
1689   f->do_oop(&_java_system_loader);
1690   f->do_oop(&_system_loader_lock_obj);
1691 
1692   // Adjust dictionary
1693   dictionary()->oops_do(f);
1694 
1695   // Visit extra methods
1696   invoke_method_table()->oops_do(f);
1697 }
1698 
1699 // Extended Class redefinition support.
1700 // If one of these classes is replaced, we need to replace it in these places.
1701 // KlassClosure::do_klass should take the address of a class but we can
1702 // change that later.
1703 void SystemDictionary::preloaded_classes_do(KlassClosure* f) {
1704   for (int k = (int)FIRST_WKID; k < (int)WKID_LIMIT; k++) {
1705     f->do_klass(_well_known_klasses[k]);




1595   // Now flush all code that depended on old class hierarchy.
1596   // Note: must be done *after* linking k into the hierarchy (was bug 12/9/97)
1597   // Also, first reinitialize vtable because it may have gotten out of synch
1598   // while the new class wasn't connected to the class hierarchy.
1599   Universe::flush_dependents_on(k);
1600 }
1601 
1602 
1603 // ----------------------------------------------------------------------------
1604 // GC support
1605 
1606 // Following roots during mark-sweep is separated in two phases.
1607 //
1608 // The first phase follows preloaded classes and all other system
1609 // classes, since these will never get unloaded anyway.
1610 //
1611 // The second phase removes (unloads) unreachable classes from the
1612 // system dictionary and follows the remaining classes' contents.
1613 
1614 void SystemDictionary::always_strong_oops_do(OopClosure* blk) {
1615   roots_oops_do(blk, NULL);






1616 }
1617 
1618 void SystemDictionary::always_strong_classes_do(KlassClosure* closure) {
1619   // Follow all system classes and temporary placeholders in dictionary
1620   dictionary()->always_strong_classes_do(closure);
1621 
1622   // Placeholders. These represent classes we're actively loading.
1623   placeholders()->classes_do(closure);
1624 }
1625 
1626 // Calculate a "good" systemdictionary size based
1627 // on predicted or current loaded classes count
1628 int SystemDictionary::calculate_systemdictionary_size(int classcount) {
1629   int newsize = _old_default_sdsize;
1630   if ((classcount > 0)  && !DumpSharedSpaces) {
1631     int desiredsize = classcount/_average_depth_goal;
1632     for (newsize = _primelist[_sdgeneration]; _sdgeneration < _prime_array_size -1;
1633          newsize = _primelist[++_sdgeneration]) {
1634       if (desiredsize <=  newsize) {
1635         break;


1660 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
1661 // Note: anonymous classes are not in the SD.
1662 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) {
1663   // First, mark for unload all ClassLoaderData referencing a dead class loader.
1664   bool has_dead_loaders = ClassLoaderDataGraph::do_unloading(is_alive);
1665   bool unloading_occurred = false;
1666   if (has_dead_loaders) {
1667     unloading_occurred = dictionary()->do_unloading();
1668     constraints()->purge_loader_constraints();
1669     resolution_errors()->purge_resolution_errors();
1670   }
1671   // Oops referenced by the system dictionary may get unreachable independently
1672   // of the class loader (eg. cached protection domain oops). So we need to
1673   // explicitly unlink them here instead of in Dictionary::do_unloading.
1674   dictionary()->unlink(is_alive);
1675 #ifdef ASSERT
1676   VerifySDReachableAndLiveClosure cl(is_alive);
1677   dictionary()->oops_do(&cl);
1678 #endif
1679   return unloading_occurred;
1680 }
1681 
1682 void SystemDictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {
1683   strong->do_oop(&_java_system_loader);
1684   strong->do_oop(&_system_loader_lock_obj);
1685 
1686   // Adjust dictionary
1687   dictionary()->roots_oops_do(strong, weak);
1688 
1689   // Visit extra methods
1690   invoke_method_table()->oops_do(strong);
1691 }
1692 
1693 void SystemDictionary::oops_do(OopClosure* f) {
1694   f->do_oop(&_java_system_loader);
1695   f->do_oop(&_system_loader_lock_obj);
1696 
1697   // Adjust dictionary
1698   dictionary()->oops_do(f);
1699 
1700   // Visit extra methods
1701   invoke_method_table()->oops_do(f);
1702 }
1703 
1704 // Extended Class redefinition support.
1705 // If one of these classes is replaced, we need to replace it in these places.
1706 // KlassClosure::do_klass should take the address of a class but we can
1707 // change that later.
1708 void SystemDictionary::preloaded_classes_do(KlassClosure* f) {
1709   for (int k = (int)FIRST_WKID; k < (int)WKID_LIMIT; k++) {
1710     f->do_klass(_well_known_klasses[k]);