Skip to content

Commit a40775b

Browse files
committed
SysModuleBuiltins.ExceptHookNode: use cached version of the GetTracebackFrameNode
1 parent b45a77a commit a40775b

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,8 @@ abstract static class ExceptHookNode extends PythonBuiltinNode {
839839
static final String VALUE_UNKNOWN = "<unknown>";
840840
static final String NL = "\n";
841841

842-
@Child private TracebackBuiltins.MaterializeTruffleStacktraceNode truffleStacktraceNode;
842+
@Child private TracebackBuiltins.GetTracebackFrameNode getTbNode;
843+
@Child private TracebackBuiltins.MaterializeTruffleStacktraceNode materializeStacktraceNode;
843844

844845
@CompilerDirectives.ValueType
845846
static final class SyntaxErrData {
@@ -859,14 +860,22 @@ static final class SyntaxErrData {
859860
}
860861

861862
private PTraceback getNextTb(PTraceback traceback) {
862-
if (truffleStacktraceNode == null) {
863+
if (materializeStacktraceNode == null) {
863864
CompilerDirectives.transferToInterpreterAndInvalidate();
864-
truffleStacktraceNode = insert(TracebackBuiltinsFactory.MaterializeTruffleStacktraceNodeGen.create());
865+
materializeStacktraceNode = insert(TracebackBuiltinsFactory.MaterializeTruffleStacktraceNodeGen.create());
865866
}
866-
truffleStacktraceNode.execute(traceback);
867+
materializeStacktraceNode.execute(traceback);
867868
return traceback.getNext();
868869
}
869870

871+
private PFrame getFrameTb(VirtualFrame frame, PTraceback tb) {
872+
if (getTbNode == null) {
873+
CompilerDirectives.transferToInterpreterAndInvalidate();
874+
getTbNode = insert(TracebackBuiltins.GetTracebackFrameNode.create());
875+
}
876+
return getTbNode.execute(frame, tb);
877+
}
878+
870879
private static void write(VirtualFrame frame, Object file, String data) {
871880
PyObjectCallMethodObjArgs.getUncached().execute(frame, file, WRITE, data);
872881
}
@@ -875,12 +884,8 @@ private static void flush(VirtualFrame frame, Object file) {
875884
PyObjectCallMethodObjArgs.getUncached().execute(frame, file, FLUSH);
876885
}
877886

878-
private static PFrame getFrame(VirtualFrame frame, PTraceback tb) {
879-
return TracebackBuiltins.GetTracebackFrameNode.getUncached().execute(frame, tb);
880-
}
881-
882887
private PCode getCode(VirtualFrame frame, PTraceback tb) {
883-
return factory().createCode(getFrame(frame, tb).getTarget());
888+
return factory().createCode(getFrameTb(frame, tb).getTarget());
884889
}
885890

886891
private static Object str(VirtualFrame frame, Object value) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,6 @@ public static GetTracebackFrameNode create() {
192192
return TracebackBuiltinsFactory.GetTracebackFrameNodeFactory.create(null);
193193
}
194194

195-
public static GetTracebackFrameNode getUncached() {
196-
return TracebackBuiltinsFactory.GetTracebackFrameNodeFactory.getInstance().getUncachedInstance();
197-
}
198-
199195
@Specialization(guards = "hasPFrame(tb)")
200196
PFrame getExisting(PTraceback tb) {
201197
return tb.getFrame();

0 commit comments

Comments
 (0)