58
58
import com .oracle .truffle .api .dsl .Specialization ;
59
59
import com .oracle .truffle .api .frame .Frame ;
60
60
import com .oracle .truffle .api .nodes .Node ;
61
- import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
62
61
63
62
@ GenerateUncached
64
63
@ ImportStatic (SpecialMethodSlot .class )
@@ -69,51 +68,44 @@ public abstract class GetAwaitableNode extends Node {
69
68
@ Specialization
70
69
public static Object doGenerator (PGenerator generator ,
71
70
@ 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 ) {
75
73
if (generator .isCoroutine ()) {
76
74
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 );
79
76
} else {
80
77
return generator ;
81
78
}
82
79
} 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" );
85
81
}
86
82
}
87
83
88
84
@ Specialization
89
85
public static Object doGeneric (Frame frame , Object awaitable ,
90
86
@ 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 ,
93
89
@ Cached (parameters = "Await" ) LookupSpecialMethodSlotNode findAwait ,
94
90
@ Cached TypeNodes .GetNameNode getName ,
95
91
@ Cached InlinedGetClassNode getAwaitableType ,
96
92
@ Cached InlinedGetClassNode getIteratorType ,
97
93
@ Cached CallUnaryMethodNode callAwait ,
98
- @ Cached .Shared ("errors" ) @ Cached InlinedBranchProfile errorProfile ,
99
94
@ Cached PyIterCheckNode iterCheck ) {
100
95
Object type = getAwaitableType .execute (inliningTarget , awaitable );
101
96
Object getter = findAwait .execute (frame , type , awaitable );
102
97
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 ));
105
99
}
106
100
Object iterator = callAwait .executeObject (getter , awaitable );
107
101
if (iterCheck .execute (inliningTarget , iterator )) {
108
102
return iterator ;
109
103
}
110
104
Object itType = getIteratorType .execute (inliningTarget , iterator );
111
105
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 );
114
107
} 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 ));
117
109
}
118
110
}
119
111
0 commit comments