Skip to content

Commit e40fde6

Browse files
author
David Simms
committed
[BACKOUT] 8367608: [lworld] Update/reimplement valhalla benchmarks for JEP 401
1 parent 1c011a3 commit e40fde6

File tree

315 files changed

+33729
-20466
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

315 files changed

+33729
-20466
lines changed

make/test/BuildMicrobenchmark.gmk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \
9797
--add-exports java.base/jdk.internal.util=ALL-UNNAMED \
9898
--add-exports java.base/jdk.internal.value=ALL-UNNAMED \
9999
--add-exports java.base/jdk.internal.vm=ALL-UNNAMED \
100-
--add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED \
101100
--add-exports java.base/sun.invoke.util=ALL-UNNAMED \
102101
--add-exports java.base/sun.security.util=ALL-UNNAMED \
103102
--add-exports java.base/sun.security.util.math=ALL-UNNAMED \

test/micro/org/openjdk/bench/valhalla/ackermann/AckermannBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
4141
@State(Scope.Thread)
4242
public abstract class AckermannBase {
4343

44-
// ackermann(1,1748) + ackermann(2,1897) + ackermann(3,8) == 9999999 invocations
44+
// ackermann(1,1748)+ ackermann(2,1897)+ ackermann(3,8); == 9999999 calls
4545
// max depth - 3798
4646
public static final int X1 = 1;
4747
public static final int Y1 = 1748;

test/micro/org/openjdk/bench/valhalla/ackermann/Identity.java

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package org.openjdk.bench.valhalla.ackermann;
24+
25+
import org.openjdk.bench.valhalla.types.Int64;
26+
import org.openjdk.bench.valhalla.types.R64byte;
27+
import org.openjdk.jmh.annotations.Benchmark;
28+
import org.openjdk.jmh.annotations.OperationsPerInvocation;
29+
30+
public class Identity64byte extends AckermannBase {
31+
32+
private static R64byte ack_ref(R64byte x, R64byte y) {
33+
return x.longValue() == 0 ?
34+
new R64byte(y.longValue() + 1) :
35+
(y.longValue() == 0 ?
36+
ack_ref(new R64byte(x.longValue()-1) , new R64byte(1)) :
37+
ack_ref(new R64byte(x.longValue()-1), ack_ref(x, new R64byte(y.longValue()-1))));
38+
}
39+
40+
@Benchmark
41+
@OperationsPerInvocation(OPI)
42+
public long ack_Ref() {
43+
return ack_ref(new R64byte(X1), new R64byte(Y1)).longValue()
44+
+ ack_ref(new R64byte(X2), new R64byte(Y2)).longValue()
45+
+ ack_ref(new R64byte(X3), new R64byte(Y3)).longValue();
46+
}
47+
48+
private static Int64 ack_inter(Int64 x, Int64 y) {
49+
return x.longValue() == 0 ?
50+
new R64byte(y.longValue() + 1) :
51+
(y.longValue() == 0 ?
52+
ack_inter(new R64byte(x.longValue()-1) , new R64byte(1)) :
53+
ack_inter(new R64byte(x.longValue()-1), ack_inter(x, new R64byte(y.longValue()-1))));
54+
}
55+
56+
@Benchmark
57+
@OperationsPerInvocation(OPI)
58+
public long ack_Int() {
59+
return ack_inter(new R64byte(X1), new R64byte(Y1)).longValue()
60+
+ ack_inter(new R64byte(X2), new R64byte(Y2)).longValue()
61+
+ ack_inter(new R64byte(X3), new R64byte(Y3)).longValue();
62+
}
63+
64+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package org.openjdk.bench.valhalla.ackermann;
24+
25+
import org.openjdk.bench.valhalla.types.Int64;
26+
import org.openjdk.bench.valhalla.types.R64int;
27+
import org.openjdk.jmh.annotations.Benchmark;
28+
import org.openjdk.jmh.annotations.OperationsPerInvocation;
29+
30+
public class Identity64int extends AckermannBase {
31+
32+
private static R64int ack_ref(R64int x, R64int y) {
33+
return x.longValue() == 0 ?
34+
new R64int(y.longValue() + 1) :
35+
(y.longValue() == 0 ?
36+
ack_ref(new R64int(x.longValue()-1) , new R64int(1)) :
37+
ack_ref(new R64int(x.longValue()-1), ack_ref(x, new R64int(y.longValue()-1))));
38+
}
39+
40+
@Benchmark
41+
@OperationsPerInvocation(OPI)
42+
public long ack_Ref() {
43+
return ack_ref(new R64int(X1), new R64int(Y1)).longValue()
44+
+ ack_ref(new R64int(X2), new R64int(Y2)).longValue()
45+
+ ack_ref(new R64int(X3), new R64int(Y3)).longValue();
46+
}
47+
48+
private static Int64 ack_inter(Int64 x, Int64 y) {
49+
return x.longValue() == 0 ?
50+
new R64int(y.longValue() + 1) :
51+
(y.longValue() == 0 ?
52+
ack_inter(new R64int(x.longValue()-1) , new R64int(1)) :
53+
ack_inter(new R64int(x.longValue()-1), ack_inter(x, new R64int(y.longValue()-1))));
54+
}
55+
56+
@Benchmark
57+
@OperationsPerInvocation(OPI)
58+
public long ack_Int() {
59+
return ack_inter(new R64int(X1), new R64int(Y1)).longValue()
60+
+ ack_inter(new R64int(X2), new R64int(Y2)).longValue()
61+
+ ack_inter(new R64int(X3), new R64int(Y3)).longValue();
62+
}
63+
64+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package org.openjdk.bench.valhalla.ackermann;
24+
25+
import org.openjdk.bench.valhalla.types.Int64;
26+
import org.openjdk.bench.valhalla.types.R64long;
27+
import org.openjdk.jmh.annotations.Benchmark;
28+
import org.openjdk.jmh.annotations.OperationsPerInvocation;
29+
30+
public class Identity64long extends AckermannBase {
31+
32+
private static R64long ack_ref(R64long x, R64long y) {
33+
return x.longValue() == 0 ?
34+
new R64long(y.longValue() + 1) :
35+
(y.longValue() == 0 ?
36+
ack_ref(new R64long(x.longValue()-1) , new R64long(1)) :
37+
ack_ref(new R64long(x.longValue()-1), ack_ref(x, new R64long(y.longValue()-1))));
38+
}
39+
40+
@Benchmark
41+
@OperationsPerInvocation(OPI)
42+
public long ack_Ref() {
43+
return ack_ref(new R64long(X1), new R64long(Y1)).longValue()
44+
+ ack_ref(new R64long(X2), new R64long(Y2)).longValue()
45+
+ ack_ref(new R64long(X3), new R64long(Y3)).longValue();
46+
}
47+
48+
private static Int64 ack_inter(Int64 x, Int64 y) {
49+
return x.longValue() == 0 ?
50+
new R64long(y.longValue() + 1) :
51+
(y.longValue() == 0 ?
52+
ack_inter(new R64long(x.longValue()-1) , new R64long(1)) :
53+
ack_inter(new R64long(x.longValue()-1), ack_inter(x, new R64long(y.longValue()-1))));
54+
}
55+
56+
@Benchmark
57+
@OperationsPerInvocation(OPI)
58+
public long ack_Int() {
59+
return ack_inter(new R64long(X1), new R64long(Y1)).longValue()
60+
+ ack_inter(new R64long(X2), new R64long(Y2)).longValue()
61+
+ ack_inter(new R64long(X3), new R64long(Y3)).longValue();
62+
}
63+
64+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package org.openjdk.bench.valhalla.ackermann;
24+
25+
import org.openjdk.jmh.annotations.Benchmark;
26+
import org.openjdk.jmh.annotations.OperationsPerInvocation;
27+
28+
public class IdentityLong extends AckermannBase {
29+
30+
private static Long ack_Long(Long x, Long y) {
31+
return x == 0 ?
32+
y + 1 :
33+
(y == 0 ?
34+
ack_Long(x - 1, 1L) :
35+
ack_Long(x - 1, ack_Long(x, y - 1)));
36+
}
37+
38+
@Benchmark
39+
@OperationsPerInvocation(OPI)
40+
public long ref_Long() {
41+
return ack_Long(Long.valueOf(X1), Long.valueOf(Y1))
42+
+ ack_Long(Long.valueOf(X2), Long.valueOf(Y2))
43+
+ ack_Long(Long.valueOf(X3), Long.valueOf(Y3));
44+
}
45+
46+
}

0 commit comments

Comments
 (0)