Mercurial > hg > truffle
comparison src/share/vm/classfile/systemDictionary.hpp @ 132:60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
Summary: combine many scalar variables into a single enum-indexed array in SystemDictionary.
Reviewed-by: kvn
author | jrose |
---|---|
date | Tue, 29 Apr 2008 19:45:22 -0700 |
parents | a61af66fc99e |
children | 83c868b757c0 |
comparison
equal
deleted
inserted
replaced
131:6e825ad773c6 | 132:60b728ec77c1 |
---|---|
62 class PlaceholderTable; | 62 class PlaceholderTable; |
63 class LoaderConstraintTable; | 63 class LoaderConstraintTable; |
64 class HashtableBucket; | 64 class HashtableBucket; |
65 class ResolutionErrorTable; | 65 class ResolutionErrorTable; |
66 | 66 |
67 // Certain classes are preloaded, such as java.lang.Object and java.lang.String. | |
68 // They are all "well-known", in the sense that no class loader is allowed | |
69 // to provide a different definition. | |
70 // | |
71 // These klasses must all have names defined in vmSymbols. | |
72 | |
73 #define WK_KLASS_ENUM_NAME(kname) kname##_knum | |
74 | |
75 // Each well-known class has a short klass name (like object_klass), | |
76 // a vmSymbol name (like java_lang_Object), and a flag word | |
77 // that makes some minor distinctions, like whether the klass | |
78 // is preloaded, optional, release-specific, etc. | |
79 // The order of these definitions is significant; it is the order in which | |
80 // preloading is actually performed by initialize_preloaded_classes. | |
81 | |
82 #define WK_KLASSES_DO(template) \ | |
83 /* well-known classes */ \ | |
84 template(object_klass, java_lang_Object, Pre) \ | |
85 template(string_klass, java_lang_String, Pre) \ | |
86 template(class_klass, java_lang_Class, Pre) \ | |
87 template(cloneable_klass, java_lang_Cloneable, Pre) \ | |
88 template(classloader_klass, java_lang_ClassLoader, Pre) \ | |
89 template(serializable_klass, java_io_Serializable, Pre) \ | |
90 template(system_klass, java_lang_System, Pre) \ | |
91 template(throwable_klass, java_lang_Throwable, Pre) \ | |
92 template(error_klass, java_lang_Error, Pre) \ | |
93 template(threaddeath_klass, java_lang_ThreadDeath, Pre) \ | |
94 template(exception_klass, java_lang_Exception, Pre) \ | |
95 template(runtime_exception_klass, java_lang_RuntimeException, Pre) \ | |
96 template(protectionDomain_klass, java_security_ProtectionDomain, Pre) \ | |
97 template(AccessControlContext_klass, java_security_AccessControlContext, Pre) \ | |
98 template(classNotFoundException_klass, java_lang_ClassNotFoundException, Pre) \ | |
99 template(noClassDefFoundError_klass, java_lang_NoClassDefFoundError, Pre) \ | |
100 template(linkageError_klass, java_lang_LinkageError, Pre) \ | |
101 template(ClassCastException_klass, java_lang_ClassCastException, Pre) \ | |
102 template(ArrayStoreException_klass, java_lang_ArrayStoreException, Pre) \ | |
103 template(virtualMachineError_klass, java_lang_VirtualMachineError, Pre) \ | |
104 template(OutOfMemoryError_klass, java_lang_OutOfMemoryError, Pre) \ | |
105 template(StackOverflowError_klass, java_lang_StackOverflowError, Pre) \ | |
106 template(IllegalMonitorStateException_klass, java_lang_IllegalMonitorStateException, Pre) \ | |
107 template(reference_klass, java_lang_ref_Reference, Pre) \ | |
108 \ | |
109 /* Preload ref klasses and set reference types */ \ | |
110 template(soft_reference_klass, java_lang_ref_SoftReference, Pre) \ | |
111 template(weak_reference_klass, java_lang_ref_WeakReference, Pre) \ | |
112 template(final_reference_klass, java_lang_ref_FinalReference, Pre) \ | |
113 template(phantom_reference_klass, java_lang_ref_PhantomReference, Pre) \ | |
114 template(finalizer_klass, java_lang_ref_Finalizer, Pre) \ | |
115 \ | |
116 template(thread_klass, java_lang_Thread, Pre) \ | |
117 template(threadGroup_klass, java_lang_ThreadGroup, Pre) \ | |
118 template(properties_klass, java_util_Properties, Pre) \ | |
119 template(reflect_accessible_object_klass, java_lang_reflect_AccessibleObject, Pre) \ | |
120 template(reflect_field_klass, java_lang_reflect_Field, Pre) \ | |
121 template(reflect_method_klass, java_lang_reflect_Method, Pre) \ | |
122 template(reflect_constructor_klass, java_lang_reflect_Constructor, Pre) \ | |
123 \ | |
124 /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \ | |
125 /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \ | |
126 /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \ | |
127 template(reflect_magic_klass, sun_reflect_MagicAccessorImpl, Opt) \ | |
128 template(reflect_method_accessor_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \ | |
129 template(reflect_constructor_accessor_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \ | |
130 template(reflect_delegating_classloader_klass, sun_reflect_DelegatingClassLoader, Opt) \ | |
131 template(reflect_constant_pool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15) \ | |
132 template(reflect_unsafe_static_field_accessor_impl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15) \ | |
133 \ | |
134 template(vector_klass, java_util_Vector, Pre) \ | |
135 template(hashtable_klass, java_util_Hashtable, Pre) \ | |
136 template(stringBuffer_klass, java_lang_StringBuffer, Pre) \ | |
137 \ | |
138 /* It's NULL in non-1.4 JDKs. */ \ | |
139 template(stackTraceElement_klass, java_lang_StackTraceElement, Opt) \ | |
140 /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \ | |
141 /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \ | |
142 template(java_nio_Buffer_klass, java_nio_Buffer, Opt) \ | |
143 \ | |
144 /* If this class isn't present, it won't be referenced. */ \ | |
145 template(sun_misc_AtomicLongCSImpl_klass, sun_misc_AtomicLongCSImpl, Opt) \ | |
146 \ | |
147 template(sun_jkernel_DownloadManager_klass, sun_jkernel_DownloadManager, Opt_Kernel) \ | |
148 \ | |
149 /* Preload boxing klasses */ \ | |
150 template(boolean_klass, java_lang_Boolean, Pre) \ | |
151 template(char_klass, java_lang_Character, Pre) \ | |
152 template(float_klass, java_lang_Float, Pre) \ | |
153 template(double_klass, java_lang_Double, Pre) \ | |
154 template(byte_klass, java_lang_Byte, Pre) \ | |
155 template(short_klass, java_lang_Short, Pre) \ | |
156 template(int_klass, java_lang_Integer, Pre) \ | |
157 template(long_klass, java_lang_Long, Pre) \ | |
158 /*end*/ | |
159 | |
160 | |
67 class SystemDictionary : AllStatic { | 161 class SystemDictionary : AllStatic { |
68 friend class VMStructs; | 162 friend class VMStructs; |
69 friend class CompactingPermGenGen; | 163 friend class CompactingPermGenGen; |
70 NOT_PRODUCT(friend class instanceKlassKlass;) | 164 NOT_PRODUCT(friend class instanceKlassKlass;) |
71 | 165 |
72 public: | 166 public: |
167 enum WKID { | |
168 NO_WKID = 0, | |
169 | |
170 #define WK_KLASS_ENUM(name, ignore_s, ignore_o) WK_KLASS_ENUM_NAME(name), | |
171 WK_KLASSES_DO(WK_KLASS_ENUM) | |
172 #undef WK_KLASS_ENUM | |
173 | |
174 WKID_LIMIT, | |
175 | |
176 FIRST_WKID = NO_WKID + 1 | |
177 }; | |
178 | |
179 enum InitOption { | |
180 Pre, // preloaded; error if not present | |
181 | |
182 // Order is significant. Options before this point require resolve_or_fail. | |
183 // Options after this point will use resolve_or_null instead. | |
184 | |
185 Opt, // preload tried; NULL if not present | |
186 Opt_Only_JDK14NewRef, // preload tried; use only with NewReflection | |
187 Opt_Only_JDK15, // preload tried; use only with JDK1.5+ | |
188 Opt_Kernel, // preload tried only #ifdef KERNEL | |
189 OPTION_LIMIT, | |
190 CEIL_LG_OPTION_LIMIT = 4 // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT) | |
191 }; | |
192 | |
193 | |
73 // Returns a class with a given class name and class loader. Loads the | 194 // Returns a class with a given class name and class loader. Loads the |
74 // class if needed. If not found a NoClassDefFoundError or a | 195 // class if needed. If not found a NoClassDefFoundError or a |
75 // ClassNotFoundException is thrown, depending on the value on the | 196 // ClassNotFoundException is thrown, depending on the value on the |
76 // throw_error flag. For most uses the throw_error argument should be set | 197 // throw_error flag. For most uses the throw_error argument should be set |
77 // to true. | 198 // to true. |
120 // If not found NULL is returned. | 241 // If not found NULL is returned. |
121 static klassOop find_instance_or_array_klass(symbolHandle class_name, | 242 static klassOop find_instance_or_array_klass(symbolHandle class_name, |
122 Handle class_loader, | 243 Handle class_loader, |
123 Handle protection_domain, | 244 Handle protection_domain, |
124 TRAPS); | 245 TRAPS); |
246 | |
247 // If the given name is known to vmSymbols, return the well-know klass: | |
248 static klassOop find_well_known_klass(symbolOop class_name); | |
125 | 249 |
126 // Lookup an instance or array class that has already been loaded | 250 // Lookup an instance or array class that has already been loaded |
127 // either into the given class loader, or else into another class | 251 // either into the given class loader, or else into another class |
128 // loader that is constrained (via loader constraints) to produce | 252 // loader that is constrained (via loader constraints) to produce |
129 // a consistent class. Do not take protection domains into account. | 253 // a consistent class. Do not take protection domains into account. |
233 static klassOop check_klass(klassOop k) { | 357 static klassOop check_klass(klassOop k) { |
234 assert(k != NULL, "preloaded klass not initialized"); | 358 assert(k != NULL, "preloaded klass not initialized"); |
235 return k; | 359 return k; |
236 } | 360 } |
237 | 361 |
362 static klassOop check_klass_Pre(klassOop k) { return check_klass(k); } | |
363 static klassOop check_klass_Opt(klassOop k) { return k; } | |
364 static klassOop check_klass_Opt_Kernel(klassOop k) { return k; } //== Opt | |
365 static klassOop check_klass_Opt_Only_JDK15(klassOop k) { | |
366 assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only"); | |
367 return k; | |
368 } | |
369 static klassOop check_klass_Opt_Only_JDK14NewRef(klassOop k) { | |
370 assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only"); | |
371 // despite the optional loading, if you use this it must be present: | |
372 return check_klass(k); | |
373 } | |
374 | |
375 static bool initialize_wk_klass(WKID id, int init_opt, TRAPS); | |
376 static void initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS); | |
377 static void initialize_wk_klasses_through(WKID end_id, WKID &start_id, TRAPS) { | |
378 int limit = (int)end_id + 1; | |
379 initialize_wk_klasses_until((WKID) limit, start_id, THREAD); | |
380 } | |
381 | |
238 public: | 382 public: |
239 static klassOop object_klass() { return check_klass(_object_klass); } | 383 #define WK_KLASS_DECLARE(name, ignore_symbol, option) \ |
240 static klassOop string_klass() { return check_klass(_string_klass); } | 384 static klassOop name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); } |
241 static klassOop class_klass() { return check_klass(_class_klass); } | 385 WK_KLASSES_DO(WK_KLASS_DECLARE); |
242 static klassOop cloneable_klass() { return check_klass(_cloneable_klass); } | 386 #undef WK_KLASS_DECLARE |
243 static klassOop classloader_klass() { return check_klass(_classloader_klass); } | 387 |
244 static klassOop serializable_klass() { return check_klass(_serializable_klass); } | 388 // Local definition for direct access to the private array: |
245 static klassOop system_klass() { return check_klass(_system_klass); } | 389 #define WK_KLASS(name) _well_known_klasses[WK_KLASS_ENUM_NAME(name)] |
246 | |
247 static klassOop throwable_klass() { return check_klass(_throwable_klass); } | |
248 static klassOop error_klass() { return check_klass(_error_klass); } | |
249 static klassOop threaddeath_klass() { return check_klass(_threaddeath_klass); } | |
250 static klassOop exception_klass() { return check_klass(_exception_klass); } | |
251 static klassOop runtime_exception_klass() { return check_klass(_runtime_exception_klass); } | |
252 static klassOop classNotFoundException_klass() { return check_klass(_classNotFoundException_klass); } | |
253 static klassOop noClassDefFoundError_klass() { return check_klass(_noClassDefFoundError_klass); } | |
254 static klassOop linkageError_klass() { return check_klass(_linkageError_klass); } | |
255 static klassOop ClassCastException_klass() { return check_klass(_classCastException_klass); } | |
256 static klassOop ArrayStoreException_klass() { return check_klass(_arrayStoreException_klass); } | |
257 static klassOop virtualMachineError_klass() { return check_klass(_virtualMachineError_klass); } | |
258 static klassOop OutOfMemoryError_klass() { return check_klass(_outOfMemoryError_klass); } | |
259 static klassOop StackOverflowError_klass() { return check_klass(_StackOverflowError_klass); } | |
260 static klassOop IllegalMonitorStateException_klass() { return check_klass(_illegalMonitorStateException_klass); } | |
261 static klassOop protectionDomain_klass() { return check_klass(_protectionDomain_klass); } | |
262 static klassOop AccessControlContext_klass() { return check_klass(_AccessControlContext_klass); } | |
263 static klassOop reference_klass() { return check_klass(_reference_klass); } | |
264 static klassOop soft_reference_klass() { return check_klass(_soft_reference_klass); } | |
265 static klassOop weak_reference_klass() { return check_klass(_weak_reference_klass); } | |
266 static klassOop final_reference_klass() { return check_klass(_final_reference_klass); } | |
267 static klassOop phantom_reference_klass() { return check_klass(_phantom_reference_klass); } | |
268 static klassOop finalizer_klass() { return check_klass(_finalizer_klass); } | |
269 | |
270 static klassOop thread_klass() { return check_klass(_thread_klass); } | |
271 static klassOop threadGroup_klass() { return check_klass(_threadGroup_klass); } | |
272 static klassOop properties_klass() { return check_klass(_properties_klass); } | |
273 static klassOop reflect_accessible_object_klass() { return check_klass(_reflect_accessible_object_klass); } | |
274 static klassOop reflect_field_klass() { return check_klass(_reflect_field_klass); } | |
275 static klassOop reflect_method_klass() { return check_klass(_reflect_method_klass); } | |
276 static klassOop reflect_constructor_klass() { return check_klass(_reflect_constructor_klass); } | |
277 static klassOop reflect_method_accessor_klass() { | |
278 assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only"); | |
279 return check_klass(_reflect_method_accessor_klass); | |
280 } | |
281 static klassOop reflect_constructor_accessor_klass() { | |
282 assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only"); | |
283 return check_klass(_reflect_constructor_accessor_klass); | |
284 } | |
285 // NOTE: needed too early in bootstrapping process to have checks based on JDK version | |
286 static klassOop reflect_magic_klass() { return _reflect_magic_klass; } | |
287 static klassOop reflect_delegating_classloader_klass() { return _reflect_delegating_classloader_klass; } | |
288 static klassOop reflect_constant_pool_klass() { | |
289 assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only"); | |
290 return _reflect_constant_pool_klass; | |
291 } | |
292 static klassOop reflect_unsafe_static_field_accessor_impl_klass() { | |
293 assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only"); | |
294 return _reflect_unsafe_static_field_accessor_impl_klass; | |
295 } | |
296 | |
297 static klassOop vector_klass() { return check_klass(_vector_klass); } | |
298 static klassOop hashtable_klass() { return check_klass(_hashtable_klass); } | |
299 static klassOop stringBuffer_klass() { return check_klass(_stringBuffer_klass); } | |
300 static klassOop stackTraceElement_klass() { return check_klass(_stackTraceElement_klass); } | |
301 | |
302 static klassOop java_nio_Buffer_klass() { return check_klass(_java_nio_Buffer_klass); } | |
303 | |
304 static klassOop sun_misc_AtomicLongCSImpl_klass() { return _sun_misc_AtomicLongCSImpl_klass; } | |
305 | |
306 // To support incremental JRE downloads (KERNEL JRE). Null if not present. | |
307 static klassOop sun_jkernel_DownloadManager_klass() { return _sun_jkernel_DownloadManager_klass; } | |
308 | |
309 static klassOop boolean_klass() { return check_klass(_boolean_klass); } | |
310 static klassOop char_klass() { return check_klass(_char_klass); } | |
311 static klassOop float_klass() { return check_klass(_float_klass); } | |
312 static klassOop double_klass() { return check_klass(_double_klass); } | |
313 static klassOop byte_klass() { return check_klass(_byte_klass); } | |
314 static klassOop short_klass() { return check_klass(_short_klass); } | |
315 static klassOop int_klass() { return check_klass(_int_klass); } | |
316 static klassOop long_klass() { return check_klass(_long_klass); } | |
317 | 390 |
318 static klassOop box_klass(BasicType t) { | 391 static klassOop box_klass(BasicType t) { |
319 assert((uint)t < T_VOID+1, "range check"); | 392 assert((uint)t < T_VOID+1, "range check"); |
320 return check_klass(_box_klasses[t]); | 393 return check_klass(_box_klasses[t]); |
321 } | 394 } |
333 | 406 |
334 public: | 407 public: |
335 // Tells whether ClassLoader.checkPackageAccess is present | 408 // Tells whether ClassLoader.checkPackageAccess is present |
336 static bool has_checkPackageAccess() { return _has_checkPackageAccess; } | 409 static bool has_checkPackageAccess() { return _has_checkPackageAccess; } |
337 | 410 |
338 static bool class_klass_loaded() { return _class_klass != NULL; } | 411 static bool class_klass_loaded() { return WK_KLASS(class_klass) != NULL; } |
339 static bool cloneable_klass_loaded() { return _cloneable_klass != NULL; } | 412 static bool cloneable_klass_loaded() { return WK_KLASS(cloneable_klass) != NULL; } |
340 | 413 |
341 // Returns default system loader | 414 // Returns default system loader |
342 static oop java_system_loader(); | 415 static oop java_system_loader(); |
343 | 416 |
344 // Compute the default system loader | 417 // Compute the default system loader |
496 static void update_dictionary(int d_index, unsigned int d_hash, | 569 static void update_dictionary(int d_index, unsigned int d_hash, |
497 int p_index, unsigned int p_hash, | 570 int p_index, unsigned int p_hash, |
498 instanceKlassHandle k, Handle loader, TRAPS); | 571 instanceKlassHandle k, Handle loader, TRAPS); |
499 | 572 |
500 // Variables holding commonly used klasses (preloaded) | 573 // Variables holding commonly used klasses (preloaded) |
501 static klassOop _object_klass; | 574 static klassOop _well_known_klasses[]; |
502 static klassOop _string_klass; | |
503 static klassOop _class_klass; | |
504 static klassOop _cloneable_klass; | |
505 static klassOop _classloader_klass; | |
506 static klassOop _serializable_klass; | |
507 static klassOop _system_klass; | |
508 | |
509 static klassOop _throwable_klass; | |
510 static klassOop _error_klass; | |
511 static klassOop _threaddeath_klass; | |
512 static klassOop _exception_klass; | |
513 static klassOop _runtime_exception_klass; | |
514 static klassOop _classNotFoundException_klass; | |
515 static klassOop _noClassDefFoundError_klass; | |
516 static klassOop _linkageError_klass; | |
517 static klassOop _classCastException_klass; | |
518 static klassOop _arrayStoreException_klass; | |
519 static klassOop _virtualMachineError_klass; | |
520 static klassOop _outOfMemoryError_klass; | |
521 static klassOop _StackOverflowError_klass; | |
522 static klassOop _illegalMonitorStateException_klass; | |
523 static klassOop _protectionDomain_klass; | |
524 static klassOop _AccessControlContext_klass; | |
525 static klassOop _reference_klass; | |
526 static klassOop _soft_reference_klass; | |
527 static klassOop _weak_reference_klass; | |
528 static klassOop _final_reference_klass; | |
529 static klassOop _phantom_reference_klass; | |
530 static klassOop _finalizer_klass; | |
531 | |
532 static klassOop _thread_klass; | |
533 static klassOop _threadGroup_klass; | |
534 static klassOop _properties_klass; | |
535 static klassOop _reflect_accessible_object_klass; | |
536 static klassOop _reflect_field_klass; | |
537 static klassOop _reflect_method_klass; | |
538 static klassOop _reflect_constructor_klass; | |
539 // 1.4 reflection implementation | |
540 static klassOop _reflect_magic_klass; | |
541 static klassOop _reflect_method_accessor_klass; | |
542 static klassOop _reflect_constructor_accessor_klass; | |
543 static klassOop _reflect_delegating_classloader_klass; | |
544 // 1.5 annotations implementation | |
545 static klassOop _reflect_constant_pool_klass; | |
546 static klassOop _reflect_unsafe_static_field_accessor_impl_klass; | |
547 | |
548 static klassOop _stringBuffer_klass; | |
549 static klassOop _vector_klass; | |
550 static klassOop _hashtable_klass; | |
551 | |
552 static klassOop _stackTraceElement_klass; | |
553 | |
554 static klassOop _java_nio_Buffer_klass; | |
555 | |
556 static klassOop _sun_misc_AtomicLongCSImpl_klass; | |
557 | |
558 // KERNEL JRE support. | |
559 static klassOop _sun_jkernel_DownloadManager_klass; | |
560 | 575 |
561 // Lazily loaded klasses | 576 // Lazily loaded klasses |
562 static volatile klassOop _abstract_ownable_synchronizer_klass; | 577 static volatile klassOop _abstract_ownable_synchronizer_klass; |
563 | 578 |
564 // Box klasses | 579 // table of box klasses (int_klass, etc.) |
565 static klassOop _boolean_klass; | |
566 static klassOop _char_klass; | |
567 static klassOop _float_klass; | |
568 static klassOop _double_klass; | |
569 static klassOop _byte_klass; | |
570 static klassOop _short_klass; | |
571 static klassOop _int_klass; | |
572 static klassOop _long_klass; | |
573 | |
574 // table of same | |
575 static klassOop _box_klasses[T_VOID+1]; | 580 static klassOop _box_klasses[T_VOID+1]; |
576 | 581 |
577 static oop _java_system_loader; | 582 static oop _java_system_loader; |
578 | 583 |
579 static bool _has_loadClassInternal; | 584 static bool _has_loadClassInternal; |