Skip to content

Commit 3c7b5cb

Browse files
committed
[GR-65266] Add support for Shenandoah
PullRequest: graal/20857
2 parents 5c704c9 + 6e0aa35 commit 3c7b5cb

File tree

46 files changed

+3061
-110
lines changed

Some content is hidden

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

46 files changed

+3061
-110
lines changed

compiler/ci/ci_common/benchmark-builders.jsonnet

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

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

8490
local metrics_builds = std.flattenArrays([
@@ -90,7 +96,8 @@
9096
for suite in metrics_suites
9197
]),
9298

93-
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,
99+
local all_builds = main_builds + weekly_amd64_forks_builds + weekly_aarch64_forks_builds + profiling_builds + avx_builds + zgc_builds + zgc_avx_builds +
100+
shenandoah_builds + aarch64_builds + metrics_builds,
94101
local filtered_builds = [b for b in all_builds if b.is_jdk_supported(b.jdk_version) && b.is_arch_supported(b.arch)],
95102
// adds a "defined_in" field to all builds mentioning the location of this current file
96103
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: 2 additions & 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),
@@ -72,6 +73,7 @@
7273
mx_benchmark.add_java_vm(JvmciJdkVm('server', 'default-serialgc', ['-server', '-XX:-EnableJVMCI', '-XX:+UseSerialGC']), _suite, 2)
7374
mx_benchmark.add_java_vm(JvmciJdkVm('server', 'default-pargc', ['-server', '-XX:-EnableJVMCI', '-XX:+UseParallelGC']), _suite, 2)
7475
mx_benchmark.add_java_vm(JvmciJdkVm('server', 'default-zgc', ['-server', '-XX:-EnableJVMCI', '-XX:+UseZGC']), _suite, 2)
76+
mx_benchmark.add_java_vm(JvmciJdkVm('server', 'default-shenandoah', ['-server', '-XX:-EnableJVMCI', '-XX:+UseShenandoahGC']), _suite, 2)
7577
mx_benchmark.add_java_vm(JvmciJdkVm('server', 'default-no-tiered-comp', ['-server', '-XX:-EnableJVMCI', '-XX:-TieredCompilation']), _suite, 2)
7678
mx_benchmark.add_java_vm(JvmciJdkVm('server', 'hosted', ['-server', '-XX:+EnableJVMCI']), _suite, 3)
7779

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ public final class GraalOptions {
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);
196196

197+
@Option(help = "Permit RegisterPressure setting to cause compilation to fail.", type = OptionType.Debug)
198+
public static final OptionKey<Boolean> BailoutOnRegisterPressureFailure = new OptionKey<>(false);
199+
197200
@Option(help = "Eliminates redundant conditional expressions and statements where possible. " +
198201
"This can improve performance because fewer logic instructions have to be executed.", type = OptionType.Expert)
199202
public static final OptionKey<Boolean> ConditionalElimination = new OptionKey<>(true);

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/core/phases/EconomyLowTier.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import jdk.graal.compiler.debug.Assertions;
2828
import jdk.graal.compiler.graph.Graph;
29+
import jdk.graal.compiler.nodes.GraphState;
2930
import jdk.graal.compiler.options.OptionValues;
3031
import jdk.graal.compiler.phases.PlaceholderPhase;
3132
import jdk.graal.compiler.phases.common.AddressLoweringPhase;
@@ -37,6 +38,7 @@
3738
import jdk.graal.compiler.phases.common.LowTierLoweringPhase;
3839
import jdk.graal.compiler.phases.common.RemoveOpaqueValuePhase;
3940
import jdk.graal.compiler.phases.common.TransplantGraphsPhase;
41+
import jdk.graal.compiler.phases.common.WriteBarrierAdditionPhase;
4042
import jdk.graal.compiler.phases.schedule.SchedulePhase;
4143
import jdk.graal.compiler.phases.tiers.LowTierContext;
4244

@@ -51,6 +53,7 @@ public EconomyLowTier(OptionValues options) {
5153
appendPhase(new LowTierLoweringPhase(canonicalizer));
5254
appendPhase(new ExpandLogicPhase(canonicalizer));
5355

56+
appendPhase(new WriteBarrierAdditionPhase(GraphState.StageFlag.LOW_TIER_BARRIER_ADDITION));
5457
appendPhase(new EconomyPiRemovalPhase(canonicalizer));
5558

5659
if (Assertions.assertionsEnabled()) {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/phases/LowTier.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import jdk.graal.compiler.core.common.GraalOptions;
3030
import jdk.graal.compiler.graph.Graph;
31+
import jdk.graal.compiler.nodes.GraphState;
3132
import jdk.graal.compiler.options.Option;
3233
import jdk.graal.compiler.options.OptionKey;
3334
import jdk.graal.compiler.options.OptionType;
@@ -47,6 +48,7 @@
4748
import jdk.graal.compiler.phases.common.PropagateDeoptimizeProbabilityPhase;
4849
import jdk.graal.compiler.phases.common.RemoveOpaqueValuePhase;
4950
import jdk.graal.compiler.phases.common.TransplantGraphsPhase;
51+
import jdk.graal.compiler.phases.common.WriteBarrierAdditionPhase;
5052
import jdk.graal.compiler.phases.schedule.SchedulePhase;
5153
import jdk.graal.compiler.phases.schedule.SchedulePhase.SchedulingStrategy;
5254
import jdk.graal.compiler.phases.tiers.LowTierContext;
@@ -87,6 +89,8 @@ public LowTier(OptionValues options) {
8789
appendPhase(new FixReadsPhase(true,
8890
new SchedulePhase(GraalOptions.StressTestEarlyReads.getValue(options) ? SchedulingStrategy.EARLIEST : SchedulingStrategy.LATEST_OUT_OF_LOOPS_IMPLICIT_NULL_CHECKS)));
8991

92+
appendPhase(new WriteBarrierAdditionPhase(GraphState.StageFlag.LOW_TIER_BARRIER_ADDITION));
93+
9094
appendPhase(canonicalizerWithoutGVN);
9195

9296
/*

0 commit comments

Comments
 (0)