Skip to content

Commit 2450c9d

Browse files
msimacektomasstupka
authored andcommitted
Save the current bci every bytecode loop
1 parent aba0f1e commit 2450c9d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/FrameInfo.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ public int bciToLine(int bci) {
6363
}
6464

6565
public int getBci(Frame frame) {
66-
if (frame.isInt(rootNode.bcioffset)) {
67-
return frame.getInt(rootNode.bcioffset);
68-
}
69-
return -1;
66+
return frame.getIntStatic(rootNode.bcioffset);
7067
}
7168

7269
public Object getYieldFrom(Frame generatorFrame, int bci, int stackTop) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ private static FrameDescriptor makeFrameDescriptor(CodeUnit co) {
416416
// stack
417417
newBuilder.addSlots(co.stacksize, FrameSlotKind.Illegal);
418418
// BCI filled when unwinding the stack or when pausing generators
419-
newBuilder.addSlot(FrameSlotKind.Int, null, null);
419+
newBuilder.addSlot(FrameSlotKind.Static, null, null);
420420
if (co.isGeneratorOrCoroutine()) {
421421
// stackTop saved when pausing a generator
422422
newBuilder.addSlot(FrameSlotKind.Int, null, null);
@@ -754,6 +754,9 @@ Object executeFromBci(VirtualFrame virtualFrame, Frame localFrame, Frame stackFr
754754
long[] localLongConsts = longConsts;
755755
String[] localNames = names;
756756
Node[] localNodes = adoptedNodes;
757+
final int bciSlot = bcioffset;
758+
759+
virtualFrame.setIntStatic(bciSlot, initialBci);
757760

758761
/*
759762
* This separate tracking of local exception is necessary to make exception state saving
@@ -775,6 +778,7 @@ Object executeFromBci(VirtualFrame virtualFrame, Frame localFrame, Frame stackFr
775778
while (true) {
776779
final byte bc = localBC[bci];
777780
final int beginBci = bci;
781+
virtualFrame.setIntStatic(bciSlot, bci);
778782

779783
CompilerAsserts.partialEvaluationConstant(bc);
780784
CompilerAsserts.partialEvaluationConstant(bci);
@@ -1409,7 +1413,7 @@ Object executeFromBci(VirtualFrame virtualFrame, Frame localFrame, Frame stackFr
14091413
}
14101414
if (newTarget == -1) {
14111415
// For tracebacks
1412-
virtualFrame.setInt(bcioffset, beginBci);
1416+
virtualFrame.setIntStatic(bciSlot, beginBci);
14131417
if (isGeneratorOrCoroutine) {
14141418
if (localFrame != stackFrame) {
14151419
// Unwind the generator frame stack

0 commit comments

Comments
 (0)