Skip to content

Commit a1ca629

Browse files
committed
[GR-27475] Add ZGC support
PullRequest: graal/12636
2 parents bccab95 + 7431ef1 commit a1ca629

File tree

186 files changed

+3850
-1469
lines changed

Some content is hidden

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

186 files changed

+3850
-1469
lines changed

compiler/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Optimization phases should use the `OptimizationLog` to log transformations. Rea
1414
`Profdiff.md` to learn how to compare performed optimizations in hot compilations of 2 experiments.
1515
* The `-Dgraal.PrintCompilation=true` output now includes stub compilations. For example:
1616
`StubCompilation-57 <stub> exceptionHandler (Object,Word)void | 166us 0B bytecodes 88B codesize 137kB allocated`
17+
* (GR-27475) Add support for the ZGC collector on HotSpot.
1718

1819
## Version 22.3.0
1920
* (GR-19840): An image produced by GraalVM's jlink now includes and uses libgraal by default and its `java -version` output includes GraalVM branding.

compiler/ci/ci_common/benchmark-builders.jsonnet

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@
6363
for suite in bench.groups.main_suites
6464
],
6565

66+
local zgc_builds = [
67+
c.weekly + hw.x52 + jdk + cc.libgraal + cc.zgc_mode + suite,
68+
for jdk in cc.bench_jdks
69+
for suite in bench.groups.main_suites
70+
],
71+
72+
local zgc_avx_builds = [
73+
c.monthly + hw.x82 + jdk + cc.libgraal + cc.zgc_mode + avx + suite,
74+
for avx in [cc.avx2_mode, cc.avx3_mode]
75+
for jdk in cc.bench_jdks
76+
for suite in bench.groups.main_suites
77+
],
78+
6679
local no_tiered_builds = [
6780
c.weekly + hw.x52 + jdk + cc.libgraal + cc.no_tiered_comp + suite,
6881
for jdk in cc.bench_jdks
@@ -76,7 +89,7 @@
7689
],
7790

7891

79-
local all_builds = main_builds + weekly_amd64_forks_builds + weekly_aarch64_forks_builds + profiling_builds + avx_builds + aarch64_builds + no_tiered_builds + no_profile_info_builds,
92+
local all_builds = main_builds + weekly_amd64_forks_builds + weekly_aarch64_forks_builds + profiling_builds + avx_builds + zgc_builds + zgc_avx_builds + aarch64_builds + no_tiered_builds + no_profile_info_builds,
8093
local filtered_builds = [b for b in all_builds if b.is_jdk_supported(b.jdk_version) && b.is_arch_supported(b.arch)],
8194
// adds a "defined_in" field to all builds mentioning the location of this current file
8295
builds:: [{ defined_in: std.thisFile } + b for b in filtered_builds]

compiler/ci/ci_common/compiler-common.libsonnet

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,12 @@
167167
environment+: {
168168
"JVM_CONFIG"+: "-avx3",
169169
}
170+
},
171+
172+
zgc_mode:: {
173+
platform+:: "-zgc",
174+
environment+: {
175+
"JVM_CONFIG"+: "-zgc",
176+
}
170177
}
171178
}

compiler/ci/ci_common/gate.jsonnet

Lines changed: 74 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@
55
local s = self,
66
local t(limit) = {timelimit: limit},
77

