< prev index next >

src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java

Print this page




 629             HotSpotResolvedObjectTypeImpl resolvedHolder;
 630             try {
 631                 resolvedHolder = compilerToVM().resolveFieldInPool(this, index, (HotSpotResolvedJavaMethodImpl) method, (byte) opcode, info);
 632             } catch (Throwable t) {
 633                 /*
 634                  * If there was an exception resolving the field we give up and return an unresolved
 635                  * field.
 636                  */
 637                 return new UnresolvedJavaField(holder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
 638             }
 639             final int flags = info[0];
 640             final int offset = info[1];
 641             final int fieldIndex = info[2];
 642             HotSpotResolvedJavaField result = resolvedHolder.createField(type, offset, flags, fieldIndex);
 643             return result;
 644         } else {
 645             return new UnresolvedJavaField(holder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
 646         }
 647     }
 648 
 649     /*
 650      * Converts a raw index from the bytecodes to a constant pool index (not a cache index).
 651      *
 652      * @param rawIndex index from the bytecode
 653      *
 654      * @param opcode bytecode to convert the index for
 655      *
 656      * @return constant pool index
 657      */
 658     public int rawIndexToConstantPoolIndex(int rawIndex, int opcode) {
 659         int index;
 660         if (isInvokedynamicIndex(rawIndex)) {
 661             assert opcode == Bytecodes.INVOKEDYNAMIC;
 662             index = decodeInvokedynamicIndex(rawIndex) + config().constantPoolCpCacheIndexTag;
 663         } else {
 664             assert opcode != Bytecodes.INVOKEDYNAMIC;
 665             index = rawIndexToConstantPoolCacheIndex(rawIndex, opcode);
 666         }
 667         return compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index);
 668     }
 669 


 743 
 744                 break;
 745             case InvokeDynamic:
 746                 if (isInvokedynamicIndex(cpi)) {
 747                     compilerToVM().resolveInvokeDynamicInPool(this, cpi);
 748                 }
 749                 break;
 750             default:
 751                 // nothing
 752                 break;
 753         }
 754 
 755     }
 756 
 757     // Lazily initialized.
 758     private static String[] signaturePolymorphicHolders;
 759 
 760     /**
 761      * Determines if {@code type} contains signature polymorphic methods.
 762      */


 763     static boolean isSignaturePolymorphicHolder(final ResolvedJavaType type) {
 764         String name = type.getName();
 765         if (signaturePolymorphicHolders == null) {
 766             signaturePolymorphicHolders = compilerToVM().getSignaturePolymorphicHolders();
 767         }
 768         for (String holder : signaturePolymorphicHolders) {
 769             if (name.equals(holder)) {
 770                 return true;
 771             }
 772         }
 773         return false;
 774     }
 775 
 776     /**
 777      * Check for a resolved dynamic adapter method at the specified index, resulting from either a
 778      * resolved invokedynamic or invokevirtual on a signature polymorphic MethodHandle method
 779      * (HotSpot invokehandle).
 780      *
 781      * @param cpi the constant pool index
 782      * @param opcode the opcode of the instruction for which the lookup is being performed


 629             HotSpotResolvedObjectTypeImpl resolvedHolder;
 630             try {
 631                 resolvedHolder = compilerToVM().resolveFieldInPool(this, index, (HotSpotResolvedJavaMethodImpl) method, (byte) opcode, info);
 632             } catch (Throwable t) {
 633                 /*
 634                  * If there was an exception resolving the field we give up and return an unresolved
 635                  * field.
 636                  */
 637                 return new UnresolvedJavaField(holder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
 638             }
 639             final int flags = info[0];
 640             final int offset = info[1];
 641             final int fieldIndex = info[2];
 642             HotSpotResolvedJavaField result = resolvedHolder.createField(type, offset, flags, fieldIndex);
 643             return result;
 644         } else {
 645             return new UnresolvedJavaField(holder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
 646         }
 647     }
 648 
 649     /**
 650      * Converts a raw index from the bytecodes to a constant pool index (not a cache index).
 651      *
 652      * @param rawIndex index from the bytecode
 653      *
 654      * @param opcode bytecode to convert the index for
 655      *
 656      * @return constant pool index
 657      */
 658     public int rawIndexToConstantPoolIndex(int rawIndex, int opcode) {
 659         int index;
 660         if (isInvokedynamicIndex(rawIndex)) {
 661             assert opcode == Bytecodes.INVOKEDYNAMIC;
 662             index = decodeInvokedynamicIndex(rawIndex) + config().constantPoolCpCacheIndexTag;
 663         } else {
 664             assert opcode != Bytecodes.INVOKEDYNAMIC;
 665             index = rawIndexToConstantPoolCacheIndex(rawIndex, opcode);
 666         }
 667         return compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index);
 668     }
 669 


 743 
 744                 break;
 745             case InvokeDynamic:
 746                 if (isInvokedynamicIndex(cpi)) {
 747                     compilerToVM().resolveInvokeDynamicInPool(this, cpi);
 748                 }
 749                 break;
 750             default:
 751                 // nothing
 752                 break;
 753         }
 754 
 755     }
 756 
 757     // Lazily initialized.
 758     private static String[] signaturePolymorphicHolders;
 759 
 760     /**
 761      * Determines if {@code type} contains signature polymorphic methods.
 762      */
 763     @SuppressFBWarnings(value = "LI_LAZY_INIT_STATIC", justification = "signaturePolymorphicHolders is a cache, not a singleton that must be constructed exactly once" +
 764                     "and compiler re-ordering is not an issue due to the VM call")
 765     static boolean isSignaturePolymorphicHolder(final ResolvedJavaType type) {
 766         String name = type.getName();
 767         if (signaturePolymorphicHolders == null) {
 768             signaturePolymorphicHolders = compilerToVM().getSignaturePolymorphicHolders();
 769         }
 770         for (String holder : signaturePolymorphicHolders) {
 771             if (name.equals(holder)) {
 772                 return true;
 773             }
 774         }
 775         return false;
 776     }
 777 
 778     /**
 779      * Check for a resolved dynamic adapter method at the specified index, resulting from either a
 780      * resolved invokedynamic or invokevirtual on a signature polymorphic MethodHandle method
 781      * (HotSpot invokehandle).
 782      *
 783      * @param cpi the constant pool index
 784      * @param opcode the opcode of the instruction for which the lookup is being performed
< prev index next >