218218import com .oracle .graal .python .nodes .expression .BinaryArithmetic ;
219219import com .oracle .graal .python .nodes .expression .BinaryComparisonNode ;
220220import com .oracle .graal .python .nodes .expression .BinaryOpNode ;
221- import com .oracle .graal .python .nodes .expression .CoerceToBooleanNode ;
222221import com .oracle .graal .python .nodes .expression .TernaryArithmetic ;
223222import com .oracle .graal .python .nodes .frame .GetFrameLocalsNode ;
224223import com .oracle .graal .python .nodes .frame .ReadCallerFrameNode ;
@@ -334,9 +333,8 @@ public abstract static class AbsNode extends PythonUnaryBuiltinNode {
334333
335334 @ Specialization
336335 static Object absObject (VirtualFrame frame , Object object ,
337- @ Bind ("this" ) Node inliningTarget ,
338336 @ Cached PyNumberAbsoluteNode absoluteNode ) {
339- return absoluteNode .execute (frame , inliningTarget , object );
337+ return absoluteNode .executeCached (frame , object );
340338 }
341339 }
342340
@@ -403,11 +401,11 @@ static boolean doGenericSequence(VirtualFrame frame, Node inliningTarget, Sequen
403401
404402 for (int i = 0 ; loopConditionProfile .profile (inliningTarget , i < seqLength ); i ++) {
405403 if (nodeType == AnyOrAllNodeType .ALL &&
406- earlyExitProfile .profile (inliningTarget , !isTrueNode .execute (frame , inliningTarget , getItem .execute (inliningTarget , sequenceStorage , i )))) {
404+ earlyExitProfile .profile (inliningTarget , !isTrueNode .execute (frame , getItem .execute (inliningTarget , sequenceStorage , i )))) {
407405 LoopNode .reportLoopCount (inliningTarget , i );
408406 return false ;
409407 } else if (nodeType == AnyOrAllNodeType .ANY &&
410- earlyExitProfile .profile (inliningTarget , isTrueNode .execute (frame , inliningTarget , getItem .execute (inliningTarget , sequenceStorage , i )))) {
408+ earlyExitProfile .profile (inliningTarget , isTrueNode .execute (frame , getItem .execute (inliningTarget , sequenceStorage , i )))) {
411409 LoopNode .reportLoopCount (inliningTarget , i );
412410 return true ;
413411 }
@@ -436,10 +434,10 @@ protected boolean doHashStorage(VirtualFrame frame, HashingStorage hashingStorag
436434 while (loopConditionProfile .profile (inliningTarget , getIterNext .execute (inliningTarget , hashingStorage , it ))) {
437435 Object key = getIterKey .execute (inliningTarget , hashingStorage , it );
438436 if (nodeType == AnyOrAllNodeType .ALL ) {
439- if (!isTrueNode .execute (frame , inliningTarget , key )) {
437+ if (!isTrueNode .execute (frame , key )) {
440438 return false ;
441439 }
442- } else if (nodeType == AnyOrAllNodeType .ANY && isTrueNode .execute (frame , inliningTarget , key )) {
440+ } else if (nodeType == AnyOrAllNodeType .ANY && isTrueNode .execute (frame , key )) {
443441 return true ;
444442 }
445443 }
@@ -485,7 +483,7 @@ static boolean doObject(VirtualFrame frame, Object object,
485483 try {
486484 Object next = nextNode .execute (frame , iterator );
487485 nbrIter ++;
488- if (!isTrueNode .execute (frame , inliningTarget , next )) {
486+ if (!isTrueNode .execute (frame , next )) {
489487 return false ;
490488 }
491489 } catch (PException e ) {
@@ -538,7 +536,7 @@ static boolean doObject(VirtualFrame frame, Object object,
538536 try {
539537 Object next = nextNode .execute (frame , iterator );
540538 nbrIter ++;
541- if (isTrueNode .execute (frame , inliningTarget , next )) {
539+ if (isTrueNode .execute (frame , next )) {
542540 return true ;
543541 }
544542 } catch (PException e ) {
@@ -1458,35 +1456,35 @@ public IsInstanceNode createRecursive(byte newDepth) {
14581456 return BuiltinFunctionsFactory .IsInstanceNodeFactory .create (newDepth );
14591457 }
14601458
1461- private static TriState isInstanceCheckInternal (VirtualFrame frame , Node inliningTarget , Object instance , Object cls , LookupAndCallBinaryNode instanceCheckNode ,
1462- CoerceToBooleanNode castToBooleanNode ) {
1459+ private static TriState isInstanceCheckInternal (VirtualFrame frame , Object instance , Object cls , LookupAndCallBinaryNode instanceCheckNode ,
1460+ PyObjectIsTrueNode castToBooleanNode ) {
14631461 Object instanceCheckResult = instanceCheckNode .executeObject (frame , cls , instance );
14641462 if (instanceCheckResult == NOT_IMPLEMENTED ) {
14651463 return TriState .UNDEFINED ;
14661464 }
1467- return TriState .valueOf (castToBooleanNode .executeBoolean (frame , inliningTarget , instanceCheckResult ));
1465+ return TriState .valueOf (castToBooleanNode .execute (frame , instanceCheckResult ));
14681466 }
14691467
14701468 @ Specialization (guards = "isPythonClass(cls)" )
14711469 static boolean isInstance (VirtualFrame frame , Object instance , Object cls ,
14721470 @ Bind ("this" ) Node inliningTarget ,
14731471 @ Shared ("instanceCheck" ) @ Cached ("create(InstanceCheck)" ) LookupAndCallBinaryNode instanceCheckNode ,
1474- @ Exclusive @ Cached CoerceToBooleanNode . YesNode castToBooleanNode ,
1472+ @ Exclusive @ Cached PyObjectIsTrueNode castToBooleanNode ,
14751473 @ Cached GetClassNode getClassNode ,
14761474 @ Cached IsSameTypeNode isSameTypeNode ,
14771475 @ Cached IsSubtypeNode isSubtypeNode ) {
14781476 Object instanceClass = getClassNode .execute (inliningTarget , instance );
14791477 return isSameTypeNode .execute (inliningTarget , instanceClass , cls ) || isSubtypeNode .execute (frame , instanceClass , cls )//
1480- || isInstanceCheckInternal (frame , inliningTarget , instance , cls , instanceCheckNode , castToBooleanNode ) == TriState .TRUE ;
1478+ || isInstanceCheckInternal (frame , instance , cls , instanceCheckNode , castToBooleanNode ) == TriState .TRUE ;
14811479 }
14821480
14831481 @ Specialization (guards = {"!isPTuple(cls)" , "!isPythonClass(cls)" })
14841482 static boolean isInstance (VirtualFrame frame , Object instance , Object cls ,
14851483 @ Bind ("this" ) Node inliningTarget ,
14861484 @ Shared ("instanceCheck" ) @ Cached ("create(InstanceCheck)" ) LookupAndCallBinaryNode instanceCheckNode ,
1487- @ Exclusive @ Cached CoerceToBooleanNode . YesNode castToBooleanNode ,
1485+ @ Exclusive @ Cached PyObjectIsTrueNode castToBooleanNode ,
14881486 @ Cached TypeBuiltins .InstanceCheckNode typeInstanceCheckNode ) {
1489- TriState check = isInstanceCheckInternal (frame , inliningTarget , instance , cls , instanceCheckNode , castToBooleanNode );
1487+ TriState check = isInstanceCheckInternal (frame , instance , cls , instanceCheckNode , castToBooleanNode );
14901488 if (check == TriState .UNDEFINED ) {
14911489 return typeInstanceCheckNode .executeWith (frame , cls , instance );
14921490 }
@@ -1515,13 +1513,12 @@ public IsSubClassNode createRecursive(byte newDepth) {
15151513
15161514 @ Specialization (guards = "!isPTuple(cls)" )
15171515 static boolean isSubclass (VirtualFrame frame , Object derived , Object cls ,
1518- @ Bind ("this" ) Node inliningTarget ,
15191516 @ Cached ("create(Subclasscheck)" ) LookupAndCallBinaryNode subclassCheckNode ,
1520- @ Cached CoerceToBooleanNode . YesNode castToBooleanNode ,
1517+ @ Cached PyObjectIsTrueNode castToBooleanNode ,
15211518 @ Cached IsSubtypeNode isSubtypeNode ) {
15221519 Object instanceCheckResult = subclassCheckNode .executeObject (frame , cls , derived );
15231520 if (instanceCheckResult != NOT_IMPLEMENTED ) {
1524- return castToBooleanNode .executeBoolean (frame , inliningTarget , instanceCheckResult );
1521+ return castToBooleanNode .execute (frame , instanceCheckResult );
15251522 }
15261523 return isSubtypeNode .execute (frame , derived , cls );
15271524 }
@@ -1583,7 +1580,7 @@ static Object minmaxSequenceWithKey(VirtualFrame frame, Node inliningTarget, Obj
15831580 BinaryComparisonNode compare ,
15841581 @ Exclusive @ Cached PyObjectGetIter getIter ,
15851582 @ Cached (inline = false ) GetNextNode nextNode ,
1586- @ Exclusive @ Cached CoerceToBooleanNode . YesNode castToBooleanNode ,
1583+ @ Exclusive @ Cached PyObjectIsTrueNode castToBooleanNode ,
15871584 @ Exclusive @ Cached CallNode .Lazy keyCall ,
15881585 @ Exclusive @ Cached InlinedBranchProfile seenNonBoolean ,
15891586 @ Exclusive @ Cached InlinedConditionProfile keywordArgIsNone ,
@@ -1624,10 +1621,10 @@ static Object minmaxSequenceWithKey(VirtualFrame frame, Node inliningTarget, Obj
16241621 isTrue = compare .executeBool (frame , nextKey , currentKey );
16251622 } catch (UnexpectedResultException e ) {
16261623 seenNonBoolean .enter (inliningTarget );
1627- isTrue = castToBooleanNode .executeBoolean (frame , inliningTarget , e .getResult ());
1624+ isTrue = castToBooleanNode .execute (frame , e .getResult ());
16281625 }
16291626 } else {
1630- isTrue = castToBooleanNode .executeBoolean (frame , inliningTarget , compare .executeObject (frame , nextKey , currentKey ));
1627+ isTrue = castToBooleanNode .execute (frame , compare .executeObject (frame , nextKey , currentKey ));
16311628 }
16321629 if (isTrue ) {
16331630 currentKey = nextKey ;
@@ -1644,7 +1641,7 @@ static Object minmaxSequenceWithKey(VirtualFrame frame, Node inliningTarget, Obj
16441641 @ Specialization (guards = {"args.length != 0" })
16451642 static Object minmaxBinaryWithKey (VirtualFrame frame , Node inliningTarget , Object arg1 , Object [] args , Object keywordArgIn , Object defaultVal , String name , BinaryComparisonNode compare ,
16461643 @ Exclusive @ Cached CallNode .Lazy keyCall ,
1647- @ Exclusive @ Cached CoerceToBooleanNode . YesNode castToBooleanNode ,
1644+ @ Exclusive @ Cached PyObjectIsTrueNode castToBooleanNode ,
16481645 @ Exclusive @ Cached InlinedBranchProfile seenNonBoolean ,
16491646 @ Exclusive @ Cached InlinedConditionProfile keywordArgIsNone ,
16501647 @ Exclusive @ Cached InlinedConditionProfile moreThanTwo ,
@@ -1668,10 +1665,10 @@ static Object minmaxBinaryWithKey(VirtualFrame frame, Node inliningTarget, Objec
16681665 isTrue = compare .executeBool (frame , nextKey , currentKey );
16691666 } catch (UnexpectedResultException e ) {
16701667 seenNonBoolean .enter (inliningTarget );
1671- isTrue = castToBooleanNode .executeBoolean (frame , inliningTarget , e .getResult ());
1668+ isTrue = castToBooleanNode .execute (frame , e .getResult ());
16721669 }
16731670 } else {
1674- isTrue = castToBooleanNode .executeBoolean (frame , inliningTarget , compare .executeObject (frame , nextKey , currentKey ));
1671+ isTrue = castToBooleanNode .execute (frame , compare .executeObject (frame , nextKey , currentKey ));
16751672 }
16761673 if (isTrue ) {
16771674 currentKey = nextKey ;
@@ -1688,10 +1685,10 @@ static Object minmaxBinaryWithKey(VirtualFrame frame, Node inliningTarget, Objec
16881685 isTrue = compare .executeBool (frame , nextKey , currentKey );
16891686 } catch (UnexpectedResultException e ) {
16901687 seenNonBoolean .enter (inliningTarget );
1691- isTrue = castToBooleanNode .executeBoolean (frame , inliningTarget , e .getResult ());
1688+ isTrue = castToBooleanNode .execute (frame , e .getResult ());
16921689 }
16931690 } else {
1694- isTrue = castToBooleanNode .executeBoolean (frame , inliningTarget , compare .executeObject (frame , nextKey , currentKey ));
1691+ isTrue = castToBooleanNode .execute (frame , compare .executeObject (frame , nextKey , currentKey ));
16951692 }
16961693 if (isTrue ) {
16971694 currentKey = nextKey ;
@@ -1882,7 +1879,7 @@ PNone printGeneric(VirtualFrame frame, Object[] values, Object sepIn, Object end
18821879 @ Bind ("this" ) Node inliningTarget ,
18831880 @ Cached CastToTruffleStringNode castSep ,
18841881 @ Cached CastToTruffleStringNode castEnd ,
1885- @ Cached CoerceToBooleanNode . YesNode castFlush ,
1882+ @ Cached PyObjectIsTrueNode castFlush ,
18861883 @ Exclusive @ Cached PyObjectGetAttr getWriteMethod ,
18871884 @ Exclusive @ Cached CallNode callWrite ,
18881885 @ Exclusive @ Cached PyObjectCallMethodObjArgs callFlush ,
@@ -1916,7 +1913,7 @@ PNone printGeneric(VirtualFrame frame, Object[] values, Object sepIn, Object end
19161913 if (flushIn instanceof PNone ) {
19171914 flush = false ;
19181915 } else {
1919- flush = castFlush .executeBoolean (frame , inliningTarget , flushIn );
1916+ flush = castFlush .execute (frame , flushIn );
19201917 }
19211918 return printAllGiven (frame , values , sep , end , file , flush , inliningTarget , getWriteMethod , callWrite , callFlush , strNode );
19221919 }
@@ -2152,21 +2149,18 @@ public abstract static class SumFunctionNode extends PythonBuiltinNode {
21522149
21532150 @ Child private LookupAndCallUnaryNode next = LookupAndCallUnaryNode .create (SpecialMethodSlot .Next );
21542151
2155- @ Specialization (guards = "isNoValue(start)" , rewriteOn = UnexpectedResultException .class )
2156- int sumIntNone (VirtualFrame frame , Object arg1 , @ SuppressWarnings ("unused" ) PNone start ,
2157- @ Bind ("this" ) Node inliningTarget ,
2158- @ Shared @ Cached PyNumberAddNode addNode ,
2159- @ Shared @ Cached IsBuiltinObjectProfile errorProfile ,
2160- @ Shared ("getIter" ) @ Cached PyObjectGetIter getIter ) throws UnexpectedResultException {
2161- return sumIntInternal (frame , inliningTarget , arg1 , 0 , addNode , getIter , errorProfile );
2152+ public static boolean isIntOrNone (Object o ) {
2153+ return o instanceof Integer || PGuards .isNoValue (o );
21622154 }
21632155
2164- @ Specialization (rewriteOn = UnexpectedResultException .class )
2165- int sumIntInt (VirtualFrame frame , Object arg1 , int start ,
2156+ @ Specialization (guards = "isIntOrNone(startIn)" , rewriteOn = UnexpectedResultException .class )
2157+ int sumInt (VirtualFrame frame , Object arg1 , Object startIn ,
21662158 @ Bind ("this" ) Node inliningTarget ,
2159+ @ Shared @ Cached InlinedConditionProfile hasStart ,
21672160 @ Shared @ Cached PyNumberAddNode addNode ,
21682161 @ Shared @ Cached IsBuiltinObjectProfile errorProfile ,
21692162 @ Shared ("getIter" ) @ Cached PyObjectGetIter getIter ) throws UnexpectedResultException {
2163+ int start = hasStart .profile (inliningTarget , startIn instanceof Integer ) ? (Integer ) startIn : 0 ;
21702164 return sumIntInternal (frame , inliningTarget , arg1 , start , addNode , getIter , errorProfile );
21712165 }
21722166
@@ -2229,7 +2223,7 @@ private double sumDoubleInternal(VirtualFrame frame, Node inliningTarget, Object
22292223 }
22302224 }
22312225
2232- @ Specialization (replaces = {"sumIntNone" , "sumIntInt " , "sumDoubleDouble" })
2226+ @ Specialization (replaces = {"sumInt " , "sumDoubleDouble" })
22332227 Object sum (VirtualFrame frame , Object arg1 , Object start ,
22342228 @ Bind ("this" ) Node inliningTarget ,
22352229 @ Shared @ Cached PyNumberAddNode addNode ,
0 commit comments