@@ -80,42 +80,6 @@ protected short getConstantPoolIndexFromRefMap(int rawcode, int bci) {
80
80
return (short )cpool .objectToCPIndex (refIndex );
81
81
}
82
82
83
- protected short getConstantPoolIndex (int rawcode , int bci ) {
84
- // get ConstantPool index from ConstantPoolCacheIndex at given bci
85
- String fmt = Bytecodes .format (rawcode );
86
- int cpCacheIndex ;
87
- switch (fmt .length ()) {
88
- case 2 : cpCacheIndex = method .getBytecodeByteArg (bci ); break ;
89
- case 3 : cpCacheIndex = method .getBytecodeShortArg (bci ); break ;
90
- case 5 :
91
- if (fmt .contains ("__" ))
92
- cpCacheIndex = method .getBytecodeShortArg (bci );
93
- else
94
- cpCacheIndex = method .getBytecodeIntArg (bci );
95
- break ;
96
- default : throw new IllegalArgumentException ();
97
- }
98
-
99
- if (cpCache == null ) {
100
- return (short ) cpCacheIndex ;
101
- } else if (fmt .contains ("JJJJ" )) {
102
- // Invokedynamic require special handling
103
- cpCacheIndex = ~cpCacheIndex ;
104
- cpCacheIndex = bytes .swapInt (cpCacheIndex );
105
- short cpIndex = (short ) cpCache .getIndyEntryAt (cpCacheIndex ).getConstantPoolIndex ();
106
- Assert .that (cpool .getTagAt (cpIndex ).isInvokeDynamic (), "CP Entry should be InvokeDynamic" );
107
- return cpIndex ;
108
- } else if (fmt .contains ("JJ" )) {
109
- // change byte-ordering and go via cache
110
- return (short ) cpCache .getEntryAt ((int ) (0xFFFF & bytes .swapShort ((short )cpCacheIndex ))).getConstantPoolIndex ();
111
- } else if (fmt .contains ("j" )) {
112
- // go via cache
113
- return (short ) cpCache .getEntryAt ((int ) (0xFF & cpCacheIndex )).getConstantPoolIndex ();
114
- } else {
115
- return (short ) cpCacheIndex ;
116
- }
117
- }
118
-
119
83
private static void writeShort (byte [] buf , int index , short value ) {
120
84
buf [index ] = (byte ) ((value >> 8 ) & 0x00FF );
121
85
buf [index + 1 ] = (byte ) (value & 0x00FF );
@@ -152,22 +116,29 @@ public void rewrite() {
152
116
case Bytecodes ._getstatic :
153
117
case Bytecodes ._putstatic :
154
118
case Bytecodes ._getfield :
155
- case Bytecodes ._putfield :
119
+ case Bytecodes ._putfield : {
120
+ int fieldIndex = method .getNativeShortArg (bci + 1 );
121
+ cpoolIndex = (short ) cpCache .getFieldEntryAt (fieldIndex ).getConstantPoolIndex ();
122
+ writeShort (code , bci + 1 , cpoolIndex );
123
+ break ;
124
+ }
156
125
case Bytecodes ._invokevirtual :
157
126
case Bytecodes ._invokespecial :
158
127
case Bytecodes ._invokestatic :
159
128
case Bytecodes ._invokeinterface : {
160
- cpoolIndex = getConstantPoolIndex (hotspotcode , bci + 1 );
129
+ int cpci = method .getNativeShortArg (bci + 1 );
130
+ cpoolIndex = (short ) cpCache .getEntryAt (cpci ).getConstantPoolIndex ();
161
131
writeShort (code , bci + 1 , cpoolIndex );
162
132
break ;
163
133
}
164
134
165
- case Bytecodes ._invokedynamic :
166
- cpoolIndex = getConstantPoolIndex (hotspotcode , bci + 1 );
135
+ case Bytecodes ._invokedynamic : {
136
+ int cpci = method .getNativeIntArg (bci + 1 );
137
+ cpoolIndex = (short ) cpCache .getIndyEntryAt (~cpci ).getConstantPoolIndex ();
167
138
writeShort (code , bci + 1 , cpoolIndex );
168
139
writeShort (code , bci + 3 , (short )0 ); // clear out trailing bytes
169
140
break ;
170
-
141
+ }
171
142
case Bytecodes ._ldc_w :
172
143
if (hotspotcode != bytecode ) {
173
144
// fast_aldc_w puts constant in reference map
0 commit comments