53
53
import com .oracle .truffle .api .RootCallTarget ;
54
54
import com .oracle .truffle .api .frame .FrameDescriptor ;
55
55
import com .oracle .truffle .api .frame .VirtualFrame ;
56
+ import com .oracle .truffle .api .profiles .ConditionProfile ;
56
57
import com .oracle .truffle .api .source .SourceSection ;
57
58
import com .oracle .truffle .api .strings .TruffleString ;
58
59
@@ -63,6 +64,7 @@ public class PBytecodeGeneratorFunctionRootNode extends PRootNode {
63
64
@ CompilationFinal (dimensions = 1 ) private final RootCallTarget [] callTargets ;
64
65
65
66
@ Child private PythonObjectFactory factory = PythonObjectFactory .create ();
67
+ private final ConditionProfile isIterableCoroutine = ConditionProfile .create ();
66
68
67
69
@ TruffleBoundary
68
70
public PBytecodeGeneratorFunctionRootNode (PythonLanguage language , FrameDescriptor frameDescriptor , PBytecodeRootNode rootNode , TruffleString originalName ) {
@@ -85,12 +87,11 @@ public Object execute(VirtualFrame frame) {
85
87
// if CO_ITERABLE_COROUTINE was explicitly set (likely by types.coroutine), we have to
86
88
// pass the information to the generator
87
89
// .gi_code.co_flags will still be wrong, but at least await will work correctly
88
- if (( generatorFunction .getCode ().getFlags () & 0x100 ) != 0 ) {
90
+ if (isIterableCoroutine . profile (( generatorFunction .getCode ().getFlags () & 0x100 ) != 0 ) ) {
89
91
return factory .createIterableCoroutine (generatorFunction .getName (), generatorFunction .getQualname (), rootNode , callTargets , arguments );
90
92
} else {
91
93
return factory .createGenerator (generatorFunction .getName (), generatorFunction .getQualname (), rootNode , callTargets , arguments );
92
94
}
93
-
94
95
} else if (rootNode .getCodeUnit ().isCoroutine ()) {
95
96
return factory .createCoroutine (generatorFunction .getName (), generatorFunction .getQualname (), rootNode , callTargets , arguments );
96
97
} else if (rootNode .getCodeUnit ().isAsyncGenerator ()) {
0 commit comments