723 case JVM_CONSTANT_Class:
724 {
725 assert(cache_index == _no_index_sentinel, "should not have been set");
726 Klass* resolved = klass_at_impl(this_cp, index, true, CHECK_NULL);
727 // ldc wants the java mirror.
728 result_oop = resolved->java_mirror();
729 break;
730 }
731
732 case JVM_CONSTANT_String:
733 assert(cache_index != _no_index_sentinel, "should have been set");
734 if (this_cp->is_pseudo_string_at(index)) {
735 result_oop = this_cp->pseudo_string_at(index, cache_index);
736 break;
737 }
738 result_oop = string_at_impl(this_cp, index, cache_index, CHECK_NULL);
739 break;
740
741 case JVM_CONSTANT_MethodHandleInError:
742 case JVM_CONSTANT_MethodTypeInError:
743 {
744 throw_resolution_error(this_cp, index, CHECK_NULL);
745 break;
746 }
747
748 case JVM_CONSTANT_MethodHandle:
749 {
750 int ref_kind = this_cp->method_handle_ref_kind_at(index);
751 int callee_index = this_cp->method_handle_klass_index_at(index);
752 Symbol* name = this_cp->method_handle_name_ref_at(index);
753 Symbol* signature = this_cp->method_handle_signature_ref_at(index);
754 constantTag m_tag = this_cp->tag_at(this_cp->method_handle_index_at(index));
755 { ResourceMark rm(THREAD);
756 log_debug(class, resolve)("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s",
757 ref_kind, index, this_cp->method_handle_index_at(index),
758 callee_index, name->as_C_string(), signature->as_C_string());
759 }
760
761 Klass* callee = klass_at_impl(this_cp, callee_index, true, CHECK_NULL);
762
1390 s->increment_refcount();
1391 to_cp->symbol_at_put(to_i, s);
1392 } break;
1393
1394 case JVM_CONSTANT_MethodType:
1395 case JVM_CONSTANT_MethodTypeInError:
1396 {
1397 jint k = from_cp->method_type_index_at(from_i);
1398 to_cp->method_type_index_at_put(to_i, k);
1399 } break;
1400
1401 case JVM_CONSTANT_MethodHandle:
1402 case JVM_CONSTANT_MethodHandleInError:
1403 {
1404 int k1 = from_cp->method_handle_ref_kind_at(from_i);
1405 int k2 = from_cp->method_handle_index_at(from_i);
1406 to_cp->method_handle_index_at_put(to_i, k1, k2);
1407 } break;
1408
1409 case JVM_CONSTANT_InvokeDynamic:
1410 {
1411 int k1 = from_cp->invoke_dynamic_bootstrap_specifier_index(from_i);
1412 int k2 = from_cp->invoke_dynamic_name_and_type_ref_index_at(from_i);
1413 k1 += operand_array_length(to_cp->operands()); // to_cp might already have operands
1414 to_cp->invoke_dynamic_at_put(to_i, k1, k2);
1415 } break;
1416
1417 // Invalid is used as the tag for the second constant pool entry
1418 // occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should
1419 // not be seen by itself.
1420 case JVM_CONSTANT_Invalid: // fall through
1421
1422 default:
1423 {
1424 ShouldNotReachHere();
1425 } break;
1426 }
1427 } // end copy_entry_to()
1428
1429 // Search constant pool search_cp for an entry that matches this
1651 case JVM_CONSTANT_UnresolvedClass:
1652 case JVM_CONSTANT_UnresolvedClassInError:
1653 case JVM_CONSTANT_StringIndex:
1654 case JVM_CONSTANT_MethodType:
1655 case JVM_CONSTANT_MethodTypeInError:
1656 return 3;
1657
1658 case JVM_CONSTANT_MethodHandle:
1659 case JVM_CONSTANT_MethodHandleInError:
1660 return 4; //tag, ref_kind, ref_index
1661
1662 case JVM_CONSTANT_Integer:
1663 case JVM_CONSTANT_Float:
1664 case JVM_CONSTANT_Fieldref:
1665 case JVM_CONSTANT_Methodref:
1666 case JVM_CONSTANT_InterfaceMethodref:
1667 case JVM_CONSTANT_NameAndType:
1668 return 5;
1669
1670 case JVM_CONSTANT_InvokeDynamic:
1671 // u1 tag, u2 bsm, u2 nt
1672 return 5;
1673
1674 case JVM_CONSTANT_Long:
1675 case JVM_CONSTANT_Double:
1676 return 9;
1677 }
1678 assert(false, "cpool_entry_size: Invalid constant pool entry tag");
1679 return 1;
1680 } /* end cpool_entry_size */
1681
1682
1683 // SymbolHashMap is used to find a constant pool index from a string.
1684 // This function fills in SymbolHashMaps, one for utf8s and one for
1685 // class names, returns size of the cpool raw bytes.
1686 jint ConstantPool::hash_entries_to(SymbolHashMap *symmap,
1687 SymbolHashMap *classmap) {
1688 jint size = 0;
1689
1690 for (u2 idx = 1; idx < length(); idx++) {
1835 break;
1836 }
1837 case JVM_CONSTANT_MethodHandle:
1838 case JVM_CONSTANT_MethodHandleInError: {
1839 *bytes = JVM_CONSTANT_MethodHandle;
1840 int kind = method_handle_ref_kind_at(idx);
1841 idx1 = method_handle_index_at(idx);
1842 *(bytes+1) = (unsigned char) kind;
1843 Bytes::put_Java_u2((address) (bytes+2), idx1);
1844 DBG(printf("JVM_CONSTANT_MethodHandle: %d %hd", kind, idx1));
1845 break;
1846 }
1847 case JVM_CONSTANT_MethodType:
1848 case JVM_CONSTANT_MethodTypeInError: {
1849 *bytes = JVM_CONSTANT_MethodType;
1850 idx1 = method_type_index_at(idx);
1851 Bytes::put_Java_u2((address) (bytes+1), idx1);
1852 DBG(printf("JVM_CONSTANT_MethodType: %hd", idx1));
1853 break;
1854 }
1855 case JVM_CONSTANT_InvokeDynamic: {
1856 *bytes = tag;
1857 idx1 = extract_low_short_from_int(*int_at_addr(idx));
1858 idx2 = extract_high_short_from_int(*int_at_addr(idx));
1859 assert(idx2 == invoke_dynamic_name_and_type_ref_index_at(idx), "correct half of u4");
1860 Bytes::put_Java_u2((address) (bytes+1), idx1);
1861 Bytes::put_Java_u2((address) (bytes+3), idx2);
1862 DBG(printf("JVM_CONSTANT_InvokeDynamic: %hd %hd", idx1, idx2));
1863 break;
1864 }
1865 }
1866 DBG(printf("\n"));
1867 bytes += ent_size;
1868 size += ent_size;
1869 }
1870 assert(size == cpool_size, "Size mismatch");
1871
1872 // Keep temorarily for debugging until it's stable.
1873 DBG(print_cpool_bytes(cnt, start_bytes));
1874 return (int)(bytes - start_bytes);
1875 } /* end copy_cpool_bytes */
2041 assert(tag_at(name_index).is_symbol(), "sanity");
2042
2043 Klass* klass = resolved_klasses()->at(resolved_klass_index);
2044 if (klass != NULL) {
2045 klass->print_value_on(st);
2046 } else {
2047 symbol_at(name_index)->print_value_on(st);
2048 }
2049 }
2050 break;
2051 case JVM_CONSTANT_MethodHandle :
2052 case JVM_CONSTANT_MethodHandleInError :
2053 st->print("ref_kind=%d", method_handle_ref_kind_at(index));
2054 st->print(" ref_index=%d", method_handle_index_at(index));
2055 break;
2056 case JVM_CONSTANT_MethodType :
2057 case JVM_CONSTANT_MethodTypeInError :
2058 st->print("signature_index=%d", method_type_index_at(index));
2059 break;
2060 case JVM_CONSTANT_InvokeDynamic :
2061 {
2062 st->print("bootstrap_method_index=%d", invoke_dynamic_bootstrap_method_ref_index_at(index));
2063 st->print(" name_and_type_index=%d", invoke_dynamic_name_and_type_ref_index_at(index));
2064 int argc = invoke_dynamic_argument_count_at(index);
2065 if (argc > 0) {
2066 for (int arg_i = 0; arg_i < argc; arg_i++) {
2067 int arg = invoke_dynamic_argument_index_at(index, arg_i);
2068 st->print((arg_i == 0 ? " arguments={%d" : ", %d"), arg);
2069 }
2070 st->print("}");
2071 }
2072 }
2073 break;
2074 default:
2075 ShouldNotReachHere();
2076 break;
2077 }
2078 st->cr();
2079 }
2080
|
723 case JVM_CONSTANT_Class:
724 {
725 assert(cache_index == _no_index_sentinel, "should not have been set");
726 Klass* resolved = klass_at_impl(this_cp, index, true, CHECK_NULL);
727 // ldc wants the java mirror.
728 result_oop = resolved->java_mirror();
729 break;
730 }
731
732 case JVM_CONSTANT_String:
733 assert(cache_index != _no_index_sentinel, "should have been set");
734 if (this_cp->is_pseudo_string_at(index)) {
735 result_oop = this_cp->pseudo_string_at(index, cache_index);
736 break;
737 }
738 result_oop = string_at_impl(this_cp, index, cache_index, CHECK_NULL);
739 break;
740
741 case JVM_CONSTANT_MethodHandleInError:
742 case JVM_CONSTANT_MethodTypeInError:
743 case JVM_CONSTANT_InvokeDynamicInError:
744 {
745 throw_resolution_error(this_cp, index, CHECK_NULL);
746 break;
747 }
748
749 case JVM_CONSTANT_MethodHandle:
750 {
751 int ref_kind = this_cp->method_handle_ref_kind_at(index);
752 int callee_index = this_cp->method_handle_klass_index_at(index);
753 Symbol* name = this_cp->method_handle_name_ref_at(index);
754 Symbol* signature = this_cp->method_handle_signature_ref_at(index);
755 constantTag m_tag = this_cp->tag_at(this_cp->method_handle_index_at(index));
756 { ResourceMark rm(THREAD);
757 log_debug(class, resolve)("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s",
758 ref_kind, index, this_cp->method_handle_index_at(index),
759 callee_index, name->as_C_string(), signature->as_C_string());
760 }
761
762 Klass* callee = klass_at_impl(this_cp, callee_index, true, CHECK_NULL);
763
1391 s->increment_refcount();
1392 to_cp->symbol_at_put(to_i, s);
1393 } break;
1394
1395 case JVM_CONSTANT_MethodType:
1396 case JVM_CONSTANT_MethodTypeInError:
1397 {
1398 jint k = from_cp->method_type_index_at(from_i);
1399 to_cp->method_type_index_at_put(to_i, k);
1400 } break;
1401
1402 case JVM_CONSTANT_MethodHandle:
1403 case JVM_CONSTANT_MethodHandleInError:
1404 {
1405 int k1 = from_cp->method_handle_ref_kind_at(from_i);
1406 int k2 = from_cp->method_handle_index_at(from_i);
1407 to_cp->method_handle_index_at_put(to_i, k1, k2);
1408 } break;
1409
1410 case JVM_CONSTANT_InvokeDynamic:
1411 case JVM_CONSTANT_InvokeDynamicInError:
1412 {
1413 int k1 = from_cp->invoke_dynamic_bootstrap_specifier_index(from_i);
1414 int k2 = from_cp->invoke_dynamic_name_and_type_ref_index_at(from_i);
1415 k1 += operand_array_length(to_cp->operands()); // to_cp might already have operands
1416 to_cp->invoke_dynamic_at_put(to_i, k1, k2);
1417 } break;
1418
1419 // Invalid is used as the tag for the second constant pool entry
1420 // occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should
1421 // not be seen by itself.
1422 case JVM_CONSTANT_Invalid: // fall through
1423
1424 default:
1425 {
1426 ShouldNotReachHere();
1427 } break;
1428 }
1429 } // end copy_entry_to()
1430
1431 // Search constant pool search_cp for an entry that matches this
1653 case JVM_CONSTANT_UnresolvedClass:
1654 case JVM_CONSTANT_UnresolvedClassInError:
1655 case JVM_CONSTANT_StringIndex:
1656 case JVM_CONSTANT_MethodType:
1657 case JVM_CONSTANT_MethodTypeInError:
1658 return 3;
1659
1660 case JVM_CONSTANT_MethodHandle:
1661 case JVM_CONSTANT_MethodHandleInError:
1662 return 4; //tag, ref_kind, ref_index
1663
1664 case JVM_CONSTANT_Integer:
1665 case JVM_CONSTANT_Float:
1666 case JVM_CONSTANT_Fieldref:
1667 case JVM_CONSTANT_Methodref:
1668 case JVM_CONSTANT_InterfaceMethodref:
1669 case JVM_CONSTANT_NameAndType:
1670 return 5;
1671
1672 case JVM_CONSTANT_InvokeDynamic:
1673 case JVM_CONSTANT_InvokeDynamicInError:
1674 // u1 tag, u2 bsm, u2 nt
1675 return 5;
1676
1677 case JVM_CONSTANT_Long:
1678 case JVM_CONSTANT_Double:
1679 return 9;
1680 }
1681 assert(false, "cpool_entry_size: Invalid constant pool entry tag");
1682 return 1;
1683 } /* end cpool_entry_size */
1684
1685
1686 // SymbolHashMap is used to find a constant pool index from a string.
1687 // This function fills in SymbolHashMaps, one for utf8s and one for
1688 // class names, returns size of the cpool raw bytes.
1689 jint ConstantPool::hash_entries_to(SymbolHashMap *symmap,
1690 SymbolHashMap *classmap) {
1691 jint size = 0;
1692
1693 for (u2 idx = 1; idx < length(); idx++) {
1838 break;
1839 }
1840 case JVM_CONSTANT_MethodHandle:
1841 case JVM_CONSTANT_MethodHandleInError: {
1842 *bytes = JVM_CONSTANT_MethodHandle;
1843 int kind = method_handle_ref_kind_at(idx);
1844 idx1 = method_handle_index_at(idx);
1845 *(bytes+1) = (unsigned char) kind;
1846 Bytes::put_Java_u2((address) (bytes+2), idx1);
1847 DBG(printf("JVM_CONSTANT_MethodHandle: %d %hd", kind, idx1));
1848 break;
1849 }
1850 case JVM_CONSTANT_MethodType:
1851 case JVM_CONSTANT_MethodTypeInError: {
1852 *bytes = JVM_CONSTANT_MethodType;
1853 idx1 = method_type_index_at(idx);
1854 Bytes::put_Java_u2((address) (bytes+1), idx1);
1855 DBG(printf("JVM_CONSTANT_MethodType: %hd", idx1));
1856 break;
1857 }
1858 case JVM_CONSTANT_InvokeDynamic:
1859 case JVM_CONSTANT_InvokeDynamicInError: {
1860 *bytes = tag;
1861 idx1 = extract_low_short_from_int(*int_at_addr(idx));
1862 idx2 = extract_high_short_from_int(*int_at_addr(idx));
1863 assert(idx2 == invoke_dynamic_name_and_type_ref_index_at(idx), "correct half of u4");
1864 Bytes::put_Java_u2((address) (bytes+1), idx1);
1865 Bytes::put_Java_u2((address) (bytes+3), idx2);
1866 DBG(printf("JVM_CONSTANT_InvokeDynamic: %hd %hd", idx1, idx2));
1867 break;
1868 }
1869 }
1870 DBG(printf("\n"));
1871 bytes += ent_size;
1872 size += ent_size;
1873 }
1874 assert(size == cpool_size, "Size mismatch");
1875
1876 // Keep temorarily for debugging until it's stable.
1877 DBG(print_cpool_bytes(cnt, start_bytes));
1878 return (int)(bytes - start_bytes);
1879 } /* end copy_cpool_bytes */
2045 assert(tag_at(name_index).is_symbol(), "sanity");
2046
2047 Klass* klass = resolved_klasses()->at(resolved_klass_index);
2048 if (klass != NULL) {
2049 klass->print_value_on(st);
2050 } else {
2051 symbol_at(name_index)->print_value_on(st);
2052 }
2053 }
2054 break;
2055 case JVM_CONSTANT_MethodHandle :
2056 case JVM_CONSTANT_MethodHandleInError :
2057 st->print("ref_kind=%d", method_handle_ref_kind_at(index));
2058 st->print(" ref_index=%d", method_handle_index_at(index));
2059 break;
2060 case JVM_CONSTANT_MethodType :
2061 case JVM_CONSTANT_MethodTypeInError :
2062 st->print("signature_index=%d", method_type_index_at(index));
2063 break;
2064 case JVM_CONSTANT_InvokeDynamic :
2065 case JVM_CONSTANT_InvokeDynamicInError :
2066 {
2067 st->print("bootstrap_method_index=%d", invoke_dynamic_bootstrap_method_ref_index_at(index));
2068 st->print(" name_and_type_index=%d", invoke_dynamic_name_and_type_ref_index_at(index));
2069 int argc = invoke_dynamic_argument_count_at(index);
2070 if (argc > 0) {
2071 for (int arg_i = 0; arg_i < argc; arg_i++) {
2072 int arg = invoke_dynamic_argument_index_at(index, arg_i);
2073 st->print((arg_i == 0 ? " arguments={%d" : ", %d"), arg);
2074 }
2075 st->print("}");
2076 }
2077 }
2078 break;
2079 default:
2080 ShouldNotReachHere();
2081 break;
2082 }
2083 st->cr();
2084 }
2085
|