60
60
import com .oracle .graal .python .nodes .function .builtins .PythonVarargsBuiltinNode ;
61
61
import com .oracle .graal .python .nodes .object .IsBuiltinClassProfile ;
62
62
import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
63
- import com .oracle .graal .python .nodes .util .CastToDoubleNode ;
63
+ import com .oracle .graal .python .nodes .util .CoerceToDoubleNode ;
64
64
import com .oracle .graal .python .nodes .util .CastToIntegerFromIntNode ;
65
65
import com .oracle .graal .python .runtime .exception .PException ;
66
66
import com .oracle .graal .python .runtime .exception .PythonErrorType ;
@@ -137,7 +137,7 @@ public double doPI(PInt value) {
137
137
138
138
@ Specialization (guards = "!isNumber(value)" )
139
139
public double doGeneral (VirtualFrame frame , Object value ,
140
- @ Cached ("create()" ) CastToDoubleNode convertToFloat ) {
140
+ @ Cached ("create()" ) CoerceToDoubleNode convertToFloat ) {
141
141
return count (convertToFloat .execute (frame , value ));
142
142
}
143
143
}
@@ -267,7 +267,7 @@ public Object ceil(VirtualFrame frame, PInt value,
267
267
268
268
@ Specialization (guards = {"!isNumber(value)" })
269
269
public Object ceil (VirtualFrame frame , Object value ,
270
- @ Cached ("create()" ) CastToDoubleNode convertToFloat ,
270
+ @ Cached ("create()" ) CoerceToDoubleNode convertToFloat ,
271
271
@ Cached ("create(__CEIL__)" ) LookupAndCallUnaryNode dispatchCeil ) {
272
272
Object result = dispatchCeil .executeObject (frame , value );
273
273
if (result == PNone .NO_VALUE ) {
@@ -331,8 +331,8 @@ public double copySignPIPI(PInt magnitude, PInt sign) {
331
331
332
332
@ Specialization (guards = "!isNumber(magnitude) || !isNumber(sign)" )
333
333
public double copySignOO (VirtualFrame frame , Object magnitude , Object sign ,
334
- @ Cached ("create()" ) CastToDoubleNode castMagnitudeNode ,
335
- @ Cached ("create()" ) CastToDoubleNode castSignNode ) {
334
+ @ Cached ("create()" ) CoerceToDoubleNode castMagnitudeNode ,
335
+ @ Cached ("create()" ) CoerceToDoubleNode castSignNode ) {
336
336
return copySignDD (castMagnitudeNode .execute (frame , magnitude ), castSignNode .execute (frame , sign ));
337
337
}
338
338
}
@@ -585,7 +585,7 @@ public Object floorPI(VirtualFrame frame, PInt value,
585
585
@ Specialization (guards = {"!isNumber(value)" })
586
586
public Object floor (VirtualFrame frame , Object value ,
587
587
@ Cached ("create(__FLOOR__)" ) LookupAndCallUnaryNode dispatchFloor ,
588
- @ Cached ("create()" ) CastToDoubleNode castNode ,
588
+ @ Cached ("create()" ) CoerceToDoubleNode castNode ,
589
589
@ Cached ("create()" ) FloorNode recursiveNode ) {
590
590
Object result = dispatchFloor .executeObject (frame , value );
591
591
if (PNone .NO_VALUE == result ) {
@@ -680,8 +680,8 @@ public double fmodPID(PInt left, double right) {
680
680
681
681
@ Specialization (guards = {"!isNumber(left) || !isNumber(right)" })
682
682
public double fmodLO (VirtualFrame frame , Object left , Object right ,
683
- @ Cached ("create()" ) CastToDoubleNode castLeftNode ,
684
- @ Cached ("create()" ) CastToDoubleNode castRightNode ,
683
+ @ Cached ("create()" ) CoerceToDoubleNode castLeftNode ,
684
+ @ Cached ("create()" ) CoerceToDoubleNode castRightNode ,
685
685
@ Cached ("createBinaryProfile()" ) ConditionProfile infProfile ,
686
686
@ Cached ("createBinaryProfile()" ) ConditionProfile zeroProfile ) {
687
687
return fmodDD (castLeftNode .execute (frame , left ), castRightNode .execute (frame , right ), infProfile , zeroProfile );
@@ -768,7 +768,7 @@ public PTuple frexpPI(VirtualFrame frame, PInt value,
768
768
769
769
@ Specialization (guards = "!isNumber(value)" )
770
770
public PTuple frexpO (VirtualFrame frame , Object value ,
771
- @ Cached ("create()" ) CastToDoubleNode convertToFloat ) {
771
+ @ Cached ("create()" ) CoerceToDoubleNode convertToFloat ) {
772
772
return frexpD (convertToFloat .execute (frame , value ));
773
773
}
774
774
}
@@ -795,7 +795,7 @@ public boolean isNan(double value) {
795
795
796
796
@ Specialization (guards = "!isNumber(value)" )
797
797
public boolean isinf (VirtualFrame frame , Object value ,
798
- @ Cached ("create()" ) CastToDoubleNode convertToFloat ) {
798
+ @ Cached ("create()" ) CoerceToDoubleNode convertToFloat ) {
799
799
return isNan (convertToFloat .execute (frame , value ));
800
800
}
801
801
}
@@ -808,10 +808,10 @@ public abstract static class IsCloseNode extends PythonBuiltinNode {
808
808
private static final double DEFAULT_REL = 1e-09 ;
809
809
private static final double DEFAULT_ABS = 0.0 ;
810
810
811
- @ Child private CastToDoubleNode castANode ;
812
- @ Child private CastToDoubleNode castBNode ;
813
- @ Child private CastToDoubleNode castRelNode ;
814
- @ Child private CastToDoubleNode castAbsNode ;
811
+ @ Child private CoerceToDoubleNode castANode ;
812
+ @ Child private CoerceToDoubleNode castBNode ;
813
+ @ Child private CoerceToDoubleNode castRelNode ;
814
+ @ Child private CoerceToDoubleNode castAbsNode ;
815
815
816
816
private boolean isCloseDouble (double a , double b , double rel_tol , double abs_tol ) {
817
817
double diff ;
@@ -883,10 +883,10 @@ public boolean isClose(long a, long b, double rel_tol, double abs_tol) {
883
883
public boolean isClose (VirtualFrame frame , Object a , Object b , Object rel_tol , Object abs_tol ) {
884
884
if (castAbsNode == null ) {
885
885
CompilerDirectives .transferToInterpreterAndInvalidate ();
886
- castANode = insert (CastToDoubleNode .create ());
887
- castBNode = insert (CastToDoubleNode .create ());
888
- castRelNode = insert (CastToDoubleNode .create ());
889
- castAbsNode = insert (CastToDoubleNode .create ());
886
+ castANode = insert (CoerceToDoubleNode .create ());
887
+ castBNode = insert (CoerceToDoubleNode .create ());
888
+ castRelNode = insert (CoerceToDoubleNode .create ());
889
+ castAbsNode = insert (CoerceToDoubleNode .create ());
890
890
}
891
891
double a_value = castANode .execute (frame , a );
892
892
double b_value = castBNode .execute (frame , b );
@@ -986,15 +986,15 @@ public double ldexpPIL(PInt mantissa, long exp) {
986
986
return exceptInfinity (Math .scalb (dm , makeInt (exp )), dm );
987
987
}
988
988
989
- @ Child private CastToDoubleNode castNode ;
989
+ @ Child private CoerceToDoubleNode castNode ;
990
990
@ Child private LdexpNode recursiveNode ;
991
991
992
992
@ Fallback
993
993
public double ldexpOO (VirtualFrame frame , Object mantissa , Object exp ) {
994
994
if (PGuards .isInteger (exp ) || PGuards .isPInt (exp ) || (exp instanceof Boolean )) {
995
995
if (recursiveNode == null ) {
996
996
CompilerDirectives .transferToInterpreterAndInvalidate ();
997
- castNode = insert (CastToDoubleNode .create ());
997
+ castNode = insert (CoerceToDoubleNode .create ());
998
998
recursiveNode = insert (LdexpNode .create ());
999
999
}
1000
1000
return recursiveNode .execute (frame , castNode .execute (frame , mantissa ), exp );
@@ -1040,7 +1040,7 @@ PTuple modfPI(PInt value) {
1040
1040
1041
1041
@ Specialization (guards = "!isNumber(value)" )
1042
1042
PTuple modfO (VirtualFrame frame , Object value ,
1043
- @ Cached ("create()" ) CastToDoubleNode convertToFloatNode ) {
1043
+ @ Cached ("create()" ) CoerceToDoubleNode convertToFloatNode ) {
1044
1044
return modfD (convertToFloatNode .execute (frame , value ));
1045
1045
}
1046
1046
}
@@ -1055,7 +1055,7 @@ public abstract static class FsumNode extends PythonUnaryBuiltinNode {
1055
1055
double doIt (VirtualFrame frame , Object iterable ,
1056
1056
@ Cached GetIteratorNode getIterator ,
1057
1057
@ Cached ("create(__NEXT__)" ) LookupAndCallUnaryNode next ,
1058
- @ Cached CastToDoubleNode toFloat ,
1058
+ @ Cached CoerceToDoubleNode toFloat ,
1059
1059
@ Cached IsBuiltinClassProfile stopProfile ) {
1060
1060
Object iterator = getIterator .executeWith (frame , iterable );
1061
1061
return fsum (frame , iterator , next , toFloat , stopProfile );
@@ -1071,7 +1071,7 @@ public abstract static class FsumNode extends PythonUnaryBuiltinNode {
1071
1071
* is little bit faster. The testFSum in test_math.py takes in different implementations:
1072
1072
* CPython ~0.6s CurrentImpl: ~14.3s Using BigDecimal: ~15.1
1073
1073
*/
1074
- private double fsum (VirtualFrame frame , Object iterator , LookupAndCallUnaryNode next , CastToDoubleNode toFloat , IsBuiltinClassProfile stopProfile ) {
1074
+ private double fsum (VirtualFrame frame , Object iterator , LookupAndCallUnaryNode next , CoerceToDoubleNode toFloat , IsBuiltinClassProfile stopProfile ) {
1075
1075
double x , y , t , hi , lo = 0 , yr , inf_sum = 0 , special_sum = 0 , sum ;
1076
1076
double xsave ;
1077
1077
int i , j , n = 0 , arayLength = 32 ;
@@ -1427,7 +1427,7 @@ public boolean isfinite(double value) {
1427
1427
1428
1428
@ Specialization (guards = "!isNumber(value)" )
1429
1429
public boolean isinf (VirtualFrame frame , Object value ,
1430
- @ Cached ("create()" ) CastToDoubleNode convertToFloat ) {
1430
+ @ Cached ("create()" ) CoerceToDoubleNode convertToFloat ) {
1431
1431
return isfinite (convertToFloat .execute (frame , value ));
1432
1432
}
1433
1433
}
@@ -1455,7 +1455,7 @@ public boolean isinf(double value) {
1455
1455
1456
1456
@ Specialization (guards = "!isNumber(value)" )
1457
1457
public boolean isinf (VirtualFrame frame , Object value ,
1458
- @ Cached ("create()" ) CastToDoubleNode convertToFloat ) {
1458
+ @ Cached ("create()" ) CoerceToDoubleNode convertToFloat ) {
1459
1459
return isinf (convertToFloat .execute (frame , value ));
1460
1460
}
1461
1461
}
@@ -1466,22 +1466,22 @@ public boolean isinf(VirtualFrame frame, Object value,
1466
1466
@ GenerateNodeFactory
1467
1467
public abstract static class LogNode extends PythonBinaryBuiltinNode {
1468
1468
1469
- @ Child private CastToDoubleNode valueCastNode ;
1470
- @ Child private CastToDoubleNode baseCastNode ;
1469
+ @ Child private CoerceToDoubleNode valueCastNode ;
1470
+ @ Child private CoerceToDoubleNode baseCastNode ;
1471
1471
@ Child private LogNode recLogNode ;
1472
1472
1473
- private CastToDoubleNode getValueCastNode () {
1473
+ private CoerceToDoubleNode getValueCastNode () {
1474
1474
if (valueCastNode == null ) {
1475
1475
CompilerDirectives .transferToInterpreterAndInvalidate ();
1476
- valueCastNode = insert (CastToDoubleNode .create ());
1476
+ valueCastNode = insert (CoerceToDoubleNode .create ());
1477
1477
}
1478
1478
return valueCastNode ;
1479
1479
}
1480
1480
1481
- private CastToDoubleNode getBaseCastNode () {
1481
+ private CoerceToDoubleNode getBaseCastNode () {
1482
1482
if (baseCastNode == null ) {
1483
1483
CompilerDirectives .transferToInterpreterAndInvalidate ();
1484
- baseCastNode = insert (CastToDoubleNode .create ());
1484
+ baseCastNode = insert (CoerceToDoubleNode .create ());
1485
1485
}
1486
1486
return baseCastNode ;
1487
1487
}
@@ -1770,7 +1770,7 @@ public double fabs(double value) {
1770
1770
1771
1771
@ Specialization (guards = "!isNumber(value)" )
1772
1772
public double fabs (VirtualFrame frame , Object value ,
1773
- @ Cached ("create()" ) CastToDoubleNode castValueNode ) {
1773
+ @ Cached ("create()" ) CoerceToDoubleNode castValueNode ) {
1774
1774
return fabs (castValueNode .execute (frame , value ));
1775
1775
}
1776
1776
}
@@ -1871,8 +1871,8 @@ public abstract static class PowNode extends PythonBinaryBuiltinNode {
1871
1871
1872
1872
@ Specialization (guards = {"!isNumber(left)||!isNumber(right)" })
1873
1873
double pow (VirtualFrame frame , Object left , Object right ,
1874
- @ Cached ("create()" ) CastToDoubleNode convertLeftFloat ,
1875
- @ Cached ("create()" ) CastToDoubleNode convertRightFloat ) {
1874
+ @ Cached ("create()" ) CoerceToDoubleNode convertLeftFloat ,
1875
+ @ Cached ("create()" ) CoerceToDoubleNode convertRightFloat ) {
1876
1876
return pow (convertLeftFloat .execute (frame , left ), convertRightFloat .execute (frame , right ));
1877
1877
}
1878
1878
}
@@ -1945,8 +1945,8 @@ public abstract static class Atan2Node extends PythonBinaryBuiltinNode {
1945
1945
1946
1946
@ Specialization (guards = "!isNumber(left) || !isNumber(right)" )
1947
1947
double atan2 (VirtualFrame frame , Object left , Object right ,
1948
- @ Cached ("create()" ) CastToDoubleNode convertLeftFloat ,
1949
- @ Cached ("create()" ) CastToDoubleNode convertRightFloat ) {
1948
+ @ Cached ("create()" ) CoerceToDoubleNode convertLeftFloat ,
1949
+ @ Cached ("create()" ) CoerceToDoubleNode convertRightFloat ) {
1950
1950
return atan2DD (convertLeftFloat .execute (frame , left ), convertRightFloat .execute (frame , right ));
1951
1951
}
1952
1952
}
@@ -1986,8 +1986,8 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments,
1986
1986
1987
1987
@ Specialization (guards = "arguments.length == 2" )
1988
1988
public double hypot2 (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object self , Object [] arguments , PKeyword [] keywords ,
1989
- @ Cached ("create()" ) CastToDoubleNode xCastNode ,
1990
- @ Cached ("create()" ) CastToDoubleNode yCastNode ) {
1989
+ @ Cached ("create()" ) CoerceToDoubleNode xCastNode ,
1990
+ @ Cached ("create()" ) CoerceToDoubleNode yCastNode ) {
1991
1991
if (keywords .length != 0 ) {
1992
1992
throw raise (PythonBuiltinClassType .TypeError , "hypot() takes no keyword arguments" );
1993
1993
}
@@ -2002,7 +2002,7 @@ public double hypot2(VirtualFrame frame, @SuppressWarnings("unused") Object self
2002
2002
2003
2003
@ Specialization
2004
2004
public double hypotGeneric (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object self , Object [] arguments , PKeyword [] keywords ,
2005
- @ Cached ("create()" ) CastToDoubleNode castNode ) {
2005
+ @ Cached ("create()" ) CoerceToDoubleNode castNode ) {
2006
2006
if (keywords .length != 0 ) {
2007
2007
throw raise (PythonBuiltinClassType .TypeError , "hypot() takes no keyword arguments" );
2008
2008
}
0 commit comments