Skip to content

Commit 80d45ed

Browse files
committed
Fix exception chaining
1 parent 50d6363 commit 80d45ed

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
import com.oracle.graal.python.nodes.subscript.DeleteItemNode;
129129
import com.oracle.graal.python.nodes.subscript.GetItemNode;
130130
import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode;
131+
import com.oracle.graal.python.nodes.util.ExceptionStateNodes;
131132
import com.oracle.graal.python.parser.GeneratorInfo;
132133
import com.oracle.graal.python.runtime.ExecutionContext.CalleeContext;
133134
import com.oracle.graal.python.runtime.PythonContext;
@@ -382,6 +383,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod
382383
@Children private final Node[] adoptedNodes;
383384
@Child private CalleeContext calleeContext = CalleeContext.create();
384385
@Child private PythonObjectFactory factory = PythonObjectFactory.create();
386+
@Child private ExceptionStateNodes.GetCaughtExceptionNode getCaughtExceptionNode;
385387
@CompilationFinal private LoopConditionProfile exceptionChainProfile1 = LoopConditionProfile.createCountingProfile();
386388
@CompilationFinal private LoopConditionProfile exceptionChainProfile2 = LoopConditionProfile.createCountingProfile();
387389
@CompilationFinal private Object osrMetadata;
@@ -1373,7 +1375,11 @@ Object executeFromBci(VirtualFrame virtualFrame, Frame localFrame, Frame stackFr
13731375
}
13741376
long newTarget = findHandler(bci);
13751377
CompilerAsserts.partialEvaluationConstant(newTarget);
1376-
PException exceptionState = PArguments.getException(virtualFrame);
1378+
if (getCaughtExceptionNode == null) {
1379+
CompilerDirectives.transferToInterpreterAndInvalidate();
1380+
getCaughtExceptionNode = ExceptionStateNodes.GetCaughtExceptionNode.create();
1381+
}
1382+
PException exceptionState = getCaughtExceptionNode.execute(virtualFrame);
13771383
if (exceptionState != null) {
13781384
ExceptionHandlingStatementNode.chainExceptions(pe.getUnreifiedException(), exceptionState, exceptionChainProfile1, exceptionChainProfile2);
13791385
}

0 commit comments

Comments
 (0)