209 // All of these should have been reverted back to ClassIndex before calling
210 // this function.
211 ShouldNotReachHere();
212 #endif
213 }
214 }
215 allocate_resolved_klasses(loader_data, num_klasses, THREAD);
216 }
217
218 // Anonymous class support:
219 void ConstantPool::klass_at_put(int class_index, int name_index, int resolved_klass_index, Klass* k, Symbol* name) {
220 assert(is_within_bounds(class_index), "index out of bounds");
221 assert(is_within_bounds(name_index), "index out of bounds");
222 assert((resolved_klass_index & 0xffff0000) == 0, "must be");
223 *int_at_addr(class_index) =
224 build_int_from_shorts((jushort)resolved_klass_index, (jushort)name_index);
225
226 symbol_at_put(name_index, name);
227 name->increment_refcount();
228 Klass** adr = resolved_klasses()->adr_at(resolved_klass_index);
229 OrderAccess::release_store_ptr((Klass* volatile *)adr, k);
230
231 // The interpreter assumes when the tag is stored, the klass is resolved
232 // and the Klass* non-NULL, so we need hardware store ordering here.
233 if (k != NULL) {
234 release_tag_at_put(class_index, JVM_CONSTANT_Class);
235 } else {
236 release_tag_at_put(class_index, JVM_CONSTANT_UnresolvedClass);
237 }
238 }
239
240 // Anonymous class support:
241 void ConstantPool::klass_at_put(int class_index, Klass* k) {
242 assert(k != NULL, "must be valid klass");
243 CPKlassSlot kslot = klass_slot_at(class_index);
244 int resolved_klass_index = kslot.resolved_klass_index();
245 Klass** adr = resolved_klasses()->adr_at(resolved_klass_index);
246 OrderAccess::release_store_ptr((Klass* volatile *)adr, k);
247
248 // The interpreter assumes when the tag is stored, the klass is resolved
249 // and the Klass* non-NULL, so we need hardware store ordering here.
250 release_tag_at_put(class_index, JVM_CONSTANT_Class);
251 }
252
253 #if INCLUDE_CDS_JAVA_HEAP
254 // Archive the resolved references
255 void ConstantPool::archive_resolved_references(Thread* THREAD) {
256 if (_cache == NULL) {
257 return; // nothing to do
258 }
259
260 InstanceKlass *ik = pool_holder();
261 if (!(ik->is_shared_boot_class() || ik->is_shared_platform_class() ||
262 ik->is_shared_app_class())) {
263 // Archiving resolved references for classes from non-builtin loaders
264 // is not yet supported.
265 set_resolved_references(NULL);
266 return;
494 // If CHECK_NULL above doesn't return the exception, that means that
495 // some other thread has beaten us and has resolved the class.
496 // To preserve old behavior, we return the resolved class.
497 klass = this_cp->resolved_klasses()->at(resolved_klass_index);
498 assert(klass != NULL, "must be resolved if exception was cleared");
499 return klass;
500 } else {
501 return NULL; // return the pending exception
502 }
503 }
504
505 // Make this class loader depend upon the class loader owning the class reference
506 ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data();
507 this_key->record_dependency(k, CHECK_NULL); // Can throw OOM
508
509 // logging for class+resolve.
510 if (log_is_enabled(Debug, class, resolve)){
511 trace_class_resolution(this_cp, k);
512 }
513 Klass** adr = this_cp->resolved_klasses()->adr_at(resolved_klass_index);
514 OrderAccess::release_store_ptr((Klass* volatile *)adr, k);
515 // The interpreter assumes when the tag is stored, the klass is resolved
516 // and the Klass* stored in _resolved_klasses is non-NULL, so we need
517 // hardware store ordering here.
518 this_cp->release_tag_at_put(which, JVM_CONSTANT_Class);
519 return k;
520 }
521
522
523 // Does not update ConstantPool* - to avoid any exception throwing. Used
524 // by compiler and exception handling. Also used to avoid classloads for
525 // instanceof operations. Returns NULL if the class has not been loaded or
526 // if the verification of constant pool failed
527 Klass* ConstantPool::klass_at_if_loaded(const constantPoolHandle& this_cp, int which) {
528 CPKlassSlot kslot = this_cp->klass_slot_at(which);
529 int resolved_klass_index = kslot.resolved_klass_index();
530 int name_index = kslot.name_index();
531 assert(this_cp->tag_at(name_index).is_symbol(), "sanity");
532
533 Klass* k = this_cp->resolved_klasses()->at(resolved_klass_index);
534 if (k != NULL) {
|
209 // All of these should have been reverted back to ClassIndex before calling
210 // this function.
211 ShouldNotReachHere();
212 #endif
213 }
214 }
215 allocate_resolved_klasses(loader_data, num_klasses, THREAD);
216 }
217
218 // Anonymous class support:
219 void ConstantPool::klass_at_put(int class_index, int name_index, int resolved_klass_index, Klass* k, Symbol* name) {
220 assert(is_within_bounds(class_index), "index out of bounds");
221 assert(is_within_bounds(name_index), "index out of bounds");
222 assert((resolved_klass_index & 0xffff0000) == 0, "must be");
223 *int_at_addr(class_index) =
224 build_int_from_shorts((jushort)resolved_klass_index, (jushort)name_index);
225
226 symbol_at_put(name_index, name);
227 name->increment_refcount();
228 Klass** adr = resolved_klasses()->adr_at(resolved_klass_index);
229 OrderAccess::release_store((Klass* volatile *)adr, k);
230
231 // The interpreter assumes when the tag is stored, the klass is resolved
232 // and the Klass* non-NULL, so we need hardware store ordering here.
233 if (k != NULL) {
234 release_tag_at_put(class_index, JVM_CONSTANT_Class);
235 } else {
236 release_tag_at_put(class_index, JVM_CONSTANT_UnresolvedClass);
237 }
238 }
239
240 // Anonymous class support:
241 void ConstantPool::klass_at_put(int class_index, Klass* k) {
242 assert(k != NULL, "must be valid klass");
243 CPKlassSlot kslot = klass_slot_at(class_index);
244 int resolved_klass_index = kslot.resolved_klass_index();
245 Klass** adr = resolved_klasses()->adr_at(resolved_klass_index);
246 OrderAccess::release_store((Klass* volatile *)adr, k);
247
248 // The interpreter assumes when the tag is stored, the klass is resolved
249 // and the Klass* non-NULL, so we need hardware store ordering here.
250 release_tag_at_put(class_index, JVM_CONSTANT_Class);
251 }
252
253 #if INCLUDE_CDS_JAVA_HEAP
254 // Archive the resolved references
255 void ConstantPool::archive_resolved_references(Thread* THREAD) {
256 if (_cache == NULL) {
257 return; // nothing to do
258 }
259
260 InstanceKlass *ik = pool_holder();
261 if (!(ik->is_shared_boot_class() || ik->is_shared_platform_class() ||
262 ik->is_shared_app_class())) {
263 // Archiving resolved references for classes from non-builtin loaders
264 // is not yet supported.
265 set_resolved_references(NULL);
266 return;
494 // If CHECK_NULL above doesn't return the exception, that means that
495 // some other thread has beaten us and has resolved the class.
496 // To preserve old behavior, we return the resolved class.
497 klass = this_cp->resolved_klasses()->at(resolved_klass_index);
498 assert(klass != NULL, "must be resolved if exception was cleared");
499 return klass;
500 } else {
501 return NULL; // return the pending exception
502 }
503 }
504
505 // Make this class loader depend upon the class loader owning the class reference
506 ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data();
507 this_key->record_dependency(k, CHECK_NULL); // Can throw OOM
508
509 // logging for class+resolve.
510 if (log_is_enabled(Debug, class, resolve)){
511 trace_class_resolution(this_cp, k);
512 }
513 Klass** adr = this_cp->resolved_klasses()->adr_at(resolved_klass_index);
514 OrderAccess::release_store((Klass* volatile *)adr, k);
515 // The interpreter assumes when the tag is stored, the klass is resolved
516 // and the Klass* stored in _resolved_klasses is non-NULL, so we need
517 // hardware store ordering here.
518 this_cp->release_tag_at_put(which, JVM_CONSTANT_Class);
519 return k;
520 }
521
522
523 // Does not update ConstantPool* - to avoid any exception throwing. Used
524 // by compiler and exception handling. Also used to avoid classloads for
525 // instanceof operations. Returns NULL if the class has not been loaded or
526 // if the verification of constant pool failed
527 Klass* ConstantPool::klass_at_if_loaded(const constantPoolHandle& this_cp, int which) {
528 CPKlassSlot kslot = this_cp->klass_slot_at(which);
529 int resolved_klass_index = kslot.resolved_klass_index();
530 int name_index = kslot.name_index();
531 assert(this_cp->tag_at(name_index).is_symbol(), "sanity");
532
533 Klass* k = this_cp->resolved_klasses()->at(resolved_klass_index);
534 if (k != NULL) {
|