Skip to content

Commit dc359f7

Browse files
committed
Rename CastToDouble to CoerceToDouble
1 parent 27fe7a5 commit dc359f7

File tree

4 files changed

+57
-56
lines changed

4 files changed

+57
-56
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
import com.oracle.graal.python.nodes.subscript.SliceLiteralNode;
173173
import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes;
174174
import com.oracle.graal.python.nodes.util.CastToByteNode;
175-
import com.oracle.graal.python.nodes.util.CastToDoubleNode;
175+
import com.oracle.graal.python.nodes.util.CoerceToDoubleNode;
176176
import com.oracle.graal.python.nodes.util.CastToJavaIntNode;
177177
import com.oracle.graal.python.nodes.util.CastToJavaStringNode;
178178
import com.oracle.graal.python.nodes.util.CastToJavaStringNodeGen;
@@ -498,8 +498,8 @@ PComplex complexFromObjectObject(LazyPythonClass cls, String real, Object imagin
498498
private GetLazyClassNode getClassNode;
499499
private IsBuiltinClassProfile isComplexTypeProfile;
500500
private BranchProfile errorProfile;
501-
private CastToDoubleNode castRealNode;
502-
private CastToDoubleNode castImagNode;
501+
private CoerceToDoubleNode castRealNode;
502+
private CoerceToDoubleNode castImagNode;
503503
private IsBuiltinClassProfile profile;
504504
private LookupAndCallUnaryNode.LookupAndCallUnaryDynamicNode callComplexFunc;
505505

@@ -525,18 +525,18 @@ private BranchProfile getErrorProfile() {
525525
return errorProfile;
526526
}
527527

528-
private CastToDoubleNode getCastRealNode() {
528+
private CoerceToDoubleNode getCastRealNode() {
529529
if (castRealNode == null) {
530530
CompilerDirectives.transferToInterpreterAndInvalidate();
531-
castRealNode = insert(CastToDoubleNode.create());
531+
castRealNode = insert(CoerceToDoubleNode.create());
532532
}
533533
return castRealNode;
534534
}
535535

536-
private CastToDoubleNode getCastImagNode() {
536+
private CoerceToDoubleNode getCastImagNode() {
537537
if (castImagNode == null) {
538538
CompilerDirectives.transferToInterpreterAndInvalidate();
539-
castImagNode = insert(CastToDoubleNode.create());
539+
castImagNode = insert(CoerceToDoubleNode.create());
540540
}
541541
return castImagNode;
542542
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode;
6161
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
6262
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;
6464
import com.oracle.graal.python.nodes.util.CastToIntegerFromIntNode;
6565
import com.oracle.graal.python.runtime.exception.PException;
6666
import com.oracle.graal.python.runtime.exception.PythonErrorType;
@@ -137,7 +137,7 @@ public double doPI(PInt value) {
137137

138138
@Specialization(guards = "!isNumber(value)")
139139
public double doGeneral(VirtualFrame frame, Object value,
140-
@Cached("create()") CastToDoubleNode convertToFloat) {
140+
@Cached("create()") CoerceToDoubleNode convertToFloat) {
141141
return count(convertToFloat.execute(frame, value));
142142
}
143143
}
@@ -267,7 +267,7 @@ public Object ceil(VirtualFrame frame, PInt value,
267267

268268
@Specialization(guards = {"!isNumber(value)"})
269269
public Object ceil(VirtualFrame frame, Object value,
270-
@Cached("create()") CastToDoubleNode convertToFloat,
270+
@Cached("create()") CoerceToDoubleNode convertToFloat,
271271
@Cached("create(__CEIL__)") LookupAndCallUnaryNode dispatchCeil) {
272272
Object result = dispatchCeil.executeObject(frame, value);
273273
if (result == PNone.NO_VALUE) {
@@ -331,8 +331,8 @@ public double copySignPIPI(PInt magnitude, PInt sign) {
331331

332332
@Specialization(guards = "!isNumber(magnitude) || !isNumber(sign)")
333333
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) {
336336
return copySignDD(castMagnitudeNode.execute(frame, magnitude), castSignNode.execute(frame, sign));
337337
}
338338
}
@@ -585,7 +585,7 @@ public Object floorPI(VirtualFrame frame, PInt value,
585585
@Specialization(guards = {"!isNumber(value)"})
586586
public Object floor(VirtualFrame frame, Object value,
587587
@Cached("create(__FLOOR__)") LookupAndCallUnaryNode dispatchFloor,
588-
@Cached("create()") CastToDoubleNode castNode,
588+
@Cached("create()") CoerceToDoubleNode castNode,
589589
@Cached("create()") FloorNode recursiveNode) {
590590
Object result = dispatchFloor.executeObject(frame, value);
591591
if (PNone.NO_VALUE == result) {
@@ -680,8 +680,8 @@ public double fmodPID(PInt left, double right) {
680680

681681
@Specialization(guards = {"!isNumber(left) || !isNumber(right)"})
682682
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,
685685
@Cached("createBinaryProfile()") ConditionProfile infProfile,
686686
@Cached("createBinaryProfile()") ConditionProfile zeroProfile) {
687687
return fmodDD(castLeftNode.execute(frame, left), castRightNode.execute(frame, right), infProfile, zeroProfile);
@@ -768,7 +768,7 @@ public PTuple frexpPI(VirtualFrame frame, PInt value,
768768

769769
@Specialization(guards = "!isNumber(value)")
770770
public PTuple frexpO(VirtualFrame frame, Object value,
771-
@Cached("create()") CastToDoubleNode convertToFloat) {
771+
@Cached("create()") CoerceToDoubleNode convertToFloat) {
772772
return frexpD(convertToFloat.execute(frame, value));
773773
}
774774
}
@@ -795,7 +795,7 @@ public boolean isNan(double value) {
795795

796796
@Specialization(guards = "!isNumber(value)")
797797
public boolean isinf(VirtualFrame frame, Object value,
798-
@Cached("create()") CastToDoubleNode convertToFloat) {
798+
@Cached("create()") CoerceToDoubleNode convertToFloat) {
799799
return isNan(convertToFloat.execute(frame, value));
800800
}
801801
}
@@ -808,10 +808,10 @@ public abstract static class IsCloseNode extends PythonBuiltinNode {
808808
private static final double DEFAULT_REL = 1e-09;
809809
private static final double DEFAULT_ABS = 0.0;
810810

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;
815815

816816
private boolean isCloseDouble(double a, double b, double rel_tol, double abs_tol) {
817817
double diff;
@@ -883,10 +883,10 @@ public boolean isClose(long a, long b, double rel_tol, double abs_tol) {
883883
public boolean isClose(VirtualFrame frame, Object a, Object b, Object rel_tol, Object abs_tol) {
884884
if (castAbsNode == null) {
885885
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());
890890
}
891891
double a_value = castANode.execute(frame, a);
892892
double b_value = castBNode.execute(frame, b);
@@ -986,15 +986,15 @@ public double ldexpPIL(PInt mantissa, long exp) {
986986
return exceptInfinity(Math.scalb(dm, makeInt(exp)), dm);
987987
}
988988

989-
@Child private CastToDoubleNode castNode;
989+
@Child private CoerceToDoubleNode castNode;
990990
@Child private LdexpNode recursiveNode;
991991

992992
@Fallback
993993
public double ldexpOO(VirtualFrame frame, Object mantissa, Object exp) {
994994
if (PGuards.isInteger(exp) || PGuards.isPInt(exp) || (exp instanceof Boolean)) {
995995
if (recursiveNode == null) {
996996
CompilerDirectives.transferToInterpreterAndInvalidate();
997-
castNode = insert(CastToDoubleNode.create());
997+
castNode = insert(CoerceToDoubleNode.create());
998998
recursiveNode = insert(LdexpNode.create());
999999
}
10001000
return recursiveNode.execute(frame, castNode.execute(frame, mantissa), exp);
@@ -1040,7 +1040,7 @@ PTuple modfPI(PInt value) {
10401040

10411041
@Specialization(guards = "!isNumber(value)")
10421042
PTuple modfO(VirtualFrame frame, Object value,
1043-
@Cached("create()") CastToDoubleNode convertToFloatNode) {
1043+
@Cached("create()") CoerceToDoubleNode convertToFloatNode) {
10441044
return modfD(convertToFloatNode.execute(frame, value));
10451045
}
10461046
}
@@ -1055,7 +1055,7 @@ public abstract static class FsumNode extends PythonUnaryBuiltinNode {
10551055
double doIt(VirtualFrame frame, Object iterable,
10561056
@Cached GetIteratorNode getIterator,
10571057
@Cached("create(__NEXT__)") LookupAndCallUnaryNode next,
1058-
@Cached CastToDoubleNode toFloat,
1058+
@Cached CoerceToDoubleNode toFloat,
10591059
@Cached IsBuiltinClassProfile stopProfile) {
10601060
Object iterator = getIterator.executeWith(frame, iterable);
10611061
return fsum(frame, iterator, next, toFloat, stopProfile);
@@ -1071,7 +1071,7 @@ public abstract static class FsumNode extends PythonUnaryBuiltinNode {
10711071
* is little bit faster. The testFSum in test_math.py takes in different implementations:
10721072
* CPython ~0.6s CurrentImpl: ~14.3s Using BigDecimal: ~15.1
10731073
*/
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) {
10751075
double x, y, t, hi, lo = 0, yr, inf_sum = 0, special_sum = 0, sum;
10761076
double xsave;
10771077
int i, j, n = 0, arayLength = 32;
@@ -1427,7 +1427,7 @@ public boolean isfinite(double value) {
14271427

14281428
@Specialization(guards = "!isNumber(value)")
14291429
public boolean isinf(VirtualFrame frame, Object value,
1430-
@Cached("create()") CastToDoubleNode convertToFloat) {
1430+
@Cached("create()") CoerceToDoubleNode convertToFloat) {
14311431
return isfinite(convertToFloat.execute(frame, value));
14321432
}
14331433
}
@@ -1455,7 +1455,7 @@ public boolean isinf(double value) {
14551455

14561456
@Specialization(guards = "!isNumber(value)")
14571457
public boolean isinf(VirtualFrame frame, Object value,
1458-
@Cached("create()") CastToDoubleNode convertToFloat) {
1458+
@Cached("create()") CoerceToDoubleNode convertToFloat) {
14591459
return isinf(convertToFloat.execute(frame, value));
14601460
}
14611461
}
@@ -1466,22 +1466,22 @@ public boolean isinf(VirtualFrame frame, Object value,
14661466
@GenerateNodeFactory
14671467
public abstract static class LogNode extends PythonBinaryBuiltinNode {
14681468

1469-
@Child private CastToDoubleNode valueCastNode;
1470-
@Child private CastToDoubleNode baseCastNode;
1469+
@Child private CoerceToDoubleNode valueCastNode;
1470+
@Child private CoerceToDoubleNode baseCastNode;
14711471
@Child private LogNode recLogNode;
14721472

1473-
private CastToDoubleNode getValueCastNode() {
1473+
private CoerceToDoubleNode getValueCastNode() {
14741474
if (valueCastNode == null) {
14751475
CompilerDirectives.transferToInterpreterAndInvalidate();
1476-
valueCastNode = insert(CastToDoubleNode.create());
1476+
valueCastNode = insert(CoerceToDoubleNode.create());
14771477
}
14781478
return valueCastNode;
14791479
}
14801480

1481-
private CastToDoubleNode getBaseCastNode() {
1481+
private CoerceToDoubleNode getBaseCastNode() {
14821482
if (baseCastNode == null) {
14831483
CompilerDirectives.transferToInterpreterAndInvalidate();
1484-
baseCastNode = insert(CastToDoubleNode.create());
1484+
baseCastNode = insert(CoerceToDoubleNode.create());
14851485
}
14861486
return baseCastNode;
14871487
}
@@ -1770,7 +1770,7 @@ public double fabs(double value) {
17701770

17711771
@Specialization(guards = "!isNumber(value)")
17721772
public double fabs(VirtualFrame frame, Object value,
1773-
@Cached("create()") CastToDoubleNode castValueNode) {
1773+
@Cached("create()") CoerceToDoubleNode castValueNode) {
17741774
return fabs(castValueNode.execute(frame, value));
17751775
}
17761776
}
@@ -1871,8 +1871,8 @@ public abstract static class PowNode extends PythonBinaryBuiltinNode {
18711871

18721872
@Specialization(guards = {"!isNumber(left)||!isNumber(right)"})
18731873
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) {
18761876
return pow(convertLeftFloat.execute(frame, left), convertRightFloat.execute(frame, right));
18771877
}
18781878
}
@@ -1945,8 +1945,8 @@ public abstract static class Atan2Node extends PythonBinaryBuiltinNode {
19451945

19461946
@Specialization(guards = "!isNumber(left) || !isNumber(right)")
19471947
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) {
19501950
return atan2DD(convertLeftFloat.execute(frame, left), convertRightFloat.execute(frame, right));
19511951
}
19521952
}
@@ -1986,8 +1986,8 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments,
19861986

19871987
@Specialization(guards = "arguments.length == 2")
19881988
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) {
19911991
if (keywords.length != 0) {
19921992
throw raise(PythonBuiltinClassType.TypeError, "hypot() takes no keyword arguments");
19931993
}
@@ -2002,7 +2002,7 @@ public double hypot2(VirtualFrame frame, @SuppressWarnings("unused") Object self
20022002

20032003
@Specialization
20042004
public double hypotGeneric(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] arguments, PKeyword[] keywords,
2005-
@Cached("create()") CastToDoubleNode castNode) {
2005+
@Cached("create()") CoerceToDoubleNode castNode) {
20062006
if (keywords.length != 0) {
20072007
throw raise(PythonBuiltinClassType.TypeError, "hypot() takes no keyword arguments");
20082008
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/LockBuiltins.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
6464
import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode;
6565
import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
66-
import com.oracle.graal.python.nodes.util.CastToDoubleNode;
66+
import com.oracle.graal.python.nodes.util.CoerceToDoubleNode;
6767
import com.oracle.truffle.api.CompilerDirectives;
6868
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
6969
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
@@ -84,17 +84,18 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
8484
@Builtin(name = "acquire", minNumOfPositionalArgs = 1, parameterNames = {"self", "blocking", "timeout"})
8585
@GenerateNodeFactory
8686
abstract static class AcquireLockNode extends PythonTernaryBuiltinNode {
87-
private @Child CastToDoubleNode castToDoubleNode;
87+
private @Child
88+
CoerceToDoubleNode coerceToDoubleNode;
8889
private @Child CoerceToBooleanNode castToBooleanNode;
8990
private @CompilationFinal ConditionProfile isBlockingProfile = ConditionProfile.createBinaryProfile();
9091
private @CompilationFinal ConditionProfile defaultTimeoutProfile = ConditionProfile.createBinaryProfile();
9192

92-
private CastToDoubleNode getCastToDoubleNode() {
93-
if (castToDoubleNode == null) {
93+
private CoerceToDoubleNode getCoerceToDoubleNode() {
94+
if (coerceToDoubleNode == null) {
9495
CompilerDirectives.transferToInterpreterAndInvalidate();
95-
castToDoubleNode = insert(CastToDoubleNode.create());
96+
coerceToDoubleNode = insert(CoerceToDoubleNode.create());
9697
}
97-
return castToDoubleNode;
98+
return coerceToDoubleNode;
9899
}
99100

100101
private CoerceToBooleanNode getCastToBooleanNode() {
@@ -111,7 +112,7 @@ boolean doAcquire(VirtualFrame frame, AbstractPythonLock self, Object blocking,
111112
boolean isBlocking = (blocking instanceof PNone) ? DEFAULT_BLOCKING : getCastToBooleanNode().executeBoolean(frame, blocking);
112113
double timeoutSeconds = UNSET_TIMEOUT;
113114
if (!(timeout instanceof PNone)) {
114-
timeoutSeconds = getCastToDoubleNode().execute(frame, timeout);
115+
timeoutSeconds = getCoerceToDoubleNode().execute(frame, timeout);
115116

116117
if (timeoutSeconds != UNSET_TIMEOUT) {
117118
if (!isBlocking) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToDoubleNode.java renamed to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToDoubleNode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@
6161

6262
@TypeSystemReference(PythonArithmeticTypes.class)
6363
@ImportStatic(MathGuards.class)
64-
public abstract class CastToDoubleNode extends PNodeWithContext {
64+
public abstract class CoerceToDoubleNode extends PNodeWithContext {
6565
@Child private LookupAndCallUnaryNode callFloatNode;
6666

6767
public abstract double execute(VirtualFrame frame, Object x);
6868

69-
public static CastToDoubleNode create() {
70-
return CastToDoubleNodeGen.create();
69+
public static CoerceToDoubleNode create() {
70+
return CoerceToDoubleNodeGen.create();
7171
}
7272

7373
@Specialization

0 commit comments

Comments
 (0)