8+
local jmh_benchmark_test = {
9+
run+: [
10+
# blackbox jmh test
11+
["mx", "benchmark", "jmh-dist:GRAAL_COMPILER_MICRO_BENCHMARKS",
12+
"--fail-fast",
13+
"--",
14+
"-Djmh.ignoreLock=true",
15+
"--jvm-config=" + jvm_config,
16+
"--jvm=server",
17+
"--",
18+
".*TestJMH.*" ],
19+
# whitebox jmh test
20+
["mx", "benchmark", "jmh-whitebox:*",
21+
"--fail-fast",
22+
"--",
23+
"-Djmh.ignoreLock=true",
24+
"--jvm-config=" + jvm_config,
25+
"--jvm=server",
26+
"--",
27+
".*TestJMH.*" ]
28+
]
29+
},
30+
831
setup:: {
932
setup+: [
1033
["cd", "./" + config.compiler.compiler_suite],
@@ -56,6 +79,8 @@
5679
},
5780

5881
test:: s.base(no_warning_as_error=true),
82+
test_zgc:: s.base(no_warning_as_error=true, extra_vm_args="-XX:+UseZGC"),
83+
5984

6085
jacoco_gate_args:: ["--jacoco-omit-excluded", "--jacoco-relativize-paths", "--jacoco-omit-src-gen", "--jacocout", "coverage", "--jacoco-format", "lcov"],
6186
upload_coverage:: ["mx", "sversions", "--print-repositories", "--json", "|", "coverage-uploader.py", "--associated-repos", "-"],
@@ -91,38 +116,31 @@
91116
logs+: ["*/*_compilation.log"]
92117
},
93118

119+
truffle_xcomp_zgc:: s.base("build,unittest",
120+
extra_vm_args="-Dpolyglot.engine.AllowExperimentalOptions=true " +
121+
"-Dpolyglot.engine.CompileImmediately=true " +
122+
"-Dpolyglot.engine.BackgroundCompilation=false " +
123+
"-Dtck.inlineVerifierInstrument=false " +
124+
"-XX:+UseZGC",
125+
extra_unittest_args="--very-verbose truffle") + {
126+
environment+: {"TRACE_COMPILATION": "true"},
127+
logs+: ["*/*_compilation.log"]
128+
},
129+
94130
ctw:: s.base("build,ctw", no_warning_as_error=true),
131+
ctw_zgc:: s.base("build,ctw", no_warning_as_error=true, extra_vm_args="-XX:+UseZGC"),
95132

96133
ctw_economy:: s.base("build,ctweconomy", extra_vm_args="-Dgraal.CompilerConfiguration=economy"),
97134
ctw_phaseplan_fuzzing:: s.base("build,ctwphaseplanfuzzing"),
98135

99136
# Runs some benchmarks as tests
100-
benchmarktest:: s.base("build,benchmarktest") + {
101-
run+: [
102-
# blackbox jmh test
103-
["mx", "benchmark", "jmh-dist:GRAAL_COMPILER_MICRO_BENCHMARKS",
104-
"--fail-fast",
105-
"--",
106-
"-Djmh.ignoreLock=true",
107-
"--jvm-config=" + jvm_config,
108-
"--jvm=server",
109-
"--",
110-
".*TestJMH.*" ],
111-
# whitebox jmh test
112-
["mx", "benchmark", "jmh-whitebox:*",
113-
"--fail-fast",
114-
"--",
115-
"-Djmh.ignoreLock=true",
116-
"--jvm-config=" + jvm_config,
117-
"--jvm=server",
118-
"--",
119-
".*TestJMH.*" ]
120-
]
121-
},
137+
benchmarktest:: s.base("build,benchmarktest") + jmh_benchmark_test,
138+
benchmarktest_zgc:: s.base("build,benchmarktest", extra_vm_args="-XX:+UseZGC") + jmh_benchmark_test,
122139

123140
bootstrap:: s.base("build,bootstrap", no_warning_as_error=true),
124141
bootstrap_lite:: s.base("build,bootstraplite", no_warning_as_error=true),
125142
bootstrap_full:: s.base("build,bootstrapfullverify", no_warning_as_error=true),
143+
bootstrap_full_zgc:: s.base("build,bootstrapfullverify", no_warning_as_error=true, extra_vm_args="-XX:+UseZGC"),
126144
bootstrap_economy:: s.base("build,bootstrapeconomy", no_warning_as_error=true, extra_vm_args="-Dgraal.CompilerConfiguration=economy"),
127145

