Skip to content

Commit 6311f52

Browse files
committed
Shenadoah fixes
1 parent aef81e2 commit 6311f52

File tree

12 files changed

+162
-82
lines changed

12 files changed

+162
-82
lines changed

compiler/ci/ci_common/benchmark-builders.jsonnet

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@
8181
for suite in bench.groups.main_suites
8282
],
8383

84+
local shenandoah_builds = [
85+
c.weekly + hw.x52 + jdk + cc.libgraal + cc.shenandoah_mode + suite,
86+
for jdk in cc.product_jdks
87+
for suite in bench.groups.main_suites + [bench.specjbb2015]
88+
],
89+
8490
local metrics_suites = [bench.dacapo, bench.scala_dacapo, bench.renaissance, bench.specjvm2008],
8591

8692
local metrics_builds = std.flattenArrays([
@@ -92,7 +98,8 @@
9298
for suite in metrics_suites
9399
]),
94100

95-
local all_builds = main_builds + weekly_amd64_forks_builds + weekly_aarch64_forks_builds + profiling_builds + avx_builds + zgc_builds + zgc_avx_builds + aarch64_builds + metrics_builds,
101+
local all_builds = main_builds + weekly_amd64_forks_builds + weekly_aarch64_forks_builds + profiling_builds + avx_builds + zgc_builds + zgc_avx_builds +
102+
shenandoah_builds + aarch64_builds + metrics_builds,
96103
local filtered_builds = [b for b in all_builds if b.is_jdk_supported(b.jdk_version) && b.is_arch_supported(b.arch)],
97104
// adds a "defined_in" field to all builds mentioning the location of this current file
98105
builds:: utils.add_defined_in(filtered_builds, std.thisFile),

compiler/ci/ci_common/compiler-common.libsonnet

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@
191191
}
192192
},
193193

