Skip to content

Commit 0b89f88

Browse files
committed
Use exact math operations from Math module for now
1 parent 9887cb6 commit 0b89f88

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@
184184
import com.oracle.graal.python.runtime.sequence.storage.LongSequenceStorage;
185185
import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage;
186186
import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
187-
import com.oracle.graal.python.util.OverflowException;
188187
import com.oracle.graal.python.util.PythonUtils;
189188
import com.oracle.truffle.api.Assumption;
190189
import com.oracle.truffle.api.CompilerAsserts;
@@ -2143,8 +2142,8 @@ private void bytecodeBinaryOpIII(VirtualFrame virtualFrame, int stackTop, int bc
21432142
case BinaryOpsConstants.ADD:
21442143
case BinaryOpsConstants.INPLACE_ADD:
21452144
try {
2146-
result = PythonUtils.addExact(left, right);
2147-
} catch (OverflowException e) {
2145+
result = Math.addExact(left, right);
2146+
} catch (ArithmeticException e) {
21482147
CompilerDirectives.transferToInterpreterAndInvalidate();
21492148
bytecode[bci] = OpCodesConstants.BINARY_OP_II_O;
21502149
bytecodeBinaryOpIIO(virtualFrame, stackTop, bci, adoptedNodes, op);
@@ -2154,8 +2153,8 @@ private void bytecodeBinaryOpIII(VirtualFrame virtualFrame, int stackTop, int bc
21542153
case BinaryOpsConstants.SUB:
21552154
case BinaryOpsConstants.INPLACE_SUB:
21562155
try {
2157-
result = PythonUtils.subtractExact(left, right);
2158-
} catch (OverflowException e) {
2156+
result = Math.subtractExact(left, right);
2157+
} catch (ArithmeticException e) {
21592158
CompilerDirectives.transferToInterpreterAndInvalidate();
21602159
bytecode[bci] = OpCodesConstants.BINARY_OP_II_O;
21612160
bytecodeBinaryOpIIO(virtualFrame, stackTop, bci, adoptedNodes, op);
@@ -2165,8 +2164,8 @@ private void bytecodeBinaryOpIII(VirtualFrame virtualFrame, int stackTop, int bc
21652164
case BinaryOpsConstants.MUL:
21662165
case BinaryOpsConstants.INPLACE_MUL:
21672166
try {
2168-
result = PythonUtils.multiplyExact(left, right);
2169-
} catch (OverflowException e) {
2167+
result = Math.multiplyExact(left, right);
2168+
} catch (ArithmeticException e) {
21702169
CompilerDirectives.transferToInterpreterAndInvalidate();
21712170
bytecode[bci] = OpCodesConstants.BINARY_OP_II_O;
21722171
bytecodeBinaryOpIIO(virtualFrame, stackTop, bci, adoptedNodes, op);

0 commit comments

Comments
 (0)