128146
style:: c.deps.eclipse + c.deps.jdt + s.base("style,fullbuild,javadoc"),
@@ -163,26 +181,34 @@
163181
# fields of the denoted build.
164182
local gates = {
165183
"gate-compiler-test-labsjdk-20-linux-amd64": t("1:00:00") + c.mach5_target,
184+
"gate-compiler-test-labsjdk-17-linux-amd64": t("1:00:00"),
166185
"gate-compiler-test-labsjdk-20-linux-aarch64": t("1:50:00"),
167186
"gate-compiler-test-labsjdk-20-darwin-amd64": t("1:00:00") + c.mach5_target,
168187
"gate-compiler-test-labsjdk-20-darwin-aarch64": t("1:00:00"),
169-
"gate-compiler-test-labsjdk-20-windows-amd64": t("55:00") + c.mach5_target,
188+
"gate-compiler-test_zgc-labsjdk-20-linux-amd64": t("1:00:00") + c.mach5_target,
189+
"gate-compiler-test_zgc-labsjdk-20-linux-aarch64": t("1:50:00"),
190+
"gate-compiler-test_zgc-labsjdk-20-darwin-amd64": t("1:00:00") + c.mach5_target,
191+
"gate-compiler-test_zgc-labsjdk-20-darwin-aarch64": t("1:00:00"),
170192

171193
"gate-compiler-style-labsjdk-20-linux-amd64": t("45:00"),
172194

173195
"gate-compiler-ctw-labsjdk-20-linux-amd64": c.mach5_target,
174196
"gate-compiler-ctw-labsjdk-20-windows-amd64": t("1:50:00"),
197+
"gate-compiler-ctw_zgc-labsjdk-20-linux-amd64": c.mach5_target,
175198

176199
"gate-compiler-ctw_economy-labsjdk-20-linux-amd64": {},
177200
"gate-compiler-ctw_economy-labsjdk-20-windows-amd64": t("1:50:00"),
178201

179202
"gate-compiler-benchmarktest-labsjdk-20-linux-amd64": {},
203+
"gate-compiler-benchmarktest_zgc-labsjdk-20-linux-amd64": {},
180204

181205
"gate-compiler-truffle_xcomp-labsjdk-20-linux-amd64": t("1:30:00"),
206+
"gate-compiler-truffle_xcomp_zgc-labsjdk-20-linux-amd64": t("1:30:00"),
182207

183208
"gate-compiler-bootstrap_lite-labsjdk-20-darwin-amd64": t("1:00:00") + c.mach5_target,
184209

185-
"gate-compiler-bootstrap_full-labsjdk-20-linux-amd64": s.many_cores + c.mach5_target
210+
"gate-compiler-bootstrap_full-labsjdk-20-linux-amd64": s.many_cores + c.mach5_target,
211+
"gate-compiler-bootstrap_full_zgc-labsjdk-20-linux-amd64": s.many_cores + c.mach5_target
186212
},
187213

188214
# This map defines the builders that run daily. Each key in this map
@@ -211,7 +237,6 @@
211237
notify_emails: ["[email protected]"],
212238
},
213239

214-
"weekly-compiler-test-labsjdk-17-linux-amd64": {},
215240
"weekly-compiler-test-labsjdk-17-linux-aarch64": {},
216241
"weekly-compiler-test-labsjdk-17-windows-amd64": {},
217242
"weekly-compiler-test-labsjdk-17-darwin-amd64": {},
@@ -220,6 +245,7 @@
220245
"weekly-compiler-test_vec16-labsjdk-20-linux-amd64": {},
221246
"weekly-compiler-test_avx0-labsjdk-20-linux-amd64": {},
222247
"weekly-compiler-test_avx1-labsjdk-20-linux-amd64": {},
248+
223249
"weekly-compiler-test_jtt_phaseplan_fuzzing-labsjdk-20-linux-amd64": {
224250
notify_groups: [],
225251
notify_emails: ["[email protected]"],
@@ -345,6 +371,28 @@
345371
]
346372
],
347373

