Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert multiply to use non-intrinsic exactness checks
The call to Math.multiplyExact works very well when the result does not overflow, skipping range checks and using the host CPU's support for overflow checks. However when we are dancing on the range boundary and multiplyExact fails repeatedly, the cost of raising all those exceptions massively outweighs the gains. This is the primary cause of performance issues reported in jruby#8516. This patch reverts to a version of the old range-checking logic. Performance on the bug report's benchmark is an order of magnitude faster for the two cases that seemed to overflow a lot, and the other cases do not seem to degrade. Fixes jruby#8516
- Loading branch information