424 if (sym->byte_at(0) == '[') { |
424 if (sym->byte_at(0) == '[') { |
425 fail_type = _unloaded_ciobjarrayklass; |
425 fail_type = _unloaded_ciobjarrayklass; |
426 } else { |
426 } else { |
427 fail_type = _unloaded_ciinstance_klass; |
427 fail_type = _unloaded_ciinstance_klass; |
428 } |
428 } |
429 KlassHandle found_klass; |
429 Klass* found_klass; |
430 { |
430 { |
431 ttyUnlocker ttyul; // release tty lock to avoid ordering problems |
431 ttyUnlocker ttyul; // release tty lock to avoid ordering problems |
432 MutexLocker ml(Compile_lock); |
432 MutexLocker ml(Compile_lock); |
433 Klass* kls; |
433 Klass* kls; |
434 if (!require_local) { |
434 if (!require_local) { |
436 KILL_COMPILE_ON_FATAL_(fail_type)); |
436 KILL_COMPILE_ON_FATAL_(fail_type)); |
437 } else { |
437 } else { |
438 kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, |
438 kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, |
439 KILL_COMPILE_ON_FATAL_(fail_type)); |
439 KILL_COMPILE_ON_FATAL_(fail_type)); |
440 } |
440 } |
441 found_klass = KlassHandle(THREAD, kls); |
441 found_klass = kls; |
442 } |
442 } |
443 |
443 |
444 // If we fail to find an array klass, look again for its element type. |
444 // If we fail to find an array klass, look again for its element type. |
445 // The element type may be available either locally or via constraints. |
445 // The element type may be available either locally or via constraints. |
446 // In either case, if we can find the element type in the system dictionary, |
446 // In either case, if we can find the element type in the system dictionary, |
465 // Now make an array for it |
465 // Now make an array for it |
466 return ciObjArrayKlass::make_impl(elem_klass); |
466 return ciObjArrayKlass::make_impl(elem_klass); |
467 } |
467 } |
468 } |
468 } |
469 |
469 |
470 if (found_klass() == NULL && !cpool.is_null() && cpool->has_preresolution()) { |
470 if (found_klass == NULL && !cpool.is_null() && cpool->has_preresolution()) { |
471 // Look inside the constant pool for pre-resolved class entries. |
471 // Look inside the constant pool for pre-resolved class entries. |
472 for (int i = cpool->length() - 1; i >= 1; i--) { |
472 for (int i = cpool->length() - 1; i >= 1; i--) { |
473 if (cpool->tag_at(i).is_klass()) { |
473 if (cpool->tag_at(i).is_klass()) { |
474 Klass* kls = cpool->resolved_klass_at(i); |
474 Klass* kls = cpool->resolved_klass_at(i); |
475 if (kls->name() == sym) { |
475 if (kls->name() == sym) { |
476 found_klass = KlassHandle(THREAD, kls); |
476 found_klass = kls; |
477 break; |
477 break; |
478 } |
478 } |
479 } |
479 } |
480 } |
480 } |
481 } |
481 } |
482 |
482 |
483 if (found_klass() != NULL) { |
483 if (found_klass != NULL) { |
484 // Found it. Build a CI handle. |
484 // Found it. Build a CI handle. |
485 return get_klass(found_klass()); |
485 return get_klass(found_klass); |
486 } |
486 } |
487 |
487 |
488 if (require_local) return NULL; |
488 if (require_local) return NULL; |
489 |
489 |
490 // Not yet loaded into the VM, or not governed by loader constraints. |
490 // Not yet loaded into the VM, or not governed by loader constraints. |
510 ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool, |
510 ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool, |
511 int index, |
511 int index, |
512 bool& is_accessible, |
512 bool& is_accessible, |
513 ciInstanceKlass* accessor) { |
513 ciInstanceKlass* accessor) { |
514 EXCEPTION_CONTEXT; |
514 EXCEPTION_CONTEXT; |
515 KlassHandle klass; // = NULL; |
515 Klass* klass = NULL; |
516 Symbol* klass_name = NULL; |
516 Symbol* klass_name = NULL; |
517 |
517 |
518 if (cpool->tag_at(index).is_symbol()) { |
518 if (cpool->tag_at(index).is_symbol()) { |
519 klass_name = cpool->symbol_at(index); |
519 klass_name = cpool->symbol_at(index); |
520 } else { |
520 } else { |
521 // Check if it's resolved if it's not a symbol constant pool entry. |
521 // Check if it's resolved if it's not a symbol constant pool entry. |
522 klass = KlassHandle(THREAD, ConstantPool::klass_at_if_loaded(cpool, index)); |
522 klass = ConstantPool::klass_at_if_loaded(cpool, index); |
523 // Try to look it up by name. |
523 // Try to look it up by name. |
524 if (klass.is_null()) { |
524 if (klass == NULL) { |
525 klass_name = cpool->klass_name_at(index); |
525 klass_name = cpool->klass_name_at(index); |
526 } |
526 } |
527 } |
527 } |
528 |
528 |
529 if (klass.is_null()) { |
529 if (klass == NULL) { |
530 // Not found in constant pool. Use the name to do the lookup. |
530 // Not found in constant pool. Use the name to do the lookup. |
531 ciKlass* k = get_klass_by_name_impl(accessor, |
531 ciKlass* k = get_klass_by_name_impl(accessor, |
532 cpool, |
532 cpool, |
533 get_symbol(klass_name), |
533 get_symbol(klass_name), |
534 false); |
534 false); |
546 return k; |
546 return k; |
547 } |
547 } |
548 |
548 |
549 // Check for prior unloaded klass. The SystemDictionary's answers |
549 // Check for prior unloaded klass. The SystemDictionary's answers |
550 // can vary over time but the compiler needs consistency. |
550 // can vary over time but the compiler needs consistency. |
551 ciSymbol* name = get_symbol(klass()->name()); |
551 ciSymbol* name = get_symbol(klass->name()); |
552 ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name); |
552 ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name); |
553 if (unloaded_klass != NULL) { |
553 if (unloaded_klass != NULL) { |
554 is_accessible = false; |
554 is_accessible = false; |
555 return unloaded_klass; |
555 return unloaded_klass; |
556 } |
556 } |
557 |
557 |
558 // It is known to be accessible, since it was found in the constant pool. |
558 // It is known to be accessible, since it was found in the constant pool. |
559 is_accessible = true; |
559 is_accessible = true; |
560 return get_klass(klass()); |
560 return get_klass(klass); |
561 } |
561 } |
562 |
562 |
563 // ------------------------------------------------------------------ |
563 // ------------------------------------------------------------------ |
564 // ciEnv::get_klass_by_index |
564 // ciEnv::get_klass_by_index |
565 // |
565 // |
711 Bytecodes::Code bc, |
711 Bytecodes::Code bc, |
712 constantTag tag) { |
712 constantTag tag) { |
713 // Accessibility checks are performed in ciEnv::get_method_by_index_impl. |
713 // Accessibility checks are performed in ciEnv::get_method_by_index_impl. |
714 assert(check_klass_accessibility(accessor, holder->get_Klass()), "holder not accessible"); |
714 assert(check_klass_accessibility(accessor, holder->get_Klass()), "holder not accessible"); |
715 |
715 |
716 KlassHandle h_accessor(accessor->get_instanceKlass()); |
716 InstanceKlass* accessor_klass = accessor->get_instanceKlass(); |
717 KlassHandle h_holder(holder->get_Klass()); |
717 Klass* holder_klass = holder->get_Klass(); |
718 methodHandle dest_method; |
718 methodHandle dest_method; |
719 LinkInfo link_info(h_holder, name, sig, h_accessor, LinkInfo::needs_access_check, tag); |
719 LinkInfo link_info(holder_klass, name, sig, accessor_klass, LinkInfo::needs_access_check, tag); |
720 switch (bc) { |
720 switch (bc) { |
721 case Bytecodes::_invokestatic: |
721 case Bytecodes::_invokestatic: |
722 dest_method = |
722 dest_method = |
723 LinkResolver::resolve_static_call_or_null(link_info); |
723 LinkResolver::resolve_static_call_or_null(link_info); |
724 break; |
724 break; |