|
105 | 105 | import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CArrayWrapper;
|
106 | 106 | import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CByteArrayWrapper;
|
107 | 107 | import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CStringWrapper;
|
| 108 | +import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.ClearCurrentExceptionNode; |
108 | 109 | import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.EnsureTruffleStringNode;
|
109 | 110 | import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.TransformExceptionFromNativeNode;
|
| 111 | +import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.TransformExceptionToNativeNode; |
110 | 112 | import com.oracle.graal.python.builtins.objects.cext.common.CExtContext;
|
111 | 113 | import com.oracle.graal.python.builtins.objects.cext.common.CExtContext.ModuleSpec;
|
112 | 114 | import com.oracle.graal.python.builtins.objects.cext.common.GetNextVaArgNode;
|
|
125 | 127 | import com.oracle.graal.python.builtins.objects.module.PythonModule;
|
126 | 128 | import com.oracle.graal.python.builtins.objects.object.PythonObject;
|
127 | 129 | import com.oracle.graal.python.builtins.objects.str.PString;
|
128 |
| -import com.oracle.graal.python.builtins.objects.traceback.LazyTraceback; |
129 | 130 | import com.oracle.graal.python.builtins.objects.traceback.MaterializeLazyTracebackNode;
|
130 | 131 | import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass;
|
131 | 132 | import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass;
|
|
153 | 154 | import com.oracle.graal.python.nodes.call.CallNode;
|
154 | 155 | import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode.LookupAndCallUnaryDynamicNode;
|
155 | 156 | import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
|
156 |
| -import com.oracle.graal.python.nodes.frame.GetCurrentFrameRef; |
157 | 157 | import com.oracle.graal.python.nodes.object.GetClassNode;
|
158 | 158 | import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode;
|
159 | 159 | import com.oracle.graal.python.nodes.util.CannotCastException;
|
@@ -994,94 +994,6 @@ static long doSingleContext(Object cls, CFields nativeMember, HiddenAttr managed
|
994 | 994 | }
|
995 | 995 | }
|
996 | 996 |
|
997 |
| - /** |
998 |
| - * Use this node to transform an exception to native if a Python exception was thrown during an |
999 |
| - * upcall and before returning to native code. This node will reify the exception appropriately |
1000 |
| - * and register the exception as the current exception. |
1001 |
| - */ |
1002 |
| - @GenerateInline(inlineByDefault = true) |
1003 |
| - @GenerateCached |
1004 |
| - @GenerateUncached |
1005 |
| - public abstract static class TransformExceptionToNativeNode extends Node { |
1006 |
| - |
1007 |
| - public abstract void execute(Frame frame, Node inliningTarget, PException e, LazyTraceback tb); |
1008 |
| - |
1009 |
| - public final void execute(Node inliningTarget, PException e) { |
1010 |
| - execute(null, inliningTarget, e, null); |
1011 |
| - } |
1012 |
| - |
1013 |
| - public final void execute(Frame frame, Node inliningTarget, PException e) { |
1014 |
| - execute(frame, inliningTarget, e, null); |
1015 |
| - } |
1016 |
| - |
1017 |
| - public final void execute(Node inliningTarget, PException e, LazyTraceback tb) { |
1018 |
| - execute(null, inliningTarget, e, tb); |
1019 |
| - } |
1020 |
| - |
1021 |
| - public final void executeCached(PException e) { |
1022 |
| - execute(null, this, e, null); |
1023 |
| - } |
1024 |
| - |
1025 |
| - @Specialization |
1026 |
| - static void setCurrentException(Frame frame, Node inliningTarget, PException e, LazyTraceback tb, |
1027 |
| - @Cached GetCurrentFrameRef getCurrentFrameRef, |
1028 |
| - @Cached GetThreadStateNode getThreadStateNode, |
1029 |
| - @Cached GetClassNode getClassNode, |
1030 |
| - @Cached(inline = false) PythonToNativeNode pythonToNativeNode, |
1031 |
| - @Cached(inline = false) CStructAccess.WritePointerNode writePointerNode) { |
1032 |
| - // TODO connect f_back |
1033 |
| - getCurrentFrameRef.execute(frame, inliningTarget).markAsEscaped(); |
1034 |
| - PythonContext.PythonThreadState threadState = getThreadStateNode.execute(inliningTarget); |
1035 |
| - if (tb != null) { |
1036 |
| - threadState.setCurrentException(e, tb); |
1037 |
| - } else { |
1038 |
| - threadState.setCurrentException(e); |
1039 |
| - } |
1040 |
| - /* |
1041 |
| - * Mirror the global exception state to native for faster access. For now, we only write |
1042 |
| - * 'PyThreadState.curexc_type' (which is the only one required for 'PyErr_Occurred'). |
1043 |
| - * Since that won't escape the exception object to the program, we can use |
1044 |
| - * 'getUnreifiedException'. As soon as we provide the exception object and the traceback |
1045 |
| - * as well, we need to use 'getEscapedException'. |
1046 |
| - */ |
1047 |
| - PThreadState nativeWrapper = threadState.getNativeWrapper(); |
1048 |
| - if (nativeWrapper != null) { |
1049 |
| - Object exceptionType = getClassNode.execute(inliningTarget, e.getUnreifiedException()); |
1050 |
| - Object nativeThreadState = PThreadState.getOrCreateNativeThreadState(threadState); |
1051 |
| - /* |
1052 |
| - * Write a borrowed ref to the native mirror because we need to keep that in sync |
1053 |
| - * anyway. |
1054 |
| - */ |
1055 |
| - writePointerNode.write(nativeThreadState, CFields.PyThreadState__curexc_type, pythonToNativeNode.execute(exceptionType)); |
1056 |
| - } |
1057 |
| - } |
1058 |
| - } |
1059 |
| - |
1060 |
| - @GenerateInline |
1061 |
| - @GenerateCached(false) |
1062 |
| - @GenerateUncached |
1063 |
| - public abstract static class ClearCurrentExceptionNode extends Node { |
1064 |
| - |
1065 |
| - public abstract void execute(Node inliningTarget, PythonThreadState threadState); |
1066 |
| - |
1067 |
| - public final PException getCurrentExceptionForReraise(Node inliningTarget, PythonThreadState threadState) { |
1068 |
| - PException exceptionForReraise = threadState.getCurrentExceptionForReraise(); |
1069 |
| - execute(inliningTarget, threadState); |
1070 |
| - return exceptionForReraise; |
1071 |
| - } |
1072 |
| - |
1073 |
| - @Specialization |
1074 |
| - static void doGeneric(PythonThreadState threadState, |
1075 |
| - @Cached(inline = false) CStructAccess.WritePointerNode writePointerNode) { |
1076 |
| - threadState.clearCurrentException(); |
1077 |
| - PThreadState nativeWrapper = threadState.getNativeWrapper(); |
1078 |
| - if (nativeWrapper != null) { |
1079 |
| - Object nativeThreadState = PThreadState.getOrCreateNativeThreadState(threadState); |
1080 |
| - writePointerNode.write(nativeThreadState, CFields.PyThreadState__curexc_type, 0L); |
1081 |
| - } |
1082 |
| - } |
1083 |
| - } |
1084 |
| - |
1085 | 997 | @GenerateInline
|
1086 | 998 | @GenerateCached(false)
|
1087 | 999 | @GenerateUncached
|
|
0 commit comments