11/*
22 * Copyright (c) 2023, Azul Systems, Inc. All rights reserved.
3+ * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
34 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45 *
56 * This code is free software; you can redistribute it and/or modify it
3031import org .openjdk .jmh .annotations .Scope ;
3132import org .openjdk .jmh .annotations .Setup ;
3233import org .openjdk .jmh .annotations .State ;
33- import org .openjdk .jmh .infra .Blackhole ;
3434
3535import java .util .Random ;
3636import java .util .concurrent .TimeUnit ;
@@ -50,7 +50,7 @@ public class DremFrem {
5050
5151 @ Benchmark
5252 @ OperationsPerInvocation (DEFAULT_X_RANGE * DEFAULT_Y_RANGE )
53- public void calcFloatJava (Blackhole bh ) {
53+ public void calcFloatJava () {
5454 for (int i = 0 ; i < DEFAULT_X_RANGE ; i ++) {
5555 for (int j = DEFAULT_Y_RANGE ; j > 0 ; j --) {
5656 float x = i ;
@@ -63,7 +63,7 @@ public void calcFloatJava(Blackhole bh) {
6363
6464 @ Benchmark
6565 @ OperationsPerInvocation (DEFAULT_X_RANGE * DEFAULT_Y_RANGE )
66- public void calcDoubleJava (Blackhole bh ) {
66+ public void calcDoubleJava () {
6767 for (int i = 0 ; i < DEFAULT_X_RANGE ; i ++) {
6868 for (int j = DEFAULT_Y_RANGE ; j > 0 ; j --) {
6969 double x = i ;
@@ -73,157 +73,4 @@ public void calcDoubleJava(Blackhole bh) {
7373 }
7474 }
7575 }
76-
77- @ SuppressWarnings ("divzero" )
78- public void cornercaseFloatJava_divzero (Blackhole bh ) {
79- assert Float .isNaN (10 / 0 );
80- assert Float .isNaN (10 / 0 );
81- }
82-
83- @ Benchmark
84- @ OperationsPerInvocation (DEFAULT_X_RANGE * DEFAULT_Y_RANGE )
85- public void cornercaseFloatJava (Blackhole bh ) {
86- for (int i = 0 ; i < DEFAULT_X_RANGE * DEFAULT_Y_RANGE ; i ++) {
87- // Generate some NaNs.
88- float nan = Float .NaN ;
89- float zero_div_zero = 0.0f / 0.0f ;
90- float sqrt_negative = (float )Math .sqrt (-1.0 );
91- float log_negative = (float )Math .log (-1.0 );
92- float inf_minus_inf = Float .POSITIVE_INFINITY - Float .POSITIVE_INFINITY ;
93- float inf_times_zero = Float .POSITIVE_INFINITY * 0.0f ;
94- float quiet_nan1 = Float .intBitsToFloat (0x7fc00001 );
95- float quiet_nan2 = Float .intBitsToFloat (0x7fc00002 );
96- float signaling_nan1 = Float .intBitsToFloat (0x7fa00001 );
97- float signaling_nan2 = Float .intBitsToFloat (0x7fa00002 );
98- float nan_minus = -nan ;
99-
100- // Generate some infinities.
101- float positive_inf = Float .POSITIVE_INFINITY ;
102- float negative_inf = Float .NEGATIVE_INFINITY ;
103- float one_div_zero = 1.0f / 0.0f ;
104- float log_zero = (float )Math .log (0.0 );
105-
106- // Double check that they are actually NaNs.
107- assert Float .isNaN (nan );
108- assert Float .isNaN (zero_div_zero );
109- assert Float .isNaN (sqrt_negative );
110- assert Float .isNaN (inf_minus_inf );
111- assert Float .isNaN (inf_times_zero );
112- assert Float .isNaN (quiet_nan1 );
113- assert Float .isNaN (quiet_nan2 );
114- assert Float .isNaN (signaling_nan1 );
115- assert Float .isNaN (signaling_nan2 );
116- assert Float .isNaN (nan_minus );
117- assert Float .isNaN (log_negative );
118-
119- // Double check that they are infinities.
120- assert Float .isInfinite (positive_inf );
121- assert Float .isInfinite (negative_inf );
122- assert !Float .isNaN (positive_inf );
123- assert !Float .isNaN (negative_inf );
124- assert one_div_zero == positive_inf ;
125- assert log_zero == negative_inf ;
126- // Double check infinities.
127-
128- assert Float .isNaN (positive_inf / 10 );
129- assert Float .isNaN (negative_inf / 10 );
130- cornercaseFloatJava_divzero (bh );
131- assert (+10 / positive_inf ) == +10 ;
132- assert (+10 / negative_inf ) == +10 ;
133- assert (-10 / positive_inf ) == -10 ;
134- assert (-10 / negative_inf ) == -10 ;
135-
136- // NaN comparisons always fail.
137- // Therefore, all tests that we will do afterwards will be just isNaN.
138- assert !(1.0f < nan );
139- assert !(1.0f == nan );
140- assert !(1.0f > nan );
141- assert !(nan == nan );
142-
143- // NaN propagate through most operations.
144- assert Float .isNaN (nan + 1.0f );
145- assert Float .isNaN (1.0f + nan );
146- assert Float .isNaN (nan + nan );
147- assert Float .isNaN (nan / 1.0f );
148- assert Float .isNaN (1.0f / nan );
149- assert Float .isNaN ((float )Math .sqrt ((double )nan ));
150- }
151- }
152-
153- @ SuppressWarnings ("divzero" )
154- public void cornercaseDoubleJava_divzero (Blackhole bh ) {
155- assert Double .isNaN (10 / 0 );
156- assert Double .isNaN (10 / 0 );
157- }
158-
159- @ Benchmark
160- @ OperationsPerInvocation (DEFAULT_X_RANGE * DEFAULT_Y_RANGE )
161- public void cornercaseDoubleJava (Blackhole bh ) {
162- for (int i = 0 ; i < DEFAULT_X_RANGE * DEFAULT_Y_RANGE ; i ++) {
163- // Generate some NaNs.
164- double nan = Double .NaN ;
165- double zero_div_zero = 0.0f / 0.0f ;
166- double sqrt_negative = (double )Math .sqrt (-1.0 );
167- double log_negative = (double )Math .log (-1.0 );
168- double inf_minus_inf = Double .POSITIVE_INFINITY - Double .POSITIVE_INFINITY ;
169- double inf_times_zero = Double .POSITIVE_INFINITY * 0.0f ;
170- double quiet_nan1 = Double .longBitsToDouble (0x7ffc000000000001L );
171- double quiet_nan2 = Double .longBitsToDouble (0x7ffc000000000002L );
172- double signaling_nan1 = Double .longBitsToDouble (0x7ffa000000000001L );
173- double signaling_nan2 = Double .longBitsToDouble (0x7ffa000000000002L );
174- double nan_minus = -nan ;
175-
176- // Generate some infinities.
177- double positive_inf = Double .POSITIVE_INFINITY ;
178- double negative_inf = Double .NEGATIVE_INFINITY ;
179- double one_div_zero = 1.0d / 0.0f ;
180- double log_zero = (double )Math .log (0.0 );
181-
182- // Double check that they are actually NaNs.
183- assert Double .isNaN (nan );
184- assert Double .isNaN (zero_div_zero );
185- assert Double .isNaN (sqrt_negative );
186- assert Double .isNaN (inf_minus_inf );
187- assert Double .isNaN (inf_times_zero );
188- assert Double .isNaN (quiet_nan1 );
189- assert Double .isNaN (quiet_nan2 );
190- assert Double .isNaN (signaling_nan1 );
191- assert Double .isNaN (signaling_nan2 );
192- assert Double .isNaN (nan_minus );
193- assert Double .isNaN (log_negative );
194-
195- // Double check that they are infinities.
196- assert Double .isInfinite (positive_inf );
197- assert Double .isInfinite (negative_inf );
198- assert !Double .isNaN (positive_inf );
199- assert !Double .isNaN (negative_inf );
200- assert one_div_zero == positive_inf ;
201- assert log_zero == negative_inf ;
202- // Double check infinities.
203-
204- assert Double .isNaN (positive_inf / 10 );
205- assert Double .isNaN (negative_inf / 10 );
206- cornercaseDoubleJava_divzero (bh );
207- assert (+10 / positive_inf ) == +10 ;
208- assert (+10 / negative_inf ) == +10 ;
209- assert (-10 / positive_inf ) == -10 ;
210- assert (-10 / negative_inf ) == -10 ;
211-
212- // NaN comparisons always fail.
213- // Therefore, all tests that we will do afterwards will be just isNaN.
214- assert !(1.0d < nan );
215- assert !(1.0d == nan );
216- assert !(1.0d > nan );
217- assert !(nan == nan );
218-
219- // NaN propagate through most operations.
220- assert Double .isNaN (nan + 1.0d );
221- assert Double .isNaN (1.0d + nan );
222- assert Double .isNaN (nan + nan );
223- assert Double .isNaN (nan / 1.0d );
224- assert Double .isNaN (1.0d / nan );
225- assert Double .isNaN ((double )Math .sqrt ((double )nan ));
226- }
227- }
228-
22976}
0 commit comments