@@ -742,7 +742,11 @@ Object executeFromBci(VirtualFrame virtualFrame, Frame localFrame, Frame stackFr
742
742
Object globals = PArguments .getGlobals (virtualFrame );
743
743
Object locals = PArguments .getSpecialArgument (virtualFrame );
744
744
745
- int loopCount = 0 ;
745
+ /*
746
+ * We use an array as a workaround for not being able to specify which local variables are
747
+ * loop constants (GR-35338).
748
+ */
749
+ int [] loopCount = new int []{0 };
746
750
int stackTop = initialStackTop ;
747
751
int bci = initialBci ;
748
752
@@ -1007,8 +1011,8 @@ Object executeFromBci(VirtualFrame virtualFrame, Frame localFrame, Frame stackFr
1007
1011
break ;
1008
1012
}
1009
1013
case OpCodesConstants .RETURN_VALUE : {
1010
- if (CompilerDirectives .inInterpreter () && loopCount > 0 ) {
1011
- LoopNode .reportLoopCount (this , loopCount );
1014
+ if (CompilerDirectives .hasNextTier () && loopCount [ 0 ] > 0 ) {
1015
+ LoopNode .reportLoopCount (this , loopCount [ 0 ] );
1012
1016
}
1013
1017
Object value = stackFrame .getObject (stackTop );
1014
1018
if (isGeneratorOrCoroutine ) {
@@ -1158,8 +1162,8 @@ Object executeFromBci(VirtualFrame virtualFrame, Frame localFrame, Frame stackFr
1158
1162
case OpCodesConstants .JUMP_BACKWARD : {
1159
1163
oparg |= Byte .toUnsignedInt (localBC [bci + 1 ]);
1160
1164
bci -= oparg ;
1161
- if (CompilerDirectives .inInterpreter ()) {
1162
- loopCount ++;
1165
+ if (CompilerDirectives .hasNextTier ()) {
1166
+ loopCount [ 0 ] ++;
1163
1167
}
1164
1168
if (CompilerDirectives .inInterpreter () && BytecodeOSRNode .pollOSRBackEdge (osrNode )) {
1165
1169
/*
@@ -1174,8 +1178,8 @@ Object executeFromBci(VirtualFrame virtualFrame, Frame localFrame, Frame stackFr
1174
1178
*/
1175
1179
Object osrResult = BytecodeOSRNode .tryOSR (osrNode , bci , stackTop , null , virtualFrame );
1176
1180
if (osrResult != null ) {
1177
- if (CompilerDirectives .inInterpreter () && loopCount > 0 ) {
1178
- LoopNode .reportLoopCount (this , loopCount );
1181
+ if (CompilerDirectives .hasNextTier () && loopCount [ 0 ] > 0 ) {
1182
+ LoopNode .reportLoopCount (this , loopCount [ 0 ] );
1179
1183
}
1180
1184
return osrResult ;
1181
1185
}
@@ -1293,8 +1297,8 @@ Object executeFromBci(VirtualFrame virtualFrame, Frame localFrame, Frame stackFr
1293
1297
throw bytecodeEndExcHandler (stackFrame , stackTop );
1294
1298
}
1295
1299
case OpCodesConstants .YIELD_VALUE : {
1296
- if (CompilerDirectives .inInterpreter () && loopCount > 0 ) {
1297
- LoopNode .reportLoopCount (this , loopCount );
1300
+ if (CompilerDirectives .hasNextTier () && loopCount [ 0 ] > 0 ) {
1301
+ LoopNode .reportLoopCount (this , loopCount [ 0 ] );
1298
1302
}
1299
1303
Object value = stackFrame .getObject (stackTop );
1300
1304
stackFrame .setObject (stackTop --, null );
@@ -1410,8 +1414,8 @@ Object executeFromBci(VirtualFrame virtualFrame, Frame localFrame, Frame stackFr
1410
1414
clearFrameSlots (localFrame , stackoffset , initialStackTop );
1411
1415
}
1412
1416
}
1413
- if (CompilerDirectives .inInterpreter () && loopCount > 0 ) {
1414
- LoopNode .reportLoopCount (this , loopCount );
1417
+ if (CompilerDirectives .hasNextTier () && loopCount [ 0 ] > 0 ) {
1418
+ LoopNode .reportLoopCount (this , loopCount [ 0 ] );
1415
1419
}
1416
1420
if (e == pe ) {
1417
1421
throw pe ;
0 commit comments