|
105 | 105 | import com.oracle.truffle.api.nodes.UnexpectedResultException;
|
106 | 106 | import com.oracle.truffle.api.object.DynamicObjectLibrary;
|
107 | 107 | import com.oracle.truffle.api.object.HiddenKey;
|
| 108 | +import com.oracle.truffle.api.profiles.BranchProfile; |
108 | 109 |
|
109 | 110 | @CoreFunctions(defineModule = "_warnings")
|
110 | 111 | public class WarningsModuleBuiltins extends PythonBuiltins {
|
@@ -942,12 +943,18 @@ public final void warn(Frame frame, Object category, String message) {
|
942 | 943 | protected abstract void execute(Frame frame, Object source, Object category, String format, int stackLevel, Object... formatArgs);
|
943 | 944 |
|
944 | 945 | private static final class WarnNodeCached extends WarnNode {
|
| 946 | + @CompilationFinal BranchProfile noFrame = BranchProfile.create(); |
945 | 947 | @CompilationFinal ContextReference<PythonContext> ctxRef;
|
946 | 948 | @Child PythonObjectLibrary lib;
|
947 | 949 | @Child WarningsModuleNode moduleFunctionsNode;
|
948 | 950 |
|
949 | 951 | @Override
|
950 | 952 | protected void execute(Frame frame, Object source, Object category, String format, int stackLevel, Object... formatArgs) {
|
| 953 | + if (frame == null) { |
| 954 | + noFrame.enter(); |
| 955 | + UNCACHED.execute(null, source, category, format, stackLevel, formatArgs); |
| 956 | + return; |
| 957 | + } |
951 | 958 | assert frame instanceof VirtualFrame;
|
952 | 959 | if (ctxRef == null) {
|
953 | 960 | CompilerDirectives.transferToInterpreterAndInvalidate();
|
@@ -1006,7 +1013,6 @@ protected void execute(Frame frame, Object source, Object category, String forma
|
1006 | 1013 | }
|
1007 | 1014 | lib.callObject(warn, null, message, category, stackLevel, source);
|
1008 | 1015 | }
|
1009 |
| - |
1010 | 1016 | }
|
1011 | 1017 | }
|
1012 | 1018 | }
|
0 commit comments