404 int pool_index = invokedynamic_cp_cache_entry_at(which)->constant_pool_index(); 405 pool_index = invoke_dynamic_name_and_type_ref_index_at(pool_index); 406 assert(tag_at(pool_index).is_name_and_type(), ""); 407 return pool_index; 408 } 409 // change byte-ordering and go via cache 410 i = remap_instruction_operand_from_cache(which); 411 } else { 412 if (tag_at(which).is_invoke_dynamic()) { 413 int pool_index = invoke_dynamic_name_and_type_ref_index_at(which); 414 assert(tag_at(pool_index).is_name_and_type(), ""); 415 return pool_index; 416 } 417 } 418 assert(tag_at(i).is_field_or_method(), "Corrupted constant pool"); 419 assert(!tag_at(i).is_invoke_dynamic(), "Must be handled above"); 420 jint ref_index = *int_at_addr(i); 421 return extract_high_short_from_int(ref_index); 422 } 423 424 425 int ConstantPool::impl_klass_ref_index_at(int which, bool uncached) { 426 guarantee(!ConstantPool::is_invokedynamic_index(which), 427 "an invokedynamic instruction does not have a klass"); 428 int i = which; 429 if (!uncached && cache() != NULL) { 430 // change byte-ordering and go via cache 431 i = remap_instruction_operand_from_cache(which); 432 } 433 assert(tag_at(i).is_field_or_method(), "Corrupted constant pool"); 434 jint ref_index = *int_at_addr(i); 435 return extract_low_short_from_int(ref_index); 436 } 437 438 439 440 int ConstantPool::remap_instruction_operand_from_cache(int operand) { 441 int cpc_index = operand; 442 DEBUG_ONLY(cpc_index -= CPCACHE_INDEX_TAG); 443 assert((int)(u2)cpc_index == cpc_index, "clean u2"); 659 if (this_cp->is_pseudo_string_at(index)) { 660 result_oop = this_cp->pseudo_string_at(index, cache_index); 661 break; 662 } 663 result_oop = string_at_impl(this_cp, index, cache_index, CHECK_NULL); 664 break; 665 666 case JVM_CONSTANT_MethodHandleInError: 667 case JVM_CONSTANT_MethodTypeInError: 668 { 669 throw_resolution_error(this_cp, index, CHECK_NULL); 670 break; 671 } 672 673 case JVM_CONSTANT_MethodHandle: 674 { 675 int ref_kind = this_cp->method_handle_ref_kind_at(index); 676 int callee_index = this_cp->method_handle_klass_index_at(index); 677 Symbol* name = this_cp->method_handle_name_ref_at(index); 678 Symbol* signature = this_cp->method_handle_signature_ref_at(index); 679 if (PrintMiscellaneous) 680 tty->print_cr("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s", 681 ref_kind, index, this_cp->method_handle_index_at(index), 682 callee_index, name->as_C_string(), signature->as_C_string()); 683 KlassHandle callee; 684 { Klass* k = klass_at_impl(this_cp, callee_index, true, CHECK_NULL); 685 callee = KlassHandle(THREAD, k); 686 } 687 KlassHandle klass(THREAD, this_cp->pool_holder()); 688 Handle value = SystemDictionary::link_method_handle_constant(klass, ref_kind, 689 callee, name, signature, 690 THREAD); 691 result_oop = value(); 692 if (HAS_PENDING_EXCEPTION) { 693 save_and_throw_exception(this_cp, index, tag, CHECK_NULL); 694 } 695 break; 696 } 697 698 case JVM_CONSTANT_MethodType: 699 { 700 Symbol* signature = this_cp->method_type_signature_at(index); 701 if (PrintMiscellaneous) 702 tty->print_cr("resolve JVM_CONSTANT_MethodType [%d/%d] %s", 703 index, this_cp->method_type_index_at(index), 704 signature->as_C_string()); 705 KlassHandle klass(THREAD, this_cp->pool_holder()); 706 Handle value = SystemDictionary::find_method_handle_type(signature, klass, THREAD); | 404 int pool_index = invokedynamic_cp_cache_entry_at(which)->constant_pool_index(); 405 pool_index = invoke_dynamic_name_and_type_ref_index_at(pool_index); 406 assert(tag_at(pool_index).is_name_and_type(), ""); 407 return pool_index; 408 } 409 // change byte-ordering and go via cache 410 i = remap_instruction_operand_from_cache(which); 411 } else { 412 if (tag_at(which).is_invoke_dynamic()) { 413 int pool_index = invoke_dynamic_name_and_type_ref_index_at(which); 414 assert(tag_at(pool_index).is_name_and_type(), ""); 415 return pool_index; 416 } 417 } 418 assert(tag_at(i).is_field_or_method(), "Corrupted constant pool"); 419 assert(!tag_at(i).is_invoke_dynamic(), "Must be handled above"); 420 jint ref_index = *int_at_addr(i); 421 return extract_high_short_from_int(ref_index); 422 } 423 424 constantTag ConstantPool::impl_tag_ref_at(int which, bool uncached) { 425 int pool_index = which; 426 if (!uncached && cache() != NULL) { 427 if (ConstantPool::is_invokedynamic_index(which)) { 428 // Invokedynamic index is index into resolved_references 429 pool_index = invokedynamic_cp_cache_entry_at(which)->constant_pool_index(); 430 } else { 431 // change byte-ordering and go via cache 432 pool_index = remap_instruction_operand_from_cache(which); 433 } 434 } 435 return tag_at(pool_index); 436 } 437 438 int ConstantPool::impl_klass_ref_index_at(int which, bool uncached) { 439 guarantee(!ConstantPool::is_invokedynamic_index(which), 440 "an invokedynamic instruction does not have a klass"); 441 int i = which; 442 if (!uncached && cache() != NULL) { 443 // change byte-ordering and go via cache 444 i = remap_instruction_operand_from_cache(which); 445 } 446 assert(tag_at(i).is_field_or_method(), "Corrupted constant pool"); 447 jint ref_index = *int_at_addr(i); 448 return extract_low_short_from_int(ref_index); 449 } 450 451 452 453 int ConstantPool::remap_instruction_operand_from_cache(int operand) { 454 int cpc_index = operand; 455 DEBUG_ONLY(cpc_index -= CPCACHE_INDEX_TAG); 456 assert((int)(u2)cpc_index == cpc_index, "clean u2"); 672 if (this_cp->is_pseudo_string_at(index)) { 673 result_oop = this_cp->pseudo_string_at(index, cache_index); 674 break; 675 } 676 result_oop = string_at_impl(this_cp, index, cache_index, CHECK_NULL); 677 break; 678 679 case JVM_CONSTANT_MethodHandleInError: 680 case JVM_CONSTANT_MethodTypeInError: 681 { 682 throw_resolution_error(this_cp, index, CHECK_NULL); 683 break; 684 } 685 686 case JVM_CONSTANT_MethodHandle: 687 { 688 int ref_kind = this_cp->method_handle_ref_kind_at(index); 689 int callee_index = this_cp->method_handle_klass_index_at(index); 690 Symbol* name = this_cp->method_handle_name_ref_at(index); 691 Symbol* signature = this_cp->method_handle_signature_ref_at(index); 692 constantTag m_tag = this_cp->tag_at(this_cp->method_handle_index_at(index)); 693 if (PrintMiscellaneous) 694 tty->print_cr("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s", 695 ref_kind, index, this_cp->method_handle_index_at(index), 696 callee_index, name->as_C_string(), signature->as_C_string()); 697 KlassHandle callee; 698 { Klass* k = klass_at_impl(this_cp, callee_index, true, CHECK_NULL); 699 callee = KlassHandle(THREAD, k); 700 } 701 // Check tag consistency, relax for interface static default method. 702 if ((callee->is_interface() && !m_tag.is_interface_method()) || 703 (!callee->is_interface() && m_tag.is_interface_method())) { 704 ResourceMark rm(THREAD); 705 char buf[200]; 706 jio_snprintf(buf, sizeof(buf), "Inconsistent constant data for %s.%s%s at index %d", 707 callee->name()->as_C_string(), name->as_C_string(), signature->as_C_string(), index); 708 THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 709 } 710 711 KlassHandle klass(THREAD, this_cp->pool_holder()); 712 Handle value = SystemDictionary::link_method_handle_constant(klass, ref_kind, 713 callee, name, signature, 714 THREAD); 715 result_oop = value(); 716 if (HAS_PENDING_EXCEPTION) { 717 save_and_throw_exception(this_cp, index, tag, CHECK_NULL); 718 } 719 break; 720 } 721 722 case JVM_CONSTANT_MethodType: 723 { 724 Symbol* signature = this_cp->method_type_signature_at(index); 725 if (PrintMiscellaneous) 726 tty->print_cr("resolve JVM_CONSTANT_MethodType [%d/%d] %s", 727 index, this_cp->method_type_index_at(index), 728 signature->as_C_string()); 729 KlassHandle klass(THREAD, this_cp->pool_holder()); 730 Handle value = SystemDictionary::find_method_handle_type(signature, klass, THREAD); |