@@ -249,6 +249,10 @@ public abstract static class CallNode extends PythonVarargsBuiltinNode {
249
249
@ Child private IsSubtypeNode isSubTypeNode ;
250
250
@ Child private TypeNodes .GetNameNode getNameNode ;
251
251
252
+ @ CompilationFinal private ConditionProfile hasNew = ConditionProfile .createBinaryProfile ();
253
+ @ CompilationFinal private ConditionProfile hasInit = ConditionProfile .createBinaryProfile ();
254
+ @ CompilationFinal private ConditionProfile gotInitResult = ConditionProfile .createBinaryProfile ();
255
+
252
256
@ CompilationFinal private boolean newWasDescriptor = false ;
253
257
254
258
public static CallNode create () {
@@ -379,7 +383,7 @@ protected Object doItIndirect1(VirtualFrame frame, PythonNativeObject self, Obje
379
383
380
384
private Object op (VirtualFrame frame , Object self , Object [] arguments , PKeyword [] keywords , boolean doCreateArgs , PythonObjectLibrary lib ) {
381
385
Object newMethod = lookupNew .execute (self );
382
- if (newMethod != PNone .NO_VALUE ) {
386
+ if (hasNew . profile ( newMethod != PNone .NO_VALUE ) ) {
383
387
CompilerAsserts .partialEvaluationConstant (doCreateArgs );
384
388
Object [] newArgs = doCreateArgs ? PositionalArgumentsNode .prependArgument (self , arguments ) : arguments ;
385
389
Object newInstance ;
@@ -396,7 +400,7 @@ private Object op(VirtualFrame frame, Object self, Object[] arguments, PKeyword[
396
400
Object newInstanceKlass = lib .getLazyPythonClass (newInstance );
397
401
if (isSubType (newInstanceKlass , self )) {
398
402
Object initMethod = lookupInit .execute (frame , newInstanceKlass , newInstance );
399
- if (initMethod != PNone .NO_VALUE ) {
403
+ if (hasInit . profile ( initMethod != PNone .NO_VALUE ) ) {
400
404
Object [] initArgs ;
401
405
if (doCreateArgs ) {
402
406
initArgs = PositionalArgumentsNode .prependArgument (newInstance , arguments );
@@ -406,7 +410,7 @@ private Object op(VirtualFrame frame, Object self, Object[] arguments, PKeyword[
406
410
initArgs = arguments ;
407
411
}
408
412
Object initResult = dispatchInit .execute (frame , initMethod , initArgs , keywords );
409
- if (initResult != PNone .NONE && initResult != PNone .NO_VALUE ) {
413
+ if (gotInitResult . profile ( initResult != PNone .NONE && initResult != PNone .NO_VALUE ) ) {
410
414
throw raise (TypeError , ErrorMessages .SHOULD_RETURN_NONE , "__init__()" );
411
415
}
412
416
}
0 commit comments