71
71
import com .oracle .graal .python .builtins .objects .common .DynamicObjectStorage ;
72
72
import com .oracle .graal .python .builtins .objects .common .PHashingCollection ;
73
73
import com .oracle .graal .python .builtins .objects .dict .PDict ;
74
+ import com .oracle .graal .python .builtins .objects .function .PBuiltinFunction ;
75
+ import com .oracle .graal .python .builtins .objects .function .PFunction ;
74
76
import com .oracle .graal .python .builtins .objects .function .PKeyword ;
75
77
import com .oracle .graal .python .builtins .objects .list .PList ;
76
78
import com .oracle .graal .python .builtins .objects .mappingproxy .PMappingproxy ;
108
110
import com .oracle .graal .python .runtime .exception .PythonErrorType ;
109
111
import com .oracle .truffle .api .CompilerAsserts ;
110
112
import com .oracle .truffle .api .CompilerDirectives ;
113
+ import com .oracle .truffle .api .CompilerDirectives .CompilationFinal ;
111
114
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
112
115
import com .oracle .truffle .api .dsl .Cached ;
113
116
import com .oracle .truffle .api .dsl .Fallback ;
114
117
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
115
118
import com .oracle .truffle .api .dsl .ImportStatic ;
116
119
import com .oracle .truffle .api .dsl .NodeFactory ;
120
+ import com .oracle .truffle .api .dsl .ReportPolymorphism ;
117
121
import com .oracle .truffle .api .dsl .Specialization ;
118
122
import com .oracle .truffle .api .dsl .TypeSystemReference ;
119
123
import com .oracle .truffle .api .frame .VirtualFrame ;
@@ -191,6 +195,7 @@ Object doit(Object object,
191
195
192
196
@ Builtin (name = __CALL__ , minNumOfPositionalArgs = 1 , takesVarArgs = true , takesVarKeywordArgs = true )
193
197
@ GenerateNodeFactory
198
+ @ ReportPolymorphism
194
199
public abstract static class CallNode extends PythonVarargsBuiltinNode {
195
200
@ Child private CallVarargsMethodNode dispatchNew = CallVarargsMethodNode .create ();
196
201
@ Child private LookupAndCallTernaryNode callNewGet = LookupAndCallTernaryNode .create (__GET__ );
@@ -199,9 +204,10 @@ public abstract static class CallNode extends PythonVarargsBuiltinNode {
199
204
@ Child private LookupAttributeInMRONode lookupInit = LookupAttributeInMRONode .create (__INIT__ );
200
205
@ Child private TypeNodes .IsSameTypeNode isSameTypeNode ;
201
206
@ Child private TypeNodes .GetNameNode getNameNode ;
202
-
203
207
@ Child private IsBuiltinClassProfile isClassClassProfile = IsBuiltinClassProfile .create ();
204
208
209
+ @ CompilationFinal private boolean newWasDescriptor = false ;
210
+
205
211
public static CallNode create () {
206
212
return CallNodeFactory .create ();
207
213
}
@@ -332,7 +338,17 @@ private Object op(VirtualFrame frame, Object self, Object[] arguments, PKeyword[
332
338
if (newMethod != PNone .NO_VALUE ) {
333
339
CompilerAsserts .partialEvaluationConstant (doCreateArgs );
334
340
Object [] newArgs = doCreateArgs ? PositionalArgumentsNode .prependArgument (self , arguments ) : arguments ;
335
- Object newInstance = dispatchNew .execute (frame , callNewGet .execute (frame , newMethod , PNone .NONE , self ), newArgs , keywords );
341
+ Object newInstance ;
342
+ if (!newWasDescriptor && (newMethod instanceof PFunction || newMethod instanceof PBuiltinFunction )) {
343
+ newInstance = dispatchNew .execute (frame , newMethod , newArgs , keywords );
344
+ } else {
345
+ if (!newWasDescriptor ) {
346
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
347
+ reportPolymorphicSpecialize ();
348
+ newWasDescriptor = true ;
349
+ }
350
+ newInstance = dispatchNew .execute (frame , callNewGet .execute (frame , newMethod , PNone .NONE , self ), newArgs , keywords );
351
+ }
336
352
Object newInstanceKlass = lib .getLazyPythonClass (newInstance );
337
353
if (isSameType (newInstanceKlass , self )) {
338
354
if (arguments .length == 2 && isClassClassProfile .profileClass (self , PythonBuiltinClassType .PythonClass )) {
0 commit comments