466 ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool,
467 int index,
468 bool& is_accessible,
469 ciInstanceKlass* accessor) {
470 EXCEPTION_CONTEXT;
471 KlassHandle klass; // = NULL;
472 Symbol* klass_name = NULL;
473
474 if (cpool->tag_at(index).is_symbol()) {
475 klass_name = cpool->symbol_at(index);
476 } else {
477 // Check if it's resolved if it's not a symbol constant pool entry.
478 klass = KlassHandle(THREAD, ConstantPool::klass_at_if_loaded(cpool, index));
479
480 if (klass.is_null()) {
481 // The klass has not been inserted into the constant pool.
482 // Try to look it up by name.
483 {
484 // We have to lock the cpool to keep the oop from being resolved
485 // while we are accessing it.
486 MonitorLockerEx ml(cpool->lock());
487 constantTag tag = cpool->tag_at(index);
488 if (tag.is_klass()) {
489 // The klass has been inserted into the constant pool
490 // very recently.
491 klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
492 } else {
493 assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
494 klass_name = cpool->unresolved_klass_at(index);
495 }
496 }
497 }
498 }
499
500 if (klass.is_null()) {
501 // Not found in constant pool. Use the name to do the lookup.
502 ciKlass* k = get_klass_by_name_impl(accessor,
503 cpool,
504 get_symbol(klass_name),
505 false);
506 // Calculate accessibility the hard way.
|
466 ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool,
467 int index,
468 bool& is_accessible,
469 ciInstanceKlass* accessor) {
470 EXCEPTION_CONTEXT;
471 KlassHandle klass; // = NULL;
472 Symbol* klass_name = NULL;
473
474 if (cpool->tag_at(index).is_symbol()) {
475 klass_name = cpool->symbol_at(index);
476 } else {
477 // Check if it's resolved if it's not a symbol constant pool entry.
478 klass = KlassHandle(THREAD, ConstantPool::klass_at_if_loaded(cpool, index));
479
480 if (klass.is_null()) {
481 // The klass has not been inserted into the constant pool.
482 // Try to look it up by name.
483 {
484 // We have to lock the cpool to keep the oop from being resolved
485 // while we are accessing it.
486 oop cplock = cpool->lock();
487 ObjectLocker ol(cplock, THREAD, cplock != NULL);
488 constantTag tag = cpool->tag_at(index);
489 if (tag.is_klass()) {
490 // The klass has been inserted into the constant pool
491 // very recently.
492 klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
493 } else {
494 assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
495 klass_name = cpool->unresolved_klass_at(index);
496 }
497 }
498 }
499 }
500
501 if (klass.is_null()) {
502 // Not found in constant pool. Use the name to do the lookup.
503 ciKlass* k = get_klass_by_name_impl(accessor,
504 cpool,
505 get_symbol(klass_name),
506 false);
507 // Calculate accessibility the hard way.
|