194+
shenandoah_mode:: {
195+
platform+:: "-shenandoah",
196+
environment+: {
197+
"JVM_CONFIG"+: "-shenandoah",
198+
}
199+
},
200+
194201
serialgc_mode:: {
195202
platform+:: "-serialgc",
196203
environment+: {

compiler/ci/ci_common/gate.jsonnet

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@
101101
test:: s.base(no_warning_as_error=true, extra_vm_args="-Djdk.graal.DetailedAsserts=true"),
102102
unittest_compiler:: s.base(tags="build,unittest-compiler", no_warning_as_error=true, extra_vm_args="-Djdk.graal.DetailedAsserts=true"),
103103
unittest_truffle:: s.base(tags="build,unittest-truffle", no_warning_as_error=true, extra_vm_args="-Djdk.graal.DetailedAsserts=true"),
104+
104105
test_zgc:: s.base(no_warning_as_error=true, extra_vm_args="-XX:+UseZGC"),
105106
unittest_compiler_zgc:: s.base(tags="build,unittest-compiler", no_warning_as_error=true, extra_vm_args="-XX:+UseZGC"),
106107
unittest_truffle_zgc:: s.base(tags="build,unittest-truffle", no_warning_as_error=true, extra_vm_args="-XX:+UseZGC"),
108+
109+
test_shenandoah:: s.base(no_warning_as_error=true, extra_vm_args="-XX:+UseShenandoahGC"),
110+
unittest_compiler_shenandoah:: s.base(tags="build,unittest-compiler", no_warning_as_error=true, extra_vm_args="-XX:+UseShenandoahGC"),
111+
unittest_truffle_shenandoah:: s.base(tags="build,unittest-truffle", no_warning_as_error=true, extra_vm_args="-XX:+UseShenandoahGC"),
112+
107113
test_serialgc:: s.base(no_warning_as_error=true, extra_vm_args="-XX:+UseSerialGC"),
108114

109115
jacoco_gate_args:: ["--jacoco-omit-excluded", "--jacoco-relativize-paths", "--jacoco-omit-src-gen", "--jacocout", "coverage", "--jacoco-format", "lcov"],
@@ -131,55 +137,39 @@
131137

132138
# Runs truffle tests in a mode similar to HotSpot's -Xcomp option
133139
# (i.e. compile immediately without background compilation).
134-
truffle_xcomp:: s.base("build,unittest",
140+
truffle_xcomp_base(extra_vm_args=""):: s.base("build,unittest",
135141
extra_vm_args="-Dpolyglot.engine.AllowExperimentalOptions=true " +
136142
"-Dpolyglot.engine.CompileImmediately=true " +
137143
"-Dpolyglot.engine.BackgroundCompilation=false " +
138-
"-Dtck.inlineVerifierInstrument=false",
144+
"-Dtck.inlineVerifierInstrument=false" + extra_vm_args,
139145
extra_unittest_args="--verbose truffle") + {
140146
environment+: {"TRACE_COMPILATION": "true"},
141147
logs+: ["*/*_compilation.log"],
142148
components+: ["truffle"],
143149
},
144150

145-
truffle_xcomp_zgc:: s.base("build,unittest",
146-
extra_vm_args="-Dpolyglot.engine.AllowExperimentalOptions=true " +
147-
"-Dpolyglot.engine.CompileImmediately=true " +
148-
"-Dpolyglot.engine.BackgroundCompilation=false " +
149-
"-Dtck.inlineVerifierInstrument=false " +
150-
"-XX:+UseZGC",
151-
extra_unittest_args="--verbose truffle") + {
152-
environment+: {"TRACE_COMPILATION": "true"},
153-
logs+: ["*/*_compilation.log"],
154-
components+: ["truffle"],
155-
},
156-
157-
truffle_xcomp_serialgc:: s.base("build,unittest",
158-
extra_vm_args="-Dpolyglot.engine.AllowExperimentalOptions=true " +
159-
"-Dpolyglot.engine.CompileImmediately=true " +
160-
"-Dpolyglot.engine.BackgroundCompilation=false " +
161-
"-Dtck.inlineVerifierInstrument=false " +
162-
"-XX:+UseSerialGC",
163-
extra_unittest_args="--verbose truffle") + {
164-
environment+: {"TRACE_COMPILATION": "true"},
165-
logs+: ["*/*_compilation.log"],
166-
components+: ["truffle"],
167-
},
151+
truffle_xcomp:: s.truffle_xcomp_base(),
152+
truffle_xcomp_zgc:: s.truffle_xcomp_base(" -XX:+UseZGC"),
153+
truffle_xcomp_shenandoah:: s.truffle_xcomp_base(" -XX:+UseShenandoahGC"),
154+
truffle_xcomp_serialgc:: s.truffle_xcomp_base(" -XX:+UseSerialGC"),
168155

169156
ctw:: s.base("build,ctw", no_warning_as_error=true),
170157
ctw_zgc:: s.base("build,ctw", no_warning_as_error=true, extra_vm_args="-XX:+UseZGC"),
158+
ctw_shenandoah:: s.base("build,ctw", no_warning_as_error=true, extra_vm_args="-XX:+UseShenandoahGC"),
171159

172160
ctw_economy:: s.base("build,ctweconomy", extra_vm_args="-Djdk.graal.CompilerConfiguration=economy"),
173161
ctw_phaseplan_fuzzing:: s.base("build,ctwphaseplanfuzzing"),
174162

175163
# Runs some benchmarks as tests
176164
benchmarktest:: s.base("build,benchmarktest") + jmh_benchmark_test,
177165
benchmarktest_zgc:: s.base("build,benchmarktest", extra_vm_args="-XX:+UseZGC") + jmh_benchmark_test,
166+
benchmarktest_shenandoah:: s.base("build,benchmarktest", extra_vm_args="-XX:+UseShenandoahGC") + jmh_benchmark_test,
178167

179168
bootstrap:: s.base("build,bootstrap", no_warning_as_error=true),
180169
bootstrap_lite:: s.base("build,bootstraplite", no_warning_as_error=true),
181170
bootstrap_full:: s.base("build,bootstrapfullverify", no_warning_as_error=true),
182171
bootstrap_full_zgc:: s.base("build,bootstrapfullverify", no_warning_as_error=true, extra_vm_args="-XX:+UseZGC"),
172+
bootstrap_full_shenandoah:: s.base("build,bootstrapfullverify", no_warning_as_error=true, extra_vm_args="-XX:+UseShenandoahGC"),
183173
bootstrap_economy:: s.base("build,bootstrapeconomy", no_warning_as_error=true, extra_vm_args="-Djdk.graal.CompilerConfiguration=economy"),
184174

185175
style:: c.deps.eclipse + c.deps.jdt + c.deps.spotbugs + s.base("style,fullbuild,javadoc") + galahad.exclude,
@@ -491,28 +481,45 @@
491481
self.make_build(self.jdk_latest, "linux-amd64", "coverage_avx3").build
492482
],
493483

494-
# Test ZGC on supported platforms. Windows requires version 1083 or later which will
495-
# probably require adding some capabilities.
496-
local all_zgc_builds = [self.make_build(jdk, os_arch, task).build + galahad.exclude
497-
for jdk in [
498-
self.jdk_latest
499-
]
500-
for os_arch in [
501-
"linux-amd64",
502-
"linux-aarch64",
503-
"darwin-amd64",
504-
"darwin-aarch64"
505-
]
506-
for task in [
507-
"test_zgc",
508-
"unittest_compiler_zgc",
509-
"unittest_truffle_zgc",
510-
"truffle_xcomp_zgc",
511-
"ctw_zgc",
512-
"benchmarktest_zgc",
513-
"bootstrap_full_zgc",
514-
]
515-
],
484+
# Test ZGC on supported platforms. Windows requires version 1083 or later which will
485+
# probably require adding some capabilities.
486+
local all_zgc_builds = [self.make_build(jdk, os_arch, task).build + galahad.exclude
487+
for jdk in [
488+
self.jdk_latest
489+
]
490+
for os_arch in [
491+
"linux-amd64",
492+
"linux-aarch64",
493+
"darwin-amd64",
494+
"darwin-aarch64"
495+
]
496+
for task in [
497+
"test_zgc",
498+
"unittest_compiler_zgc",
499+
"unittest_truffle_zgc",
500+
"truffle_xcomp_zgc",
501+
"ctw_zgc",
502+
"benchmarktest_zgc",
503+
"bootstrap_full_zgc",
504+
]
505+
],
506+
507+
# Test Shenandoah on supported platforms.
508+
local all_shenandoah_builds = [self.make_build(jdk, os_arch, task).build + galahad.exclude
509+
for jdk in [
510+
self.jdk_latest
511+
]
512+
for os_arch in all_os_arches
513+
for task in [
514+
"test_shenandoah",
515+
"unittest_compiler_shenandoah",
516+
"unittest_truffle_shenandoah",
517+
"truffle_xcomp_shenandoah",
518+
"ctw_shenandoah",
519+
"benchmarktest_shenandoah",
520+
"bootstrap_full_shenandoah",
521+
]
522+
],
516523

517524
# Run unittests with SerialGC.
518525
local all_serialgc_builds = [self.make_build(self.jdk_latest, os_arch, task).build + galahad.exclude
@@ -563,6 +570,7 @@
563570
all_platforms_builds +
564571
all_coverage_builds +
565572
all_zgc_builds +
573+
all_shenandoah_builds +
566574
all_serialgc_builds +
567575
style_builds +
568576
linux_amd64_jdk_latest_builds +

compiler/ci/ci_includes/baseline-benchmarks.jsonnet

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
local gc_variants_builds = std.flattenArrays([
6161
[
6262
c.monthly + hw.x52 + jdk + cc.c2 + cc.zgc_mode + suite,
63+
c.monthly + hw.x52 + jdk + cc.c2 + cc.shenandoah_mode + suite,
6364
]
6465
for jdk in cc.product_jdks
6566
for suite in bench.groups.main_suites
@@ -68,6 +69,7 @@
6869
c.monthly + hw.x52 + jdk + cc.c2 + cc.serialgc_mode + bench.microservice_benchmarks,
6970
c.monthly + hw.x52 + jdk + cc.c2 + cc.pargc_mode + bench.microservice_benchmarks,
7071
c.monthly + hw.x52 + jdk + cc.c2 + cc.zgc_mode + bench.microservice_benchmarks,
72+
c.monthly + hw.x52 + jdk + cc.c2 + cc.shenandoah_mode + bench.microservice_benchmarks,
7173
]
7274
for jdk in cc.product_jdks
7375
]),

compiler/mx.compiler/mx_graal_benchmark.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
('zgc', ['-XX:+UseZGC'], 12),
4949
('zgc-avx2', ['-XX:+UseZGC', '-XX:UseAVX=2'], 12),
5050
('zgc-avx3', ['-XX:+UseZGC', '-XX:UseAVX=3'], 12),
51+
('shenandoah', ['-XX:+UseShenandoahGC'], 12),
5152
('no-comp-oops', ['-XX:-UseCompressedOops'], 0),
5253
('no-profile-info', ['-Djvmci.UseProfilingInformation=false'], 0),
5354
('no-splitting', ['-Dpolyglot.engine.Splitting=false'], 0),

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/PointerTrackingTest.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,33 @@
2424
*/
2525
package jdk.graal.compiler.replacements.test;
2626

27+
import org.junit.Assume;
28+
import org.junit.Before;
29+
import org.junit.Test;
30+
2731
import jdk.graal.compiler.api.directives.GraalDirectives;
32+
import jdk.graal.compiler.api.test.Graal;
2833
import jdk.graal.compiler.debug.DebugCloseable;
2934
import jdk.graal.compiler.debug.DebugContext;
3035
import jdk.graal.compiler.debug.GraalError;
36+
import jdk.graal.compiler.hotspot.HotSpotGraalRuntime;
3137
import jdk.graal.compiler.nodes.ValueNode;
3238
import jdk.graal.compiler.nodes.graphbuilderconf.GraphBuilderContext;
3339
import jdk.graal.compiler.nodes.graphbuilderconf.InvocationPlugin;
3440
import jdk.graal.compiler.nodes.graphbuilderconf.InvocationPlugins;
3541
import jdk.graal.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration;
3642
import jdk.graal.compiler.replacements.Snippets;
43+
import jdk.graal.compiler.runtime.RuntimeProvider;
3744
import jdk.graal.compiler.word.WordCastNode;
38-
import org.junit.Test;
39-
4045
import jdk.vm.ci.meta.JavaKind;
4146
import jdk.vm.ci.meta.ResolvedJavaMethod;
4247

4348
public class PointerTrackingTest extends ReplacementsTest implements Snippets {
49+
@Before
50+
public void before() {
51+
HotSpotGraalRuntime runtime = (HotSpotGraalRuntime) Graal.getRequiredCapability(RuntimeProvider.class);
52+
Assume.assumeTrue("doesn't aggressively move objects", runtime.getGarbageCollector() != HotSpotGraalRuntime.HotSpotGC.Shenandoah);
53+
}
4454

4555
@Test
4656
public void testTracking() {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/GraalOptions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ public final class GraalOptions {
193193
// Register allocator debugging
194194
@Option(help = "Comma separated list of registers that register allocation is limited to.", type = OptionType.Debug)
195195
public static final OptionKey<String> RegisterPressure = new OptionKey<>(null);
196+
@Option(help = "Permit RegisterPressure setting to cause compilation to fail.", type = OptionType.Debug)
197+
public static final OptionKey<Boolean> BailoutOnRegisterPressureFailure = new OptionKey<>(false);
196198

197199
@Option(help = "Eliminates redundant conditional expressions and statements where possible. " +
198200
"This can improve performance because fewer logic instructions have to be executed.", type = OptionType.Expert)

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/gen/LIRCompilerBackend.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package jdk.graal.compiler.core.gen;
2626

27+
import java.util.Arrays;
2728
import java.util.Collection;
2829
import java.util.List;
2930

@@ -114,12 +115,12 @@ public static LIRGenerationResult emitLIR(Backend backend, StructuredGraph graph
114115
try {
115116
return emitLIR0(backend, graph, stub, registerConfig, lirSuites, allocationRestrictedTo, entryPointDecorator);
116117
} catch (OutOfRegistersException e) {
117-
if (allocationRestrictedTo != null) {
118+
if (allocationRestrictedTo != null && !GraalOptions.BailoutOnRegisterPressureFailure.getValue(graph.getOptions())) {
118119
allocationRestrictedTo = null;
119120
return emitLIR0(backend, graph, stub, registerConfig, lirSuites, allocationRestrictedTo, entryPointDecorator);
120121
}
121122
/* If the re-execution fails we convert the exception into a "hard" failure */
122-
throw new GraalError(e);
123+
throw new GraalError(e, "out of registers%s", allocationRestrictedTo == null ? "" : ": " + Arrays.toString(allocationRestrictedTo));
123124
} finally {
124125
graph.checkCancellation();
125126
}

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalRuntime.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,23 @@ public enum HotSpotGC {
232232
Serial("UseSerialGC"),
233233
Parallel("UseParallelGC"),
234234
G1("UseG1GC"),
235-
Z(true, true, flagIsSet("UseZGC")),
236-
Epsilon(true, true, flagIsSet("UseEpsilonGC")),
237-
Shenandoah(true, true, flagIsSet("UseShenandoahGC"));
235+
Epsilon("UseEpsilonGC"),
236+
// GR-54355 ZGC and Shenandoah require extra work to support vectorization
237+
Z("UseZGC", false),
238+
Shenandoah("UseShenandoahGC", false);
238239

239240
HotSpotGC(String flag) {
240-
this(true, true, flagIsSet(flag));
241+
this(true, true, true, flagIsSet(flag));
241242
}
242243

243-
HotSpotGC(boolean supported, boolean expectNamePresent, Predicate<GraalHotSpotVMConfig> predicate) {
244+
HotSpotGC(String flag, boolean supportsVectorization) {
245+
this(true, true, supportsVectorization, flagIsSet(flag));
246+
}
247+
248+
HotSpotGC(boolean supported, boolean expectNamePresent, boolean supportsVectorization, Predicate<GraalHotSpotVMConfig> predicate) {
244249
this.supported = supported;
245250
this.expectNamePresent = expectNamePresent;
251+
this.supportsVectorization = supportsVectorization;
246252
this.predicate = predicate;
247253
}
248254

@@ -256,6 +262,15 @@ private static Predicate<GraalHotSpotVMConfig> flagIsSet(String flag) {
256262
*/
257263
final boolean supported;
258264

265+
/**
266+
* Specifies if this GC supports vectorization of objects.
267+
*/
268+
final boolean supportsVectorization;
269+
270+
public boolean supportsVectorization() {
271+
return supportsVectorization;
272+
}
273+
259274
/**
260275
* Specifies if {@link #name()} is expected to be present in the {@code CollectedHeap::Name}
261276
* C++ enum.

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/gc/shenandoah/ShenandoahBarrierSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public void verifyBarriers(StructuredGraph graph) {
329329
if (!base.stamp(NodeView.DEFAULT).isObjectStamp()) {
330330
GraalError.guarantee(read.getBarrierType() == BarrierType.NONE, "no barrier for non-heap read: %s", read);
331331
} else {
332-
GraalError.guarantee(read.getBarrierType() == BarrierType.READ, "missing barriers for heap read: %s", read);
332+
GraalError.guarantee(read.getBarrierType() == BarrierType.FIELD, "missing barriers for heap read: %s", read);
333333
}
334334
} else if (node instanceof AddressableMemoryAccess access) {
335335
if (access.getBarrierType() != BarrierType.NONE) {

0 commit comments

Comments
 (0)