Details

Bug

Resolution: Fixed

P4

8

b91

Verified
Description
I am working on Boxing elimination in Hotspot JIT and the java/lang/Math/DivModTests.java fails like next:
bash2.05b$ bin/java d64 Xcomp DivModTests
FAIL: Math.floorMod(3, 3) = 0 differs from Math.floor(x, y): 0
FAIL: Math.floorMod(2, 3) = 2 differs from Math.floor(x, y): 2
FAIL: Math.floorMod(1, 3) = 1 differs from Math.floor(x, y): 1
...
FAIL: Long.floorMod(9223372036854775808, 1) = 0 is different than BigDecimal result: 0
Exception in thread "main" java.lang.RuntimeException: 51 errors found in DivMod methods.
at DivModTests.main(DivModTests.java:48)
The problem are next checks which compare boxing object (Integer or Long) with int (or long) value:
140 if (fr != result) {
243 if (fr != result) {
javac generates pointers compare for such cases:
119 fast_iload #8
121 invokestatic 18 <java/lang/Integer.valueOf(I)Ljava/lang/Integer;>
124 aload_3
125 if_acmpeq 163
These checks will only pass if a value is in the range of boxing cache (as they are in the test) .
If 'result' is not in [128,127] range the test will fail as above.
bash2.05b$ bin/java d64 Xcomp DivModTests
FAIL: Math.floorMod(3, 3) = 0 differs from Math.floor(x, y): 0
FAIL: Math.floorMod(2, 3) = 2 differs from Math.floor(x, y): 2
FAIL: Math.floorMod(1, 3) = 1 differs from Math.floor(x, y): 1
...
FAIL: Long.floorMod(9223372036854775808, 1) = 0 is different than BigDecimal result: 0
Exception in thread "main" java.lang.RuntimeException: 51 errors found in DivMod methods.
at DivModTests.main(DivModTests.java:48)
The problem are next checks which compare boxing object (Integer or Long) with int (or long) value:
140 if (fr != result) {
243 if (fr != result) {
javac generates pointers compare for such cases:
119 fast_iload #8
121 invokestatic 18 <java/lang/Integer.valueOf(I)Ljava/lang/Integer;>
124 aload_3
125 if_acmpeq 163
These checks will only pass if a value is in the range of boxing cache (as they are in the test) .
If 'result' is not in [128,127] range the test will fail as above.
Attachments
Issue Links
 relates to

JDK6282196 There should be Math.mod(number, modulo) methods
 Closed

JDK8014286 failed java/lang/Math/DivModTests.java after 6934604 changes
 Resolved