58 oop SystemDictionary::java_system_loader() { |
58 oop SystemDictionary::java_system_loader() { |
59 return _java_system_loader; |
59 return _java_system_loader; |
60 } |
60 } |
61 |
61 |
62 void SystemDictionary::compute_java_system_loader(TRAPS) { |
62 void SystemDictionary::compute_java_system_loader(TRAPS) { |
63 KlassHandle system_klass(THREAD, WK_KLASS(classloader_klass)); |
63 KlassHandle system_klass(THREAD, WK_KLASS(ClassLoader_klass)); |
64 JavaValue result(T_OBJECT); |
64 JavaValue result(T_OBJECT); |
65 JavaCalls::call_static(&result, |
65 JavaCalls::call_static(&result, |
66 KlassHandle(THREAD, WK_KLASS(classloader_klass)), |
66 KlassHandle(THREAD, WK_KLASS(ClassLoader_klass)), |
67 vmSymbolHandles::getSystemClassLoader_name(), |
67 vmSymbolHandles::getSystemClassLoader_name(), |
68 vmSymbolHandles::void_classloader_signature(), |
68 vmSymbolHandles::void_classloader_signature(), |
69 CHECK); |
69 CHECK); |
70 |
70 |
71 _java_system_loader = (oop)result.get_jobject(); |
71 _java_system_loader = (oop)result.get_jobject(); |
97 if (UnsyncloadClass || class_loader.is_null()) return true; |
97 if (UnsyncloadClass || class_loader.is_null()) return true; |
98 if (AlwaysLockClassLoader) return false; |
98 if (AlwaysLockClassLoader) return false; |
99 return java_lang_Class::parallelCapable(class_loader()); |
99 return java_lang_Class::parallelCapable(class_loader()); |
100 } |
100 } |
101 // ---------------------------------------------------------------------------- |
101 // ---------------------------------------------------------------------------- |
|
102 // ParallelDefineClass flag does not apply to bootclass loader |
|
103 bool SystemDictionary::is_parallelDefine(Handle class_loader) { |
|
104 if (class_loader.is_null()) return false; |
|
105 if (AllowParallelDefineClass && java_lang_Class::parallelCapable(class_loader())) { |
|
106 return true; |
|
107 } |
|
108 return false; |
|
109 } |
|
110 // ---------------------------------------------------------------------------- |
102 // Resolving of classes |
111 // Resolving of classes |
103 |
112 |
104 // Forwards to resolve_or_null |
113 // Forwards to resolve_or_null |
105 |
114 |
106 klassOop SystemDictionary::resolve_or_fail(symbolHandle class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) { |
115 klassOop SystemDictionary::resolve_or_fail(symbolHandle class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) { |
117 if (HAS_PENDING_EXCEPTION) { |
126 if (HAS_PENDING_EXCEPTION) { |
118 // If we have a pending exception we forward it to the caller, unless throw_error is true, |
127 // If we have a pending exception we forward it to the caller, unless throw_error is true, |
119 // in which case we have to check whether the pending exception is a ClassNotFoundException, |
128 // in which case we have to check whether the pending exception is a ClassNotFoundException, |
120 // and if so convert it to a NoClassDefFoundError |
129 // and if so convert it to a NoClassDefFoundError |
121 // And chain the original ClassNotFoundException |
130 // And chain the original ClassNotFoundException |
122 if (throw_error && PENDING_EXCEPTION->is_a(SystemDictionary::classNotFoundException_klass())) { |
131 if (throw_error && PENDING_EXCEPTION->is_a(SystemDictionary::ClassNotFoundException_klass())) { |
123 ResourceMark rm(THREAD); |
132 ResourceMark rm(THREAD); |
124 assert(klass_h() == NULL, "Should not have result with exception pending"); |
133 assert(klass_h() == NULL, "Should not have result with exception pending"); |
125 Handle e(THREAD, PENDING_EXCEPTION); |
134 Handle e(THREAD, PENDING_EXCEPTION); |
126 CLEAR_PENDING_EXCEPTION; |
135 CLEAR_PENDING_EXCEPTION; |
127 THROW_MSG_CAUSE_0(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string(), e); |
136 THROW_MSG_CAUSE_0(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string(), e); |
348 tty->print(" - loading: "); klass()->print_value_on(tty); tty->cr(); |
357 tty->print(" - loading: "); klass()->print_value_on(tty); tty->cr(); |
349 } |
358 } |
350 |
359 |
351 assert(class_loader() != NULL, "should not have non-null protection domain for null classloader"); |
360 assert(class_loader() != NULL, "should not have non-null protection domain for null classloader"); |
352 |
361 |
353 KlassHandle system_loader(THREAD, SystemDictionary::classloader_klass()); |
362 KlassHandle system_loader(THREAD, SystemDictionary::ClassLoader_klass()); |
354 JavaCalls::call_special(&result, |
363 JavaCalls::call_special(&result, |
355 class_loader, |
364 class_loader, |
356 system_loader, |
365 system_loader, |
357 vmSymbolHandles::checkPackageAccess_name(), |
366 vmSymbolHandles::checkPackageAccess_name(), |
358 vmSymbolHandles::class_protectiondomain_signature(), |
367 vmSymbolHandles::class_protectiondomain_signature(), |
722 if (!class_has_been_loaded) { |
731 if (!class_has_been_loaded) { |
723 |
732 |
724 // Do actual loading |
733 // Do actual loading |
725 k = load_instance_class(name, class_loader, THREAD); |
734 k = load_instance_class(name, class_loader, THREAD); |
726 |
735 |
727 // For UnsyncloadClass and AllowParallelDefineClass only: |
736 // For UnsyncloadClass only |
728 // If they got a linkageError, check if a parallel class load succeeded. |
737 // If they got a linkageError, check if a parallel class load succeeded. |
729 // If it did, then for bytecode resolution the specification requires |
738 // If it did, then for bytecode resolution the specification requires |
730 // that we return the same result we did for the other thread, i.e. the |
739 // that we return the same result we did for the other thread, i.e. the |
731 // successfully loaded instanceKlass |
740 // successfully loaded instanceKlass |
732 // Should not get here for classloaders that support parallelism |
741 // Should not get here for classloaders that support parallelism |
733 // with the new cleaner mechanism |
742 // with the new cleaner mechanism, even with AllowParallelDefineClass |
734 // Bootstrap goes through here to allow for an extra guarantee check |
743 // Bootstrap goes through here to allow for an extra guarantee check |
735 if (UnsyncloadClass || (class_loader.is_null())) { |
744 if (UnsyncloadClass || (class_loader.is_null())) { |
736 if (k.is_null() && HAS_PENDING_EXCEPTION |
745 if (k.is_null() && HAS_PENDING_EXCEPTION |
737 && PENDING_EXCEPTION->is_a(SystemDictionary::linkageError_klass())) { |
746 && PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { |
738 MutexLocker mu(SystemDictionary_lock, THREAD); |
747 MutexLocker mu(SystemDictionary_lock, THREAD); |
739 klassOop check = find_class(d_index, d_hash, name, class_loader); |
748 klassOop check = find_class(d_index, d_hash, name, class_loader); |
740 if (check != NULL) { |
749 if (check != NULL) { |
741 // Klass is already loaded, so just use it |
750 // Klass is already loaded, so just use it |
742 k = instanceKlassHandle(THREAD, check); |
751 k = instanceKlassHandle(THREAD, check); |
1356 // Translate to external class name format, i.e., convert '/' chars to '.' |
1365 // Translate to external class name format, i.e., convert '/' chars to '.' |
1357 Handle string = java_lang_String::externalize_classname(s, CHECK_(nh)); |
1366 Handle string = java_lang_String::externalize_classname(s, CHECK_(nh)); |
1358 |
1367 |
1359 JavaValue result(T_OBJECT); |
1368 JavaValue result(T_OBJECT); |
1360 |
1369 |
1361 KlassHandle spec_klass (THREAD, SystemDictionary::classloader_klass()); |
1370 KlassHandle spec_klass (THREAD, SystemDictionary::ClassLoader_klass()); |
1362 |
1371 |
1363 // Call public unsynchronized loadClass(String) directly for all class loaders |
1372 // Call public unsynchronized loadClass(String) directly for all class loaders |
1364 // for parallelCapable class loaders. JDK >=7, loadClass(String, boolean) will |
1373 // for parallelCapable class loaders. JDK >=7, loadClass(String, boolean) will |
1365 // acquire a class-name based lock rather than the class loader object lock. |
1374 // acquire a class-name based lock rather than the class loader object lock. |
1366 // JDK < 7 already acquire the class loader lock in loadClass(String, boolean), |
1375 // JDK < 7 already acquire the class loader lock in loadClass(String, boolean), |
1481 |
1490 |
1482 } |
1491 } |
1483 } |
1492 } |
1484 |
1493 |
1485 // Support parallel classloading |
1494 // Support parallel classloading |
1486 // Initial implementation for bootstrap classloader |
1495 // All parallel class loaders, including bootstrap classloader |
1487 // For custom class loaders that support parallel classloading, |
1496 // lock a placeholder entry for this class/class_loader pair |
|
1497 // to allow parallel defines of different classes for this class loader |
1488 // With AllowParallelDefine flag==true, in case they do not synchronize around |
1498 // With AllowParallelDefine flag==true, in case they do not synchronize around |
1489 // FindLoadedClass/DefineClass, calls, we check for parallel |
1499 // FindLoadedClass/DefineClass, calls, we check for parallel |
1490 // loading for them, wait if a defineClass is in progress |
1500 // loading for them, wait if a defineClass is in progress |
1491 // and return the initial requestor's results |
1501 // and return the initial requestor's results |
|
1502 // This flag does not apply to the bootstrap classloader. |
1492 // With AllowParallelDefine flag==false, call through to define_instance_class |
1503 // With AllowParallelDefine flag==false, call through to define_instance_class |
1493 // which will throw LinkageError: duplicate class definition. |
1504 // which will throw LinkageError: duplicate class definition. |
|
1505 // False is the requested default. |
1494 // For better performance, the class loaders should synchronize |
1506 // For better performance, the class loaders should synchronize |
1495 // findClass(), i.e. FindLoadedClass/DefineClassIfAbsent or they |
1507 // findClass(), i.e. FindLoadedClass/DefineClassIfAbsent or they |
1496 // potentially waste time reading and parsing the bytestream. |
1508 // potentially waste time reading and parsing the bytestream. |
1497 // Note: VM callers should ensure consistency of k/class_name,class_loader |
1509 // Note: VM callers should ensure consistency of k/class_name,class_loader |
1498 instanceKlassHandle SystemDictionary::find_or_define_instance_class(symbolHandle class_name, Handle class_loader, instanceKlassHandle k, TRAPS) { |
1510 instanceKlassHandle SystemDictionary::find_or_define_instance_class(symbolHandle class_name, Handle class_loader, instanceKlassHandle k, TRAPS) { |
1509 PlaceholderEntry* probe; |
1521 PlaceholderEntry* probe; |
1510 |
1522 |
1511 { |
1523 { |
1512 MutexLocker mu(SystemDictionary_lock, THREAD); |
1524 MutexLocker mu(SystemDictionary_lock, THREAD); |
1513 // First check if class already defined |
1525 // First check if class already defined |
1514 klassOop check = find_class(d_index, d_hash, name_h, class_loader); |
1526 if (UnsyncloadClass || (is_parallelDefine(class_loader))) { |
1515 if (check != NULL) { |
1527 klassOop check = find_class(d_index, d_hash, name_h, class_loader); |
1516 return(instanceKlassHandle(THREAD, check)); |
1528 if (check != NULL) { |
|
1529 return(instanceKlassHandle(THREAD, check)); |
|
1530 } |
1517 } |
1531 } |
1518 |
1532 |
1519 // Acquire define token for this class/classloader |
1533 // Acquire define token for this class/classloader |
1520 symbolHandle nullsymbolHandle; |
1534 symbolHandle nullsymbolHandle; |
1521 probe = placeholders()->find_and_add(p_index, p_hash, name_h, class_loader, PlaceholderTable::DEFINE_CLASS, nullsymbolHandle, THREAD); |
1535 probe = placeholders()->find_and_add(p_index, p_hash, name_h, class_loader, PlaceholderTable::DEFINE_CLASS, nullsymbolHandle, THREAD); |
1527 SystemDictionary_lock->wait(); |
1541 SystemDictionary_lock->wait(); |
1528 } |
1542 } |
1529 // Only special cases allow parallel defines and can use other thread's results |
1543 // Only special cases allow parallel defines and can use other thread's results |
1530 // Other cases fall through, and may run into duplicate defines |
1544 // Other cases fall through, and may run into duplicate defines |
1531 // caught by finding an entry in the SystemDictionary |
1545 // caught by finding an entry in the SystemDictionary |
1532 if ((UnsyncloadClass || AllowParallelDefineClass) && (probe->instanceKlass() != NULL)) { |
1546 if ((UnsyncloadClass || is_parallelDefine(class_loader)) && (probe->instanceKlass() != NULL)) { |
1533 probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS); |
1547 probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS); |
1534 placeholders()->find_and_remove(p_index, p_hash, name_h, class_loader, THREAD); |
1548 placeholders()->find_and_remove(p_index, p_hash, name_h, class_loader, THREAD); |
1535 SystemDictionary_lock->notify_all(); |
1549 SystemDictionary_lock->notify_all(); |
1536 #ifdef ASSERT |
1550 #ifdef ASSERT |
1537 klassOop check = find_class(d_index, d_hash, name_h, class_loader); |
1551 klassOop check = find_class(d_index, d_hash, name_h, class_loader); |
1928 start_id = limit_id; |
1942 start_id = limit_id; |
1929 } |
1943 } |
1930 |
1944 |
1931 |
1945 |
1932 void SystemDictionary::initialize_preloaded_classes(TRAPS) { |
1946 void SystemDictionary::initialize_preloaded_classes(TRAPS) { |
1933 assert(WK_KLASS(object_klass) == NULL, "preloaded classes should only be initialized once"); |
1947 assert(WK_KLASS(Object_klass) == NULL, "preloaded classes should only be initialized once"); |
1934 // Preload commonly used klasses |
1948 // Preload commonly used klasses |
1935 WKID scan = FIRST_WKID; |
1949 WKID scan = FIRST_WKID; |
1936 // first do Object, String, Class |
1950 // first do Object, String, Class |
1937 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(class_klass), scan, CHECK); |
1951 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK); |
1938 |
1952 |
1939 debug_only(instanceKlass::verify_class_klass_nonstatic_oop_maps(WK_KLASS(class_klass))); |
1953 debug_only(instanceKlass::verify_class_klass_nonstatic_oop_maps(WK_KLASS(Class_klass))); |
1940 |
1954 |
1941 // Fixup mirrors for classes loaded before java.lang.Class. |
1955 // Fixup mirrors for classes loaded before java.lang.Class. |
1942 // These calls iterate over the objects currently in the perm gen |
1956 // These calls iterate over the objects currently in the perm gen |
1943 // so calling them at this point is matters (not before when there |
1957 // so calling them at this point is matters (not before when there |
1944 // are fewer objects and not later after there are more objects |
1958 // are fewer objects and not later after there are more objects |
1945 // in the perm gen. |
1959 // in the perm gen. |
1946 Universe::initialize_basic_type_mirrors(CHECK); |
1960 Universe::initialize_basic_type_mirrors(CHECK); |
1947 Universe::fixup_mirrors(CHECK); |
1961 Universe::fixup_mirrors(CHECK); |
1948 |
1962 |
1949 // do a bunch more: |
1963 // do a bunch more: |
1950 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(reference_klass), scan, CHECK); |
1964 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Reference_klass), scan, CHECK); |
1951 |
1965 |
1952 // Preload ref klasses and set reference types |
1966 // Preload ref klasses and set reference types |
1953 instanceKlass::cast(WK_KLASS(reference_klass))->set_reference_type(REF_OTHER); |
1967 instanceKlass::cast(WK_KLASS(Reference_klass))->set_reference_type(REF_OTHER); |
1954 instanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(reference_klass)); |
1968 instanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass)); |
1955 |
1969 |
1956 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(phantom_reference_klass), scan, CHECK); |
1970 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(PhantomReference_klass), scan, CHECK); |
1957 instanceKlass::cast(WK_KLASS(soft_reference_klass))->set_reference_type(REF_SOFT); |
1971 instanceKlass::cast(WK_KLASS(SoftReference_klass))->set_reference_type(REF_SOFT); |
1958 instanceKlass::cast(WK_KLASS(weak_reference_klass))->set_reference_type(REF_WEAK); |
1972 instanceKlass::cast(WK_KLASS(WeakReference_klass))->set_reference_type(REF_WEAK); |
1959 instanceKlass::cast(WK_KLASS(final_reference_klass))->set_reference_type(REF_FINAL); |
1973 instanceKlass::cast(WK_KLASS(FinalReference_klass))->set_reference_type(REF_FINAL); |
1960 instanceKlass::cast(WK_KLASS(phantom_reference_klass))->set_reference_type(REF_PHANTOM); |
1974 instanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM); |
1961 |
1975 |
1962 WKID meth_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass); |
1976 WKID meth_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass); |
1963 WKID meth_group_end = WK_KLASS_ENUM_NAME(WrongMethodTypeException_klass); |
1977 WKID meth_group_end = WK_KLASS_ENUM_NAME(WrongMethodTypeException_klass); |
1964 initialize_wk_klasses_until(meth_group_start, scan, CHECK); |
1978 initialize_wk_klasses_until(meth_group_start, scan, CHECK); |
1965 if (EnableMethodHandles) { |
1979 if (EnableMethodHandles) { |
1968 if (_well_known_klasses[meth_group_start] == NULL) { |
1982 if (_well_known_klasses[meth_group_start] == NULL) { |
1969 // Skip the rest of the method handle classes, if MethodHandle is not loaded. |
1983 // Skip the rest of the method handle classes, if MethodHandle is not loaded. |
1970 scan = WKID(meth_group_end+1); |
1984 scan = WKID(meth_group_end+1); |
1971 } |
1985 } |
1972 WKID indy_group_start = WK_KLASS_ENUM_NAME(Linkage_klass); |
1986 WKID indy_group_start = WK_KLASS_ENUM_NAME(Linkage_klass); |
1973 WKID indy_group_end = WK_KLASS_ENUM_NAME(Dynamic_klass); |
1987 WKID indy_group_end = WK_KLASS_ENUM_NAME(InvokeDynamic_klass); |
1974 initialize_wk_klasses_until(indy_group_start, scan, CHECK); |
1988 initialize_wk_klasses_until(indy_group_start, scan, CHECK); |
1975 if (EnableInvokeDynamic) { |
1989 if (EnableInvokeDynamic) { |
1976 initialize_wk_klasses_through(indy_group_start, scan, CHECK); |
1990 initialize_wk_klasses_through(indy_group_end, scan, CHECK); |
1977 } |
1991 } |
1978 if (_well_known_klasses[indy_group_start] == NULL) { |
1992 if (_well_known_klasses[indy_group_start] == NULL) { |
1979 // Skip the rest of the dynamic typing classes, if Linkage is not loaded. |
1993 // Skip the rest of the dynamic typing classes, if Linkage is not loaded. |
1980 scan = WKID(indy_group_end+1); |
1994 scan = WKID(indy_group_end+1); |
1981 } |
1995 } |
1982 |
1996 |
1983 initialize_wk_klasses_until(WKID_LIMIT, scan, CHECK); |
1997 initialize_wk_klasses_until(WKID_LIMIT, scan, CHECK); |
1984 |
1998 |
1985 _box_klasses[T_BOOLEAN] = WK_KLASS(boolean_klass); |
1999 _box_klasses[T_BOOLEAN] = WK_KLASS(Boolean_klass); |
1986 _box_klasses[T_CHAR] = WK_KLASS(char_klass); |
2000 _box_klasses[T_CHAR] = WK_KLASS(Character_klass); |
1987 _box_klasses[T_FLOAT] = WK_KLASS(float_klass); |
2001 _box_klasses[T_FLOAT] = WK_KLASS(Float_klass); |
1988 _box_klasses[T_DOUBLE] = WK_KLASS(double_klass); |
2002 _box_klasses[T_DOUBLE] = WK_KLASS(Double_klass); |
1989 _box_klasses[T_BYTE] = WK_KLASS(byte_klass); |
2003 _box_klasses[T_BYTE] = WK_KLASS(Byte_klass); |
1990 _box_klasses[T_SHORT] = WK_KLASS(short_klass); |
2004 _box_klasses[T_SHORT] = WK_KLASS(Short_klass); |
1991 _box_klasses[T_INT] = WK_KLASS(int_klass); |
2005 _box_klasses[T_INT] = WK_KLASS(Integer_klass); |
1992 _box_klasses[T_LONG] = WK_KLASS(long_klass); |
2006 _box_klasses[T_LONG] = WK_KLASS(Long_klass); |
1993 //_box_klasses[T_OBJECT] = WK_KLASS(object_klass); |
2007 //_box_klasses[T_OBJECT] = WK_KLASS(object_klass); |
1994 //_box_klasses[T_ARRAY] = WK_KLASS(object_klass); |
2008 //_box_klasses[T_ARRAY] = WK_KLASS(object_klass); |
1995 |
2009 |
1996 #ifdef KERNEL |
2010 #ifdef KERNEL |
1997 if (sun_jkernel_DownloadManager_klass() == NULL) { |
2011 if (sun_jkernel_DownloadManager_klass() == NULL) { |
1998 warning("Cannot find sun/jkernel/DownloadManager"); |
2012 warning("Cannot find sun/jkernel/DownloadManager"); |
1999 } |
2013 } |
2000 #endif // KERNEL |
2014 #endif // KERNEL |
2001 |
2015 |
2002 { // Compute whether we should use loadClass or loadClassInternal when loading classes. |
2016 { // Compute whether we should use loadClass or loadClassInternal when loading classes. |
2003 methodOop method = instanceKlass::cast(classloader_klass())->find_method(vmSymbols::loadClassInternal_name(), vmSymbols::string_class_signature()); |
2017 methodOop method = instanceKlass::cast(ClassLoader_klass())->find_method(vmSymbols::loadClassInternal_name(), vmSymbols::string_class_signature()); |
2004 _has_loadClassInternal = (method != NULL); |
2018 _has_loadClassInternal = (method != NULL); |
2005 } |
2019 } |
2006 { // Compute whether we should use checkPackageAccess or NOT |
2020 { // Compute whether we should use checkPackageAccess or NOT |
2007 methodOop method = instanceKlass::cast(classloader_klass())->find_method(vmSymbols::checkPackageAccess_name(), vmSymbols::class_protectiondomain_signature()); |
2021 methodOop method = instanceKlass::cast(ClassLoader_klass())->find_method(vmSymbols::checkPackageAccess_name(), vmSymbols::class_protectiondomain_signature()); |
2008 _has_checkPackageAccess = (method != NULL); |
2022 _has_checkPackageAccess = (method != NULL); |
2009 } |
2023 } |
2010 } |
2024 } |
2011 |
2025 |
2012 // Tells if a given klass is a box (wrapper class, such as java.lang.Integer). |
2026 // Tells if a given klass is a box (wrapper class, such as java.lang.Integer). |
2341 unsigned int hash = invoke_method_table()->compute_hash(signature); |
2355 unsigned int hash = invoke_method_table()->compute_hash(signature); |
2342 int index = invoke_method_table()->hash_to_index(hash); |
2356 int index = invoke_method_table()->hash_to_index(hash); |
2343 SymbolPropertyEntry* spe = invoke_method_table()->find_entry(index, hash, signature); |
2357 SymbolPropertyEntry* spe = invoke_method_table()->find_entry(index, hash, signature); |
2344 if (spe == NULL || spe->property_oop() == NULL) { |
2358 if (spe == NULL || spe->property_oop() == NULL) { |
2345 // Must create lots of stuff here, but outside of the SystemDictionary lock. |
2359 // Must create lots of stuff here, but outside of the SystemDictionary lock. |
|
2360 if (THREAD->is_Compiler_thread()) |
|
2361 return NULL; // do not attempt from within compiler |
2346 Handle mt = compute_method_handle_type(signature(), |
2362 Handle mt = compute_method_handle_type(signature(), |
2347 class_loader, protection_domain, |
2363 class_loader, protection_domain, |
2348 CHECK_NULL); |
2364 CHECK_NULL); |
2349 KlassHandle mh_klass = SystemDictionaryHandles::MethodHandle_klass(); |
2365 KlassHandle mh_klass = SystemDictionaryHandles::MethodHandle_klass(); |
2350 methodHandle m = methodOopDesc::make_invoke_method(mh_klass, signature, |
2366 methodHandle m = methodOopDesc::make_invoke_method(mh_klass, signature, |
2373 Handle class_loader, |
2389 Handle class_loader, |
2374 Handle protection_domain, |
2390 Handle protection_domain, |
2375 TRAPS) { |
2391 TRAPS) { |
2376 Handle empty; |
2392 Handle empty; |
2377 int npts = ArgumentCount(signature()).size(); |
2393 int npts = ArgumentCount(signature()).size(); |
2378 objArrayHandle pts = oopFactory::new_objArray(SystemDictionary::class_klass(), npts, CHECK_(empty)); |
2394 objArrayHandle pts = oopFactory::new_objArray(SystemDictionary::Class_klass(), npts, CHECK_(empty)); |
2379 int arg = 0; |
2395 int arg = 0; |
2380 Handle rt; // the return type from the signature |
2396 Handle rt; // the return type from the signature |
2381 for (SignatureStream ss(signature()); !ss.is_done(); ss.next()) { |
2397 for (SignatureStream ss(signature()); !ss.is_done(); ss.next()) { |
2382 oop mirror; |
2398 oop mirror; |
2383 if (!ss.is_object()) { |
2399 if (!ss.is_object()) { |
2419 int caller_bci, |
2435 int caller_bci, |
2420 symbolHandle name, |
2436 symbolHandle name, |
2421 methodHandle mh_invdyn, |
2437 methodHandle mh_invdyn, |
2422 TRAPS) { |
2438 TRAPS) { |
2423 Handle empty; |
2439 Handle empty; |
2424 // call sun.dyn.CallSiteImpl::makeSite(caller, name, mtype, cmid, cbci) |
2440 // call java.dyn.CallSite::makeSite(caller, name, mtype, cmid, cbci) |
2425 oop name_str_oop = StringTable::intern(name(), CHECK_(empty)); // not a handle! |
2441 oop name_str_oop = StringTable::intern(name(), CHECK_(empty)); // not a handle! |
2426 JavaCallArguments args(Handle(THREAD, caller->java_mirror())); |
2442 JavaCallArguments args(Handle(THREAD, caller->java_mirror())); |
2427 args.push_oop(name_str_oop); |
2443 args.push_oop(name_str_oop); |
2428 args.push_oop(mh_invdyn->method_handle_type()); |
2444 args.push_oop(mh_invdyn->method_handle_type()); |
2429 args.push_int(caller_method_idnum); |
2445 args.push_int(caller_method_idnum); |
2430 args.push_int(caller_bci); |
2446 args.push_int(caller_bci); |
2431 JavaValue result(T_OBJECT); |
2447 JavaValue result(T_OBJECT); |
2432 JavaCalls::call_static(&result, |
2448 JavaCalls::call_static(&result, |
2433 SystemDictionary::CallSiteImpl_klass(), |
2449 SystemDictionary::CallSite_klass(), |
2434 vmSymbols::makeSite_name(), vmSymbols::makeSite_signature(), |
2450 vmSymbols::makeSite_name(), vmSymbols::makeSite_signature(), |
2435 &args, CHECK_(empty)); |
2451 &args, CHECK_(empty)); |
2436 oop call_site_oop = (oop) result.get_jobject(); |
2452 oop call_site_oop = (oop) result.get_jobject(); |
2437 assert(call_site_oop->is_oop() |
2453 assert(call_site_oop->is_oop() |
2438 /*&& sun_dyn_CallSiteImpl::is_instance(call_site_oop)*/, "must be sane"); |
2454 /*&& java_dyn_CallSite::is_instance(call_site_oop)*/, "must be sane"); |
2439 sun_dyn_CallSiteImpl::set_vmmethod(call_site_oop, mh_invdyn()); |
2455 java_dyn_CallSite::set_vmmethod(call_site_oop, mh_invdyn()); |
2440 if (TraceMethodHandles) { |
2456 if (TraceMethodHandles) { |
|
2457 #ifndef PRODUCT |
2441 tty->print_cr("Linked invokedynamic bci=%d site="INTPTR_FORMAT":", caller_bci, call_site_oop); |
2458 tty->print_cr("Linked invokedynamic bci=%d site="INTPTR_FORMAT":", caller_bci, call_site_oop); |
2442 call_site_oop->print(); |
2459 call_site_oop->print(); |
2443 tty->cr(); |
2460 tty->cr(); |
|
2461 #endif //PRODUCT |
2444 } |
2462 } |
2445 return call_site_oop; |
2463 return call_site_oop; |
2446 } |
2464 } |
2447 |
2465 |
2448 Handle SystemDictionary::find_bootstrap_method(KlassHandle caller, |
2466 Handle SystemDictionary::find_bootstrap_method(KlassHandle caller, |
2451 Handle empty; |
2469 Handle empty; |
2452 if (!caller->oop_is_instance()) return empty; |
2470 if (!caller->oop_is_instance()) return empty; |
2453 |
2471 |
2454 instanceKlassHandle ik(THREAD, caller()); |
2472 instanceKlassHandle ik(THREAD, caller()); |
2455 |
2473 |
2456 if (ik->bootstrap_method() != NULL) { |
2474 oop boot_method_oop = ik->bootstrap_method(); |
2457 return Handle(THREAD, ik->bootstrap_method()); |
2475 if (boot_method_oop != NULL) { |
2458 } |
2476 if (TraceMethodHandles) { |
|
2477 tty->print_cr("bootstrap method for "PTR_FORMAT" cached as "PTR_FORMAT":", ik(), boot_method_oop); |
|
2478 } |
|
2479 NOT_PRODUCT(if (!boot_method_oop->is_oop()) { tty->print_cr("*** boot MH of "PTR_FORMAT" = "PTR_FORMAT, ik(), boot_method_oop); ik()->print(); }); |
|
2480 assert(boot_method_oop->is_oop() |
|
2481 && java_dyn_MethodHandle::is_instance(boot_method_oop), "must be sane"); |
|
2482 return Handle(THREAD, boot_method_oop); |
|
2483 } |
|
2484 boot_method_oop = NULL; // GC safety |
2459 |
2485 |
2460 // call java.dyn.Linkage::findBootstrapMethod(caller, sbk) |
2486 // call java.dyn.Linkage::findBootstrapMethod(caller, sbk) |
2461 JavaCallArguments args(Handle(THREAD, ik->java_mirror())); |
2487 JavaCallArguments args(Handle(THREAD, ik->java_mirror())); |
2462 if (search_bootstrap_klass.is_null()) |
2488 if (search_bootstrap_klass.is_null()) |
2463 args.push_oop(Handle()); |
2489 args.push_oop(Handle()); |
2467 JavaCalls::call_static(&result, |
2493 JavaCalls::call_static(&result, |
2468 SystemDictionary::Linkage_klass(), |
2494 SystemDictionary::Linkage_klass(), |
2469 vmSymbols::findBootstrapMethod_name(), |
2495 vmSymbols::findBootstrapMethod_name(), |
2470 vmSymbols::findBootstrapMethod_signature(), |
2496 vmSymbols::findBootstrapMethod_signature(), |
2471 &args, CHECK_(empty)); |
2497 &args, CHECK_(empty)); |
2472 oop boot_method_oop = (oop) result.get_jobject(); |
2498 boot_method_oop = (oop) result.get_jobject(); |
2473 |
2499 |
2474 if (boot_method_oop != NULL) { |
2500 if (boot_method_oop != NULL) { |
|
2501 if (TraceMethodHandles) { |
|
2502 #ifndef PRODUCT |
|
2503 tty->print_cr("--------"); |
|
2504 tty->print_cr("bootstrap method for "PTR_FORMAT" computed as "PTR_FORMAT":", ik(), boot_method_oop); |
|
2505 ik()->print(); |
|
2506 boot_method_oop->print(); |
|
2507 tty->print_cr("========"); |
|
2508 #endif //PRODUCT |
|
2509 } |
2475 assert(boot_method_oop->is_oop() |
2510 assert(boot_method_oop->is_oop() |
2476 && java_dyn_MethodHandle::is_instance(boot_method_oop), "must be sane"); |
2511 && java_dyn_MethodHandle::is_instance(boot_method_oop), "must be sane"); |
2477 // probably no race conditions, but let's be careful: |
2512 // probably no race conditions, but let's be careful: |
2478 if (Atomic::cmpxchg_ptr(boot_method_oop, ik->adr_bootstrap_method(), NULL) == NULL) |
2513 if (Atomic::cmpxchg_ptr(boot_method_oop, ik->adr_bootstrap_method(), NULL) == NULL) |
2479 ik->set_bootstrap_method(boot_method_oop); |
2514 ik->set_bootstrap_method(boot_method_oop); |
2480 else |
2515 else |
2481 boot_method_oop = ik->bootstrap_method(); |
2516 boot_method_oop = ik->bootstrap_method(); |
2482 } else { |
2517 } else { |
|
2518 if (TraceMethodHandles) { |
|
2519 #ifndef PRODUCT |
|
2520 tty->print_cr("--------"); |
|
2521 tty->print_cr("bootstrap method for "PTR_FORMAT" computed as NULL:", ik()); |
|
2522 ik()->print(); |
|
2523 tty->print_cr("========"); |
|
2524 #endif //PRODUCT |
|
2525 } |
2483 boot_method_oop = ik->bootstrap_method(); |
2526 boot_method_oop = ik->bootstrap_method(); |
2484 } |
2527 } |
2485 |
2528 |
2486 return Handle(THREAD, boot_method_oop); |
2529 return Handle(THREAD, boot_method_oop); |
2487 } |
2530 } |
2545 GCMutexLocker mu(SystemDictionary_lock); |
2588 GCMutexLocker mu(SystemDictionary_lock); |
2546 placeholders()->verify(); |
2589 placeholders()->verify(); |
2547 |
2590 |
2548 // Verify constraint table |
2591 // Verify constraint table |
2549 guarantee(constraints() != NULL, "Verify of loader constraints failed"); |
2592 guarantee(constraints() != NULL, "Verify of loader constraints failed"); |
2550 constraints()->verify(dictionary()); |
2593 constraints()->verify(dictionary(), placeholders()); |
2551 } |
2594 } |
2552 |
2595 |
2553 |
2596 |
2554 void SystemDictionary::verify_obj_klass_present(Handle obj, |
2597 void SystemDictionary::verify_obj_klass_present(Handle obj, |
2555 symbolHandle class_name, |
2598 symbolHandle class_name, |