Skip to content

Commit a93c031

Browse files
committed
tweak bytecodeLoadFastO, it is one of the most frequent bytecodes
1 parent acd7f08 commit a93c031

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3696,16 +3696,27 @@ private void bytecodeLoadFastO(VirtualFrame virtualFrame, Frame localFrame, int
36963696
} catch (FrameSlotTypeException e) {
36973697
// This should only happen when quickened concurrently in multi-context
36983698
// mode
3699-
generalizeVariableStores(index);
3700-
value = localFrame.getValue(index);
3699+
value = generalizeBytecodeLoadFastO(localFrame, index);
37013700
}
37023701
if (value == null) {
3703-
PRaiseNode raiseNode = insertChildNode(adoptedNodes, bci, PRaiseNodeGen.class, NODE_RAISE);
3704-
throw raiseNode.raise(PythonBuiltinClassType.UnboundLocalError, ErrorMessages.LOCAL_VAR_REFERENCED_BEFORE_ASSIGMENT, varnames[index]);
3702+
throw raiseVarReferencedBeforeAssignment(bci, index);
37053703
}
37063704
virtualFrame.setObject(stackTop, value);
37073705
}
37083706

3707+
@InliningCutoff
3708+
private PException raiseVarReferencedBeforeAssignment(int bci, int index) {
3709+
PRaiseNode raiseNode = insertChildNode(adoptedNodes, bci, PRaiseNodeGen.class, NODE_RAISE);
3710+
throw raiseNode.raise(PythonBuiltinClassType.UnboundLocalError, ErrorMessages.LOCAL_VAR_REFERENCED_BEFORE_ASSIGMENT, varnames[index]);
3711+
}
3712+
3713+
@InliningCutoff
3714+
private Object generalizeBytecodeLoadFastO(Frame localFrame, int index) {
3715+
CompilerDirectives.transferToInterpreterAndInvalidate();
3716+
generalizeVariableStores(index);
3717+
return localFrame.getValue(index);
3718+
}
3719+
37093720
private static byte stackSlotTypeToTypeId(VirtualFrame virtualFrame, int stackTop) {
37103721
return QuickeningTypes.fromFrameSlotTag(virtualFrame.getTag(stackTop));
37113722
}

0 commit comments

Comments
 (0)