Skip to content

Commit a14f02d

Browse files
committed
8256267: Relax compiler/floatingpoint/NaNTest.java for x86_32 and lower -XX:+UseSSE
Reviewed-by: kvn, iignatyev
1 parent 7c73fff commit a14f02d

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

test/hotspot/jtreg/compiler/floatingpoint/NaNTest.java

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,23 @@
2424
* @test
2525
* @bug 8076373
2626
* @summary Verify if signaling NaNs are preserved.
27+
* @library /test/lib /
2728
*
28-
* @run main compiler.floatingpoint.NaNTest
29+
* @build sun.hotspot.WhiteBox
30+
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
31+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
32+
* compiler.floatingpoint.NaNTest
2933
*/
3034

3135
package compiler.floatingpoint;
3236

37+
import jdk.test.lib.Platform;
38+
import jtreg.SkippedException;
39+
import sun.hotspot.WhiteBox;
40+
3341
public class NaNTest {
42+
static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
43+
3444
static void testFloat() {
3545
int originalValue = 0x7f800001;
3646
int readBackValue = Float.floatToRawIntBits(Float.intBitsToFloat(originalValue));
@@ -63,11 +73,34 @@ static void testDouble() {
6373
}
6474

6575
public static void main(String args[]) {
66-
System.out.println("### NanTest started");
76+
// Some platforms are known to strip signaling NaNs.
77+
// The block below can be used to except them.
78+
boolean expectStableFloats = true;
79+
boolean expectStableDoubles = true;
80+
81+
// On x86_32 without relevant SSE-enabled stubs, we are entering
82+
// native methods that use FPU instructions, and those strip the
83+
// signaling NaNs.
84+
if (Platform.isX86()) {
85+
int sse = WHITE_BOX.getIntxVMFlag("UseSSE").intValue();
86+
expectStableFloats = (sse >= 1);
87+
expectStableDoubles = (sse >= 2);
88+
}
89+
90+
if (expectStableFloats) {
91+
testFloat();
92+
} else {
93+
System.out.println("Stable floats cannot be expected, skipping");
94+
}
6795

68-
testFloat();
69-
testDouble();
96+
if (expectStableDoubles) {
97+
testDouble();
98+
} else {
99+
System.out.println("Stable doubles cannot be expected, skipping");
100+
}
70101

71-
System.out.println("### NanTest ended");
102+
if (!expectStableFloats && !expectStableDoubles) {
103+
throw new SkippedException("No tests were run.");
104+
}
72105
}
73106
}

0 commit comments

Comments
 (0)