@@ -260,14 +260,10 @@ private static int rawIndexToConstantPoolCacheIndex(int rawIndex, int opcode) {
260260 throw new IllegalArgumentException ("not an invokedynamic constant pool index " + index );
261261 }
262262 } else {
263- if (opcode == Bytecodes .GETFIELD ||
264- opcode == Bytecodes .PUTFIELD ||
265- opcode == Bytecodes .GETSTATIC ||
266- opcode == Bytecodes .PUTSTATIC ||
267- opcode == Bytecodes .INVOKEINTERFACE ||
268- opcode == Bytecodes .INVOKEVIRTUAL ||
269- opcode == Bytecodes .INVOKESPECIAL ||
270- opcode == Bytecodes .INVOKESTATIC ) {
263+ if (opcode == Bytecodes .INVOKEINTERFACE ||
264+ opcode == Bytecodes .INVOKEVIRTUAL ||
265+ opcode == Bytecodes .INVOKESPECIAL ||
266+ opcode == Bytecodes .INVOKESTATIC ) {
271267 index = rawIndex + config ().constantPoolCpCacheIndexTag ;
272268 } else {
273269 throw new IllegalArgumentException ("unexpected opcode " + opcode );
@@ -748,8 +744,8 @@ public JavaType lookupType(int cpi, int opcode) {
748744 }
749745
750746 @ Override
751- public JavaType lookupReferencedType (int cpi , int opcode ) {
752- int index ;
747+ public JavaType lookupReferencedType (int rawIndex , int opcode ) {
748+ int cpi ;
753749 switch (opcode ) {
754750 case Bytecodes .CHECKCAST :
755751 case Bytecodes .INSTANCEOF :
@@ -759,43 +755,45 @@ public JavaType lookupReferencedType(int cpi, int opcode) {
759755 case Bytecodes .LDC :
760756 case Bytecodes .LDC_W :
761757 case Bytecodes .LDC2_W :
762- index = cpi ;
758+ cpi = rawIndex ;
763759 break ;
764760 case Bytecodes .GETSTATIC :
765761 case Bytecodes .PUTSTATIC :
766762 case Bytecodes .GETFIELD :
767763 case Bytecodes .PUTFIELD :
764+ cpi = getKlassRefIndexAt (rawIndex , opcode );
765+ break ;
768766 case Bytecodes .INVOKEVIRTUAL :
769767 case Bytecodes .INVOKESPECIAL :
770768 case Bytecodes .INVOKESTATIC :
771769 case Bytecodes .INVOKEINTERFACE : {
772- index = rawIndexToConstantPoolCacheIndex (cpi , opcode );
773- index = getKlassRefIndexAt (index , opcode );
770+ int cpci = rawIndexToConstantPoolCacheIndex (rawIndex , opcode );
771+ cpi = getKlassRefIndexAt (cpci , opcode );
774772 break ;
775773 }
776774 default :
777775 throw JVMCIError .shouldNotReachHere ("Unexpected opcode " + opcode );
778776 }
779- final Object type = compilerToVM ().lookupKlassInPool (this , index );
777+ final Object type = compilerToVM ().lookupKlassInPool (this , cpi );
780778 return getJavaType (type );
781779 }
782780
783781 @ Override
784- public JavaField lookupField (int cpi , ResolvedJavaMethod method , int opcode ) {
785- final int index = rawIndexToConstantPoolCacheIndex ( cpi , opcode );
786- final int nameAndTypeIndex = getNameAndTypeRefIndexAt (index , opcode );
782+ public JavaField lookupField (int rawIndex , ResolvedJavaMethod method , int opcode ) {
783+ final int cpi = compilerToVM (). decodeFieldIndexToCPIndex ( this , rawIndex );
784+ final int nameAndTypeIndex = getNameAndTypeRefIndexAt (rawIndex , opcode );
787785 final int typeIndex = getSignatureRefIndexAt (nameAndTypeIndex );
788786 String typeName = lookupUtf8 (typeIndex );
789787 JavaType type = runtime ().lookupType (typeName , getHolder (), false );
790788
791- final int holderIndex = getKlassRefIndexAt (index , opcode );
789+ final int holderIndex = getKlassRefIndexAt (rawIndex , opcode );
792790 JavaType fieldHolder = lookupType (holderIndex , opcode );
793791
794792 if (fieldHolder instanceof HotSpotResolvedObjectTypeImpl ) {
795793 int [] info = new int [4 ];
796794 HotSpotResolvedObjectTypeImpl resolvedHolder ;
797795 try {
798- resolvedHolder = compilerToVM ().resolveFieldInPool (this , index , (HotSpotResolvedJavaMethodImpl ) method , (byte ) opcode , info );
796+ resolvedHolder = compilerToVM ().resolveFieldInPool (this , rawIndex , (HotSpotResolvedJavaMethodImpl ) method , (byte ) opcode , info );
799797 } catch (Throwable t ) {
800798 /*
801799 * If there was an exception resolving the field we give up and return an unresolved
@@ -833,19 +831,25 @@ public int rawIndexToConstantPoolIndex(int rawIndex, int opcode) {
833831 if (opcode == Bytecodes .INVOKEDYNAMIC ) {
834832 throw new IllegalArgumentException ("unexpected INVOKEDYNAMIC at " + rawIndex );
835833 }
834+ if (opcode == Bytecodes .GETSTATIC ||
835+ opcode == Bytecodes .PUTSTATIC ||
836+ opcode == Bytecodes .GETFIELD ||
837+ opcode == Bytecodes .PUTFIELD ) {
838+ return compilerToVM ().decodeFieldIndexToCPIndex (this , rawIndex );
839+ }
836840 int index = rawIndexToConstantPoolCacheIndex (rawIndex , opcode );
837841 return compilerToVM ().constantPoolRemapInstructionOperandFromCache (this , index );
838842 }
839843
840844 @ Override
841- public void loadReferencedType (int cpi , int opcode ) {
842- loadReferencedType (cpi , opcode , true /* initialize */ );
845+ public void loadReferencedType (int rawIndex , int opcode ) {
846+ loadReferencedType (rawIndex , opcode , true /* initialize */ );
843847 }
844848
845849 @ Override
846850 @ SuppressWarnings ("fallthrough" )
847- public void loadReferencedType (int cpi , int opcode , boolean initialize ) {
848- int index ;
851+ public void loadReferencedType (int rawIndex , int opcode , boolean initialize ) {
852+ int cpi ;
849853 switch (opcode ) {
850854 case Bytecodes .CHECKCAST :
851855 case Bytecodes .INSTANCEOF :
@@ -855,57 +859,59 @@ public void loadReferencedType(int cpi, int opcode, boolean initialize) {
855859 case Bytecodes .LDC :
856860 case Bytecodes .LDC_W :
857861 case Bytecodes .LDC2_W :
858- index = cpi ;
862+ cpi = rawIndex ;
859863 break ;
860864 case Bytecodes .INVOKEDYNAMIC : {
861865 // invokedynamic indices are different from constant pool cache indices
862- if (!isInvokedynamicIndex (cpi )) {
863- throw new IllegalArgumentException ("must use invokedynamic index but got " + cpi );
866+ if (!isInvokedynamicIndex (rawIndex )) {
867+ throw new IllegalArgumentException ("must use invokedynamic index but got " + rawIndex );
864868 }
865- index = compilerToVM ().decodeIndyIndexToCPIndex (this , cpi , true );
869+ cpi = compilerToVM ().decodeIndyIndexToCPIndex (this , rawIndex , true );
866870 break ;
867871 }
868872 case Bytecodes .GETSTATIC :
869873 case Bytecodes .PUTSTATIC :
870874 case Bytecodes .GETFIELD :
871875 case Bytecodes .PUTFIELD :
876+ cpi = compilerToVM ().decodeFieldIndexToCPIndex (this , rawIndex );
877+ break ;
872878 case Bytecodes .INVOKEVIRTUAL :
873879 case Bytecodes .INVOKESPECIAL :
874880 case Bytecodes .INVOKESTATIC :
875881 case Bytecodes .INVOKEINTERFACE : {
876882 // invoke and field instructions point to a constant pool cache entry.
877- index = rawIndexToConstantPoolCacheIndex (cpi , opcode );
878- index = compilerToVM ().constantPoolRemapInstructionOperandFromCache (this , index );
883+ int cpci = rawIndexToConstantPoolCacheIndex (rawIndex , opcode );
884+ cpi = compilerToVM ().constantPoolRemapInstructionOperandFromCache (this , cpci );
879885 break ;
880886 }
881887 default :
882888 throw JVMCIError .shouldNotReachHere ("Unexpected opcode " + opcode );
883889 }
884890
885- final JvmConstant tag = getTagAt (index );
891+ final JvmConstant tag = getTagAt (cpi );
886892 if (tag == null ) {
887- assert getTagAt (index - 1 ) == constants .jvmDouble || getTagAt (index - 1 ) == constants .jvmLong ;
893+ assert getTagAt (cpi - 1 ) == constants .jvmDouble || getTagAt (cpi - 1 ) == constants .jvmLong ;
888894 return ;
889895 }
890896 switch (tag .name ) {
891897 case "Methodref" :
892898 case "Fieldref" :
893899 case "InterfaceMethodref" :
894- index = getUncachedKlassRefIndexAt (index );
900+ cpi = getUncachedKlassRefIndexAt (cpi );
895901 // Read the tag only once because it could change between multiple reads.
896- final JvmConstant klassTag = getTagAt (index );
902+ final JvmConstant klassTag = getTagAt (cpi );
897903 assert klassTag == constants .jvmClass || klassTag == constants .jvmUnresolvedClass || klassTag == constants .jvmUnresolvedClassInError : klassTag ;
898904 // fall through
899905 case "Class" :
900906 case "UnresolvedClass" :
901907 case "UnresolvedClassInError" :
902- final HotSpotResolvedObjectTypeImpl type = compilerToVM ().resolveTypeInPool (this , index );
908+ final HotSpotResolvedObjectTypeImpl type = compilerToVM ().resolveTypeInPool (this , cpi );
903909 if (initialize && !type .isPrimitive () && !type .isArray ()) {
904910 type .ensureInitialized ();
905911 }
906912 if (tag == constants .jvmMethodref ) {
907913 if (Bytecodes .isInvokeHandleAlias (opcode ) && isSignaturePolymorphicHolder (type )) {
908- final int methodRefCacheIndex = rawIndexToConstantPoolCacheIndex (cpi , opcode );
914+ final int methodRefCacheIndex = rawIndexToConstantPoolCacheIndex (rawIndex , opcode );
909915 checkTag (compilerToVM ().constantPoolRemapInstructionOperandFromCache (this , methodRefCacheIndex ), constants .jvmMethodref );
910916 compilerToVM ().resolveInvokeHandleInPool (this , methodRefCacheIndex );
911917 }
0 commit comments