Mercurial > hg > truffle
comparison src/share/vm/classfile/systemDictionary.cpp @ 20804:7848fc12602b
Merge with jdk8u40-b25
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Tue, 07 Apr 2015 14:58:49 +0200 |
parents | c307546c7b0a 9fa3bf3043a2 |
children | 6ee9b878902b |
comparison
equal
deleted
inserted
replaced
20184:84105dcdb05b | 20804:7848fc12602b |
---|---|
28 #include "classfile/javaClasses.hpp" | 28 #include "classfile/javaClasses.hpp" |
29 #include "classfile/loaderConstraints.hpp" | 29 #include "classfile/loaderConstraints.hpp" |
30 #include "classfile/placeholders.hpp" | 30 #include "classfile/placeholders.hpp" |
31 #include "classfile/resolutionErrors.hpp" | 31 #include "classfile/resolutionErrors.hpp" |
32 #include "classfile/systemDictionary.hpp" | 32 #include "classfile/systemDictionary.hpp" |
33 #if INCLUDE_CDS | |
34 #include "classfile/sharedClassUtil.hpp" | |
35 #include "classfile/systemDictionaryShared.hpp" | |
36 #endif | |
33 #include "classfile/vmSymbols.hpp" | 37 #include "classfile/vmSymbols.hpp" |
34 #include "compiler/compileBroker.hpp" | 38 #include "compiler/compileBroker.hpp" |
35 #include "interpreter/bytecodeStream.hpp" | 39 #include "interpreter/bytecodeStream.hpp" |
36 #include "interpreter/interpreter.hpp" | 40 #include "interpreter/interpreter.hpp" |
41 #include "memory/filemap.hpp" | |
37 #include "memory/gcLocker.hpp" | 42 #include "memory/gcLocker.hpp" |
38 #include "memory/oopFactory.hpp" | 43 #include "memory/oopFactory.hpp" |
39 #include "oops/instanceKlass.hpp" | 44 #include "oops/instanceKlass.hpp" |
40 #include "oops/instanceRefKlass.hpp" | 45 #include "oops/instanceRefKlass.hpp" |
41 #include "oops/klass.inline.hpp" | 46 #include "oops/klass.inline.hpp" |
44 #include "oops/oop.inline.hpp" | 49 #include "oops/oop.inline.hpp" |
45 #include "oops/oop.inline2.hpp" | 50 #include "oops/oop.inline2.hpp" |
46 #include "oops/typeArrayKlass.hpp" | 51 #include "oops/typeArrayKlass.hpp" |
47 #include "prims/jvmtiEnvBase.hpp" | 52 #include "prims/jvmtiEnvBase.hpp" |
48 #include "prims/methodHandles.hpp" | 53 #include "prims/methodHandles.hpp" |
54 #include "runtime/arguments.hpp" | |
49 #include "runtime/biasedLocking.hpp" | 55 #include "runtime/biasedLocking.hpp" |
50 #include "runtime/fieldType.hpp" | 56 #include "runtime/fieldType.hpp" |
51 #include "runtime/handles.inline.hpp" | 57 #include "runtime/handles.inline.hpp" |
52 #include "runtime/java.hpp" | 58 #include "runtime/java.hpp" |
53 #include "runtime/javaCalls.hpp" | 59 #include "runtime/javaCalls.hpp" |
54 #include "runtime/mutexLocker.hpp" | 60 #include "runtime/mutexLocker.hpp" |
61 #include "runtime/orderAccess.inline.hpp" | |
55 #include "runtime/signature.hpp" | 62 #include "runtime/signature.hpp" |
56 #include "services/classLoadingService.hpp" | 63 #include "services/classLoadingService.hpp" |
57 #include "services/threadService.hpp" | 64 #include "services/threadService.hpp" |
58 #include "utilities/macros.hpp" | 65 #include "utilities/macros.hpp" |
59 #include "utilities/ticks.hpp" | 66 #include "utilities/ticks.hpp" |
60 #ifdef GRAAL | 67 #ifdef GRAAL |
61 #include "graal/graalRuntime.hpp" | 68 #include "graal/graalRuntime.hpp" |
62 #endif | 69 #endif |
63 | |
64 #if INCLUDE_TRACE | 70 #if INCLUDE_TRACE |
65 #include "trace/tracing.hpp" | 71 #include "trace/tracing.hpp" |
66 #endif | 72 #endif |
67 | 73 |
68 Dictionary* SystemDictionary::_dictionary = NULL; | 74 Dictionary* SystemDictionary::_dictionary = NULL; |
69 PlaceholderTable* SystemDictionary::_placeholders = NULL; | 75 PlaceholderTable* SystemDictionary::_placeholders = NULL; |
70 Dictionary* SystemDictionary::_shared_dictionary = NULL; | 76 Dictionary* SystemDictionary::_shared_dictionary = NULL; |
121 vmSymbols::getSystemClassLoader_name(), | 127 vmSymbols::getSystemClassLoader_name(), |
122 vmSymbols::void_classloader_signature(), | 128 vmSymbols::void_classloader_signature(), |
123 CHECK); | 129 CHECK); |
124 | 130 |
125 _java_system_loader = (oop)result.get_jobject(); | 131 _java_system_loader = (oop)result.get_jobject(); |
132 | |
133 CDS_ONLY(SystemDictionaryShared::initialize(CHECK);) | |
126 } | 134 } |
127 | 135 |
128 | 136 |
129 ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, TRAPS) { | 137 ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, TRAPS) { |
130 if (class_loader() == NULL) return ClassLoaderData::the_null_class_loader_data(); | 138 if (class_loader() == NULL) return ClassLoaderData::the_null_class_loader_data(); |
986 if (host_klass.not_null()) { | 994 if (host_klass.not_null()) { |
987 // Create a new CLD for anonymous class, that uses the same class loader | 995 // Create a new CLD for anonymous class, that uses the same class loader |
988 // as the host_klass | 996 // as the host_klass |
989 assert(EnableInvokeDynamic, ""); | 997 assert(EnableInvokeDynamic, ""); |
990 guarantee(host_klass->class_loader() == class_loader(), "should be the same"); | 998 guarantee(host_klass->class_loader() == class_loader(), "should be the same"); |
999 guarantee(!DumpSharedSpaces, "must not create anonymous classes when dumping"); | |
991 loader_data = ClassLoaderData::anonymous_class_loader_data(class_loader(), CHECK_NULL); | 1000 loader_data = ClassLoaderData::anonymous_class_loader_data(class_loader(), CHECK_NULL); |
992 loader_data->record_dependency(host_klass(), CHECK_NULL); | 1001 loader_data->record_dependency(host_klass(), CHECK_NULL); |
993 } else { | 1002 } else { |
994 loader_data = ClassLoaderData::class_loader_data(class_loader()); | 1003 loader_data = ClassLoaderData::class_loader_data(class_loader()); |
995 } | 1004 } |
1147 } ); | 1156 } ); |
1148 | 1157 |
1149 return k(); | 1158 return k(); |
1150 } | 1159 } |
1151 | 1160 |
1152 | 1161 #if INCLUDE_CDS |
1153 void SystemDictionary::set_shared_dictionary(HashtableBucket<mtClass>* t, int length, | 1162 void SystemDictionary::set_shared_dictionary(HashtableBucket<mtClass>* t, int length, |
1154 int number_of_entries) { | 1163 int number_of_entries) { |
1155 assert(length == _nof_buckets * sizeof(HashtableBucket<mtClass>), | 1164 assert(length == _nof_buckets * sizeof(HashtableBucket<mtClass>), |
1156 "bad shared dictionary size."); | 1165 "bad shared dictionary size."); |
1157 _shared_dictionary = new Dictionary(_nof_buckets, t, number_of_entries); | 1166 _shared_dictionary = new Dictionary(_nof_buckets, t, number_of_entries); |
1180 // object hierarchy until loaded.] | 1189 // object hierarchy until loaded.] |
1181 | 1190 |
1182 instanceKlassHandle SystemDictionary::load_shared_class( | 1191 instanceKlassHandle SystemDictionary::load_shared_class( |
1183 Symbol* class_name, Handle class_loader, TRAPS) { | 1192 Symbol* class_name, Handle class_loader, TRAPS) { |
1184 instanceKlassHandle ik (THREAD, find_shared_class(class_name)); | 1193 instanceKlassHandle ik (THREAD, find_shared_class(class_name)); |
1185 return load_shared_class(ik, class_loader, THREAD); | 1194 // Make sure we only return the boot class for the NULL classloader. |
1186 } | 1195 if (ik.not_null() && |
1187 | 1196 SharedClassUtil::is_shared_boot_class(ik()) && class_loader.is_null()) { |
1188 instanceKlassHandle SystemDictionary::load_shared_class( | 1197 Handle protection_domain; |
1189 instanceKlassHandle ik, Handle class_loader, TRAPS) { | 1198 return load_shared_class(ik, class_loader, protection_domain, THREAD); |
1190 assert(class_loader.is_null(), "non-null classloader for shared class?"); | 1199 } |
1200 return instanceKlassHandle(); | |
1201 } | |
1202 | |
1203 instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik, | |
1204 Handle class_loader, | |
1205 Handle protection_domain, TRAPS) { | |
1191 if (ik.not_null()) { | 1206 if (ik.not_null()) { |
1192 instanceKlassHandle nh = instanceKlassHandle(); // null Handle | 1207 instanceKlassHandle nh = instanceKlassHandle(); // null Handle |
1193 Symbol* class_name = ik->name(); | 1208 Symbol* class_name = ik->name(); |
1194 | 1209 |
1195 // Found the class, now load the superclass and interfaces. If they | 1210 // Found the class, now load the superclass and interfaces. If they |
1196 // are shared, add them to the main system dictionary and reset | 1211 // are shared, add them to the main system dictionary and reset |
1197 // their hierarchy references (supers, subs, and interfaces). | 1212 // their hierarchy references (supers, subs, and interfaces). |
1198 | 1213 |
1199 if (ik->super() != NULL) { | 1214 if (ik->super() != NULL) { |
1200 Symbol* cn = ik->super()->name(); | 1215 Symbol* cn = ik->super()->name(); |
1201 resolve_super_or_fail(class_name, cn, | 1216 resolve_super_or_fail(class_name, cn, |
1202 class_loader, Handle(), true, CHECK_(nh)); | 1217 class_loader, protection_domain, true, CHECK_(nh)); |
1203 } | 1218 } |
1204 | 1219 |
1205 Array<Klass*>* interfaces = ik->local_interfaces(); | 1220 Array<Klass*>* interfaces = ik->local_interfaces(); |
1206 int num_interfaces = interfaces->length(); | 1221 int num_interfaces = interfaces->length(); |
1207 for (int index = 0; index < num_interfaces; index++) { | 1222 for (int index = 0; index < num_interfaces; index++) { |
1210 // Note: can not use InstanceKlass::cast here because | 1225 // Note: can not use InstanceKlass::cast here because |
1211 // interfaces' InstanceKlass's C++ vtbls haven't been | 1226 // interfaces' InstanceKlass's C++ vtbls haven't been |
1212 // reinitialized yet (they will be once the interface classes | 1227 // reinitialized yet (they will be once the interface classes |
1213 // are loaded) | 1228 // are loaded) |
1214 Symbol* name = k->name(); | 1229 Symbol* name = k->name(); |
1215 resolve_super_or_fail(class_name, name, class_loader, Handle(), false, CHECK_(nh)); | 1230 resolve_super_or_fail(class_name, name, class_loader, protection_domain, false, CHECK_(nh)); |
1216 } | 1231 } |
1217 | 1232 |
1218 // Adjust methods to recover missing data. They need addresses for | 1233 // Adjust methods to recover missing data. They need addresses for |
1219 // interpreter entry points and their default native method address | 1234 // interpreter entry points and their default native method address |
1220 // must be reset. | 1235 // must be reset. |
1221 | 1236 |
1222 // Updating methods must be done under a lock so multiple | 1237 // Updating methods must be done under a lock so multiple |
1223 // threads don't update these in parallel | 1238 // threads don't update these in parallel |
1224 // Shared classes are all currently loaded by the bootstrap | 1239 // |
1225 // classloader, so this will never cause a deadlock on | 1240 // Shared classes are all currently loaded by either the bootstrap or |
1226 // a custom class loader lock. | 1241 // internal parallel class loaders, so this will never cause a deadlock |
1227 | 1242 // on a custom class loader lock. |
1243 | |
1244 ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader()); | |
1228 { | 1245 { |
1229 Handle lockObject = compute_loader_lock_object(class_loader, THREAD); | 1246 Handle lockObject = compute_loader_lock_object(class_loader, THREAD); |
1230 check_loader_lock_contention(lockObject, THREAD); | 1247 check_loader_lock_contention(lockObject, THREAD); |
1231 ObjectLocker ol(lockObject, THREAD, true); | 1248 ObjectLocker ol(lockObject, THREAD, true); |
1232 ik->restore_unshareable_info(CHECK_(nh)); | 1249 ik->restore_unshareable_info(loader_data, protection_domain, CHECK_(nh)); |
1233 } | 1250 } |
1234 | 1251 |
1235 if (TraceClassLoading) { | 1252 if (TraceClassLoading) { |
1236 ResourceMark rm; | 1253 ResourceMark rm; |
1237 tty->print("[Loaded %s", ik->external_name()); | 1254 tty->print("[Loaded %s", ik->external_name()); |
1238 tty->print(" from shared objects file"); | 1255 tty->print(" from shared objects file"); |
1256 if (class_loader.not_null()) { | |
1257 tty->print(" by %s", loader_data->loader_name()); | |
1258 } | |
1239 tty->print_cr("]"); | 1259 tty->print_cr("]"); |
1240 } | 1260 } |
1261 | |
1262 if (DumpLoadedClassList != NULL && classlist_file->is_open()) { | |
1263 // Only dump the classes that can be stored into CDS archive | |
1264 if (SystemDictionaryShared::is_sharing_possible(loader_data)) { | |
1265 ResourceMark rm(THREAD); | |
1266 classlist_file->print_cr("%s", ik->name()->as_C_string()); | |
1267 classlist_file->flush(); | |
1268 } | |
1269 } | |
1270 | |
1241 // notify a class loaded from shared object | 1271 // notify a class loaded from shared object |
1242 ClassLoadingService::notify_class_loaded(InstanceKlass::cast(ik()), | 1272 ClassLoadingService::notify_class_loaded(InstanceKlass::cast(ik()), |
1243 true /* shared class */); | 1273 true /* shared class */); |
1244 } | 1274 } |
1245 return ik; | 1275 return ik; |
1246 } | 1276 } |
1247 | 1277 #endif // INCLUDE_CDS |
1248 | 1278 |
1249 instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) { | 1279 instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) { |
1250 instanceKlassHandle nh = instanceKlassHandle(); // null Handle | 1280 instanceKlassHandle nh = instanceKlassHandle(); // null Handle |
1251 if (class_loader.is_null()) { | 1281 if (class_loader.is_null()) { |
1252 | 1282 |
1253 // Search the shared system dictionary for classes preloaded into the | 1283 // Search the shared system dictionary for classes preloaded into the |
1254 // shared spaces. | 1284 // shared spaces. |
1255 instanceKlassHandle k; | 1285 instanceKlassHandle k; |
1256 { | 1286 { |
1287 #if INCLUDE_CDS | |
1257 PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time()); | 1288 PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time()); |
1258 k = load_shared_class(class_name, class_loader, THREAD); | 1289 k = load_shared_class(class_name, class_loader, THREAD); |
1290 #endif | |
1259 } | 1291 } |
1260 | 1292 |
1261 if (k.is_null()) { | 1293 if (k.is_null()) { |
1262 // Use VM class loader | 1294 // Use VM class loader |
1263 PerfTraceTime vmtimer(ClassLoader::perf_sys_classload_time()); | 1295 PerfTraceTime vmtimer(ClassLoader::perf_sys_classload_time()); |
1612 // Also, first reinitialize vtable because it may have gotten out of synch | 1644 // Also, first reinitialize vtable because it may have gotten out of synch |
1613 // while the new class wasn't connected to the class hierarchy. | 1645 // while the new class wasn't connected to the class hierarchy. |
1614 Universe::flush_dependents_on(k); | 1646 Universe::flush_dependents_on(k); |
1615 } | 1647 } |
1616 | 1648 |
1617 | |
1618 // ---------------------------------------------------------------------------- | 1649 // ---------------------------------------------------------------------------- |
1619 // GC support | 1650 // GC support |
1620 | 1651 |
1621 // Following roots during mark-sweep is separated in two phases. | 1652 // Following roots during mark-sweep is separated in two phases. |
1622 // | 1653 // |
1625 // | 1656 // |
1626 // The second phase removes (unloads) unreachable classes from the | 1657 // The second phase removes (unloads) unreachable classes from the |
1627 // system dictionary and follows the remaining classes' contents. | 1658 // system dictionary and follows the remaining classes' contents. |
1628 | 1659 |
1629 void SystemDictionary::always_strong_oops_do(OopClosure* blk) { | 1660 void SystemDictionary::always_strong_oops_do(OopClosure* blk) { |
1630 blk->do_oop(&_java_system_loader); | 1661 roots_oops_do(blk, NULL); |
1631 blk->do_oop(&_system_loader_lock_obj); | |
1632 #ifdef GRAAL | |
1633 blk->do_oop(&_graal_loader); | |
1634 #endif | |
1635 | |
1636 dictionary()->always_strong_oops_do(blk); | |
1637 | |
1638 // Visit extra methods | |
1639 invoke_method_table()->oops_do(blk); | |
1640 } | 1662 } |
1641 | 1663 |
1642 void SystemDictionary::always_strong_classes_do(KlassClosure* closure) { | 1664 void SystemDictionary::always_strong_classes_do(KlassClosure* closure) { |
1643 // Follow all system classes and temporary placeholders in dictionary | 1665 // Follow all system classes and temporary placeholders in dictionary |
1644 dictionary()->always_strong_classes_do(closure); | 1666 dictionary()->always_strong_classes_do(closure); |
1681 }; | 1703 }; |
1682 #endif | 1704 #endif |
1683 | 1705 |
1684 // Assumes classes in the SystemDictionary are only unloaded at a safepoint | 1706 // Assumes classes in the SystemDictionary are only unloaded at a safepoint |
1685 // Note: anonymous classes are not in the SD. | 1707 // Note: anonymous classes are not in the SD. |
1686 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) { | 1708 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive, bool clean_alive) { |
1687 // First, mark for unload all ClassLoaderData referencing a dead class loader. | 1709 // First, mark for unload all ClassLoaderData referencing a dead class loader. |
1688 bool has_dead_loaders = ClassLoaderDataGraph::do_unloading(is_alive); | 1710 bool unloading_occurred = ClassLoaderDataGraph::do_unloading(is_alive, clean_alive); |
1689 bool unloading_occurred = false; | 1711 if (unloading_occurred) { |
1690 if (has_dead_loaders) { | 1712 dictionary()->do_unloading(); |
1691 unloading_occurred = dictionary()->do_unloading(); | |
1692 constraints()->purge_loader_constraints(); | 1713 constraints()->purge_loader_constraints(); |
1693 resolution_errors()->purge_resolution_errors(); | 1714 resolution_errors()->purge_resolution_errors(); |
1694 } | 1715 } |
1695 // Oops referenced by the system dictionary may get unreachable independently | 1716 // Oops referenced by the system dictionary may get unreachable independently |
1696 // of the class loader (eg. cached protection domain oops). So we need to | 1717 // of the class loader (eg. cached protection domain oops). So we need to |
1701 dictionary()->oops_do(&cl); | 1722 dictionary()->oops_do(&cl); |
1702 #endif | 1723 #endif |
1703 return unloading_occurred; | 1724 return unloading_occurred; |
1704 } | 1725 } |
1705 | 1726 |
1727 void SystemDictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) { | |
1728 strong->do_oop(&_java_system_loader); | |
1729 strong->do_oop(&_system_loader_lock_obj); | |
1730 CDS_ONLY(SystemDictionaryShared::roots_oops_do(strong);) | |
1731 GRAAL_ONLY(blk->do_oop(&_graal_loader);) | |
1732 | |
1733 // Adjust dictionary | |
1734 dictionary()->roots_oops_do(strong, weak); | |
1735 | |
1736 // Visit extra methods | |
1737 invoke_method_table()->oops_do(strong); | |
1738 } | |
1739 | |
1706 void SystemDictionary::oops_do(OopClosure* f) { | 1740 void SystemDictionary::oops_do(OopClosure* f) { |
1707 f->do_oop(&_java_system_loader); | 1741 f->do_oop(&_java_system_loader); |
1708 f->do_oop(&_system_loader_lock_obj); | 1742 f->do_oop(&_system_loader_lock_obj); |
1709 #ifdef GRAAL | 1743 CDS_ONLY(SystemDictionaryShared::oops_do(f);) |
1710 f->do_oop(&_graal_loader); | 1744 GRAAL_ONLY(f->do_oop(&_graal_loader);) |
1711 #endif | |
1712 | 1745 |
1713 // Adjust dictionary | 1746 // Adjust dictionary |
1714 dictionary()->oops_do(f); | 1747 dictionary()->oops_do(f); |
1715 | 1748 |
1716 // Visit extra methods | 1749 // Visit extra methods |
1766 } | 1799 } |
1767 | 1800 |
1768 void SystemDictionary::methods_do(void f(Method*)) { | 1801 void SystemDictionary::methods_do(void f(Method*)) { |
1769 dictionary()->methods_do(f); | 1802 dictionary()->methods_do(f); |
1770 invoke_method_table()->methods_do(f); | 1803 invoke_method_table()->methods_do(f); |
1804 } | |
1805 | |
1806 void SystemDictionary::remove_classes_in_error_state() { | |
1807 dictionary()->remove_classes_in_error_state(); | |
1771 } | 1808 } |
1772 | 1809 |
1773 // ---------------------------------------------------------------------------- | 1810 // ---------------------------------------------------------------------------- |
1774 // Lazily load klasses | 1811 // Lazily load klasses |
1775 | 1812 |
1893 | 1930 |
1894 // Preload ref klasses and set reference types | 1931 // Preload ref klasses and set reference types |
1895 InstanceKlass::cast(WK_KLASS(Reference_klass))->set_reference_type(REF_OTHER); | 1932 InstanceKlass::cast(WK_KLASS(Reference_klass))->set_reference_type(REF_OTHER); |
1896 InstanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass)); | 1933 InstanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass)); |
1897 | 1934 |
1898 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(PhantomReference_klass), scan, CHECK); | 1935 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Cleaner_klass), scan, CHECK); |
1899 InstanceKlass::cast(WK_KLASS(SoftReference_klass))->set_reference_type(REF_SOFT); | 1936 InstanceKlass::cast(WK_KLASS(SoftReference_klass))->set_reference_type(REF_SOFT); |
1900 InstanceKlass::cast(WK_KLASS(WeakReference_klass))->set_reference_type(REF_WEAK); | 1937 InstanceKlass::cast(WK_KLASS(WeakReference_klass))->set_reference_type(REF_WEAK); |
1901 InstanceKlass::cast(WK_KLASS(FinalReference_klass))->set_reference_type(REF_FINAL); | 1938 InstanceKlass::cast(WK_KLASS(FinalReference_klass))->set_reference_type(REF_FINAL); |
1902 InstanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM); | 1939 InstanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM); |
1940 InstanceKlass::cast(WK_KLASS(Cleaner_klass))->set_reference_type(REF_CLEANER); | |
1903 | 1941 |
1904 // JSR 292 classes | 1942 // JSR 292 classes |
1905 WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass); | 1943 WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass); |
1906 WKID jsr292_group_end = WK_KLASS_ENUM_NAME(VolatileCallSite_klass); | 1944 WKID jsr292_group_end = WK_KLASS_ENUM_NAME(VolatileCallSite_klass); |
1907 initialize_wk_klasses_until(jsr292_group_start, scan, CHECK); | 1945 initialize_wk_klasses_until(jsr292_group_start, scan, CHECK); |
2261 methodHandle m; | 2299 methodHandle m; |
2262 if (spe == NULL || spe->method() == NULL) { | 2300 if (spe == NULL || spe->method() == NULL) { |
2263 spe = NULL; | 2301 spe = NULL; |
2264 // Must create lots of stuff here, but outside of the SystemDictionary lock. | 2302 // Must create lots of stuff here, but outside of the SystemDictionary lock. |
2265 m = Method::make_method_handle_intrinsic(iid, signature, CHECK_(empty)); | 2303 m = Method::make_method_handle_intrinsic(iid, signature, CHECK_(empty)); |
2266 CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier, | 2304 if (!Arguments::is_interpreter_only()) { |
2267 methodHandle(), CompileThreshold, "MH", CHECK_(empty)); | 2305 // Generate a compiled form of the MH intrinsic. |
2268 | 2306 AdapterHandlerLibrary::create_native_wrapper(m); |
2307 // Check if have the compiled code. | |
2308 if (!m->has_compiled_code()) { | |
2309 THROW_MSG_(vmSymbols::java_lang_VirtualMachineError(), | |
2310 "out of space in CodeCache for method handle intrinsic", empty); | |
2311 } | |
2312 } | |
2269 // Now grab the lock. We might have to throw away the new method, | 2313 // Now grab the lock. We might have to throw away the new method, |
2270 // if a racing thread has managed to install one at the same time. | 2314 // if a racing thread has managed to install one at the same time. |
2271 { | 2315 { |
2272 MutexLocker ml(SystemDictionary_lock, THREAD); | 2316 MutexLocker ml(SystemDictionary_lock, THREAD); |
2273 spe = invoke_method_table()->find_entry(index, hash, signature, iid); | 2317 spe = invoke_method_table()->find_entry(index, hash, signature, iid); |
2274 if (spe == NULL) | 2318 if (spe == NULL) |
2275 spe = invoke_method_table()->add_entry(index, hash, signature, iid); | 2319 spe = invoke_method_table()->add_entry(index, hash, signature, iid); |
2276 if (spe->method() == NULL) | 2320 if (spe->method() == NULL) |
2277 spe->set_method(m()); | 2321 spe->set_method(m()); |
2278 } | 2322 } |
2279 } else if (spe->method()->code() == NULL) { | 2323 } |
2280 CompileBroker::compile_method(spe->method(), InvocationEntryBci, CompLevel_highest_tier, | 2324 |
2281 methodHandle(), CompileThreshold, "MH", CHECK_(empty)); | 2325 guarantee(spe != NULL && spe->method() != NULL, ""); |
2282 } | 2326 guarantee(Arguments::is_interpreter_only() || (spe->method()->has_compiled_code() && |
2283 | 2327 spe->method()->code()->entry_point() == spe->method()->from_compiled_entry()), |
2284 guarantee(spe != NULL && spe->method() != NULL && (!UseCompiler || spe->method()->code() != NULL), "Could not compile a method handle intrinsic"); | 2328 "MH intrinsic invariant"); |
2285 return spe->method(); | 2329 return spe->method(); |
2286 } | 2330 } |
2287 | 2331 |
2288 // Helper for unpacking the return value from linkMethod and linkCallSite. | 2332 // Helper for unpacking the return value from linkMethod and linkCallSite. |
2289 static methodHandle unpack_method_and_appendix(Handle mname, | 2333 static methodHandle unpack_method_and_appendix(Handle mname, |
2591 return dictionary()->number_of_entries(); | 2635 return dictionary()->number_of_entries(); |
2592 } | 2636 } |
2593 | 2637 |
2594 | 2638 |
2595 // ---------------------------------------------------------------------------- | 2639 // ---------------------------------------------------------------------------- |
2596 #ifndef PRODUCT | 2640 void SystemDictionary::print_shared(bool details) { |
2597 | 2641 shared_dictionary()->print(details); |
2598 void SystemDictionary::print() { | 2642 } |
2599 dictionary()->print(); | 2643 |
2644 void SystemDictionary::print(bool details) { | |
2645 dictionary()->print(details); | |
2600 | 2646 |
2601 // Placeholders | 2647 // Placeholders |
2602 GCMutexLocker mu(SystemDictionary_lock); | 2648 GCMutexLocker mu(SystemDictionary_lock); |
2603 placeholders()->print(); | 2649 placeholders()->print(); |
2604 | 2650 |
2605 // loader constraints - print under SD_lock | 2651 // loader constraints - print under SD_lock |
2606 constraints()->print(); | 2652 constraints()->print(); |
2607 } | 2653 } |
2608 | 2654 |
2609 #endif | |
2610 | 2655 |
2611 void SystemDictionary::verify() { | 2656 void SystemDictionary::verify() { |
2612 guarantee(dictionary() != NULL, "Verify of system dictionary failed"); | 2657 guarantee(dictionary() != NULL, "Verify of system dictionary failed"); |
2613 guarantee(constraints() != NULL, | 2658 guarantee(constraints() != NULL, |
2614 "Verify of loader constraints failed"); | 2659 "Verify of loader constraints failed"); |
2642 oop class_loader = initiating_loader.is_null() ? (oop)NULL : initiating_loader(); | 2687 oop class_loader = initiating_loader.is_null() ? (oop)NULL : initiating_loader(); |
2643 event.set_initiatingClassLoader(class_loader != NULL ? | 2688 event.set_initiatingClassLoader(class_loader != NULL ? |
2644 class_loader->klass() : (Klass*)NULL); | 2689 class_loader->klass() : (Klass*)NULL); |
2645 event.commit(); | 2690 event.commit(); |
2646 } | 2691 } |
2647 #endif /* INCLUDE_TRACE */ | 2692 #endif // INCLUDE_TRACE |
2648 } | 2693 } |
2649 | 2694 |
2650 #ifndef PRODUCT | 2695 #ifndef PRODUCT |
2651 | 2696 |
2652 // statistics code | 2697 // statistics code |