comparison src/share/vm/classfile/systemDictionary.cpp @ 6853:d804e148cff8

Merge
author kvn
date Fri, 12 Oct 2012 09:22:52 -0700
parents 6e5a59a8e4a7 19eb999cb72c
children 633ba56cb013
comparison
equal deleted inserted replaced
6842:b9a9ed0f8eeb 6853:d804e148cff8
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, ignore_option) \
977 case vmSymbols::VM_SYMBOL_ENUM_NAME(symbol): \
978 k = WK_KLASS(name); break;
979 WK_KLASSES_DO(WK_KLASS_CASE)
980 #undef WK_KLASS_CASE
981 }
982 NOT_PRODUCT(if (k != NULL) find_wkk_wins++);
983 return k;
984 }
985 }
986 return NULL;
987 } 937 }
988 938
989 // Note: this method is much like resolve_from_stream, but 939 // Note: this method is much like resolve_from_stream, but
990 // updates no supplemental data structures. 940 // updates no supplemental data structures.
991 // TODO consolidate the two methods with a helper routine? 941 // TODO consolidate the two methods with a helper routine?
1937 int info = wk_init_info[id - FIRST_WKID]; 1887 int info = wk_init_info[id - FIRST_WKID];
1938 int sid = (info >> CEIL_LG_OPTION_LIMIT); 1888 int sid = (info >> CEIL_LG_OPTION_LIMIT);
1939 int opt = (info & right_n_bits(CEIL_LG_OPTION_LIMIT)); 1889 int opt = (info & right_n_bits(CEIL_LG_OPTION_LIMIT));
1940 1890
1941 initialize_wk_klass((WKID)id, opt, CHECK); 1891 initialize_wk_klass((WKID)id, opt, CHECK);
1942
1943 // Update limits, so find_well_known_klass can be very fast:
1944 Symbol* s = vmSymbols::symbol_at((vmSymbols::SID)sid);
1945 if (wk_klass_name_limits[1] == NULL) {
1946 wk_klass_name_limits[0] = wk_klass_name_limits[1] = s;
1947 } else if (wk_klass_name_limits[1] < s) {
1948 wk_klass_name_limits[1] = s;
1949 } else if (wk_klass_name_limits[0] > s) {
1950 wk_klass_name_limits[0] = s;
1951 }
1952 } 1892 }
1953 1893
1954 // move the starting value forward to the limit: 1894 // move the starting value forward to the limit:
1955 start_id = limit_id; 1895 start_id = limit_id;
1956 } 1896 }
1957
1958 1897
1959 void SystemDictionary::initialize_preloaded_classes(TRAPS) { 1898 void SystemDictionary::initialize_preloaded_classes(TRAPS) {
1960 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");
1961 // Preload commonly used klasses 1900 // Preload commonly used klasses
1962 WKID scan = FIRST_WKID; 1901 WKID scan = FIRST_WKID;