Mercurial > hg > truffle
annotate src/share/vm/classfile/systemDictionary.cpp @ 949:489a4f8dcd0f
6865583: Verbose CIPrintMethodCodes asserts when ldc an empty String
Summary: ldc seems to load an empty String and that leads to an assert on offset < length, which are both zero.
Reviewed-by: kvn, never
author | twisti |
---|---|
date | Thu, 27 Aug 2009 06:17:23 -0700 |
parents | 6a93908f268f |
children | ad6585fd4087 148e5441d916 |
rev | line source |
---|---|
0 | 1 /* |
579 | 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_systemDictionary.cpp.incl" | |
27 | |
28 | |
29 Dictionary* SystemDictionary::_dictionary = NULL; | |
30 PlaceholderTable* SystemDictionary::_placeholders = NULL; | |
31 Dictionary* SystemDictionary::_shared_dictionary = NULL; | |
32 LoaderConstraintTable* SystemDictionary::_loader_constraints = NULL; | |
33 ResolutionErrorTable* SystemDictionary::_resolution_errors = NULL; | |
710 | 34 SymbolPropertyTable* SystemDictionary::_invoke_method_table = NULL; |
0 | 35 |
36 | |
37 int SystemDictionary::_number_of_modifications = 0; | |
38 | |
39 oop SystemDictionary::_system_loader_lock_obj = NULL; | |
40 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
41 klassOop SystemDictionary::_well_known_klasses[SystemDictionary::WKID_LIMIT] |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
42 = { NULL /*, NULL...*/ }; |
0 | 43 |
44 klassOop SystemDictionary::_box_klasses[T_VOID+1] = { NULL /*, NULL...*/ }; | |
45 | |
46 oop SystemDictionary::_java_system_loader = NULL; | |
47 | |
48 bool SystemDictionary::_has_loadClassInternal = false; | |
49 bool SystemDictionary::_has_checkPackageAccess = false; | |
50 | |
51 // lazily initialized klass variables | |
52 volatile klassOop SystemDictionary::_abstract_ownable_synchronizer_klass = NULL; | |
53 | |
54 | |
55 // ---------------------------------------------------------------------------- | |
56 // Java-level SystemLoader | |
57 | |
58 oop SystemDictionary::java_system_loader() { | |
59 return _java_system_loader; | |
60 } | |
61 | |
62 void SystemDictionary::compute_java_system_loader(TRAPS) { | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
63 KlassHandle system_klass(THREAD, WK_KLASS(classloader_klass)); |
0 | 64 JavaValue result(T_OBJECT); |
65 JavaCalls::call_static(&result, | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
66 KlassHandle(THREAD, WK_KLASS(classloader_klass)), |
0 | 67 vmSymbolHandles::getSystemClassLoader_name(), |
68 vmSymbolHandles::void_classloader_signature(), | |
69 CHECK); | |
70 | |
71 _java_system_loader = (oop)result.get_jobject(); | |
72 } | |
73 | |
74 | |
75 // ---------------------------------------------------------------------------- | |
76 // debugging | |
77 | |
78 #ifdef ASSERT | |
79 | |
80 // return true if class_name contains no '.' (internal format is '/') | |
81 bool SystemDictionary::is_internal_format(symbolHandle class_name) { | |
82 if (class_name.not_null()) { | |
83 ResourceMark rm; | |
84 char* name = class_name->as_C_string(); | |
85 return strchr(name, '.') == NULL; | |
86 } else { | |
87 return true; | |
88 } | |
89 } | |
90 | |
91 #endif | |
92 | |
93 // ---------------------------------------------------------------------------- | |
514 | 94 // Parallel class loading check |
95 | |
96 bool SystemDictionary::is_parallelCapable(Handle class_loader) { | |
97 if (UnsyncloadClass || class_loader.is_null()) return true; | |
98 if (AlwaysLockClassLoader) return false; | |
99 return java_lang_Class::parallelCapable(class_loader()); | |
100 } | |
101 // ---------------------------------------------------------------------------- | |
0 | 102 // Resolving of classes |
103 | |
104 // Forwards to resolve_or_null | |
105 | |
106 klassOop SystemDictionary::resolve_or_fail(symbolHandle class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) { | |
107 klassOop klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD); | |
108 if (HAS_PENDING_EXCEPTION || klass == NULL) { | |
109 KlassHandle k_h(THREAD, klass); | |
110 // can return a null klass | |
111 klass = handle_resolution_exception(class_name, class_loader, protection_domain, throw_error, k_h, THREAD); | |
112 } | |
113 return klass; | |
114 } | |
115 | |
116 klassOop SystemDictionary::handle_resolution_exception(symbolHandle class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS) { | |
117 if (HAS_PENDING_EXCEPTION) { | |
118 // 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, | |
120 // and if so convert it to a NoClassDefFoundError | |
121 // And chain the original ClassNotFoundException | |
122 if (throw_error && PENDING_EXCEPTION->is_a(SystemDictionary::classNotFoundException_klass())) { | |
123 ResourceMark rm(THREAD); | |
124 assert(klass_h() == NULL, "Should not have result with exception pending"); | |
125 Handle e(THREAD, PENDING_EXCEPTION); | |
126 CLEAR_PENDING_EXCEPTION; | |
127 THROW_MSG_CAUSE_0(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string(), e); | |
128 } else { | |
129 return NULL; | |
130 } | |
131 } | |
132 // Class not found, throw appropriate error or exception depending on value of throw_error | |
133 if (klass_h() == NULL) { | |
134 ResourceMark rm(THREAD); | |
135 if (throw_error) { | |
136 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string()); | |
137 } else { | |
138 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string()); | |
139 } | |
140 } | |
141 return (klassOop)klass_h(); | |
142 } | |
143 | |
144 | |
145 klassOop SystemDictionary::resolve_or_fail(symbolHandle class_name, | |
146 bool throw_error, TRAPS) | |
147 { | |
148 return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD); | |
149 } | |
150 | |
151 | |
152 // Forwards to resolve_instance_class_or_null | |
153 | |
154 klassOop SystemDictionary::resolve_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS) { | |
155 assert(!THREAD->is_Compiler_thread(), "Can not load classes with the Compiler thread"); | |
156 if (FieldType::is_array(class_name())) { | |
157 return resolve_array_class_or_null(class_name, class_loader, protection_domain, CHECK_NULL); | |
158 } else { | |
159 return resolve_instance_class_or_null(class_name, class_loader, protection_domain, CHECK_NULL); | |
160 } | |
161 } | |
162 | |
163 klassOop SystemDictionary::resolve_or_null(symbolHandle class_name, TRAPS) { | |
164 return resolve_or_null(class_name, Handle(), Handle(), THREAD); | |
165 } | |
166 | |
167 // Forwards to resolve_instance_class_or_null | |
168 | |
169 klassOop SystemDictionary::resolve_array_class_or_null(symbolHandle class_name, | |
170 Handle class_loader, | |
171 Handle protection_domain, | |
172 TRAPS) { | |
173 assert(FieldType::is_array(class_name()), "must be array"); | |
174 jint dimension; | |
175 symbolOop object_key; | |
176 klassOop k = NULL; | |
177 // dimension and object_key are assigned as a side-effect of this call | |
178 BasicType t = FieldType::get_array_info(class_name(), | |
179 &dimension, | |
180 &object_key, | |
181 CHECK_NULL); | |
182 | |
183 if (t == T_OBJECT) { | |
184 symbolHandle h_key(THREAD, object_key); | |
185 // naked oop "k" is OK here -- we assign back into it | |
186 k = SystemDictionary::resolve_instance_class_or_null(h_key, | |
187 class_loader, | |
188 protection_domain, | |
189 CHECK_NULL); | |
190 if (k != NULL) { | |
191 k = Klass::cast(k)->array_klass(dimension, CHECK_NULL); | |
192 } | |
193 } else { | |
194 k = Universe::typeArrayKlassObj(t); | |
195 k = typeArrayKlass::cast(k)->array_klass(dimension, CHECK_NULL); | |
196 } | |
197 return k; | |
198 } | |
199 | |
200 | |
201 // Must be called for any super-class or super-interface resolution | |
202 // during class definition to allow class circularity checking | |
203 // super-interface callers: | |
204 // parse_interfaces - for defineClass & jvmtiRedefineClasses | |
205 // super-class callers: | |
206 // ClassFileParser - for defineClass & jvmtiRedefineClasses | |
207 // load_shared_class - while loading a class from shared archive | |
514 | 208 // resolve_instance_class_or_null: |
209 // via: handle_parallel_super_load | |
0 | 210 // when resolving a class that has an existing placeholder with |
211 // a saved superclass [i.e. a defineClass is currently in progress] | |
212 // if another thread is trying to resolve the class, it must do | |
213 // super-class checks on its own thread to catch class circularity | |
214 // This last call is critical in class circularity checking for cases | |
215 // where classloading is delegated to different threads and the | |
216 // classloader lock is released. | |
217 // Take the case: Base->Super->Base | |
218 // 1. If thread T1 tries to do a defineClass of class Base | |
219 // resolve_super_or_fail creates placeholder: T1, Base (super Super) | |
220 // 2. resolve_instance_class_or_null does not find SD or placeholder for Super | |
221 // so it tries to load Super | |
222 // 3. If we load the class internally, or user classloader uses same thread | |
223 // loadClassFromxxx or defineClass via parseClassFile Super ... | |
224 // 3.1 resolve_super_or_fail creates placeholder: T1, Super (super Base) | |
225 // 3.3 resolve_instance_class_or_null Base, finds placeholder for Base | |
226 // 3.4 calls resolve_super_or_fail Base | |
227 // 3.5 finds T1,Base -> throws class circularity | |
228 //OR 4. If T2 tries to resolve Super via defineClass Super ... | |
229 // 4.1 resolve_super_or_fail creates placeholder: T2, Super (super Base) | |
230 // 4.2 resolve_instance_class_or_null Base, finds placeholder for Base (super Super) | |
231 // 4.3 calls resolve_super_or_fail Super in parallel on own thread T2 | |
232 // 4.4 finds T2, Super -> throws class circularity | |
233 // Must be called, even if superclass is null, since this is | |
234 // where the placeholder entry is created which claims this | |
235 // thread is loading this class/classloader. | |
236 klassOop SystemDictionary::resolve_super_or_fail(symbolHandle child_name, | |
237 symbolHandle class_name, | |
238 Handle class_loader, | |
239 Handle protection_domain, | |
240 bool is_superclass, | |
241 TRAPS) { | |
242 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
243 // Try to get one of the well-known klasses. |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
244 // They are trusted, and do not participate in circularities. |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
245 if (LinkWellKnownClasses) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
246 klassOop k = find_well_known_klass(class_name()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
247 if (k != NULL) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
248 return k; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
249 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
250 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
251 |
0 | 252 // Double-check, if child class is already loaded, just return super-class,interface |
253 // Don't add a placedholder if already loaded, i.e. already in system dictionary | |
254 // Make sure there's a placeholder for the *child* before resolving. | |
255 // Used as a claim that this thread is currently loading superclass/classloader | |
256 // Used here for ClassCircularity checks and also for heap verification | |
257 // (every instanceKlass in the heap needs to be in the system dictionary | |
258 // or have a placeholder). | |
259 // Must check ClassCircularity before checking if super class is already loaded | |
260 // | |
261 // We might not already have a placeholder if this child_name was | |
262 // first seen via resolve_from_stream (jni_DefineClass or JVM_DefineClass); | |
263 // the name of the class might not be known until the stream is actually | |
264 // parsed. | |
265 // Bugs 4643874, 4715493 | |
266 // compute_hash can have a safepoint | |
267 | |
268 unsigned int d_hash = dictionary()->compute_hash(child_name, class_loader); | |
269 int d_index = dictionary()->hash_to_index(d_hash); | |
270 unsigned int p_hash = placeholders()->compute_hash(child_name, class_loader); | |
271 int p_index = placeholders()->hash_to_index(p_hash); | |
272 // can't throw error holding a lock | |
273 bool child_already_loaded = false; | |
274 bool throw_circularity_error = false; | |
275 { | |
276 MutexLocker mu(SystemDictionary_lock, THREAD); | |
277 klassOop childk = find_class(d_index, d_hash, child_name, class_loader); | |
278 klassOop quicksuperk; | |
279 // to support // loading: if child done loading, just return superclass | |
280 // if class_name, & class_loader don't match: | |
281 // if initial define, SD update will give LinkageError | |
282 // if redefine: compare_class_versions will give HIERARCHY_CHANGED | |
283 // so we don't throw an exception here. | |
284 // see: nsk redefclass014 & java.lang.instrument Instrument032 | |
285 if ((childk != NULL ) && (is_superclass) && | |
286 ((quicksuperk = instanceKlass::cast(childk)->super()) != NULL) && | |
287 | |
288 ((Klass::cast(quicksuperk)->name() == class_name()) && | |
289 (Klass::cast(quicksuperk)->class_loader() == class_loader()))) { | |
290 return quicksuperk; | |
291 } else { | |
292 PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, child_name, class_loader); | |
293 if (probe && probe->check_seen_thread(THREAD, PlaceholderTable::LOAD_SUPER)) { | |
294 throw_circularity_error = true; | |
295 } | |
514 | 296 } |
297 if (!throw_circularity_error) { | |
0 | 298 PlaceholderEntry* newprobe = placeholders()->find_and_add(p_index, p_hash, child_name, class_loader, PlaceholderTable::LOAD_SUPER, class_name, THREAD); |
299 } | |
300 } | |
301 if (throw_circularity_error) { | |
302 ResourceMark rm(THREAD); | |
303 THROW_MSG_0(vmSymbols::java_lang_ClassCircularityError(), child_name->as_C_string()); | |
304 } | |
305 | |
306 // java.lang.Object should have been found above | |
307 assert(class_name() != NULL, "null super class for resolving"); | |
308 // Resolve the super class or interface, check results on return | |
309 klassOop superk = NULL; | |
310 superk = SystemDictionary::resolve_or_null(class_name, | |
311 class_loader, | |
312 protection_domain, | |
313 THREAD); | |
314 | |
315 KlassHandle superk_h(THREAD, superk); | |
316 | |
317 // Note: clean up of placeholders currently in callers of | |
318 // resolve_super_or_fail - either at update_dictionary time | |
319 // or on error | |
320 { | |
321 MutexLocker mu(SystemDictionary_lock, THREAD); | |
322 PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, child_name, class_loader); | |
323 if (probe != NULL) { | |
324 probe->remove_seen_thread(THREAD, PlaceholderTable::LOAD_SUPER); | |
325 } | |
326 } | |
327 if (HAS_PENDING_EXCEPTION || superk_h() == NULL) { | |
328 // can null superk | |
329 superk_h = KlassHandle(THREAD, handle_resolution_exception(class_name, class_loader, protection_domain, true, superk_h, THREAD)); | |
330 } | |
331 | |
332 return superk_h(); | |
333 } | |
334 | |
335 void SystemDictionary::validate_protection_domain(instanceKlassHandle klass, | |
336 Handle class_loader, | |
337 Handle protection_domain, | |
338 TRAPS) { | |
339 if(!has_checkPackageAccess()) return; | |
340 | |
341 // Now we have to call back to java to check if the initating class has access | |
342 JavaValue result(T_VOID); | |
343 if (TraceProtectionDomainVerification) { | |
344 // Print out trace information | |
345 tty->print_cr("Checking package access"); | |
346 tty->print(" - class loader: "); class_loader()->print_value_on(tty); tty->cr(); | |
347 tty->print(" - protection domain: "); protection_domain()->print_value_on(tty); tty->cr(); | |
348 tty->print(" - loading: "); klass()->print_value_on(tty); tty->cr(); | |
349 } | |
350 | |
351 assert(class_loader() != NULL, "should not have non-null protection domain for null classloader"); | |
352 | |
353 KlassHandle system_loader(THREAD, SystemDictionary::classloader_klass()); | |
354 JavaCalls::call_special(&result, | |
355 class_loader, | |
356 system_loader, | |
357 vmSymbolHandles::checkPackageAccess_name(), | |
358 vmSymbolHandles::class_protectiondomain_signature(), | |
359 Handle(THREAD, klass->java_mirror()), | |
360 protection_domain, | |
361 THREAD); | |
362 | |
363 if (TraceProtectionDomainVerification) { | |
364 if (HAS_PENDING_EXCEPTION) { | |
365 tty->print_cr(" -> DENIED !!!!!!!!!!!!!!!!!!!!!"); | |
366 } else { | |
367 tty->print_cr(" -> granted"); | |
368 } | |
369 tty->cr(); | |
370 } | |
371 | |
372 if (HAS_PENDING_EXCEPTION) return; | |
373 | |
374 // If no exception has been thrown, we have validated the protection domain | |
375 // Insert the protection domain of the initiating class into the set. | |
376 { | |
377 // We recalculate the entry here -- we've called out to java since | |
378 // the last time it was calculated. | |
379 symbolHandle kn(THREAD, klass->name()); | |
380 unsigned int d_hash = dictionary()->compute_hash(kn, class_loader); | |
381 int d_index = dictionary()->hash_to_index(d_hash); | |
382 | |
383 MutexLocker mu(SystemDictionary_lock, THREAD); | |
384 { | |
385 // Note that we have an entry, and entries can be deleted only during GC, | |
386 // so we cannot allow GC to occur while we're holding this entry. | |
387 | |
388 // We're using a No_Safepoint_Verifier to catch any place where we | |
389 // might potentially do a GC at all. | |
390 // SystemDictionary::do_unloading() asserts that classes are only | |
391 // unloaded at a safepoint. | |
392 No_Safepoint_Verifier nosafepoint; | |
393 dictionary()->add_protection_domain(d_index, d_hash, klass, class_loader, | |
394 protection_domain, THREAD); | |
395 } | |
396 } | |
397 } | |
398 | |
399 // We only get here if this thread finds that another thread | |
400 // has already claimed the placeholder token for the current operation, | |
401 // but that other thread either never owned or gave up the | |
402 // object lock | |
403 // Waits on SystemDictionary_lock to indicate placeholder table updated | |
404 // On return, caller must recheck placeholder table state | |
405 // | |
406 // We only get here if | |
407 // 1) custom classLoader, i.e. not bootstrap classloader | |
408 // 2) UnsyncloadClass not set | |
409 // 3) custom classLoader has broken the class loader objectLock | |
410 // so another thread got here in parallel | |
411 // | |
412 // lockObject must be held. | |
413 // Complicated dance due to lock ordering: | |
414 // Must first release the classloader object lock to | |
415 // allow initial definer to complete the class definition | |
416 // and to avoid deadlock | |
417 // Reclaim classloader lock object with same original recursion count | |
418 // Must release SystemDictionary_lock after notify, since | |
419 // class loader lock must be claimed before SystemDictionary_lock | |
420 // to prevent deadlocks | |
421 // | |
422 // The notify allows applications that did an untimed wait() on | |
423 // the classloader object lock to not hang. | |
424 void SystemDictionary::double_lock_wait(Handle lockObject, TRAPS) { | |
425 assert_lock_strong(SystemDictionary_lock); | |
426 | |
427 bool calledholdinglock | |
428 = ObjectSynchronizer::current_thread_holds_lock((JavaThread*)THREAD, lockObject); | |
429 assert(calledholdinglock,"must hold lock for notify"); | |
514 | 430 assert((!(lockObject() == _system_loader_lock_obj) && !is_parallelCapable(lockObject)), "unexpected double_lock_wait"); |
0 | 431 ObjectSynchronizer::notifyall(lockObject, THREAD); |
432 intptr_t recursions = ObjectSynchronizer::complete_exit(lockObject, THREAD); | |
433 SystemDictionary_lock->wait(); | |
434 SystemDictionary_lock->unlock(); | |
435 ObjectSynchronizer::reenter(lockObject, recursions, THREAD); | |
436 SystemDictionary_lock->lock(); | |
437 } | |
438 | |
439 // If the class in is in the placeholder table, class loading is in progress | |
440 // For cases where the application changes threads to load classes, it | |
441 // is critical to ClassCircularity detection that we try loading | |
442 // the superclass on the same thread internally, so we do parallel | |
443 // super class loading here. | |
444 // This also is critical in cases where the original thread gets stalled | |
445 // even in non-circularity situations. | |
446 // Note: only one thread can define the class, but multiple can resolve | |
447 // Note: must call resolve_super_or_fail even if null super - | |
514 | 448 // to force placeholder entry creation for this class for circularity detection |
0 | 449 // Caller must check for pending exception |
450 // Returns non-null klassOop if other thread has completed load | |
451 // and we are done, | |
452 // If return null klassOop and no pending exception, the caller must load the class | |
453 instanceKlassHandle SystemDictionary::handle_parallel_super_load( | |
454 symbolHandle name, symbolHandle superclassname, Handle class_loader, | |
455 Handle protection_domain, Handle lockObject, TRAPS) { | |
456 | |
457 instanceKlassHandle nh = instanceKlassHandle(); // null Handle | |
458 unsigned int d_hash = dictionary()->compute_hash(name, class_loader); | |
459 int d_index = dictionary()->hash_to_index(d_hash); | |
460 unsigned int p_hash = placeholders()->compute_hash(name, class_loader); | |
461 int p_index = placeholders()->hash_to_index(p_hash); | |
462 | |
463 // superk is not used, resolve_super called for circularity check only | |
464 // This code is reached in two situations. One if this thread | |
465 // is loading the same class twice (e.g. ClassCircularity, or | |
466 // java.lang.instrument). | |
467 // The second is if another thread started the resolve_super first | |
468 // and has not yet finished. | |
469 // In both cases the original caller will clean up the placeholder | |
470 // entry on error. | |
471 klassOop superk = SystemDictionary::resolve_super_or_fail(name, | |
472 superclassname, | |
473 class_loader, | |
474 protection_domain, | |
475 true, | |
476 CHECK_(nh)); | |
477 // We don't redefine the class, so we just need to clean up if there | |
478 // was not an error (don't want to modify any system dictionary | |
479 // data structures). | |
480 { | |
481 MutexLocker mu(SystemDictionary_lock, THREAD); | |
482 placeholders()->find_and_remove(p_index, p_hash, name, class_loader, THREAD); | |
483 SystemDictionary_lock->notify_all(); | |
484 } | |
485 | |
514 | 486 // parallelCapable class loaders do NOT wait for parallel superclass loads to complete |
487 // Serial class loaders and bootstrap classloader do wait for superclass loads | |
488 if (!class_loader.is_null() && is_parallelCapable(class_loader)) { | |
0 | 489 MutexLocker mu(SystemDictionary_lock, THREAD); |
490 // Check if classloading completed while we were loading superclass or waiting | |
491 klassOop check = find_class(d_index, d_hash, name, class_loader); | |
492 if (check != NULL) { | |
493 // Klass is already loaded, so just return it | |
494 return(instanceKlassHandle(THREAD, check)); | |
495 } else { | |
496 return nh; | |
497 } | |
498 } | |
499 | |
500 // must loop to both handle other placeholder updates | |
501 // and spurious notifications | |
502 bool super_load_in_progress = true; | |
503 PlaceholderEntry* placeholder; | |
504 while (super_load_in_progress) { | |
505 MutexLocker mu(SystemDictionary_lock, THREAD); | |
506 // Check if classloading completed while we were loading superclass or waiting | |
507 klassOop check = find_class(d_index, d_hash, name, class_loader); | |
508 if (check != NULL) { | |
509 // Klass is already loaded, so just return it | |
510 return(instanceKlassHandle(THREAD, check)); | |
511 } else { | |
512 placeholder = placeholders()->get_entry(p_index, p_hash, name, class_loader); | |
513 if (placeholder && placeholder->super_load_in_progress() ){ | |
514 // Before UnsyncloadClass: | |
515 // We only get here if the application has released the | |
516 // classloader lock when another thread was in the middle of loading a | |
517 // superclass/superinterface for this class, and now | |
518 // this thread is also trying to load this class. | |
519 // To minimize surprises, the first thread that started to | |
520 // load a class should be the one to complete the loading | |
521 // with the classfile it initially expected. | |
522 // This logic has the current thread wait once it has done | |
523 // all the superclass/superinterface loading it can, until | |
524 // the original thread completes the class loading or fails | |
525 // If it completes we will use the resulting instanceKlass | |
526 // which we will find below in the systemDictionary. | |
527 // We also get here for parallel bootstrap classloader | |
528 if (class_loader.is_null()) { | |
529 SystemDictionary_lock->wait(); | |
530 } else { | |
531 double_lock_wait(lockObject, THREAD); | |
532 } | |
533 } else { | |
534 // If not in SD and not in PH, other thread's load must have failed | |
535 super_load_in_progress = false; | |
536 } | |
537 } | |
538 } | |
539 return (nh); | |
540 } | |
541 | |
542 | |
543 klassOop SystemDictionary::resolve_instance_class_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS) { | |
544 assert(class_name.not_null() && !FieldType::is_array(class_name()), "invalid class name"); | |
545 // First check to see if we should remove wrapping L and ; | |
546 symbolHandle name; | |
547 if (FieldType::is_obj(class_name())) { | |
548 ResourceMark rm(THREAD); | |
549 // Ignore wrapping L and ;. | |
550 name = oopFactory::new_symbol_handle(class_name()->as_C_string() + 1, class_name()->utf8_length() - 2, CHECK_NULL); | |
551 } else { | |
552 name = class_name; | |
553 } | |
554 | |
555 // UseNewReflection | |
556 // Fix for 4474172; see evaluation for more details | |
557 class_loader = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(class_loader())); | |
558 | |
559 // Do lookup to see if class already exist and the protection domain | |
560 // has the right access | |
561 unsigned int d_hash = dictionary()->compute_hash(name, class_loader); | |
562 int d_index = dictionary()->hash_to_index(d_hash); | |
563 klassOop probe = dictionary()->find(d_index, d_hash, name, class_loader, | |
564 protection_domain, THREAD); | |
565 if (probe != NULL) return probe; | |
566 | |
567 | |
568 // Non-bootstrap class loaders will call out to class loader and | |
569 // define via jvm/jni_DefineClass which will acquire the | |
570 // class loader object lock to protect against multiple threads | |
571 // defining the class in parallel by accident. | |
572 // This lock must be acquired here so the waiter will find | |
573 // any successful result in the SystemDictionary and not attempt | |
574 // the define | |
514 | 575 // ParallelCapable Classloaders and the bootstrap classloader, |
0 | 576 // or all classloaders with UnsyncloadClass do not acquire lock here |
577 bool DoObjectLock = true; | |
514 | 578 if (is_parallelCapable(class_loader)) { |
0 | 579 DoObjectLock = false; |
580 } | |
581 | |
582 unsigned int p_hash = placeholders()->compute_hash(name, class_loader); | |
583 int p_index = placeholders()->hash_to_index(p_hash); | |
584 | |
585 // Class is not in SystemDictionary so we have to do loading. | |
586 // Make sure we are synchronized on the class loader before we proceed | |
587 Handle lockObject = compute_loader_lock_object(class_loader, THREAD); | |
588 check_loader_lock_contention(lockObject, THREAD); | |
589 ObjectLocker ol(lockObject, THREAD, DoObjectLock); | |
590 | |
591 // Check again (after locking) if class already exist in SystemDictionary | |
592 bool class_has_been_loaded = false; | |
593 bool super_load_in_progress = false; | |
594 bool havesupername = false; | |
595 instanceKlassHandle k; | |
596 PlaceholderEntry* placeholder; | |
597 symbolHandle superclassname; | |
598 | |
599 { | |
600 MutexLocker mu(SystemDictionary_lock, THREAD); | |
601 klassOop check = find_class(d_index, d_hash, name, class_loader); | |
602 if (check != NULL) { | |
603 // Klass is already loaded, so just return it | |
604 class_has_been_loaded = true; | |
605 k = instanceKlassHandle(THREAD, check); | |
606 } else { | |
607 placeholder = placeholders()->get_entry(p_index, p_hash, name, class_loader); | |
608 if (placeholder && placeholder->super_load_in_progress()) { | |
609 super_load_in_progress = true; | |
610 if (placeholder->havesupername() == true) { | |
611 superclassname = symbolHandle(THREAD, placeholder->supername()); | |
612 havesupername = true; | |
613 } | |
614 } | |
615 } | |
616 } | |
617 | |
618 // If the class in is in the placeholder table, class loading is in progress | |
619 if (super_load_in_progress && havesupername==true) { | |
620 k = SystemDictionary::handle_parallel_super_load(name, superclassname, | |
621 class_loader, protection_domain, lockObject, THREAD); | |
622 if (HAS_PENDING_EXCEPTION) { | |
623 return NULL; | |
624 } | |
625 if (!k.is_null()) { | |
626 class_has_been_loaded = true; | |
627 } | |
628 } | |
629 | |
630 if (!class_has_been_loaded) { | |
631 | |
632 // add placeholder entry to record loading instance class | |
633 // Five cases: | |
634 // All cases need to prevent modifying bootclasssearchpath | |
635 // in parallel with a classload of same classname | |
514 | 636 // Redefineclasses uses existence of the placeholder for the duration |
637 // of the class load to prevent concurrent redefinition of not completely | |
638 // defined classes. | |
0 | 639 // case 1. traditional classloaders that rely on the classloader object lock |
640 // - no other need for LOAD_INSTANCE | |
641 // case 2. traditional classloaders that break the classloader object lock | |
642 // as a deadlock workaround. Detection of this case requires that | |
643 // this check is done while holding the classloader object lock, | |
644 // and that lock is still held when calling classloader's loadClass. | |
645 // For these classloaders, we ensure that the first requestor | |
646 // completes the load and other requestors wait for completion. | |
647 // case 3. UnsyncloadClass - don't use objectLocker | |
648 // With this flag, we allow parallel classloading of a | |
649 // class/classloader pair | |
650 // case4. Bootstrap classloader - don't own objectLocker | |
651 // This classloader supports parallelism at the classloader level, | |
652 // but only allows a single load of a class/classloader pair. | |
653 // No performance benefit and no deadlock issues. | |
514 | 654 // case 5. parallelCapable user level classloaders - without objectLocker |
655 // Allow parallel classloading of a class/classloader pair | |
0 | 656 symbolHandle nullsymbolHandle; |
657 bool throw_circularity_error = false; | |
658 { | |
659 MutexLocker mu(SystemDictionary_lock, THREAD); | |
514 | 660 if (class_loader.is_null() || !is_parallelCapable(class_loader)) { |
0 | 661 PlaceholderEntry* oldprobe = placeholders()->get_entry(p_index, p_hash, name, class_loader); |
662 if (oldprobe) { | |
663 // only need check_seen_thread once, not on each loop | |
664 // 6341374 java/lang/Instrument with -Xcomp | |
665 if (oldprobe->check_seen_thread(THREAD, PlaceholderTable::LOAD_INSTANCE)) { | |
666 throw_circularity_error = true; | |
667 } else { | |
668 // case 1: traditional: should never see load_in_progress. | |
669 while (!class_has_been_loaded && oldprobe && oldprobe->instance_load_in_progress()) { | |
670 | |
671 // case 4: bootstrap classloader: prevent futile classloading, | |
672 // wait on first requestor | |
673 if (class_loader.is_null()) { | |
674 SystemDictionary_lock->wait(); | |
675 } else { | |
676 // case 2: traditional with broken classloader lock. wait on first | |
677 // requestor. | |
678 double_lock_wait(lockObject, THREAD); | |
679 } | |
680 // Check if classloading completed while we were waiting | |
681 klassOop check = find_class(d_index, d_hash, name, class_loader); | |
682 if (check != NULL) { | |
683 // Klass is already loaded, so just return it | |
684 k = instanceKlassHandle(THREAD, check); | |
685 class_has_been_loaded = true; | |
686 } | |
687 // check if other thread failed to load and cleaned up | |
688 oldprobe = placeholders()->get_entry(p_index, p_hash, name, class_loader); | |
689 } | |
690 } | |
691 } | |
692 } | |
693 // All cases: add LOAD_INSTANCE | |
514 | 694 // case 3: UnsyncloadClass || case 5: parallelCapable: allow competing threads to try |
0 | 695 // LOAD_INSTANCE in parallel |
696 // add placeholder entry even if error - callers will remove on error | |
514 | 697 if (!throw_circularity_error && !class_has_been_loaded) { |
0 | 698 PlaceholderEntry* newprobe = placeholders()->find_and_add(p_index, p_hash, name, class_loader, PlaceholderTable::LOAD_INSTANCE, nullsymbolHandle, THREAD); |
699 // For class loaders that do not acquire the classloader object lock, | |
700 // if they did not catch another thread holding LOAD_INSTANCE, | |
701 // need a check analogous to the acquire ObjectLocker/find_class | |
702 // i.e. now that we hold the LOAD_INSTANCE token on loading this class/CL | |
703 // one final check if the load has already completed | |
514 | 704 // class loaders holding the ObjectLock shouldn't find the class here |
0 | 705 klassOop check = find_class(d_index, d_hash, name, class_loader); |
706 if (check != NULL) { | |
707 // Klass is already loaded, so just return it | |
708 k = instanceKlassHandle(THREAD, check); | |
709 class_has_been_loaded = true; | |
710 newprobe->remove_seen_thread(THREAD, PlaceholderTable::LOAD_INSTANCE); | |
514 | 711 placeholders()->find_and_remove(p_index, p_hash, name, class_loader, THREAD); |
712 SystemDictionary_lock->notify_all(); | |
0 | 713 } |
714 } | |
715 } | |
716 // must throw error outside of owning lock | |
717 if (throw_circularity_error) { | |
718 ResourceMark rm(THREAD); | |
719 THROW_MSG_0(vmSymbols::java_lang_ClassCircularityError(), name->as_C_string()); | |
720 } | |
721 | |
722 if (!class_has_been_loaded) { | |
723 | |
724 // Do actual loading | |
725 k = load_instance_class(name, class_loader, THREAD); | |
726 | |
514 | 727 // For UnsyncloadClass and AllowParallelDefineClass only: |
0 | 728 // If they got a linkageError, check if a parallel class load succeeded. |
729 // 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 | |
731 // successfully loaded instanceKlass | |
732 // Should not get here for classloaders that support parallelism | |
514 | 733 // with the new cleaner mechanism |
734 // Bootstrap goes through here to allow for an extra guarantee check | |
0 | 735 if (UnsyncloadClass || (class_loader.is_null())) { |
736 if (k.is_null() && HAS_PENDING_EXCEPTION | |
737 && PENDING_EXCEPTION->is_a(SystemDictionary::linkageError_klass())) { | |
738 MutexLocker mu(SystemDictionary_lock, THREAD); | |
739 klassOop check = find_class(d_index, d_hash, name, class_loader); | |
740 if (check != NULL) { | |
741 // Klass is already loaded, so just use it | |
742 k = instanceKlassHandle(THREAD, check); | |
743 CLEAR_PENDING_EXCEPTION; | |
744 guarantee((!class_loader.is_null()), "dup definition for bootstrap loader?"); | |
745 } | |
746 } | |
747 } | |
748 | |
749 // clean up placeholder entries for success or error | |
750 // This cleans up LOAD_INSTANCE entries | |
751 // It also cleans up LOAD_SUPER entries on errors from | |
752 // calling load_instance_class | |
753 { | |
754 MutexLocker mu(SystemDictionary_lock, THREAD); | |
755 PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, name, class_loader); | |
756 if (probe != NULL) { | |
757 probe->remove_seen_thread(THREAD, PlaceholderTable::LOAD_INSTANCE); | |
758 placeholders()->find_and_remove(p_index, p_hash, name, class_loader, THREAD); | |
759 SystemDictionary_lock->notify_all(); | |
760 } | |
761 } | |
762 | |
763 // If everything was OK (no exceptions, no null return value), and | |
764 // class_loader is NOT the defining loader, do a little more bookkeeping. | |
765 if (!HAS_PENDING_EXCEPTION && !k.is_null() && | |
766 k->class_loader() != class_loader()) { | |
767 | |
768 check_constraints(d_index, d_hash, k, class_loader, false, THREAD); | |
769 | |
770 // Need to check for a PENDING_EXCEPTION again; check_constraints | |
771 // can throw and doesn't use the CHECK macro. | |
772 if (!HAS_PENDING_EXCEPTION) { | |
773 { // Grabbing the Compile_lock prevents systemDictionary updates | |
774 // during compilations. | |
775 MutexLocker mu(Compile_lock, THREAD); | |
776 update_dictionary(d_index, d_hash, p_index, p_hash, | |
777 k, class_loader, THREAD); | |
778 } | |
779 if (JvmtiExport::should_post_class_load()) { | |
780 Thread *thread = THREAD; | |
781 assert(thread->is_Java_thread(), "thread->is_Java_thread()"); | |
782 JvmtiExport::post_class_load((JavaThread *) thread, k()); | |
783 } | |
784 } | |
785 } | |
786 if (HAS_PENDING_EXCEPTION || k.is_null()) { | |
787 // On error, clean up placeholders | |
788 { | |
789 MutexLocker mu(SystemDictionary_lock, THREAD); | |
790 placeholders()->find_and_remove(p_index, p_hash, name, class_loader, THREAD); | |
791 SystemDictionary_lock->notify_all(); | |
792 } | |
793 return NULL; | |
794 } | |
795 } | |
796 } | |
797 | |
798 #ifdef ASSERT | |
799 { | |
800 Handle loader (THREAD, k->class_loader()); | |
801 MutexLocker mu(SystemDictionary_lock, THREAD); | |
802 oop kk = find_class_or_placeholder(name, loader); | |
803 assert(kk == k(), "should be present in dictionary"); | |
804 } | |
805 #endif | |
806 | |
807 // return if the protection domain in NULL | |
808 if (protection_domain() == NULL) return k(); | |
809 | |
810 // Check the protection domain has the right access | |
811 { | |
812 MutexLocker mu(SystemDictionary_lock, THREAD); | |
813 // Note that we have an entry, and entries can be deleted only during GC, | |
814 // so we cannot allow GC to occur while we're holding this entry. | |
815 // We're using a No_Safepoint_Verifier to catch any place where we | |
816 // might potentially do a GC at all. | |
817 // SystemDictionary::do_unloading() asserts that classes are only | |
818 // unloaded at a safepoint. | |
819 No_Safepoint_Verifier nosafepoint; | |
820 if (dictionary()->is_valid_protection_domain(d_index, d_hash, name, | |
821 class_loader, | |
822 protection_domain)) { | |
823 return k(); | |
824 } | |
825 } | |
826 | |
827 // Verify protection domain. If it fails an exception is thrown | |
828 validate_protection_domain(k, class_loader, protection_domain, CHECK_(klassOop(NULL))); | |
829 | |
830 return k(); | |
831 } | |
832 | |
833 | |
834 // This routine does not lock the system dictionary. | |
835 // | |
836 // Since readers don't hold a lock, we must make sure that system | |
837 // dictionary entries are only removed at a safepoint (when only one | |
838 // thread is running), and are added to in a safe way (all links must | |
839 // be updated in an MT-safe manner). | |
840 // | |
841 // Callers should be aware that an entry could be added just after | |
842 // _dictionary->bucket(index) is read here, so the caller will not see | |
843 // the new entry. | |
844 | |
845 klassOop SystemDictionary::find(symbolHandle class_name, | |
846 Handle class_loader, | |
847 Handle protection_domain, | |
848 TRAPS) { | |
849 | |
556
48bb4a49b7ac
6790209: server VM fails with assert(will_link,"_new: typeflow responsibility")
kvn
parents:
431
diff
changeset
|
850 // UseNewReflection |
48bb4a49b7ac
6790209: server VM fails with assert(will_link,"_new: typeflow responsibility")
kvn
parents:
431
diff
changeset
|
851 // The result of this call should be consistent with the result |
48bb4a49b7ac
6790209: server VM fails with assert(will_link,"_new: typeflow responsibility")
kvn
parents:
431
diff
changeset
|
852 // of the call to resolve_instance_class_or_null(). |
48bb4a49b7ac
6790209: server VM fails with assert(will_link,"_new: typeflow responsibility")
kvn
parents:
431
diff
changeset
|
853 // See evaluation 6790209 and 4474172 for more details. |
48bb4a49b7ac
6790209: server VM fails with assert(will_link,"_new: typeflow responsibility")
kvn
parents:
431
diff
changeset
|
854 class_loader = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(class_loader())); |
48bb4a49b7ac
6790209: server VM fails with assert(will_link,"_new: typeflow responsibility")
kvn
parents:
431
diff
changeset
|
855 |
0 | 856 unsigned int d_hash = dictionary()->compute_hash(class_name, class_loader); |
857 int d_index = dictionary()->hash_to_index(d_hash); | |
858 | |
859 { | |
860 // Note that we have an entry, and entries can be deleted only during GC, | |
861 // so we cannot allow GC to occur while we're holding this entry. | |
862 // We're using a No_Safepoint_Verifier to catch any place where we | |
863 // might potentially do a GC at all. | |
864 // SystemDictionary::do_unloading() asserts that classes are only | |
865 // unloaded at a safepoint. | |
866 No_Safepoint_Verifier nosafepoint; | |
867 return dictionary()->find(d_index, d_hash, class_name, class_loader, | |
868 protection_domain, THREAD); | |
869 } | |
870 } | |
871 | |
872 | |
873 // Look for a loaded instance or array klass by name. Do not do any loading. | |
874 // return NULL in case of error. | |
875 klassOop SystemDictionary::find_instance_or_array_klass(symbolHandle class_name, | |
876 Handle class_loader, | |
877 Handle protection_domain, | |
878 TRAPS) { | |
879 klassOop k = NULL; | |
880 assert(class_name() != NULL, "class name must be non NULL"); | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
881 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
882 // Try to get one of the well-known klasses. |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
883 if (LinkWellKnownClasses) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
884 k = find_well_known_klass(class_name()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
885 if (k != NULL) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
886 return k; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
887 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
888 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
889 |
0 | 890 if (FieldType::is_array(class_name())) { |
891 // The name refers to an array. Parse the name. | |
892 jint dimension; | |
893 symbolOop object_key; | |
894 | |
895 // dimension and object_key are assigned as a side-effect of this call | |
896 BasicType t = FieldType::get_array_info(class_name(), &dimension, | |
897 &object_key, CHECK_(NULL)); | |
898 if (t != T_OBJECT) { | |
899 k = Universe::typeArrayKlassObj(t); | |
900 } else { | |
901 symbolHandle h_key(THREAD, object_key); | |
902 k = SystemDictionary::find(h_key, class_loader, protection_domain, THREAD); | |
903 } | |
904 if (k != NULL) { | |
905 k = Klass::cast(k)->array_klass_or_null(dimension); | |
906 } | |
907 } else { | |
908 k = find(class_name, class_loader, protection_domain, THREAD); | |
909 } | |
910 return k; | |
911 } | |
912 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
913 // Quick range check for names of well-known classes: |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
914 static symbolOop wk_klass_name_limits[2] = {NULL, NULL}; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
915 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
916 #ifndef PRODUCT |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
917 static int find_wkk_calls, find_wkk_probes, find_wkk_wins; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
918 // counts for "hello world": 3983, 1616, 1075 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
919 // => 60% hit after limit guard, 25% total win rate |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
920 #endif |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
921 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
922 klassOop SystemDictionary::find_well_known_klass(symbolOop class_name) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
923 // A bounds-check on class_name will quickly get a negative result. |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
924 NOT_PRODUCT(find_wkk_calls++); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
925 if (class_name >= wk_klass_name_limits[0] && |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
926 class_name <= wk_klass_name_limits[1]) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
927 NOT_PRODUCT(find_wkk_probes++); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
928 vmSymbols::SID sid = vmSymbols::find_sid(class_name); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
929 if (sid != vmSymbols::NO_SID) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
930 klassOop k = NULL; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
931 switch (sid) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
932 #define WK_KLASS_CASE(name, symbol, ignore_option) \ |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
933 case vmSymbols::VM_SYMBOL_ENUM_NAME(symbol): \ |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
934 k = WK_KLASS(name); break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
935 WK_KLASSES_DO(WK_KLASS_CASE) |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
936 #undef WK_KLASS_CASE |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
937 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
938 NOT_PRODUCT(if (k != NULL) find_wkk_wins++); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
939 return k; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
940 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
941 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
942 return NULL; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
943 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
944 |
0 | 945 // Note: this method is much like resolve_from_stream, but |
946 // updates no supplemental data structures. | |
947 // TODO consolidate the two methods with a helper routine? | |
948 klassOop SystemDictionary::parse_stream(symbolHandle class_name, | |
949 Handle class_loader, | |
950 Handle protection_domain, | |
951 ClassFileStream* st, | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
952 KlassHandle host_klass, |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
953 GrowableArray<Handle>* cp_patches, |
0 | 954 TRAPS) { |
955 symbolHandle parsed_name; | |
956 | |
957 // Parse the stream. Note that we do this even though this klass might | |
958 // already be present in the SystemDictionary, otherwise we would not | |
959 // throw potential ClassFormatErrors. | |
960 // | |
961 // Note: "name" is updated. | |
962 // Further note: a placeholder will be added for this class when | |
963 // super classes are loaded (resolve_super_or_fail). We expect this | |
964 // to be called for all classes but java.lang.Object; and we preload | |
965 // java.lang.Object through resolve_or_fail, not this path. | |
966 | |
967 instanceKlassHandle k = ClassFileParser(st).parseClassFile(class_name, | |
968 class_loader, | |
969 protection_domain, | |
710 | 970 host_klass, |
971 cp_patches, | |
0 | 972 parsed_name, |
973 THREAD); | |
974 | |
514 | 975 |
0 | 976 // We don't redefine the class, so we just need to clean up whether there |
977 // was an error or not (don't want to modify any system dictionary | |
978 // data structures). | |
979 // Parsed name could be null if we threw an error before we got far | |
980 // enough along to parse it -- in that case, there is nothing to clean up. | |
981 if (!parsed_name.is_null()) { | |
982 unsigned int p_hash = placeholders()->compute_hash(parsed_name, | |
983 class_loader); | |
984 int p_index = placeholders()->hash_to_index(p_hash); | |
985 { | |
986 MutexLocker mu(SystemDictionary_lock, THREAD); | |
987 placeholders()->find_and_remove(p_index, p_hash, parsed_name, class_loader, THREAD); | |
988 SystemDictionary_lock->notify_all(); | |
989 } | |
990 } | |
991 | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
992 if (host_klass.not_null() && k.not_null()) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
993 assert(AnonymousClasses, ""); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
994 // If it's anonymous, initialize it now, since nobody else will. |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
995 k->set_host_klass(host_klass()); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
996 |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
997 { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
998 MutexLocker mu_r(Compile_lock, THREAD); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
999 |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1000 // Add to class hierarchy, initialize vtables, and do possible |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1001 // deoptimizations. |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1002 add_to_hierarchy(k, CHECK_NULL); // No exception, but can block |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1003 |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1004 // But, do not add to system dictionary. |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1005 } |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1006 |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1007 k->eager_initialize(THREAD); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1008 |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1009 // notify jvmti |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1010 if (JvmtiExport::should_post_class_load()) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1011 assert(THREAD->is_Java_thread(), "thread->is_Java_thread()"); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1012 JvmtiExport::post_class_load((JavaThread *) THREAD, k()); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1013 } |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1014 } |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
1015 |
0 | 1016 return k(); |
1017 } | |
1018 | |
1019 // Add a klass to the system from a stream (called by jni_DefineClass and | |
1020 // JVM_DefineClass). | |
1021 // Note: class_name can be NULL. In that case we do not know the name of | |
1022 // the class until we have parsed the stream. | |
1023 | |
1024 klassOop SystemDictionary::resolve_from_stream(symbolHandle class_name, | |
1025 Handle class_loader, | |
1026 Handle protection_domain, | |
1027 ClassFileStream* st, | |
1028 TRAPS) { | |
1029 | |
514 | 1030 // Classloaders that support parallelism, e.g. bootstrap classloader, |
1031 // or all classloaders with UnsyncloadClass do not acquire lock here | |
1032 bool DoObjectLock = true; | |
1033 if (is_parallelCapable(class_loader)) { | |
1034 DoObjectLock = false; | |
1035 } | |
1036 | |
1037 // Make sure we are synchronized on the class loader before we proceed | |
0 | 1038 Handle lockObject = compute_loader_lock_object(class_loader, THREAD); |
1039 check_loader_lock_contention(lockObject, THREAD); | |
514 | 1040 ObjectLocker ol(lockObject, THREAD, DoObjectLock); |
0 | 1041 |
1042 symbolHandle parsed_name; | |
1043 | |
1044 // Parse the stream. Note that we do this even though this klass might | |
1045 // already be present in the SystemDictionary, otherwise we would not | |
1046 // throw potential ClassFormatErrors. | |
1047 // | |
1048 // Note: "name" is updated. | |
1049 // Further note: a placeholder will be added for this class when | |
1050 // super classes are loaded (resolve_super_or_fail). We expect this | |
1051 // to be called for all classes but java.lang.Object; and we preload | |
1052 // java.lang.Object through resolve_or_fail, not this path. | |
1053 | |
1054 instanceKlassHandle k = ClassFileParser(st).parseClassFile(class_name, | |
1055 class_loader, | |
1056 protection_domain, | |
1057 parsed_name, | |
1058 THREAD); | |
1059 | |
1060 const char* pkg = "java/"; | |
1061 if (!HAS_PENDING_EXCEPTION && | |
1062 !class_loader.is_null() && | |
1063 !parsed_name.is_null() && | |
1064 !strncmp((const char*)parsed_name->bytes(), pkg, strlen(pkg))) { | |
1065 // It is illegal to define classes in the "java." package from | |
1066 // JVM_DefineClass or jni_DefineClass unless you're the bootclassloader | |
1067 ResourceMark rm(THREAD); | |
1068 char* name = parsed_name->as_C_string(); | |
1069 char* index = strrchr(name, '/'); | |
1070 *index = '\0'; // chop to just the package name | |
1071 while ((index = strchr(name, '/')) != NULL) { | |
1072 *index = '.'; // replace '/' with '.' in package name | |
1073 } | |
1074 const char* fmt = "Prohibited package name: %s"; | |
1075 size_t len = strlen(fmt) + strlen(name); | |
1076 char* message = NEW_RESOURCE_ARRAY(char, len); | |
1077 jio_snprintf(message, len, fmt, name); | |
1078 Exceptions::_throw_msg(THREAD_AND_LOCATION, | |
1079 vmSymbols::java_lang_SecurityException(), message); | |
1080 } | |
1081 | |
1082 if (!HAS_PENDING_EXCEPTION) { | |
1083 assert(!parsed_name.is_null(), "Sanity"); | |
1084 assert(class_name.is_null() || class_name() == parsed_name(), | |
1085 "name mismatch"); | |
1086 // Verification prevents us from creating names with dots in them, this | |
1087 // asserts that that's the case. | |
1088 assert(is_internal_format(parsed_name), | |
1089 "external class name format used internally"); | |
1090 | |
1091 // Add class just loaded | |
514 | 1092 // If a class loader supports parallel classloading handle parallel define requests |
1093 // find_or_define_instance_class may return a different instanceKlass | |
1094 if (is_parallelCapable(class_loader)) { | |
1095 k = find_or_define_instance_class(class_name, class_loader, k, THREAD); | |
1096 } else { | |
1097 define_instance_class(k, THREAD); | |
1098 } | |
0 | 1099 } |
1100 | |
1101 // If parsing the class file or define_instance_class failed, we | |
1102 // need to remove the placeholder added on our behalf. But we | |
1103 // must make sure parsed_name is valid first (it won't be if we had | |
1104 // a format error before the class was parsed far enough to | |
1105 // find the name). | |
1106 if (HAS_PENDING_EXCEPTION && !parsed_name.is_null()) { | |
1107 unsigned int p_hash = placeholders()->compute_hash(parsed_name, | |
1108 class_loader); | |
1109 int p_index = placeholders()->hash_to_index(p_hash); | |
1110 { | |
1111 MutexLocker mu(SystemDictionary_lock, THREAD); | |
1112 placeholders()->find_and_remove(p_index, p_hash, parsed_name, class_loader, THREAD); | |
1113 SystemDictionary_lock->notify_all(); | |
1114 } | |
1115 return NULL; | |
1116 } | |
1117 | |
1118 // Make sure that we didn't leave a place holder in the | |
1119 // SystemDictionary; this is only done on success | |
1120 debug_only( { | |
1121 if (!HAS_PENDING_EXCEPTION) { | |
1122 assert(!parsed_name.is_null(), "parsed_name is still null?"); | |
1123 symbolHandle h_name (THREAD, k->name()); | |
1124 Handle h_loader (THREAD, k->class_loader()); | |
1125 | |
1126 MutexLocker mu(SystemDictionary_lock, THREAD); | |
1127 | |
1128 oop check = find_class_or_placeholder(parsed_name, class_loader); | |
1129 assert(check == k(), "should be present in the dictionary"); | |
1130 | |
1131 oop check2 = find_class_or_placeholder(h_name, h_loader); | |
1132 assert(check == check2, "name inconsistancy in SystemDictionary"); | |
1133 } | |
1134 } ); | |
1135 | |
1136 return k(); | |
1137 } | |
1138 | |
1139 | |
1140 void SystemDictionary::set_shared_dictionary(HashtableBucket* t, int length, | |
1141 int number_of_entries) { | |
1142 assert(length == _nof_buckets * sizeof(HashtableBucket), | |
1143 "bad shared dictionary size."); | |
1144 _shared_dictionary = new Dictionary(_nof_buckets, t, number_of_entries); | |
1145 } | |
1146 | |
1147 | |
1148 // If there is a shared dictionary, then find the entry for the | |
1149 // given shared system class, if any. | |
1150 | |
1151 klassOop SystemDictionary::find_shared_class(symbolHandle class_name) { | |
1152 if (shared_dictionary() != NULL) { | |
1153 unsigned int d_hash = dictionary()->compute_hash(class_name, Handle()); | |
1154 int d_index = dictionary()->hash_to_index(d_hash); | |
1155 return shared_dictionary()->find_shared_class(d_index, d_hash, class_name); | |
1156 } else { | |
1157 return NULL; | |
1158 } | |
1159 } | |
1160 | |
1161 | |
1162 // Load a class from the shared spaces (found through the shared system | |
1163 // dictionary). Force the superclass and all interfaces to be loaded. | |
1164 // Update the class definition to include sibling classes and no | |
1165 // subclasses (yet). [Classes in the shared space are not part of the | |
1166 // object hierarchy until loaded.] | |
1167 | |
1168 instanceKlassHandle SystemDictionary::load_shared_class( | |
1169 symbolHandle class_name, Handle class_loader, TRAPS) { | |
1170 instanceKlassHandle ik (THREAD, find_shared_class(class_name)); | |
1171 return load_shared_class(ik, class_loader, THREAD); | |
1172 } | |
1173 | |
1174 // Note well! Changes to this method may affect oop access order | |
1175 // in the shared archive. Please take care to not make changes that | |
1176 // adversely affect cold start time by changing the oop access order | |
1177 // that is specified in dump.cpp MarkAndMoveOrderedReadOnly and | |
1178 // MarkAndMoveOrderedReadWrite closures. | |
1179 instanceKlassHandle SystemDictionary::load_shared_class( | |
1180 instanceKlassHandle ik, Handle class_loader, TRAPS) { | |
1181 assert(class_loader.is_null(), "non-null classloader for shared class?"); | |
1182 if (ik.not_null()) { | |
1183 instanceKlassHandle nh = instanceKlassHandle(); // null Handle | |
1184 symbolHandle class_name(THREAD, ik->name()); | |
1185 | |
1186 // Found the class, now load the superclass and interfaces. If they | |
1187 // are shared, add them to the main system dictionary and reset | |
1188 // their hierarchy references (supers, subs, and interfaces). | |
1189 | |
1190 if (ik->super() != NULL) { | |
1191 symbolHandle cn(THREAD, ik->super()->klass_part()->name()); | |
1192 resolve_super_or_fail(class_name, cn, | |
1193 class_loader, Handle(), true, CHECK_(nh)); | |
1194 } | |
1195 | |
1196 objArrayHandle interfaces (THREAD, ik->local_interfaces()); | |
1197 int num_interfaces = interfaces->length(); | |
1198 for (int index = 0; index < num_interfaces; index++) { | |
1199 klassOop k = klassOop(interfaces->obj_at(index)); | |
1200 | |
1201 // Note: can not use instanceKlass::cast here because | |
1202 // interfaces' instanceKlass's C++ vtbls haven't been | |
1203 // reinitialized yet (they will be once the interface classes | |
1204 // are loaded) | |
1205 symbolHandle name (THREAD, k->klass_part()->name()); | |
1206 resolve_super_or_fail(class_name, name, class_loader, Handle(), false, CHECK_(nh)); | |
1207 } | |
1208 | |
1209 // Adjust methods to recover missing data. They need addresses for | |
1210 // interpreter entry points and their default native method address | |
1211 // must be reset. | |
1212 | |
1213 // Updating methods must be done under a lock so multiple | |
1214 // threads don't update these in parallel | |
1215 // Shared classes are all currently loaded by the bootstrap | |
1216 // classloader, so this will never cause a deadlock on | |
1217 // a custom class loader lock. | |
1218 | |
1219 { | |
1220 Handle lockObject = compute_loader_lock_object(class_loader, THREAD); | |
1221 check_loader_lock_contention(lockObject, THREAD); | |
1222 ObjectLocker ol(lockObject, THREAD, true); | |
1223 | |
1224 objArrayHandle methods (THREAD, ik->methods()); | |
1225 int num_methods = methods->length(); | |
1226 for (int index2 = 0; index2 < num_methods; ++index2) { | |
1227 methodHandle m(THREAD, methodOop(methods->obj_at(index2))); | |
1228 m()->link_method(m, CHECK_(nh)); | |
1229 } | |
1230 } | |
1231 | |
1232 if (TraceClassLoading) { | |
1233 ResourceMark rm; | |
1234 tty->print("[Loaded %s", ik->external_name()); | |
1235 tty->print(" from shared objects file"); | |
1236 tty->print_cr("]"); | |
1237 } | |
1238 // notify a class loaded from shared object | |
1239 ClassLoadingService::notify_class_loaded(instanceKlass::cast(ik()), | |
1240 true /* shared class */); | |
1241 } | |
1242 return ik; | |
1243 } | |
1244 | |
1245 #ifdef KERNEL | |
1246 // Some classes on the bootstrap class path haven't been installed on the | |
1247 // system yet. Call the DownloadManager method to make them appear in the | |
1248 // bootstrap class path and try again to load the named class. | |
1249 // Note that with delegation class loaders all classes in another loader will | |
1250 // first try to call this so it'd better be fast!! | |
1251 static instanceKlassHandle download_and_retry_class_load( | |
1252 symbolHandle class_name, | |
1253 TRAPS) { | |
1254 | |
1255 klassOop dlm = SystemDictionary::sun_jkernel_DownloadManager_klass(); | |
1256 instanceKlassHandle nk; | |
1257 | |
1258 // If download manager class isn't loaded just return. | |
1259 if (dlm == NULL) return nk; | |
1260 | |
1261 { HandleMark hm(THREAD); | |
1262 ResourceMark rm(THREAD); | |
1263 Handle s = java_lang_String::create_from_symbol(class_name, CHECK_(nk)); | |
1264 Handle class_string = java_lang_String::externalize_classname(s, CHECK_(nk)); | |
1265 | |
1266 // return value | |
1267 JavaValue result(T_OBJECT); | |
1268 | |
1269 // Call the DownloadManager. We assume that it has a lock because | |
1270 // multiple classes could be not found and downloaded at the same time. | |
1271 // class sun.misc.DownloadManager; | |
1272 // public static String getBootClassPathEntryForClass(String className); | |
1273 JavaCalls::call_static(&result, | |
1274 KlassHandle(THREAD, dlm), | |
1275 vmSymbolHandles::getBootClassPathEntryForClass_name(), | |
1276 vmSymbolHandles::string_string_signature(), | |
1277 class_string, | |
1278 CHECK_(nk)); | |
1279 | |
1280 // Get result.string and add to bootclasspath | |
1281 assert(result.get_type() == T_OBJECT, "just checking"); | |
1282 oop obj = (oop) result.get_jobject(); | |
1283 if (obj == NULL) { return nk; } | |
1284 | |
22
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
1285 Handle h_obj(THREAD, obj); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
1286 char* new_class_name = java_lang_String::as_platform_dependent_str(h_obj, |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
1287 CHECK_(nk)); |
0 | 1288 |
1289 // lock the loader | |
1290 // we use this lock because JVMTI does. | |
1291 Handle loader_lock(THREAD, SystemDictionary::system_loader_lock()); | |
1292 | |
1293 ObjectLocker ol(loader_lock, THREAD); | |
1294 // add the file to the bootclasspath | |
1295 ClassLoader::update_class_path_entry_list(new_class_name, true); | |
1296 } // end HandleMark | |
1297 | |
1298 if (TraceClassLoading) { | |
1299 ClassLoader::print_bootclasspath(); | |
1300 } | |
1301 return ClassLoader::load_classfile(class_name, CHECK_(nk)); | |
1302 } | |
1303 #endif // KERNEL | |
1304 | |
1305 | |
1306 instanceKlassHandle SystemDictionary::load_instance_class(symbolHandle class_name, Handle class_loader, TRAPS) { | |
1307 instanceKlassHandle nh = instanceKlassHandle(); // null Handle | |
1308 if (class_loader.is_null()) { | |
875
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1309 |
0 | 1310 // Search the shared system dictionary for classes preloaded into the |
1311 // shared spaces. | |
1312 instanceKlassHandle k; | |
875
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1313 { |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1314 PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time()); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1315 k = load_shared_class(class_name, class_loader, THREAD); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1316 } |
0 | 1317 |
1318 if (k.is_null()) { | |
1319 // Use VM class loader | |
875
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1320 PerfTraceTime vmtimer(ClassLoader::perf_sys_classload_time()); |
0 | 1321 k = ClassLoader::load_classfile(class_name, CHECK_(nh)); |
1322 } | |
1323 | |
1324 #ifdef KERNEL | |
1325 // If the VM class loader has failed to load the class, call the | |
1326 // DownloadManager class to make it magically appear on the classpath | |
1327 // and try again. This is only configured with the Kernel VM. | |
1328 if (k.is_null()) { | |
1329 k = download_and_retry_class_load(class_name, CHECK_(nh)); | |
1330 } | |
1331 #endif // KERNEL | |
1332 | |
514 | 1333 // find_or_define_instance_class may return a different instanceKlass |
0 | 1334 if (!k.is_null()) { |
1335 k = find_or_define_instance_class(class_name, class_loader, k, CHECK_(nh)); | |
1336 } | |
1337 return k; | |
1338 } else { | |
1339 // Use user specified class loader to load class. Call loadClass operation on class_loader. | |
1340 ResourceMark rm(THREAD); | |
1341 | |
875
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1342 assert(THREAD->is_Java_thread(), "must be a JavaThread"); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1343 JavaThread* jt = (JavaThread*) THREAD; |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1344 |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1345 PerfClassTraceTime vmtimer(ClassLoader::perf_app_classload_time(), |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1346 ClassLoader::perf_app_classload_selftime(), |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1347 ClassLoader::perf_app_classload_count(), |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1348 jt->get_thread_stat()->perf_recursion_counts_addr(), |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1349 jt->get_thread_stat()->perf_timers_addr(), |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1350 PerfClassTraceTime::CLASS_LOAD); |
6a93908f268f
6857194: Add hotspot perf counters to aid class loading performance measurement
mchung
parents:
726
diff
changeset
|
1351 |
0 | 1352 Handle s = java_lang_String::create_from_symbol(class_name, CHECK_(nh)); |
1353 // Translate to external class name format, i.e., convert '/' chars to '.' | |
1354 Handle string = java_lang_String::externalize_classname(s, CHECK_(nh)); | |
1355 | |
1356 JavaValue result(T_OBJECT); | |
1357 | |
1358 KlassHandle spec_klass (THREAD, SystemDictionary::classloader_klass()); | |
1359 | |
514 | 1360 // Call public unsynchronized loadClass(String) directly for all class loaders |
1361 // for parallelCapable class loaders. JDK >=7, loadClass(String, boolean) will | |
1362 // acquire a class-name based lock rather than the class loader object lock. | |
1363 // JDK < 7 already acquire the class loader lock in loadClass(String, boolean), | |
1364 // so the call to loadClassInternal() was not required. | |
1365 // | |
1366 // UnsyncloadClass flag means both call loadClass(String) and do | |
1367 // not acquire the class loader lock even for class loaders that are | |
1368 // not parallelCapable. This was a risky transitional | |
1369 // flag for diagnostic purposes only. It is risky to call | |
0 | 1370 // custom class loaders without synchronization. |
1371 // WARNING If a custom class loader does NOT synchronizer findClass, or callers of | |
514 | 1372 // findClass, the UnsyncloadClass flag risks unexpected timing bugs in the field. |
0 | 1373 // Do NOT assume this will be supported in future releases. |
514 | 1374 // |
1375 // Added MustCallLoadClassInternal in case we discover in the field | |
1376 // a customer that counts on this call | |
1377 if (MustCallLoadClassInternal && has_loadClassInternal()) { | |
0 | 1378 JavaCalls::call_special(&result, |
1379 class_loader, | |
1380 spec_klass, | |
1381 vmSymbolHandles::loadClassInternal_name(), | |
1382 vmSymbolHandles::string_class_signature(), | |
1383 string, | |
1384 CHECK_(nh)); | |
1385 } else { | |
1386 JavaCalls::call_virtual(&result, | |
1387 class_loader, | |
1388 spec_klass, | |
1389 vmSymbolHandles::loadClass_name(), | |
1390 vmSymbolHandles::string_class_signature(), | |
1391 string, | |
1392 CHECK_(nh)); | |
1393 } | |
1394 | |
1395 assert(result.get_type() == T_OBJECT, "just checking"); | |
1396 oop obj = (oop) result.get_jobject(); | |
1397 | |
1398 // Primitive classes return null since forName() can not be | |
1399 // used to obtain any of the Class objects representing primitives or void | |
1400 if ((obj != NULL) && !(java_lang_Class::is_primitive(obj))) { | |
1401 instanceKlassHandle k = | |
1402 instanceKlassHandle(THREAD, java_lang_Class::as_klassOop(obj)); | |
1403 // For user defined Java class loaders, check that the name returned is | |
1404 // the same as that requested. This check is done for the bootstrap | |
1405 // loader when parsing the class file. | |
1406 if (class_name() == k->name()) { | |
1407 return k; | |
1408 } | |
1409 } | |
1410 // Class is not found or has the wrong name, return NULL | |
1411 return nh; | |
1412 } | |
1413 } | |
1414 | |
1415 void SystemDictionary::define_instance_class(instanceKlassHandle k, TRAPS) { | |
1416 | |
1417 Handle class_loader_h(THREAD, k->class_loader()); | |
1418 | |
514 | 1419 // for bootstrap and other parallel classloaders don't acquire lock, |
1420 // use placeholder token | |
1421 // If a parallelCapable class loader calls define_instance_class instead of | |
1422 // find_or_define_instance_class to get here, we have a timing | |
1423 // hole with systemDictionary updates and check_constraints | |
1424 if (!class_loader_h.is_null() && !is_parallelCapable(class_loader_h)) { | |
0 | 1425 assert(ObjectSynchronizer::current_thread_holds_lock((JavaThread*)THREAD, |
1426 compute_loader_lock_object(class_loader_h, THREAD)), | |
1427 "define called without lock"); | |
1428 } | |
1429 | |
1430 // Check class-loading constraints. Throw exception if violation is detected. | |
1431 // Grabs and releases SystemDictionary_lock | |
1432 // The check_constraints/find_class call and update_dictionary sequence | |
1433 // must be "atomic" for a specific class/classloader pair so we never | |
1434 // define two different instanceKlasses for that class/classloader pair. | |
1435 // Existing classloaders will call define_instance_class with the | |
1436 // classloader lock held | |
1437 // Parallel classloaders will call find_or_define_instance_class | |
1438 // which will require a token to perform the define class | |
1439 symbolHandle name_h(THREAD, k->name()); | |
1440 unsigned int d_hash = dictionary()->compute_hash(name_h, class_loader_h); | |
1441 int d_index = dictionary()->hash_to_index(d_hash); | |
1442 check_constraints(d_index, d_hash, k, class_loader_h, true, CHECK); | |
1443 | |
1444 // Register class just loaded with class loader (placed in Vector) | |
1445 // Note we do this before updating the dictionary, as this can | |
1446 // fail with an OutOfMemoryError (if it does, we will *not* put this | |
1447 // class in the dictionary and will not update the class hierarchy). | |
1448 if (k->class_loader() != NULL) { | |
1449 methodHandle m(THREAD, Universe::loader_addClass_method()); | |
1450 JavaValue result(T_VOID); | |
1451 JavaCallArguments args(class_loader_h); | |
1452 args.push_oop(Handle(THREAD, k->java_mirror())); | |
1453 JavaCalls::call(&result, m, &args, CHECK); | |
1454 } | |
1455 | |
1456 // Add the new class. We need recompile lock during update of CHA. | |
1457 { | |
1458 unsigned int p_hash = placeholders()->compute_hash(name_h, class_loader_h); | |
1459 int p_index = placeholders()->hash_to_index(p_hash); | |
1460 | |
1461 MutexLocker mu_r(Compile_lock, THREAD); | |
1462 | |
1463 // Add to class hierarchy, initialize vtables, and do possible | |
1464 // deoptimizations. | |
1465 add_to_hierarchy(k, CHECK); // No exception, but can block | |
1466 | |
1467 // Add to systemDictionary - so other classes can see it. | |
1468 // Grabs and releases SystemDictionary_lock | |
1469 update_dictionary(d_index, d_hash, p_index, p_hash, | |
1470 k, class_loader_h, THREAD); | |
1471 } | |
1472 k->eager_initialize(THREAD); | |
1473 | |
1474 // notify jvmti | |
1475 if (JvmtiExport::should_post_class_load()) { | |
1476 assert(THREAD->is_Java_thread(), "thread->is_Java_thread()"); | |
1477 JvmtiExport::post_class_load((JavaThread *) THREAD, k()); | |
1478 | |
1479 } | |
1480 } | |
1481 | |
1482 // Support parallel classloading | |
1483 // Initial implementation for bootstrap classloader | |
1484 // For custom class loaders that support parallel classloading, | |
514 | 1485 // With AllowParallelDefine flag==true, in case they do not synchronize around |
1486 // FindLoadedClass/DefineClass, calls, we check for parallel | |
0 | 1487 // loading for them, wait if a defineClass is in progress |
1488 // and return the initial requestor's results | |
514 | 1489 // With AllowParallelDefine flag==false, call through to define_instance_class |
1490 // which will throw LinkageError: duplicate class definition. | |
0 | 1491 // For better performance, the class loaders should synchronize |
514 | 1492 // findClass(), i.e. FindLoadedClass/DefineClassIfAbsent or they |
0 | 1493 // potentially waste time reading and parsing the bytestream. |
1494 // Note: VM callers should ensure consistency of k/class_name,class_loader | |
1495 instanceKlassHandle SystemDictionary::find_or_define_instance_class(symbolHandle class_name, Handle class_loader, instanceKlassHandle k, TRAPS) { | |
1496 | |
1497 instanceKlassHandle nh = instanceKlassHandle(); // null Handle | |
515 | 1498 symbolHandle name_h(THREAD, k->name()); // passed in class_name may be null |
0 | 1499 |
515 | 1500 unsigned int d_hash = dictionary()->compute_hash(name_h, class_loader); |
0 | 1501 int d_index = dictionary()->hash_to_index(d_hash); |
1502 | |
1503 // Hold SD lock around find_class and placeholder creation for DEFINE_CLASS | |
515 | 1504 unsigned int p_hash = placeholders()->compute_hash(name_h, class_loader); |
0 | 1505 int p_index = placeholders()->hash_to_index(p_hash); |
1506 PlaceholderEntry* probe; | |
1507 | |
1508 { | |
1509 MutexLocker mu(SystemDictionary_lock, THREAD); | |
1510 // First check if class already defined | |
515 | 1511 klassOop check = find_class(d_index, d_hash, name_h, class_loader); |
0 | 1512 if (check != NULL) { |
1513 return(instanceKlassHandle(THREAD, check)); | |
1514 } | |
1515 | |
1516 // Acquire define token for this class/classloader | |
1517 symbolHandle nullsymbolHandle; | |
515 | 1518 probe = placeholders()->find_and_add(p_index, p_hash, name_h, class_loader, PlaceholderTable::DEFINE_CLASS, nullsymbolHandle, THREAD); |
514 | 1519 // Wait if another thread defining in parallel |
1520 // All threads wait - even those that will throw duplicate class: otherwise | |
1521 // caller is surprised by LinkageError: duplicate, but findLoadedClass fails | |
1522 // if other thread has not finished updating dictionary | |
1523 while (probe->definer() != NULL) { | |
1524 SystemDictionary_lock->wait(); | |
1525 } | |
1526 // Only special cases allow parallel defines and can use other thread's results | |
1527 // Other cases fall through, and may run into duplicate defines | |
1528 // caught by finding an entry in the SystemDictionary | |
1529 if ((UnsyncloadClass || AllowParallelDefineClass) && (probe->instanceKlass() != NULL)) { | |
0 | 1530 probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS); |
515 | 1531 placeholders()->find_and_remove(p_index, p_hash, name_h, class_loader, THREAD); |
514 | 1532 SystemDictionary_lock->notify_all(); |
0 | 1533 #ifdef ASSERT |
515 | 1534 klassOop check = find_class(d_index, d_hash, name_h, class_loader); |
514 | 1535 assert(check != NULL, "definer missed recording success"); |
0 | 1536 #endif |
514 | 1537 return(instanceKlassHandle(THREAD, probe->instanceKlass())); |
0 | 1538 } else { |
514 | 1539 // This thread will define the class (even if earlier thread tried and had an error) |
1540 probe->set_definer(THREAD); | |
0 | 1541 } |
1542 } | |
1543 | |
1544 define_instance_class(k, THREAD); | |
1545 | |
1546 Handle linkage_exception = Handle(); // null handle | |
1547 | |
1548 // definer must notify any waiting threads | |
1549 { | |
1550 MutexLocker mu(SystemDictionary_lock, THREAD); | |
515 | 1551 PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, name_h, class_loader); |
0 | 1552 assert(probe != NULL, "DEFINE_CLASS placeholder lost?"); |
1553 if (probe != NULL) { | |
1554 if (HAS_PENDING_EXCEPTION) { | |
1555 linkage_exception = Handle(THREAD,PENDING_EXCEPTION); | |
1556 CLEAR_PENDING_EXCEPTION; | |
1557 } else { | |
1558 probe->set_instanceKlass(k()); | |
1559 } | |
1560 probe->set_definer(NULL); | |
1561 probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS); | |
515 | 1562 placeholders()->find_and_remove(p_index, p_hash, name_h, class_loader, THREAD); |
0 | 1563 SystemDictionary_lock->notify_all(); |
1564 } | |
1565 } | |
1566 | |
1567 // Can't throw exception while holding lock due to rank ordering | |
1568 if (linkage_exception() != NULL) { | |
1569 THROW_OOP_(linkage_exception(), nh); // throws exception and returns | |
1570 } | |
1571 | |
1572 return k; | |
1573 } | |
1574 Handle SystemDictionary::compute_loader_lock_object(Handle class_loader, TRAPS) { | |
1575 // If class_loader is NULL we synchronize on _system_loader_lock_obj | |
1576 if (class_loader.is_null()) { | |
1577 return Handle(THREAD, _system_loader_lock_obj); | |
1578 } else { | |
1579 return class_loader; | |
1580 } | |
1581 } | |
1582 | |
1583 // This method is added to check how often we have to wait to grab loader | |
1584 // lock. The results are being recorded in the performance counters defined in | |
1585 // ClassLoader::_sync_systemLoaderLockContentionRate and | |
1586 // ClassLoader::_sync_nonSystemLoaderLockConteionRate. | |
1587 void SystemDictionary::check_loader_lock_contention(Handle loader_lock, TRAPS) { | |
1588 if (!UsePerfData) { | |
1589 return; | |
1590 } | |
1591 | |
1592 assert(!loader_lock.is_null(), "NULL lock object"); | |
1593 | |
1594 if (ObjectSynchronizer::query_lock_ownership((JavaThread*)THREAD, loader_lock) | |
1595 == ObjectSynchronizer::owner_other) { | |
1596 // contention will likely happen, so increment the corresponding | |
1597 // contention counter. | |
1598 if (loader_lock() == _system_loader_lock_obj) { | |
1599 ClassLoader::sync_systemLoaderLockContentionRate()->inc(); | |
1600 } else { | |
1601 ClassLoader::sync_nonSystemLoaderLockContentionRate()->inc(); | |
1602 } | |
1603 } | |
1604 } | |
1605 | |
1606 // ---------------------------------------------------------------------------- | |
1607 // Lookup | |
1608 | |
1609 klassOop SystemDictionary::find_class(int index, unsigned int hash, | |
1610 symbolHandle class_name, | |
1611 Handle class_loader) { | |
1612 assert_locked_or_safepoint(SystemDictionary_lock); | |
1613 assert (index == dictionary()->index_for(class_name, class_loader), | |
1614 "incorrect index?"); | |
1615 | |
1616 klassOop k = dictionary()->find_class(index, hash, class_name, class_loader); | |
1617 return k; | |
1618 } | |
1619 | |
1620 | |
1621 // Basic find on classes in the midst of being loaded | |
1622 symbolOop SystemDictionary::find_placeholder(int index, unsigned int hash, | |
1623 symbolHandle class_name, | |
1624 Handle class_loader) { | |
1625 assert_locked_or_safepoint(SystemDictionary_lock); | |
1626 | |
1627 return placeholders()->find_entry(index, hash, class_name, class_loader); | |
1628 } | |
1629 | |
1630 | |
1631 // Used for assertions and verification only | |
1632 oop SystemDictionary::find_class_or_placeholder(symbolHandle class_name, | |
1633 Handle class_loader) { | |
1634 #ifndef ASSERT | |
1635 guarantee(VerifyBeforeGC || | |
1636 VerifyDuringGC || | |
1637 VerifyBeforeExit || | |
1638 VerifyAfterGC, "too expensive"); | |
1639 #endif | |
1640 assert_locked_or_safepoint(SystemDictionary_lock); | |
1641 symbolOop class_name_ = class_name(); | |
1642 oop class_loader_ = class_loader(); | |
1643 | |
1644 // First look in the loaded class array | |
1645 unsigned int d_hash = dictionary()->compute_hash(class_name, class_loader); | |
1646 int d_index = dictionary()->hash_to_index(d_hash); | |
1647 oop lookup = find_class(d_index, d_hash, class_name, class_loader); | |
1648 | |
1649 if (lookup == NULL) { | |
1650 // Next try the placeholders | |
1651 unsigned int p_hash = placeholders()->compute_hash(class_name,class_loader); | |
1652 int p_index = placeholders()->hash_to_index(p_hash); | |
1653 lookup = find_placeholder(p_index, p_hash, class_name, class_loader); | |
1654 } | |
1655 | |
1656 return lookup; | |
1657 } | |
1658 | |
1659 | |
1660 // Get the next class in the diictionary. | |
1661 klassOop SystemDictionary::try_get_next_class() { | |
1662 return dictionary()->try_get_next_class(); | |
1663 } | |
1664 | |
1665 | |
1666 // ---------------------------------------------------------------------------- | |
1667 // Update hierachy. This is done before the new klass has been added to the SystemDictionary. The Recompile_lock | |
1668 // is held, to ensure that the compiler is not using the class hierachy, and that deoptimization will kick in | |
1669 // before a new class is used. | |
1670 | |
1671 void SystemDictionary::add_to_hierarchy(instanceKlassHandle k, TRAPS) { | |
1672 assert(k.not_null(), "just checking"); | |
1673 // Link into hierachy. Make sure the vtables are initialized before linking into | |
1674 k->append_to_sibling_list(); // add to superklass/sibling list | |
1675 k->process_interfaces(THREAD); // handle all "implements" declarations | |
1676 k->set_init_state(instanceKlass::loaded); | |
1677 // Now flush all code that depended on old class hierarchy. | |
1678 // Note: must be done *after* linking k into the hierarchy (was bug 12/9/97) | |
1679 // Also, first reinitialize vtable because it may have gotten out of synch | |
1680 // while the new class wasn't connected to the class hierarchy. | |
1681 Universe::flush_dependents_on(k); | |
1682 } | |
1683 | |
1684 | |
1685 // ---------------------------------------------------------------------------- | |
1686 // GC support | |
1687 | |
1688 // Following roots during mark-sweep is separated in two phases. | |
1689 // | |
1690 // The first phase follows preloaded classes and all other system | |
1691 // classes, since these will never get unloaded anyway. | |
1692 // | |
1693 // The second phase removes (unloads) unreachable classes from the | |
1694 // system dictionary and follows the remaining classes' contents. | |
1695 | |
1696 void SystemDictionary::always_strong_oops_do(OopClosure* blk) { | |
1697 // Follow preloaded classes/mirrors and system loader object | |
1698 blk->do_oop(&_java_system_loader); | |
1699 preloaded_oops_do(blk); | |
1700 always_strong_classes_do(blk); | |
1701 } | |
1702 | |
1703 | |
1704 void SystemDictionary::always_strong_classes_do(OopClosure* blk) { | |
1705 // Follow all system classes and temporary placeholders in dictionary | |
1706 dictionary()->always_strong_classes_do(blk); | |
1707 | |
1708 // Placeholders. These are *always* strong roots, as they | |
1709 // represent classes we're actively loading. | |
1710 placeholders_do(blk); | |
1711 | |
710 | 1712 // Visit extra methods |
1713 if (invoke_method_table() != NULL) | |
1714 invoke_method_table()->oops_do(blk); | |
1715 | |
0 | 1716 // Loader constraints. We must keep the symbolOop used in the name alive. |
1717 constraints()->always_strong_classes_do(blk); | |
1718 | |
1719 // Resolution errors keep the symbolOop for the error alive | |
1720 resolution_errors()->always_strong_classes_do(blk); | |
1721 } | |
1722 | |
1723 | |
1724 void SystemDictionary::placeholders_do(OopClosure* blk) { | |
1725 placeholders()->oops_do(blk); | |
1726 } | |
1727 | |
1728 | |
1729 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) { | |
1730 bool result = dictionary()->do_unloading(is_alive); | |
1731 constraints()->purge_loader_constraints(is_alive); | |
1732 resolution_errors()->purge_resolution_errors(is_alive); | |
1733 return result; | |
1734 } | |
1735 | |
1736 | |
1737 // The mirrors are scanned by shared_oops_do() which is | |
1738 // not called by oops_do(). In order to process oops in | |
1739 // a necessary order, shared_oops_do() is call by | |
1740 // Universe::oops_do(). | |
1741 void SystemDictionary::oops_do(OopClosure* f) { | |
1742 // Adjust preloaded classes and system loader object | |
1743 f->do_oop(&_java_system_loader); | |
1744 preloaded_oops_do(f); | |
1745 | |
1746 lazily_loaded_oops_do(f); | |
1747 | |
1748 // Adjust dictionary | |
1749 dictionary()->oops_do(f); | |
1750 | |
710 | 1751 // Visit extra methods |
1752 if (invoke_method_table() != NULL) | |
1753 invoke_method_table()->oops_do(f); | |
1754 | |
0 | 1755 // Partially loaded classes |
1756 placeholders()->oops_do(f); | |
1757 | |
1758 // Adjust constraint table | |
1759 constraints()->oops_do(f); | |
1760 | |
1761 // Adjust resolution error table | |
1762 resolution_errors()->oops_do(f); | |
1763 } | |
1764 | |
1765 | |
1766 void SystemDictionary::preloaded_oops_do(OopClosure* f) { | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1767 f->do_oop((oop*) &wk_klass_name_limits[0]); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1768 f->do_oop((oop*) &wk_klass_name_limits[1]); |
0 | 1769 |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1770 for (int k = (int)FIRST_WKID; k < (int)WKID_LIMIT; k++) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1771 f->do_oop((oop*) &_well_known_klasses[k]); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1772 } |
0 | 1773 |
1774 { | |
1775 for (int i = 0; i < T_VOID+1; i++) { | |
1776 if (_box_klasses[i] != NULL) { | |
1777 assert(i >= T_BOOLEAN, "checking"); | |
1778 f->do_oop((oop*) &_box_klasses[i]); | |
1779 } | |
1780 } | |
1781 } | |
1782 | |
1783 // The basic type mirrors would have already been processed in | |
1784 // Universe::oops_do(), via a call to shared_oops_do(), so should | |
1785 // not be processed again. | |
1786 | |
1787 f->do_oop((oop*) &_system_loader_lock_obj); | |
1788 FilteredFieldsMap::klasses_oops_do(f); | |
1789 } | |
1790 | |
1791 void SystemDictionary::lazily_loaded_oops_do(OopClosure* f) { | |
1792 f->do_oop((oop*) &_abstract_ownable_synchronizer_klass); | |
1793 } | |
1794 | |
1795 // Just the classes from defining class loaders | |
1796 // Don't iterate over placeholders | |
1797 void SystemDictionary::classes_do(void f(klassOop)) { | |
1798 dictionary()->classes_do(f); | |
1799 } | |
1800 | |
1801 // Added for initialize_itable_for_klass | |
1802 // Just the classes from defining class loaders | |
1803 // Don't iterate over placeholders | |
1804 void SystemDictionary::classes_do(void f(klassOop, TRAPS), TRAPS) { | |
1805 dictionary()->classes_do(f, CHECK); | |
1806 } | |
1807 | |
1808 // All classes, and their class loaders | |
1809 // Don't iterate over placeholders | |
1810 void SystemDictionary::classes_do(void f(klassOop, oop)) { | |
1811 dictionary()->classes_do(f); | |
1812 } | |
1813 | |
1814 // All classes, and their class loaders | |
1815 // (added for helpers that use HandleMarks and ResourceMarks) | |
1816 // Don't iterate over placeholders | |
1817 void SystemDictionary::classes_do(void f(klassOop, oop, TRAPS), TRAPS) { | |
1818 dictionary()->classes_do(f, CHECK); | |
1819 } | |
1820 | |
1821 void SystemDictionary::placeholders_do(void f(symbolOop, oop)) { | |
1822 placeholders()->entries_do(f); | |
1823 } | |
1824 | |
1825 void SystemDictionary::methods_do(void f(methodOop)) { | |
1826 dictionary()->methods_do(f); | |
710 | 1827 if (invoke_method_table() != NULL) |
1828 invoke_method_table()->methods_do(f); | |
0 | 1829 } |
1830 | |
1831 // ---------------------------------------------------------------------------- | |
1832 // Lazily load klasses | |
1833 | |
1834 void SystemDictionary::load_abstract_ownable_synchronizer_klass(TRAPS) { | |
1835 assert(JDK_Version::is_gte_jdk16x_version(), "Must be JDK 1.6 or later"); | |
1836 | |
1837 // if multiple threads calling this function, only one thread will load | |
1838 // the class. The other threads will find the loaded version once the | |
1839 // class is loaded. | |
1840 klassOop aos = _abstract_ownable_synchronizer_klass; | |
1841 if (aos == NULL) { | |
1842 klassOop k = resolve_or_fail(vmSymbolHandles::java_util_concurrent_locks_AbstractOwnableSynchronizer(), true, CHECK); | |
1843 // Force a fence to prevent any read before the write completes | |
1844 OrderAccess::fence(); | |
1845 _abstract_ownable_synchronizer_klass = k; | |
1846 } | |
1847 } | |
1848 | |
1849 // ---------------------------------------------------------------------------- | |
1850 // Initialization | |
1851 | |
1852 void SystemDictionary::initialize(TRAPS) { | |
1853 // Allocate arrays | |
1854 assert(dictionary() == NULL, | |
1855 "SystemDictionary should only be initialized once"); | |
1856 _dictionary = new Dictionary(_nof_buckets); | |
1857 _placeholders = new PlaceholderTable(_nof_buckets); | |
1858 _number_of_modifications = 0; | |
1859 _loader_constraints = new LoaderConstraintTable(_loader_constraint_size); | |
1860 _resolution_errors = new ResolutionErrorTable(_resolution_error_size); | |
710 | 1861 // _invoke_method_table is allocated lazily in find_method_handle_invoke() |
0 | 1862 |
1863 // Allocate private object used as system class loader lock | |
1864 _system_loader_lock_obj = oopFactory::new_system_objArray(0, CHECK); | |
1865 // Initialize basic classes | |
1866 initialize_preloaded_classes(CHECK); | |
1867 } | |
1868 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1869 // Compact table of directions on the initialization of klasses: |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1870 static const short wk_init_info[] = { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1871 #define WK_KLASS_INIT_INFO(name, symbol, option) \ |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1872 ( ((int)vmSymbols::VM_SYMBOL_ENUM_NAME(symbol) \ |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1873 << SystemDictionary::CEIL_LG_OPTION_LIMIT) \ |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1874 | (int)SystemDictionary::option ), |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1875 WK_KLASSES_DO(WK_KLASS_INIT_INFO) |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1876 #undef WK_KLASS_INIT_INFO |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1877 0 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1878 }; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1879 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1880 bool SystemDictionary::initialize_wk_klass(WKID id, int init_opt, TRAPS) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1881 assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob"); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1882 int info = wk_init_info[id - FIRST_WKID]; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1883 int sid = (info >> CEIL_LG_OPTION_LIMIT); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1884 symbolHandle symbol = vmSymbolHandles::symbol_handle_at((vmSymbols::SID)sid); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1885 klassOop* klassp = &_well_known_klasses[id]; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1886 bool must_load = (init_opt < SystemDictionary::Opt); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1887 bool try_load = true; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1888 if (init_opt == SystemDictionary::Opt_Kernel) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1889 #ifndef KERNEL |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1890 try_load = false; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1891 #endif //KERNEL |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1892 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1893 if ((*klassp) == NULL && try_load) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1894 if (must_load) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1895 (*klassp) = resolve_or_fail(symbol, true, CHECK_0); // load required class |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1896 } else { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1897 (*klassp) = resolve_or_null(symbol, CHECK_0); // load optional klass |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1898 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1899 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1900 return ((*klassp) != NULL); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1901 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1902 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1903 void SystemDictionary::initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1904 assert((int)start_id <= (int)limit_id, "IDs are out of order!"); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1905 for (int id = (int)start_id; id < (int)limit_id; id++) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1906 assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob"); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1907 int info = wk_init_info[id - FIRST_WKID]; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1908 int sid = (info >> CEIL_LG_OPTION_LIMIT); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1909 int opt = (info & right_n_bits(CEIL_LG_OPTION_LIMIT)); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1910 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1911 initialize_wk_klass((WKID)id, opt, CHECK); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1912 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1913 // Update limits, so find_well_known_klass can be very fast: |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1914 symbolOop s = vmSymbols::symbol_at((vmSymbols::SID)sid); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1915 if (wk_klass_name_limits[1] == NULL) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1916 wk_klass_name_limits[0] = wk_klass_name_limits[1] = s; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1917 } else if (wk_klass_name_limits[1] < s) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1918 wk_klass_name_limits[1] = s; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1919 } else if (wk_klass_name_limits[0] > s) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1920 wk_klass_name_limits[0] = s; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1921 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1922 } |
710 | 1923 |
1924 // move the starting value forward to the limit: | |
1925 start_id = limit_id; | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1926 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1927 |
0 | 1928 |
1929 void SystemDictionary::initialize_preloaded_classes(TRAPS) { | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1930 assert(WK_KLASS(object_klass) == NULL, "preloaded classes should only be initialized once"); |
0 | 1931 // Preload commonly used klasses |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1932 WKID scan = FIRST_WKID; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1933 // first do Object, String, Class |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1934 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(class_klass), scan, CHECK); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1935 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1936 debug_only(instanceKlass::verify_class_klass_nonstatic_oop_maps(WK_KLASS(class_klass))); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1937 |
0 | 1938 // Fixup mirrors for classes loaded before java.lang.Class. |
1939 // These calls iterate over the objects currently in the perm gen | |
1940 // so calling them at this point is matters (not before when there | |
1941 // are fewer objects and not later after there are more objects | |
1942 // in the perm gen. | |
1943 Universe::initialize_basic_type_mirrors(CHECK); | |
1944 Universe::fixup_mirrors(CHECK); | |
1945 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1946 // do a bunch more: |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1947 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(reference_klass), scan, CHECK); |
0 | 1948 |
1949 // Preload ref klasses and set reference types | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1950 instanceKlass::cast(WK_KLASS(reference_klass))->set_reference_type(REF_OTHER); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1951 instanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(reference_klass)); |
0 | 1952 |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1953 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(phantom_reference_klass), scan, CHECK); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1954 instanceKlass::cast(WK_KLASS(soft_reference_klass))->set_reference_type(REF_SOFT); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1955 instanceKlass::cast(WK_KLASS(weak_reference_klass))->set_reference_type(REF_WEAK); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1956 instanceKlass::cast(WK_KLASS(final_reference_klass))->set_reference_type(REF_FINAL); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1957 instanceKlass::cast(WK_KLASS(phantom_reference_klass))->set_reference_type(REF_PHANTOM); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1958 |
710 | 1959 WKID meth_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass); |
1960 WKID meth_group_end = WK_KLASS_ENUM_NAME(WrongMethodTypeException_klass); | |
1961 initialize_wk_klasses_until(meth_group_start, scan, CHECK); | |
1962 if (EnableMethodHandles) { | |
1963 initialize_wk_klasses_through(meth_group_start, scan, CHECK); | |
1964 } | |
1965 if (_well_known_klasses[meth_group_start] == NULL) { | |
1966 // Skip the rest of the method handle classes, if MethodHandle is not loaded. | |
1967 scan = WKID(meth_group_end+1); | |
1968 } | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1969 WKID indy_group_start = WK_KLASS_ENUM_NAME(Linkage_klass); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1970 WKID indy_group_end = WK_KLASS_ENUM_NAME(Dynamic_klass); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1971 initialize_wk_klasses_until(indy_group_start, scan, CHECK); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1972 if (EnableInvokeDynamic) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1973 initialize_wk_klasses_through(indy_group_start, scan, CHECK); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1974 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1975 if (_well_known_klasses[indy_group_start] == NULL) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1976 // Skip the rest of the dynamic typing classes, if Linkage is not loaded. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1977 scan = WKID(indy_group_end+1); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1978 } |
710 | 1979 |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1980 initialize_wk_klasses_until(WKID_LIMIT, scan, CHECK); |
0 | 1981 |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1982 _box_klasses[T_BOOLEAN] = WK_KLASS(boolean_klass); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1983 _box_klasses[T_CHAR] = WK_KLASS(char_klass); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1984 _box_klasses[T_FLOAT] = WK_KLASS(float_klass); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1985 _box_klasses[T_DOUBLE] = WK_KLASS(double_klass); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1986 _box_klasses[T_BYTE] = WK_KLASS(byte_klass); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1987 _box_klasses[T_SHORT] = WK_KLASS(short_klass); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1988 _box_klasses[T_INT] = WK_KLASS(int_klass); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1989 _box_klasses[T_LONG] = WK_KLASS(long_klass); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1990 //_box_klasses[T_OBJECT] = WK_KLASS(object_klass); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1991 //_box_klasses[T_ARRAY] = WK_KLASS(object_klass); |
0 | 1992 |
1993 #ifdef KERNEL | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
22
diff
changeset
|
1994 if (sun_jkernel_DownloadManager_klass() == NULL) { |
0 | 1995 warning("Cannot find sun/jkernel/DownloadManager"); |
1996 } | |
1997 #endif // KERNEL | |
514 | 1998 |
0 | 1999 { // Compute whether we should use loadClass or loadClassInternal when loading classes. |
2000 methodOop method = instanceKlass::cast(classloader_klass())->find_method(vmSymbols::loadClassInternal_name(), vmSymbols::string_class_signature()); | |
2001 _has_loadClassInternal = (method != NULL); | |
2002 } | |
2003 { // Compute whether we should use checkPackageAccess or NOT | |
2004 methodOop method = instanceKlass::cast(classloader_klass())->find_method(vmSymbols::checkPackageAccess_name(), vmSymbols::class_protectiondomain_signature()); | |
2005 _has_checkPackageAccess = (method != NULL); | |
2006 } | |
2007 } | |
2008 | |
2009 // Tells if a given klass is a box (wrapper class, such as java.lang.Integer). | |
2010 // If so, returns the basic type it holds. If not, returns T_OBJECT. | |
2011 BasicType SystemDictionary::box_klass_type(klassOop k) { | |
2012 assert(k != NULL, ""); | |
2013 for (int i = T_BOOLEAN; i < T_VOID+1; i++) { | |
2014 if (_box_klasses[i] == k) | |
2015 return (BasicType)i; | |
2016 } | |
2017 return T_OBJECT; | |
2018 } | |
2019 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2020 KlassHandle SystemDictionaryHandles::box_klass(BasicType t) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2021 if (t >= T_BOOLEAN && t <= T_VOID) |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2022 return KlassHandle(&SystemDictionary::_box_klasses[t], true); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2023 else |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2024 return KlassHandle(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2025 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2026 |
0 | 2027 // Constraints on class loaders. The details of the algorithm can be |
2028 // found in the OOPSLA'98 paper "Dynamic Class Loading in the Java | |
2029 // Virtual Machine" by Sheng Liang and Gilad Bracha. The basic idea is | |
2030 // that the system dictionary needs to maintain a set of contraints that | |
2031 // must be satisfied by all classes in the dictionary. | |
2032 // if defining is true, then LinkageError if already in systemDictionary | |
2033 // if initiating loader, then ok if instanceKlass matches existing entry | |
2034 | |
2035 void SystemDictionary::check_constraints(int d_index, unsigned int d_hash, | |
2036 instanceKlassHandle k, | |
2037 Handle class_loader, bool defining, | |
2038 TRAPS) { | |
2039 const char *linkage_error = NULL; | |
2040 { | |
2041 symbolHandle name (THREAD, k->name()); | |
2042 MutexLocker mu(SystemDictionary_lock, THREAD); | |
2043 | |
2044 klassOop check = find_class(d_index, d_hash, name, class_loader); | |
2045 if (check != (klassOop)NULL) { | |
2046 // if different instanceKlass - duplicate class definition, | |
2047 // else - ok, class loaded by a different thread in parallel, | |
2048 // we should only have found it if it was done loading and ok to use | |
2049 // system dictionary only holds instance classes, placeholders | |
2050 // also holds array classes | |
2051 | |
2052 assert(check->klass_part()->oop_is_instance(), "noninstance in systemdictionary"); | |
2053 if ((defining == true) || (k() != check)) { | |
2054 linkage_error = "loader (instance of %s): attempted duplicate class " | |
2055 "definition for name: \"%s\""; | |
2056 } else { | |
2057 return; | |
2058 } | |
2059 } | |
2060 | |
2061 #ifdef ASSERT | |
2062 unsigned int p_hash = placeholders()->compute_hash(name, class_loader); | |
2063 int p_index = placeholders()->hash_to_index(p_hash); | |
2064 symbolOop ph_check = find_placeholder(p_index, p_hash, name, class_loader); | |
2065 assert(ph_check == NULL || ph_check == name(), "invalid symbol"); | |
2066 #endif | |
2067 | |
2068 if (linkage_error == NULL) { | |
2069 if (constraints()->check_or_update(k, class_loader, name) == false) { | |
2070 linkage_error = "loader constraint violation: loader (instance of %s)" | |
2071 " previously initiated loading for a different type with name \"%s\""; | |
2072 } | |
2073 } | |
2074 } | |
2075 | |
2076 // Throw error now if needed (cannot throw while holding | |
2077 // SystemDictionary_lock because of rank ordering) | |
2078 | |
2079 if (linkage_error) { | |
2080 ResourceMark rm(THREAD); | |
2081 const char* class_loader_name = loader_name(class_loader()); | |
2082 char* type_name = k->name()->as_C_string(); | |
2083 size_t buflen = strlen(linkage_error) + strlen(class_loader_name) + | |
2084 strlen(type_name); | |
2085 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); | |
2086 jio_snprintf(buf, buflen, linkage_error, class_loader_name, type_name); | |
2087 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); | |
2088 } | |
2089 } | |
2090 | |
2091 | |
2092 // Update system dictionary - done after check_constraint and add_to_hierachy | |
2093 // have been called. | |
2094 void SystemDictionary::update_dictionary(int d_index, unsigned int d_hash, | |
2095 int p_index, unsigned int p_hash, | |
2096 instanceKlassHandle k, | |
2097 Handle class_loader, | |
2098 TRAPS) { | |
2099 // Compile_lock prevents systemDictionary updates during compilations | |
2100 assert_locked_or_safepoint(Compile_lock); | |
2101 symbolHandle name (THREAD, k->name()); | |
2102 | |
2103 { | |
2104 MutexLocker mu1(SystemDictionary_lock, THREAD); | |
2105 | |
2106 // See whether biased locking is enabled and if so set it for this | |
2107 // klass. | |
2108 // Note that this must be done past the last potential blocking | |
2109 // point / safepoint. We enable biased locking lazily using a | |
2110 // VM_Operation to iterate the SystemDictionary and installing the | |
2111 // biasable mark word into each instanceKlass's prototype header. | |
2112 // To avoid race conditions where we accidentally miss enabling the | |
2113 // optimization for one class in the process of being added to the | |
2114 // dictionary, we must not safepoint after the test of | |
2115 // BiasedLocking::enabled(). | |
2116 if (UseBiasedLocking && BiasedLocking::enabled()) { | |
2117 // Set biased locking bit for all loaded classes; it will be | |
2118 // cleared if revocation occurs too often for this type | |
2119 // NOTE that we must only do this when the class is initally | |
2120 // defined, not each time it is referenced from a new class loader | |
2121 if (k->class_loader() == class_loader()) { | |
2122 k->set_prototype_header(markOopDesc::biased_locking_prototype()); | |
2123 } | |
2124 } | |
2125 | |
2126 // Check for a placeholder. If there, remove it and make a | |
2127 // new system dictionary entry. | |
2128 placeholders()->find_and_remove(p_index, p_hash, name, class_loader, THREAD); | |
2129 klassOop sd_check = find_class(d_index, d_hash, name, class_loader); | |
2130 if (sd_check == NULL) { | |
2131 dictionary()->add_klass(name, class_loader, k); | |
2132 notice_modification(); | |
2133 } | |
2134 #ifdef ASSERT | |
2135 sd_check = find_class(d_index, d_hash, name, class_loader); | |
2136 assert (sd_check != NULL, "should have entry in system dictionary"); | |
2137 // Changed to allow PH to remain to complete class circularity checking | |
2138 // while only one thread can define a class at one time, multiple | |
2139 // classes can resolve the superclass for a class at one time, | |
2140 // and the placeholder is used to track that | |
2141 // symbolOop ph_check = find_placeholder(p_index, p_hash, name, class_loader); | |
2142 // assert (ph_check == NULL, "should not have a placeholder entry"); | |
2143 #endif | |
2144 SystemDictionary_lock->notify_all(); | |
2145 } | |
2146 } | |
2147 | |
2148 | |
2149 klassOop SystemDictionary::find_constrained_instance_or_array_klass( | |
2150 symbolHandle class_name, Handle class_loader, TRAPS) { | |
2151 | |
2152 // First see if it has been loaded directly. | |
2153 // Force the protection domain to be null. (This removes protection checks.) | |
2154 Handle no_protection_domain; | |
2155 klassOop klass = find_instance_or_array_klass(class_name, class_loader, | |
2156 no_protection_domain, CHECK_NULL); | |
2157 if (klass != NULL) | |
2158 return klass; | |
2159 | |
2160 // Now look to see if it has been loaded elsewhere, and is subject to | |
2161 // a loader constraint that would require this loader to return the | |
2162 // klass that is already loaded. | |
2163 if (FieldType::is_array(class_name())) { | |
2164 // Array classes are hard because their klassOops are not kept in the | |
2165 // constraint table. The array klass may be constrained, but the elem class | |
2166 // may not be. | |
2167 jint dimension; | |
2168 symbolOop object_key; | |
2169 BasicType t = FieldType::get_array_info(class_name(), &dimension, | |
2170 &object_key, CHECK_(NULL)); | |
2171 if (t != T_OBJECT) { | |
2172 klass = Universe::typeArrayKlassObj(t); | |
2173 } else { | |
2174 symbolHandle elem_name(THREAD, object_key); | |
2175 MutexLocker mu(SystemDictionary_lock, THREAD); | |
2176 klass = constraints()->find_constrained_elem_klass(class_name, elem_name, class_loader, THREAD); | |
2177 } | |
2178 if (klass != NULL) { | |
2179 klass = Klass::cast(klass)->array_klass_or_null(dimension); | |
2180 } | |
2181 } else { | |
2182 MutexLocker mu(SystemDictionary_lock, THREAD); | |
2183 // Non-array classes are easy: simply check the constraint table. | |
2184 klass = constraints()->find_constrained_klass(class_name, class_loader); | |
2185 } | |
2186 | |
2187 return klass; | |
2188 } | |
2189 | |
2190 | |
2191 bool SystemDictionary::add_loader_constraint(symbolHandle class_name, | |
2192 Handle class_loader1, | |
2193 Handle class_loader2, | |
2194 Thread* THREAD) { | |
2195 unsigned int d_hash1 = dictionary()->compute_hash(class_name, class_loader1); | |
2196 int d_index1 = dictionary()->hash_to_index(d_hash1); | |
2197 | |
2198 unsigned int d_hash2 = dictionary()->compute_hash(class_name, class_loader2); | |
2199 int d_index2 = dictionary()->hash_to_index(d_hash2); | |
2200 | |
2201 { | |
2202 MutexLocker mu_s(SystemDictionary_lock, THREAD); | |
2203 | |
2204 // Better never do a GC while we're holding these oops | |
2205 No_Safepoint_Verifier nosafepoint; | |
2206 | |
2207 klassOop klass1 = find_class(d_index1, d_hash1, class_name, class_loader1); | |
2208 klassOop klass2 = find_class(d_index2, d_hash2, class_name, class_loader2); | |
2209 return constraints()->add_entry(class_name, klass1, class_loader1, | |
2210 klass2, class_loader2); | |
2211 } | |
2212 } | |
2213 | |
2214 // Add entry to resolution error table to record the error when the first | |
2215 // attempt to resolve a reference to a class has failed. | |
2216 void SystemDictionary::add_resolution_error(constantPoolHandle pool, int which, symbolHandle error) { | |
2217 unsigned int hash = resolution_errors()->compute_hash(pool, which); | |
2218 int index = resolution_errors()->hash_to_index(hash); | |
2219 { | |
2220 MutexLocker ml(SystemDictionary_lock, Thread::current()); | |
2221 resolution_errors()->add_entry(index, hash, pool, which, error); | |
2222 } | |
2223 } | |
2224 | |
2225 // Lookup resolution error table. Returns error if found, otherwise NULL. | |
2226 symbolOop SystemDictionary::find_resolution_error(constantPoolHandle pool, int which) { | |
2227 unsigned int hash = resolution_errors()->compute_hash(pool, which); | |
2228 int index = resolution_errors()->hash_to_index(hash); | |
2229 { | |
2230 MutexLocker ml(SystemDictionary_lock, Thread::current()); | |
2231 ResolutionErrorEntry* entry = resolution_errors()->find_entry(index, hash, pool, which); | |
2232 return (entry != NULL) ? entry->error() : (symbolOop)NULL; | |
2233 } | |
2234 } | |
2235 | |
2236 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2237 // Signature constraints ensure that callers and callees agree about |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2238 // the meaning of type names in their signatures. This routine is the |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2239 // intake for constraints. It collects them from several places: |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2240 // |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2241 // * LinkResolver::resolve_method (if check_access is true) requires |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2242 // that the resolving class (the caller) and the defining class of |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2243 // the resolved method (the callee) agree on each type in the |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2244 // method's signature. |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2245 // |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2246 // * LinkResolver::resolve_interface_method performs exactly the same |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2247 // checks. |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2248 // |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2249 // * LinkResolver::resolve_field requires that the constant pool |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2250 // attempting to link to a field agree with the field's defining |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2251 // class about the type of the field signature. |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2252 // |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2253 // * klassVtable::initialize_vtable requires that, when a class |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2254 // overrides a vtable entry allocated by a superclass, that the |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2255 // overriding method (i.e., the callee) agree with the superclass |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2256 // on each type in the method's signature. |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2257 // |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2258 // * klassItable::initialize_itable requires that, when a class fills |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2259 // in its itables, for each non-abstract method installed in an |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2260 // itable, the method (i.e., the callee) agree with the interface |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2261 // on each type in the method's signature. |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2262 // |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2263 // All those methods have a boolean (check_access, checkconstraints) |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2264 // which turns off the checks. This is used from specialized contexts |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2265 // such as bootstrapping, dumping, and debugging. |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2266 // |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2267 // No direct constraint is placed between the class and its |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2268 // supertypes. Constraints are only placed along linked relations |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2269 // between callers and callees. When a method overrides or implements |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2270 // an abstract method in a supertype (superclass or interface), the |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2271 // constraints are placed as if the supertype were the caller to the |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2272 // overriding method. (This works well, since callers to the |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2273 // supertype have already established agreement between themselves and |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2274 // the supertype.) As a result of all this, a class can disagree with |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2275 // its supertype about the meaning of a type name, as long as that |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2276 // class neither calls a relevant method of the supertype, nor is |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2277 // called (perhaps via an override) from the supertype. |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2278 // |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2279 // |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2280 // SystemDictionary::check_signature_loaders(sig, l1, l2) |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2281 // |
0 | 2282 // Make sure all class components (including arrays) in the given |
2283 // signature will be resolved to the same class in both loaders. | |
2284 // Returns the name of the type that failed a loader constraint check, or | |
2285 // NULL if no constraint failed. The returned C string needs cleaning up | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2286 // with a ResourceMark in the caller. No exception except OOME is thrown. |
0 | 2287 char* SystemDictionary::check_signature_loaders(symbolHandle signature, |
2288 Handle loader1, Handle loader2, | |
2289 bool is_method, TRAPS) { | |
2290 // Nothing to do if loaders are the same. | |
2291 if (loader1() == loader2()) { | |
2292 return NULL; | |
2293 } | |
2294 | |
2295 SignatureStream sig_strm(signature, is_method); | |
2296 while (!sig_strm.is_done()) { | |
2297 if (sig_strm.is_object()) { | |
2298 symbolOop s = sig_strm.as_symbol(CHECK_NULL); | |
2299 symbolHandle sig (THREAD, s); | |
2300 if (!add_loader_constraint(sig, loader1, loader2, THREAD)) { | |
2301 return sig()->as_C_string(); | |
2302 } | |
2303 } | |
2304 sig_strm.next(); | |
2305 } | |
2306 return NULL; | |
2307 } | |
2308 | |
2309 | |
710 | 2310 methodOop SystemDictionary::find_method_handle_invoke(symbolHandle signature, |
2311 Handle class_loader, | |
2312 Handle protection_domain, | |
2313 TRAPS) { | |
2314 if (!EnableMethodHandles) return NULL; | |
2315 assert(class_loader.is_null() && protection_domain.is_null(), | |
2316 "cannot load specialized versions of MethodHandle.invoke"); | |
2317 if (invoke_method_table() == NULL) { | |
2318 // create this side table lazily | |
2319 _invoke_method_table = new SymbolPropertyTable(_invoke_method_size); | |
2320 } | |
2321 unsigned int hash = invoke_method_table()->compute_hash(signature); | |
2322 int index = invoke_method_table()->hash_to_index(hash); | |
2323 SymbolPropertyEntry* spe = invoke_method_table()->find_entry(index, hash, signature); | |
2324 if (spe == NULL || spe->property_oop() == NULL) { | |
2325 // Must create lots of stuff here, but outside of the SystemDictionary lock. | |
2326 Handle mt = compute_method_handle_type(signature(), | |
2327 class_loader, protection_domain, | |
2328 CHECK_NULL); | |
2329 KlassHandle mh_klass = SystemDictionaryHandles::MethodHandle_klass(); | |
2330 methodHandle m = methodOopDesc::make_invoke_method(mh_klass, signature, | |
2331 mt, CHECK_NULL); | |
2332 // Now grab the lock. We might have to throw away the new method, | |
2333 // if a racing thread has managed to install one at the same time. | |
2334 { | |
2335 MutexLocker ml(SystemDictionary_lock, Thread::current()); | |
2336 spe = invoke_method_table()->find_entry(index, hash, signature); | |
2337 if (spe == NULL) | |
2338 spe = invoke_method_table()->add_entry(index, hash, signature); | |
2339 if (spe->property_oop() == NULL) | |
2340 spe->set_property_oop(m()); | |
2341 } | |
2342 } | |
2343 methodOop m = (methodOop) spe->property_oop(); | |
2344 assert(m->is_method(), ""); | |
2345 return m; | |
2346 } | |
2347 | |
2348 // Ask Java code to find or construct a java.dyn.MethodType for the given | |
2349 // signature, as interpreted relative to the given class loader. | |
2350 // Because of class loader constraints, all method handle usage must be | |
2351 // consistent with this loader. | |
2352 Handle SystemDictionary::compute_method_handle_type(symbolHandle signature, | |
2353 Handle class_loader, | |
2354 Handle protection_domain, | |
2355 TRAPS) { | |
2356 Handle empty; | |
2357 int npts = ArgumentCount(signature()).size(); | |
2358 objArrayHandle pts = oopFactory::new_objArray(SystemDictionary::class_klass(), npts, CHECK_(empty)); | |
2359 int arg = 0; | |
2360 Handle rt; // the return type from the signature | |
2361 for (SignatureStream ss(signature()); !ss.is_done(); ss.next()) { | |
2362 oop mirror; | |
2363 if (!ss.is_object()) { | |
2364 mirror = Universe::java_mirror(ss.type()); | |
2365 } else { | |
2366 symbolOop name_oop = ss.as_symbol(CHECK_(empty)); | |
2367 symbolHandle name(THREAD, name_oop); | |
2368 klassOop klass = resolve_or_fail(name, | |
2369 class_loader, protection_domain, | |
2370 true, CHECK_(empty)); | |
2371 mirror = Klass::cast(klass)->java_mirror(); | |
2372 } | |
2373 if (ss.at_return_type()) | |
2374 rt = Handle(THREAD, mirror); | |
2375 else | |
2376 pts->obj_at_put(arg++, mirror); | |
2377 } | |
2378 assert(arg == npts, ""); | |
2379 | |
2380 // call MethodType java.dyn.MethodType::makeImpl(Class rt, Class[] pts, false, true) | |
2381 bool varargs = false, trusted = true; | |
2382 JavaCallArguments args(Handle(THREAD, rt())); | |
2383 args.push_oop(pts()); | |
2384 args.push_int(false); | |
2385 args.push_int(trusted); | |
2386 JavaValue result(T_OBJECT); | |
2387 JavaCalls::call_static(&result, | |
2388 SystemDictionary::MethodType_klass(), | |
2389 vmSymbols::makeImpl_name(), vmSymbols::makeImpl_signature(), | |
2390 &args, CHECK_(empty)); | |
2391 return Handle(THREAD, (oop) result.get_jobject()); | |
2392 } | |
2393 | |
2394 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2395 // Ask Java code to find or construct a java.dyn.CallSite for the given |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2396 // name and signature, as interpreted relative to the given class loader. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2397 Handle SystemDictionary::make_dynamic_call_site(KlassHandle caller, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2398 int caller_method_idnum, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2399 int caller_bci, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2400 symbolHandle name, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2401 methodHandle mh_invdyn, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2402 TRAPS) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2403 Handle empty; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2404 // call sun.dyn.CallSiteImpl::makeSite(caller, name, mtype, cmid, cbci) |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2405 oop name_str_oop = StringTable::intern(name(), CHECK_(empty)); // not a handle! |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2406 JavaCallArguments args(Handle(THREAD, caller->java_mirror())); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2407 args.push_oop(name_str_oop); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2408 args.push_oop(mh_invdyn->method_handle_type()); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2409 args.push_int(caller_method_idnum); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2410 args.push_int(caller_bci); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2411 JavaValue result(T_OBJECT); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2412 JavaCalls::call_static(&result, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2413 SystemDictionary::CallSiteImpl_klass(), |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2414 vmSymbols::makeSite_name(), vmSymbols::makeSite_signature(), |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2415 &args, CHECK_(empty)); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2416 oop call_site_oop = (oop) result.get_jobject(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2417 sun_dyn_CallSiteImpl::set_vmmethod(call_site_oop, mh_invdyn()); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2418 if (TraceMethodHandles) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2419 tty->print_cr("Linked invokedynamic bci=%d site="INTPTR_FORMAT":", caller_bci, call_site_oop); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2420 call_site_oop->print(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2421 tty->cr(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2422 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2423 return call_site_oop; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2424 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2425 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2426 Handle SystemDictionary::find_bootstrap_method(KlassHandle caller, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2427 KlassHandle search_bootstrap_klass, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2428 TRAPS) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2429 Handle empty; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2430 if (!caller->oop_is_instance()) return empty; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2431 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2432 instanceKlassHandle ik(THREAD, caller()); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2433 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2434 if (ik->bootstrap_method() != NULL) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2435 return Handle(THREAD, ik->bootstrap_method()); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2436 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2437 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2438 // call java.dyn.Linkage::findBootstrapMethod(caller, sbk) |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2439 JavaCallArguments args(Handle(THREAD, ik->java_mirror())); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2440 if (search_bootstrap_klass.is_null()) |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2441 args.push_oop(Handle()); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2442 else |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2443 args.push_oop(search_bootstrap_klass->java_mirror()); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2444 JavaValue result(T_OBJECT); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2445 JavaCalls::call_static(&result, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2446 SystemDictionary::Linkage_klass(), |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2447 vmSymbols::findBootstrapMethod_name(), |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2448 vmSymbols::findBootstrapMethod_signature(), |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2449 &args, CHECK_(empty)); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2450 oop boot_method_oop = (oop) result.get_jobject(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2451 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2452 if (boot_method_oop != NULL) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2453 // probably no race conditions, but let's be careful: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2454 if (Atomic::cmpxchg_ptr(boot_method_oop, ik->adr_bootstrap_method(), NULL) == NULL) |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2455 ik->set_bootstrap_method(boot_method_oop); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2456 else |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2457 boot_method_oop = ik->bootstrap_method(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2458 } else { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2459 boot_method_oop = ik->bootstrap_method(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2460 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2461 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2462 return Handle(THREAD, boot_method_oop); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2463 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
2464 |
0 | 2465 // Since the identity hash code for symbols changes when the symbols are |
2466 // moved from the regular perm gen (hash in the mark word) to the shared | |
2467 // spaces (hash is the address), the classes loaded into the dictionary | |
2468 // may be in the wrong buckets. | |
2469 | |
2470 void SystemDictionary::reorder_dictionary() { | |
2471 dictionary()->reorder_dictionary(); | |
2472 } | |
2473 | |
2474 | |
2475 void SystemDictionary::copy_buckets(char** top, char* end) { | |
2476 dictionary()->copy_buckets(top, end); | |
2477 } | |
2478 | |
2479 | |
2480 void SystemDictionary::copy_table(char** top, char* end) { | |
2481 dictionary()->copy_table(top, end); | |
2482 } | |
2483 | |
2484 | |
2485 void SystemDictionary::reverse() { | |
2486 dictionary()->reverse(); | |
2487 } | |
2488 | |
2489 int SystemDictionary::number_of_classes() { | |
2490 return dictionary()->number_of_entries(); | |
2491 } | |
2492 | |
2493 | |
2494 // ---------------------------------------------------------------------------- | |
2495 #ifndef PRODUCT | |
2496 | |
2497 void SystemDictionary::print() { | |
2498 dictionary()->print(); | |
2499 | |
2500 // Placeholders | |
2501 GCMutexLocker mu(SystemDictionary_lock); | |
2502 placeholders()->print(); | |
2503 | |
2504 // loader constraints - print under SD_lock | |
2505 constraints()->print(); | |
2506 } | |
2507 | |
2508 #endif | |
2509 | |
2510 void SystemDictionary::verify() { | |
2511 guarantee(dictionary() != NULL, "Verify of system dictionary failed"); | |
2512 guarantee(constraints() != NULL, | |
2513 "Verify of loader constraints failed"); | |
2514 guarantee(dictionary()->number_of_entries() >= 0 && | |
2515 placeholders()->number_of_entries() >= 0, | |
2516 "Verify of system dictionary failed"); | |
2517 | |
2518 // Verify dictionary | |
2519 dictionary()->verify(); | |
2520 | |
2521 GCMutexLocker mu(SystemDictionary_lock); | |
2522 placeholders()->verify(); | |
2523 | |
2524 // Verify constraint table | |
2525 guarantee(constraints() != NULL, "Verify of loader constraints failed"); | |
2526 constraints()->verify(dictionary()); | |
2527 } | |
2528 | |
2529 | |
2530 void SystemDictionary::verify_obj_klass_present(Handle obj, | |
2531 symbolHandle class_name, | |
2532 Handle class_loader) { | |
2533 GCMutexLocker mu(SystemDictionary_lock); | |
2534 oop probe = find_class_or_placeholder(class_name, class_loader); | |
2535 if (probe == NULL) { | |
2536 probe = SystemDictionary::find_shared_class(class_name); | |
2537 } | |
2538 guarantee(probe != NULL && | |
2539 (!probe->is_klass() || probe == obj()), | |
2540 "Loaded klasses should be in SystemDictionary"); | |
2541 } | |
2542 | |
2543 #ifndef PRODUCT | |
2544 | |
2545 // statistics code | |
2546 class ClassStatistics: AllStatic { | |
2547 private: | |
2548 static int nclasses; // number of classes | |
2549 static int nmethods; // number of methods | |
2550 static int nmethoddata; // number of methodData | |
2551 static int class_size; // size of class objects in words | |
2552 static int method_size; // size of method objects in words | |
2553 static int debug_size; // size of debug info in methods | |
2554 static int methoddata_size; // size of methodData objects in words | |
2555 | |
2556 static void do_class(klassOop k) { | |
2557 nclasses++; | |
2558 class_size += k->size(); | |
2559 if (k->klass_part()->oop_is_instance()) { | |
2560 instanceKlass* ik = (instanceKlass*)k->klass_part(); | |
2561 class_size += ik->methods()->size(); | |
2562 class_size += ik->constants()->size(); | |
2563 class_size += ik->local_interfaces()->size(); | |
2564 class_size += ik->transitive_interfaces()->size(); | |
2565 // We do not have to count implementors, since we only store one! | |
2566 class_size += ik->fields()->size(); | |
2567 } | |
2568 } | |
2569 | |
2570 static void do_method(methodOop m) { | |
2571 nmethods++; | |
2572 method_size += m->size(); | |
2573 // class loader uses same objArray for empty vectors, so don't count these | |
2574 if (m->exception_table()->length() != 0) method_size += m->exception_table()->size(); | |
2575 if (m->has_stackmap_table()) { | |
2576 method_size += m->stackmap_data()->size(); | |
2577 } | |
2578 | |
2579 methodDataOop mdo = m->method_data(); | |
2580 if (mdo != NULL) { | |
2581 nmethoddata++; | |
2582 methoddata_size += mdo->size(); | |
2583 } | |
2584 } | |
2585 | |
2586 public: | |
2587 static void print() { | |
2588 SystemDictionary::classes_do(do_class); | |
2589 SystemDictionary::methods_do(do_method); | |
2590 tty->print_cr("Class statistics:"); | |
2591 tty->print_cr("%d classes (%d bytes)", nclasses, class_size * oopSize); | |
2592 tty->print_cr("%d methods (%d bytes = %d base + %d debug info)", nmethods, | |
2593 (method_size + debug_size) * oopSize, method_size * oopSize, debug_size * oopSize); | |
2594 tty->print_cr("%d methoddata (%d bytes)", nmethoddata, methoddata_size * oopSize); | |
2595 } | |
2596 }; | |
2597 | |
2598 | |
2599 int ClassStatistics::nclasses = 0; | |
2600 int ClassStatistics::nmethods = 0; | |
2601 int ClassStatistics::nmethoddata = 0; | |
2602 int ClassStatistics::class_size = 0; | |
2603 int ClassStatistics::method_size = 0; | |
2604 int ClassStatistics::debug_size = 0; | |
2605 int ClassStatistics::methoddata_size = 0; | |
2606 | |
2607 void SystemDictionary::print_class_statistics() { | |
2608 ResourceMark rm; | |
2609 ClassStatistics::print(); | |
2610 } | |
2611 | |
2612 | |
2613 class MethodStatistics: AllStatic { | |
2614 public: | |
2615 enum { | |
2616 max_parameter_size = 10 | |
2617 }; | |
2618 private: | |
2619 | |
2620 static int _number_of_methods; | |
2621 static int _number_of_final_methods; | |
2622 static int _number_of_static_methods; | |
2623 static int _number_of_native_methods; | |
2624 static int _number_of_synchronized_methods; | |
2625 static int _number_of_profiled_methods; | |
2626 static int _number_of_bytecodes; | |
2627 static int _parameter_size_profile[max_parameter_size]; | |
2628 static int _bytecodes_profile[Bytecodes::number_of_java_codes]; | |
2629 | |
2630 static void initialize() { | |
2631 _number_of_methods = 0; | |
2632 _number_of_final_methods = 0; | |
2633 _number_of_static_methods = 0; | |
2634 _number_of_native_methods = 0; | |
2635 _number_of_synchronized_methods = 0; | |
2636 _number_of_profiled_methods = 0; | |
2637 _number_of_bytecodes = 0; | |
2638 for (int i = 0; i < max_parameter_size ; i++) _parameter_size_profile[i] = 0; | |
2639 for (int j = 0; j < Bytecodes::number_of_java_codes; j++) _bytecodes_profile [j] = 0; | |
2640 }; | |
2641 | |
2642 static void do_method(methodOop m) { | |
2643 _number_of_methods++; | |
2644 // collect flag info | |
2645 if (m->is_final() ) _number_of_final_methods++; | |
2646 if (m->is_static() ) _number_of_static_methods++; | |
2647 if (m->is_native() ) _number_of_native_methods++; | |
2648 if (m->is_synchronized()) _number_of_synchronized_methods++; | |
2649 if (m->method_data() != NULL) _number_of_profiled_methods++; | |
2650 // collect parameter size info (add one for receiver, if any) | |
2651 _parameter_size_profile[MIN2(m->size_of_parameters() + (m->is_static() ? 0 : 1), max_parameter_size - 1)]++; | |
2652 // collect bytecodes info | |
2653 { | |
2654 Thread *thread = Thread::current(); | |
2655 HandleMark hm(thread); | |
2656 BytecodeStream s(methodHandle(thread, m)); | |
2657 Bytecodes::Code c; | |
2658 while ((c = s.next()) >= 0) { | |
2659 _number_of_bytecodes++; | |
2660 _bytecodes_profile[c]++; | |
2661 } | |
2662 } | |
2663 } | |
2664 | |
2665 public: | |
2666 static void print() { | |
2667 initialize(); | |
2668 SystemDictionary::methods_do(do_method); | |
2669 // generate output | |
2670 tty->cr(); | |
2671 tty->print_cr("Method statistics (static):"); | |
2672 // flag distribution | |
2673 tty->cr(); | |
2674 tty->print_cr("%6d final methods %6.1f%%", _number_of_final_methods , _number_of_final_methods * 100.0F / _number_of_methods); | |
2675 tty->print_cr("%6d static methods %6.1f%%", _number_of_static_methods , _number_of_static_methods * 100.0F / _number_of_methods); | |
2676 tty->print_cr("%6d native methods %6.1f%%", _number_of_native_methods , _number_of_native_methods * 100.0F / _number_of_methods); | |
2677 tty->print_cr("%6d synchronized methods %6.1f%%", _number_of_synchronized_methods, _number_of_synchronized_methods * 100.0F / _number_of_methods); | |
2678 tty->print_cr("%6d profiled methods %6.1f%%", _number_of_profiled_methods, _number_of_profiled_methods * 100.0F / _number_of_methods); | |
2679 // parameter size profile | |
2680 tty->cr(); | |
2681 { int tot = 0; | |
2682 int avg = 0; | |
2683 for (int i = 0; i < max_parameter_size; i++) { | |
2684 int n = _parameter_size_profile[i]; | |
2685 tot += n; | |
2686 avg += n*i; | |
2687 tty->print_cr("parameter size = %1d: %6d methods %5.1f%%", i, n, n * 100.0F / _number_of_methods); | |
2688 } | |
2689 assert(tot == _number_of_methods, "should be the same"); | |
2690 tty->print_cr(" %6d methods 100.0%%", _number_of_methods); | |
2691 tty->print_cr("(average parameter size = %3.1f including receiver, if any)", (float)avg / _number_of_methods); | |
2692 } | |
2693 // bytecodes profile | |
2694 tty->cr(); | |
2695 { int tot = 0; | |
2696 for (int i = 0; i < Bytecodes::number_of_java_codes; i++) { | |
2697 if (Bytecodes::is_defined(i)) { | |
2698 Bytecodes::Code c = Bytecodes::cast(i); | |
2699 int n = _bytecodes_profile[c]; | |
2700 tot += n; | |
2701 tty->print_cr("%9d %7.3f%% %s", n, n * 100.0F / _number_of_bytecodes, Bytecodes::name(c)); | |
2702 } | |
2703 } | |
2704 assert(tot == _number_of_bytecodes, "should be the same"); | |
2705 tty->print_cr("%9d 100.000%%", _number_of_bytecodes); | |
2706 } | |
2707 tty->cr(); | |
2708 } | |
2709 }; | |
2710 | |
2711 int MethodStatistics::_number_of_methods; | |
2712 int MethodStatistics::_number_of_final_methods; | |
2713 int MethodStatistics::_number_of_static_methods; | |
2714 int MethodStatistics::_number_of_native_methods; | |
2715 int MethodStatistics::_number_of_synchronized_methods; | |
2716 int MethodStatistics::_number_of_profiled_methods; | |
2717 int MethodStatistics::_number_of_bytecodes; | |
2718 int MethodStatistics::_parameter_size_profile[MethodStatistics::max_parameter_size]; | |
2719 int MethodStatistics::_bytecodes_profile[Bytecodes::number_of_java_codes]; | |
2720 | |
2721 | |
2722 void SystemDictionary::print_method_statistics() { | |
2723 MethodStatistics::print(); | |
2724 } | |
2725 | |
2726 #endif // PRODUCT |