From 5f4b4b5b1e5fa55d3f9bb3a3509328a35e86e46c Mon Sep 17 00:00:00 2001 From: Ondrej Tethal Date: Fri, 4 Jul 2025 10:36:31 +0200 Subject: [PATCH] Ensure bci is constant for infrequentBytecodes --- .../nodes/bytecode/PBytecodeRootNode.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java index 1821bf253f..b52333a7aa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java @@ -2305,12 +2305,21 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod bci++; continue; } - default: { - long r = infrequentBytecodes(virtualFrame, localFrame, bc, bci, stackTop, beginBci, oparg, localBC, globals, locals, localNames, localNodes, bciSlot, localCelloffset, + case OpCodesConstants.LOAD_FROM_DICT_OR_DEREF: + case OpCodesConstants.LOAD_FROM_DICT_OR_GLOBALS: + case OpCodesConstants.MAKE_TYPE_PARAM: + stackTop = infrequentBytecodes(virtualFrame, localFrame, bc, bci, stackTop, beginBci, oparg, localBC, globals, locals, localNames, localNodes, bciSlot, localCelloffset, useCachedNodes); - stackTop = (int) (r >> 32); - bci = (int) r; - } + bci++; + break; + case OpCodesConstants.LOAD_LOCALS: + case OpCodesConstants.MAKE_TYPE_ALIAS: + case OpCodesConstants.MAKE_GENERIC: + stackTop = infrequentBytecodes(virtualFrame, localFrame, bc, bci, stackTop, beginBci, oparg, localBC, globals, locals, localNames, localNodes, bciSlot, localCelloffset, + useCachedNodes); + break; + default: + throw raiseUnknownBytecodeError(bc); } // prepare next loop oparg = 0; @@ -2400,7 +2409,7 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod } } - private long infrequentBytecodes(VirtualFrame virtualFrame, Frame localFrame, byte bc, int bci, int stackTop, int beginBci, int oparg, byte[] localBC, Object globals, Object locals, + private int infrequentBytecodes(VirtualFrame virtualFrame, Frame localFrame, byte bc, int bci, int stackTop, int beginBci, int oparg, byte[] localBC, Object globals, Object locals, TruffleString[] localNames, Node[] localNodes, int bciSlot, int localCelloffset, boolean useCachedNodes) { switch (bc) { case OpCodesConstants.LOAD_LOCALS: { @@ -2443,7 +2452,7 @@ private long infrequentBytecodes(VirtualFrame virtualFrame, Frame localFrame, by throw raiseUnknownBytecodeError(bc); } - return (long) stackTop << 32 | bci; + return stackTop; } @BytecodeInterpreterSwitch