comparison src/share/vm/classfile/systemDictionary.cpp @ 6852:19eb999cb72c

8000740: remove LinkWellKnownClasses Reviewed-by: kvn, jrose
author twisti
date Thu, 11 Oct 2012 14:46:20 -0700
parents 65d07d9ee446
children d804e148cff8
comparison
equal deleted inserted replaced
6851:94e9408dbf50 6852:19eb999cb72c
289 Symbol* class_name, 289 Symbol* class_name,
290 Handle class_loader, 290 Handle class_loader,
291 Handle protection_domain, 291 Handle protection_domain,
292 bool is_superclass, 292 bool is_superclass,
293 TRAPS) { 293 TRAPS) {
294
295 // Try to get one of the well-known klasses.
296 // They are trusted, and do not participate in circularities.
297 if (LinkWellKnownClasses) {
298 Klass* k = find_well_known_klass(class_name);
299 if (k != NULL) {
300 return k;
301 }
302 }
303
304 // Double-check, if child class is already loaded, just return super-class,interface 294 // Double-check, if child class is already loaded, just return super-class,interface
305 // Don't add a placedholder if already loaded, i.e. already in system dictionary 295 // Don't add a placedholder if already loaded, i.e. already in system dictionary
306 // Make sure there's a placeholder for the *child* before resolving. 296 // Make sure there's a placeholder for the *child* before resolving.
307 // Used as a claim that this thread is currently loading superclass/classloader 297 // Used as a claim that this thread is currently loading superclass/classloader
308 // Used here for ClassCircularity checks and also for heap verification 298 // Used here for ClassCircularity checks and also for heap verification
924 Handle protection_domain, 914 Handle protection_domain,
925 TRAPS) { 915 TRAPS) {
926 Klass* k = NULL; 916 Klass* k = NULL;
927 assert(class_name != NULL, "class name must be non NULL"); 917 assert(class_name != NULL, "class name must be non NULL");
928 918
929 // Try to get one of the well-known klasses.
930 if (LinkWellKnownClasses) {
931 k = find_well_known_klass(class_name);
932 if (k != NULL) {
933 return k;
934 }
935 }
936
937 if (FieldType::is_array(class_name)) { 919 if (FieldType::is_array(class_name)) {
938 // The name refers to an array. Parse the name. 920 // The name refers to an array. Parse the name.
939 // dimension and object_key in FieldArrayInfo are assigned as a 921 // dimension and object_key in FieldArrayInfo are assigned as a
940 // side-effect of this call 922 // side-effect of this call
941 FieldArrayInfo fd; 923 FieldArrayInfo fd;
950 } 932 }
951 } else { 933 } else {
952 k = find(class_name, class_loader, protection_domain, THREAD); 934 k = find(class_name, class_loader, protection_domain, THREAD);
953 } 935 }
954 return k; 936 return k;
955 }
956
957 // Quick range check for names of well-known classes:
958 static Symbol* wk_klass_name_limits[2] = {NULL, NULL};
959
960 #ifndef PRODUCT
961 static int find_wkk_calls, find_wkk_probes, find_wkk_wins;
962 // counts for "hello world": 3983, 1616, 1075
963 // => 60% hit after limit guard, 25% total win rate
964 #endif
965
966 Klass* SystemDictionary::find_well_known_klass(Symbol* class_name) {
967 // A bounds-check on class_name will quickly get a negative result.
968 NOT_PRODUCT(find_wkk_calls++);
969 if (class_name >= wk_klass_name_limits[0] &&
970 class_name <= wk_klass_name_limits[1]) {
971 NOT_PRODUCT(find_wkk_probes++);
972 vmSymbols::SID sid = vmSymbols::find_sid(class_name);
973 if (sid != vmSymbols::NO_SID) {
974 Klass* k = NULL;
975 switch (sid) {
976 #define WK_KLASS_CASE(name, symbol, option) \
977 case vmSymbols::VM_SYMBOL_ENUM_NAME(symbol): \
978 if (option == Pre_Link) { \
979 k = WK_KLASS(name); \
980 } \
981 break;
982 WK_KLASSES_DO(WK_KLASS_CASE)
983 #undef WK_KLASS_CASE
984 }
985 NOT_PRODUCT(if (k != NULL) find_wkk_wins++);
986 return k;
987 }
988 }
989 return NULL;
990 } 937 }
991 938
992 // Note: this method is much like resolve_from_stream, but 939 // Note: this method is much like resolve_from_stream, but
993 // updates no supplemental data structures. 940 // updates no supplemental data structures.
994 // TODO consolidate the two methods with a helper routine? 941 // TODO consolidate the two methods with a helper routine?
1940 int info = wk_init_info[id - FIRST_WKID]; 1887 int info = wk_init_info[id - FIRST_WKID];
1941 int sid = (info >> CEIL_LG_OPTION_LIMIT); 1888 int sid = (info >> CEIL_LG_OPTION_LIMIT);
1942 int opt = (info & right_n_bits(CEIL_LG_OPTION_LIMIT)); 1889 int opt = (info & right_n_bits(CEIL_LG_OPTION_LIMIT));
1943 1890
1944 initialize_wk_klass((WKID)id, opt, CHECK); 1891 initialize_wk_klass((WKID)id, opt, CHECK);
1945
1946 // Update limits, so find_well_known_klass can be very fast:
1947 Symbol* s = vmSymbols::symbol_at((vmSymbols::SID)sid);
1948 if (wk_klass_name_limits[1] == NULL) {
1949 wk_klass_name_limits[0] = wk_klass_name_limits[1] = s;
1950 } else if (wk_klass_name_limits[1] < s) {
1951 wk_klass_name_limits[1] = s;
1952 } else if (wk_klass_name_limits[0] > s) {
1953 wk_klass_name_limits[0] = s;
1954 }
1955 } 1892 }
1956 1893
1957 // move the starting value forward to the limit: 1894 // move the starting value forward to the limit:
1958 start_id = limit_id; 1895 start_id = limit_id;
1959 } 1896 }
1960
1961 #ifdef ASSERT
1962 void SystemDictionary::check_wk_pre_link_klasses() {
1963 #define WK_KLASS_CHECK(name, symbol, option) \
1964 if (option == Pre_Link) { \
1965 assert(name()->is_public(), ""); \
1966 }
1967 WK_KLASSES_DO(WK_KLASS_CHECK);
1968 #undef WK_KLASS_CHECK
1969 }
1970 #endif
1971 1897
1972 void SystemDictionary::initialize_preloaded_classes(TRAPS) { 1898 void SystemDictionary::initialize_preloaded_classes(TRAPS) {
1973 assert(WK_KLASS(Object_klass) == NULL, "preloaded classes should only be initialized once"); 1899 assert(WK_KLASS(Object_klass) == NULL, "preloaded classes should only be initialized once");
1974 // Preload commonly used klasses 1900 // Preload commonly used klasses
1975 WKID scan = FIRST_WKID; 1901 WKID scan = FIRST_WKID;
2020 // Skip the JSR 292 classes, if not enabled. 1946 // Skip the JSR 292 classes, if not enabled.
2021 scan = WKID(jsr292_group_end + 1); 1947 scan = WKID(jsr292_group_end + 1);
2022 } 1948 }
2023 1949
2024 initialize_wk_klasses_until(WKID_LIMIT, scan, CHECK); 1950 initialize_wk_klasses_until(WKID_LIMIT, scan, CHECK);
2025
2026 check_wk_pre_link_klasses();
2027 1951
2028 _box_klasses[T_BOOLEAN] = WK_KLASS(Boolean_klass); 1952 _box_klasses[T_BOOLEAN] = WK_KLASS(Boolean_klass);
2029 _box_klasses[T_CHAR] = WK_KLASS(Character_klass); 1953 _box_klasses[T_CHAR] = WK_KLASS(Character_klass);
2030 _box_klasses[T_FLOAT] = WK_KLASS(Float_klass); 1954 _box_klasses[T_FLOAT] = WK_KLASS(Float_klass);
2031 _box_klasses[T_DOUBLE] = WK_KLASS(Double_klass); 1955 _box_klasses[T_DOUBLE] = WK_KLASS(Double_klass);