Skip to content

Commit 512b937

Browse files
author
Adam Hrbac
committed
Use PRaiseNode.Lazy for error reporting
1 parent 969b4a3 commit 512b937

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,14 +2595,14 @@ public Object doGeneric(VirtualFrame frame, Object asyncIter,
25952595
@Bind("this") Node inliningTarget,
25962596
@Cached(parameters = "ANext") LookupSpecialMethodSlotNode getANext,
25972597
@Cached InlinedGetClassNode getAsyncIterType,
2598-
@Cached PRaiseNode raiseNoANext,
2598+
@Cached PRaiseNode.Lazy raiseNoANext,
25992599
@Cached CallUnaryMethodNode callANext,
26002600
@Cached TypeNodes.GetNameNode getName) {
26012601
// TODO: two argument anext
26022602
Object type = getAsyncIterType.execute(inliningTarget, asyncIter);
26032603
Object getter = getANext.execute(frame, type, asyncIter);
26042604
if (getter == NO_VALUE) {
2605-
throw raiseNoANext.raise(PythonBuiltinClassType.TypeError, ErrorMessages.OBJECT_NOT_ASYNCGEN, getName.execute(type));
2605+
throw raiseNoANext.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.OBJECT_NOT_ASYNCGEN, getName.execute(type));
26062606
}
26072607
return callANext.executeObject(frame, getter, asyncIter);
26082608
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/GetAwaitableNode.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import com.oracle.truffle.api.dsl.Specialization;
5959
import com.oracle.truffle.api.frame.Frame;
6060
import com.oracle.truffle.api.nodes.Node;
61-
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
6261

6362
@GenerateUncached
6463
@ImportStatic(SpecialMethodSlot.class)
@@ -69,51 +68,44 @@ public abstract class GetAwaitableNode extends Node {
6968
@Specialization
7069
public static Object doGenerator(PGenerator generator,
7170
@Bind("this") Node inliningTarget,
72-
@Cached.Shared("notInAwait") @Cached PRaiseNode raise,
73-
@Cached.Exclusive @Cached PRaiseNode raiseReusedCoro,
74-
@Cached.Shared("errors") @Cached InlinedBranchProfile errorProfile) {
71+
@Cached.Shared("notInAwait") @Cached PRaiseNode.Lazy raise,
72+
@Cached.Exclusive @Cached PRaiseNode.Lazy raiseReusedCoro) {
7573
if (generator.isCoroutine()) {
7674
if (generator.getYieldFrom() != null) {
77-
errorProfile.enter(inliningTarget);
78-
throw raiseReusedCoro.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CORO_ALREADY_AWAITED);
75+
throw raiseReusedCoro.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CORO_ALREADY_AWAITED);
7976
} else {
8077
return generator;
8178
}
8279
} else {
83-
errorProfile.enter(inliningTarget);
84-
throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_BE_USED_AWAIT, "generator");
80+
throw raise.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_BE_USED_AWAIT, "generator");
8581
}
8682
}
8783

8884
@Specialization
8985
public static Object doGeneric(Frame frame, Object awaitable,
9086
@Bind("this") Node inliningTarget,
91-
@Cached.Shared("notInAwait") @Cached PRaiseNode raiseNoAwait,
92-
@Cached.Exclusive @Cached PRaiseNode raiseNotIter,
87+
@Cached.Shared("notInAwait") @Cached PRaiseNode.Lazy raiseNoAwait,
88+
@Cached.Exclusive @Cached PRaiseNode.Lazy raiseNotIter,
9389
@Cached(parameters = "Await") LookupSpecialMethodSlotNode findAwait,
9490
@Cached TypeNodes.GetNameNode getName,
9591
@Cached InlinedGetClassNode getAwaitableType,
9692
@Cached InlinedGetClassNode getIteratorType,
9793
@Cached CallUnaryMethodNode callAwait,
98-
@Cached.Shared("errors") @Cached InlinedBranchProfile errorProfile,
9994
@Cached PyIterCheckNode iterCheck) {
10095
Object type = getAwaitableType.execute(inliningTarget, awaitable);
10196
Object getter = findAwait.execute(frame, type, awaitable);
10297
if (getter == PNone.NO_VALUE) {
103-
errorProfile.enter(inliningTarget);
104-
throw raiseNoAwait.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_BE_USED_AWAIT, getName.execute(type));
98+
throw raiseNoAwait.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_BE_USED_AWAIT, getName.execute(type));
10599
}
106100
Object iterator = callAwait.executeObject(getter, awaitable);
107101
if (iterCheck.execute(inliningTarget, iterator)) {
108102
return iterator;
109103
}
110104
Object itType = getIteratorType.execute(inliningTarget, iterator);
111105
if (itType == PythonBuiltinClassType.PCoroutine) {
112-
errorProfile.enter(inliningTarget);
113-
throw raiseNotIter.raise(PythonBuiltinClassType.TypeError, ErrorMessages.AWAIT_RETURN_COROUTINE);
106+
throw raiseNotIter.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.AWAIT_RETURN_COROUTINE);
114107
} else {
115-
errorProfile.enter(inliningTarget);
116-
throw raiseNotIter.raise(PythonBuiltinClassType.TypeError, ErrorMessages.AWAIT_RETURN_NON_ITER, getName.execute(itType));
108+
throw raiseNotIter.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.AWAIT_RETURN_NON_ITER, getName.execute(itType));
117109
}
118110
}
119111

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ public abstract static class SendNode extends PythonBinaryBuiltinNode {
267267

268268
@Specialization
269269
Object send(VirtualFrame frame, PGenerator self, Object value,
270-
@Bind("this") Node inliningTarget,
271270
@Cached ResumeGeneratorNode resumeGeneratorNode) {
272271
// even though this isn't a builtin for async generators, SendNode is used on async
273272
// generators by PAsyncGenSend

0 commit comments

Comments
 (0)