Skip to content

Commit 9a7e4f3

Browse files
committed
Moved usage of BigDecimal outside TruffleBoundary
1 parent 9f56199 commit 9a7e4f3

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,9 +976,14 @@ static double compareDoubleToLargeInt(double v, PInt w) {
976976
if (w.bitLength() <= 48) {
977977
return v - w.doubleValue();
978978
} else {
979-
return new BigDecimal(v).compareTo(new BigDecimal(w.getValue()));
979+
return compareUsingBigDecimal(v, w.getValue());
980980
}
981981
}
982+
983+
@TruffleBoundary
984+
private static double compareUsingBigDecimal(double v, BigInteger w) {
985+
return new BigDecimal(v).compareTo(new BigDecimal(w));
986+
}
982987
}
983988

984989
@Builtin(name = __NE__, minNumOfPositionalArgs = 2)

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,12 @@ public Object roundPIntPInt(Object arg, Object n) {
233233

234234
private Object makeInt(BigDecimal d) {
235235
try {
236-
return d.intValueExact();
236+
return intValueExact(d);
237237
} catch (ArithmeticException e) {
238238
// does not fit int, so try long
239239
}
240240
try {
241-
return d.longValueExact();
241+
return longValueExact(d);
242242
} catch (ArithmeticException e) {
243243
// does not fit long, try BigInteger
244244
}
@@ -250,6 +250,16 @@ private Object makeInt(BigDecimal d) {
250250
}
251251
}
252252

253+
@TruffleBoundary
254+
private static int intValueExact(BigDecimal d) {
255+
return d.intValueExact();
256+
}
257+
258+
@TruffleBoundary
259+
private static long longValueExact(BigDecimal d) {
260+
return d.longValueExact();
261+
}
262+
253263
@TruffleBoundary
254264
private static BigDecimal op(long arg, int n) {
255265
try {

0 commit comments

Comments
 (0)