374+
# Test ZGC on support platforms. Windows requires version 1083 or later which will
375+
# probably require adding some capabilities.
376+
local all_zgc_builds = [self.make_build(jdk, os_arch, task).build
377+
for jdk in [
378+
"17",
379+
"20"
380+
]
381+
for os_arch in [
382+
"linux-amd64",
383+
"linux-aarch64",
384+
"darwin-amd64",
385+
"darwin-aarch64"
386+
]
387+
for task in [
388+
"test_zgc",
389+
"truffle_xcomp_zgc",
390+
"ctw_zgc",
391+
"benchmarktest_zgc",
392+
"bootstrap_full_zgc"
393+
]
394+
],
395+
348396
# Builds run on only on linux-amd64-jdk20
349397
local linux_amd64_jdk20_builds = [self.make_build("20", "linux-amd64", task).build
350398
for task in [
@@ -370,6 +418,7 @@
370418
# Complete set of builds defined in this file
371419
local all_builds =
372420
all_platforms_builds +
421+
all_zgc_builds +
373422
linux_amd64_jdk20_builds +
374423
linux_amd64_jdk20Debug_builds,
375424

compiler/ci/ci_includes/baseline-benchmarks.jsonnet

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,17 @@
5959
for suite in bench.groups.main_suites
6060
]),
6161

62+
local zgc_builds = std.flattenArrays([
63+
[
64+
c.weekly + hw.x52 + jdk + cc.c2 + cc.zgc_mode + suite,
65+
]
66+
for jdk in cc.bench_jdks
67+
for suite in bench.groups.main_suites
68+
]),
6269
local all_builds = hotspot_amd64_builds + hotspot_aarch64_builds + hotspot_profiling_builds +
63-
weekly_forks_amd64_builds + weekly_forks_aarch64_builds + daily_economy_builds + weekly_economy_builds + no_tiered_builds,
70+
weekly_forks_amd64_builds + weekly_forks_aarch64_builds + daily_economy_builds + weekly_economy_builds + no_tiered_builds + zgc_builds,
6471
local filtered_builds = [b for b in all_builds if b.is_jdk_supported(b.jdk_version) && b.is_arch_supported(b.arch)],
72+
6573
// adds a "defined_in" field to all builds mentioning the location of this current file
6674
builds:: [{ defined_in: std.thisFile } + b for b in filtered_builds]
6775
}

compiler/mx.compiler/mx_compiler.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,12 @@ class GraalTags:
349349
doc = ['javadoc']
350350
phaseplan_fuzz_jtt_tests = ['phaseplan-fuzz-jtt-tests']
351351

352-
def _remove_empty_entries(a):
352+
def _remove_empty_entries(a, filter_gcs=False):
353353
"""Removes empty entries. Return value is always a list."""
354354
if not a:
355355
return []
356+
if filter_gcs:
357+
a = [x for x in a if not x.endswith('GC') or not x.startswith('-XX:+Use')]
356358
return [x for x in a if x]
357359

