@@ -616,6 +616,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod
616616 private static final byte TRACE_PROFILE_NEW_FRAME = 1 << 1 ;
617617 private static final byte TRACE_PROFILE_EXISTING_FRAME = 1 << 2 ;
618618 private static final byte TRACE_PROFILE_SYNC_LOCALS_BACK = 1 << 3 ;
619+ private static final byte TRACE_PROFILE_DID_JUMP = 1 << 4 ;
619620 @ CompilationFinal (dimensions = 1 ) byte [] traceProfileData ;
620621
621622 @ CompilationFinal private Object osrMetadata ;
@@ -1346,10 +1347,9 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod
13461347 if (isTracingEnabled (tracingOrProfilingEnabled )) {
13471348 final int stackDiff = traceLine (virtualFrame , mutableData , localBC , bci );
13481349 if (stackDiff <= 0 ) {
1349- // The loop must be partially unrollable assuming a certain sequence of bytecode
1350- // instructions. A jump can happen non-deterministically and thus break this
1351- // assumption. This can happen repeatedly, so we don't invalidate
1352- CompilerDirectives .transferToInterpreter ();
1350+ // See traceLine, if we get here, we should be in the interpreter already, but
1351+ // SVM can't prove it, so transfer again
1352+ CompilerDirectives .transferToInterpreterAndInvalidate ();
13531353 bci = mutableData .getJumpBci ();
13541354 stackTop += stackDiff ;
13551355 continue ;
@@ -3050,6 +3050,11 @@ private int traceLine(VirtualFrame virtualFrame, MutableLoopData mutableData, by
30503050 invokeTraceFunction (virtualFrame , null , mutableData .getThreadState (this ), mutableData , PythonContext .TraceEvent .LINE ,
30513051 mutableData .getPastLine (), true , bci );
30523052 if (pyFrame .didJump ()) {
3053+ enterTraceProfile (bci , TRACE_PROFILE_DID_JUMP );
3054+ // The loop must be partially unrollable assuming a certain sequence of bytecode
3055+ // instructions. A jump can happen non-deterministically and thus break this
3056+ // assumption. This can happen repeatedly, so we don't invalidate
3057+ CompilerDirectives .transferToInterpreter ();
30533058 int newBci = lineToBci (pyFrame .getJumpDestLine ());
30543059 mutableData .setPastBci (bci );
30553060 if (newBci == BytecodeCodeUnit .LINE_TO_BCI_LINE_AFTER_CODEBLOCK ) {
0 commit comments