358360
def _compiler_error_options(default_compilation_failure_action='ExitVM', vmargs=None, prefix='-Dgraal.'):
@@ -392,7 +394,7 @@ def _gate_dacapo(name, iterations, extraVMarguments=None, force_serial_gc=True,
392394
vmargs = ['-XX:+UseSerialGC'] if force_serial_gc else []
393395
if set_start_heap_size:
394396
vmargs += ['-Xms2g']
395-
vmargs += ['-XX:-UseCompressedOops', '-Djava.net.preferIPv4Stack=true'] + _compiler_error_options() + _remove_empty_entries(extraVMarguments)
397+
vmargs += ['-XX:-UseCompressedOops', '-Djava.net.preferIPv4Stack=true'] + _compiler_error_options() + _remove_empty_entries(extraVMarguments, filter_gcs=force_serial_gc)
396398
args = ['-n', str(iterations), '--preserve']
397399
if threads is not None:
398400
args += ['-t', str(threads)]
@@ -406,7 +408,7 @@ def jdk_includes_corba(jdk):
406408
def _gate_scala_dacapo(name, iterations, extraVMarguments=None):
407409
if iterations == -1:
408410
return
409-
vmargs = ['-Xms2g', '-XX:+UseSerialGC', '-XX:-UseCompressedOops'] + _compiler_error_options() + _remove_empty_entries(extraVMarguments)
411+
vmargs = ['-Xms2g', '-XX:+UseSerialGC', '-XX:-UseCompressedOops'] + _compiler_error_options() + _remove_empty_entries(extraVMarguments, filter_gcs=True)
410412
args = ['-n', str(iterations), '--preserve']
411413
return _run_benchmark('scala-dacapo', name, args, vmargs)
412414

compiler/mx.compiler/mx_graal_benchmark.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ def build_jvmci_vm_variants(raw_name, raw_config_name, extra_args, variants, inc
127127
('economy', [], 0, 'economy'),
128128
('economy-no-tiered-comp', ['-XX:-TieredCompilation'], 0, 'economy'),
129129
('g1gc', ['-XX:+UseG1GC'], 12),
130+
('zgc', ['-XX:+UseZGC'], 12),
131+
('zgc-avx2', ['-XX:+UseZGC', '-XX:UseAVX=2'], 12),
132+
('zgc-avx3', ['-XX:+UseZGC', '-XX:UseAVX=3'], 12),
130133
('no-comp-oops', ['-XX:-UseCompressedOops'], 0),
131134
('no-profile-info', ['-Djvmci.UseProfilingInformation=false'], 0),
132135
('no-splitting', ['-Dpolyglot.engine.Splitting=false'], 0),
@@ -148,6 +151,7 @@ def build_jvmci_vm_variants(raw_name, raw_config_name, extra_args, variants, inc
148151

149152

150153
mx_benchmark.add_java_vm(JvmciJdkVm('server', 'default', ['-server', '-XX:-EnableJVMCI']), _suite, 2)
154+
mx_benchmark.add_java_vm(JvmciJdkVm('server', 'default-zgc', ['-server', '-XX:-EnableJVMCI', '-XX:+UseZGC']), _suite, 2)
151155
mx_benchmark.add_java_vm(JvmciJdkVm('server', 'default-no-tiered-comp', ['-server', '-XX:-EnableJVMCI', '-XX:-TieredCompilation']), _suite, 2)
152156
mx_benchmark.add_java_vm(JvmciJdkVm('server', 'hosted', ['-server', '-XX:+EnableJVMCI']), _suite, 3)
153157

compiler/src/org.graalvm.compiler.asm.aarch64.test/src/org/graalvm/compiler/asm/aarch64/test/TestProtectedAssembler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ protected void clrex() {
214214
public void align(int modulus) {
215215
}
216216

217+
@Override
218+
public void halt() {
219+
}
220+
217221
@Override
218222
public void jmp(Label l) {
219223
}

compiler/src/org.graalvm.compiler.asm.aarch64/src/org/graalvm/compiler/asm/aarch64/AArch64Address.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,18 @@ public AddressingMode getAddressingMode() {
552552
return addressingMode;
553553
}
554554

555+
public boolean isBaseRegisterOnly() {
556+
switch (getAddressingMode()) {
557+
case IMMEDIATE_UNSIGNED_SCALED:
558+
case IMMEDIATE_SIGNED_UNSCALED:
559+
return immediate == 0;
560+
case BASE_REGISTER_ONLY:
561+
return true;
562+
default:
563+
return false;
564+
}
565+
}
566+
555567
@Override
556568
public String toString() {
557569
String addressEncoding;

compiler/src/org.graalvm.compiler.asm.aarch64/src/org/graalvm/compiler/asm/aarch64/AArch64MacroAssembler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,11 @@ public void align(int modulus) {
19841984
}
19851985
}
19861986

1987+
@Override
1988+
public void halt() {
1989+
illegal();
1990+
}
1991+
19871992
/**
19881993
* Patches jump targets when label gets bound.
19891994
*/

0 commit comments

Comments
 (0)