Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
855e6d8
Add DevMode hosted option, switch compiler configuration based on it
c-refice Dec 21, 2021
7da9c25
Fix failures in modifySuites caused by trying to find phases not pres…
c-refice Dec 21, 2021
13a2bfa
Add required SaveCalleeSavedRegisters phase to economy lir phase plan
c-refice Jan 5, 2022
73b0f90
Split GraalConfig into hosted and runtime versions
c-refice Jan 10, 2022
468613f
Override HostedConfiguration with EconomyHostedConfiguration if DevMo…
c-refice Jan 12, 2022
a7150cb
Remove DevMode option, change Optimize option to allow -Ob
c-refice Jan 12, 2022
817e7b6
Add devmode VM configs for benchmarks
c-refice Jan 17, 2022
ad0213d
Separate setting of HostedConfig and CompressEncoding
c-refice Jan 20, 2022
0b839bd
Add devmode gates to mx and ci config
c-refice Jan 24, 2022
30d6fbc
Fix replaceWithExceptionSplit with LoopExit successor
c-refice Jan 26, 2022
545a7ad
Add utility method to ParsingReason to detect hosted vs runtime compi…
c-refice Jan 26, 2022
c8c54ee
Increase timeout for libgraal truffle devmode gate
c-refice Jan 31, 2022
a9f5259
Add @Fold annotation to Optimize-related methods
c-refice Feb 1, 2022
6b926fb
Add user warning when building with -Ob
c-refice Feb 1, 2022
10edd4d
Rename getCompilerConfiguration to getHostedCompilerConfiguration in …
c-refice Feb 7, 2022
d5d5b24
Add non-singleton overload to SubstrateOptions.useEconomyCompilerConfig
c-refice Feb 7, 2022
109c5a3
Update CHANGELOG.md
c-refice Feb 9, 2022
2f42cd1
Rename 'devmode' to 'quickbuild'
c-refice Feb 9, 2022
c1390b6
Slightly reword -Ob warning message
c-refice Feb 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@
*/
package org.graalvm.compiler.lir.phases;

import org.graalvm.compiler.lir.alloc.SaveCalleeSaveRegisters;
import org.graalvm.compiler.lir.phases.PreAllocationOptimizationPhase.PreAllocationOptimizationContext;

public class EconomyPreAllocationOptimizationStage extends LIRPhaseSuite<PreAllocationOptimizationContext> {
public EconomyPreAllocationOptimizationStage() {
/*
* Although HotSpot does not use callee saved registers on any configuration, this phase is
* not optional. SVM for example uses a different calling convention that requires it. If
* used on a configuration without callee saved registers, this phase will simply do
* nothing.
*/
appendPhase(new SaveCalleeSaveRegisters());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,20 @@ public void replaceWithExceptionSplit(WithExceptionNode node, WithExceptionNode
AbstractBeginNode next = node.next();
AbstractBeginNode exceptionEdge = node.exceptionEdge();
node.replaceAtUsagesAndDelete(replacement);

if (next instanceof LoopExitNode) {
// see LoopExitNode for special case with exception nodes
BeginNode newNextBegin = add(new BeginNode());
newNextBegin.setNext(next);
next = newNextBegin;
}
if (exceptionEdge instanceof LoopExitNode) {
// see LoopExitNode for special case with exception nodes
BeginNode newExceptionEdgeBegin = add(new BeginNode());
newExceptionEdgeBegin.setNext(exceptionEdge);
exceptionEdge = newExceptionEdgeBegin;
}

replacement.setNext(next);
replacement.setExceptionEdge(exceptionEdge);
}
Expand Down
1 change: 1 addition & 0 deletions substratevm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This changelog summarizes major changes to GraalVM Native Image.

## Version 22.1.0
* (GR-36568) Add "Quick build" mode, enabled through option `-Ob`, for quicker native image builds.
* (GR-35898) Improved handling of static synchronized methods: the lock is no longer stored in the secondary monitor map, but in the mutable DynamicHubCompanion object.
* Remove support for JDK8. As a result, `JDK8OrEarlier` and `JDK11OrLater` have been deprecated and will be removed in a future release.
* (GR-26814) Red Hat added support for the GC pause-related JFR events (`GCPhasePause`, `GCPhasePauseLevel*`) to the serial GC.
Expand Down
23 changes: 21 additions & 2 deletions substratevm/ci.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@

local svm_cmd_gate = ["mx", "--kill-with-sigquit", "--strict-compliance", "gate", "--strict-mode", "--tags"],

local svm_clone_js_benchmarks = ["git", "clone", "--depth", "1", ["mx", "urlrewrite", "https://github.com/graalvm/js-benchmarks.git"], "../../js-benchmarks"],

local gate_svm_js = svm_common + {
run: [
["git", "clone", "--depth", "1", ["mx", "urlrewrite", "https://github.com/graalvm/js-benchmarks.git"], "../../js-benchmarks"],
svm_clone_js_benchmarks,
svm_cmd_gate + ["build,js"],
],
},

local gate_svm_js_quickbuild = svm_common + {
run: [
svm_clone_js_benchmarks,
svm_cmd_gate + ["build,js_quickbuild"],
],
},

local svm_unittest = {
environment+: {
"MX_TEST_RESULTS_PATTERN": "es-XXX.json",
Expand All @@ -40,6 +49,9 @@
common.darwin_amd64 + common.oraclejdk17 + gate_svm_js {
name: "gate-svm-darwin-js",
},
common.darwin_amd64 + common.oraclejdk17 + gate_svm_js_quickbuild {
name: "gate-svm-darwin-js-quickbuild",
},
common.linux_amd64 + common.oraclejdk11 + svm_common + maven + svm_unittest + {
name: "gate-svm-build-ce-11",
timelimit: "30:00",
Expand Down Expand Up @@ -84,5 +96,12 @@
svm_cmd_gate + ["build,helloworld,test,svmjunit"],
],
},
common.windows_amd64 + common.oraclejdk17 + common.devkits["windows-jdk17"] + svm_common + svm_unittest + {
name: "gate-svm-windows-basics-quickbuild",
timelimit: "1:30:00",
run: [
svm_cmd_gate + ["build,helloworld_quickbuild,test_quickbuild,svmjunit_quickbuild"],
],
},
],
}
}
116 changes: 84 additions & 32 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,20 @@ def __getattr__(self, name):
GraalTags = Tags([
'helloworld',
'helloworld_debug',
'helloworld_quickbuild',
'debuginfotest',
'debuginfotest_quickbuild',
'test',
'test_quickbuild',
'js',
'js_quickbuild',
'build',
'benchmarktest',
"nativeimagehelp",
'muslcbuild',
'hellomodule'
])


def vm_native_image_path(config=None):
return vm_executable_path('native-image', config)

Expand Down Expand Up @@ -308,31 +311,64 @@ def native_image_func(args, **kwargs):
_native_unittest_features = '--features=com.oracle.svm.test.ImageInfoTest$TestFeature,com.oracle.svm.test.ServiceLoaderTest$TestFeature,com.oracle.svm.test.SecurityServiceTest$TestFeature'

IMAGE_ASSERTION_FLAGS = ['-H:+VerifyGraalGraphs', '-H:+VerifyPhases']
DEVMODE_FLAGS = ['-Ob']


def image_demo_task(extra_image_args=None, flightrecorder=True):
image_args = ['--output-path', svmbuild_dir()]
if extra_image_args is not None:
image_args += extra_image_args
javac_image(image_args)
javac_command = ['--javac-command', ' '.join(javac_image_command(svmbuild_dir()))]
helloworld(image_args + javac_command)
helloworld(image_args + ['--shared']) # Build and run helloworld as shared library
if not mx.is_windows() and flightrecorder:
helloworld(image_args + ['-J-XX:StartFlightRecording=dumponexit=true']) # Build and run helloworld with FlightRecorder at image build time
cinterfacetutorial(extra_image_args)
clinittest([])


def truffle_unittest_task(quickbuild=False):
truffle_build_args = ['--build-args', '--macro:truffle',
'-H:MaxRuntimeCompileMethods=5000',
'-H:+TruffleCheckBlackListedMethods']
if quickbuild:
truffle_build_args += DEVMODE_FLAGS

truffle_args = truffle_build_args + ['--run-args', '--very-verbose', '--enable-timing']
# ContextPreInitializationNativeImageTest can only run with its own image.
# See class javadoc for details.
native_unittest(['com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest'] + truffle_args)

# Regular Truffle tests that can run with isolated compilation
truffle_tests = ['com.oracle.truffle.api.staticobject.test',
'com.oracle.truffle.api.test.polyglot.ContextPolicyTest']
if not quickbuild:
truffle_tests.append('com.oracle.truffle.api.test.TruffleSafepointTest')

native_unittest(truffle_tests + truffle_args)

# White Box Truffle compilation tests that need access to compiler graphs.
compiler_args = truffle_args + ['-H:-SupportCompileInIsolates']
native_unittest(['org.graalvm.compiler.truffle.test.ContextLookupCompilationTest'] + compiler_args)


def svm_gate_body(args, tasks):

with Task('image demos', tasks, tags=[GraalTags.helloworld]) as t:
if t:
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
javac_image(['--output-path', svmbuild_dir()])
javac_command = ['--javac-command', ' '.join(javac_image_command(svmbuild_dir()))]
helloworld(['--output-path', svmbuild_dir()] + javac_command)
helloworld(['--output-path', svmbuild_dir(), '--shared']) # Build and run helloworld as shared library
if not mx.is_windows():
helloworld(['--output-path', svmbuild_dir(), '-J-XX:StartFlightRecording=dumponexit=true']) # Build and run helloworld with FlightRecorder at image build time
cinterfacetutorial([])
clinittest([])
image_demo_task()

with Task('image demos debuginfo', tasks, tags=[GraalTags.helloworld_debug]) as t:
if t:
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
javac_image(['--output-path', svmbuild_dir(), '-H:GenerateDebugInfo=1'])
javac_command = ['--javac-command', ' '.join(javac_image_command(svmbuild_dir())), '-H:GenerateDebugInfo=1']
helloworld(['--output-path', svmbuild_dir()] + javac_command)
helloworld(['--output-path', svmbuild_dir(), '--shared', '-H:GenerateDebugInfo=1']) # Build and run helloworld as shared library
cinterfacetutorial(['-H:GenerateDebugInfo=1'])
clinittest([])
image_demo_task(['-H:GenerateDebugInfo=1'], flightrecorder=False)

with Task('image demos quickbuild', tasks, tags=[GraalTags.helloworld_quickbuild]) as t:
if t:
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
image_demo_task(DEVMODE_FLAGS, flightrecorder=False)

with Task('image debuginfotest', tasks, tags=[GraalTags.debuginfotest]) as t:
if t:
Expand All @@ -344,26 +380,20 @@ def svm_gate_body(args, tasks):
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
native_unittests_task()

with Task('Run Truffle unittests with SVM image', tasks, tags=["svmjunit"]) as t:
with Task('native unittests quickbuild', tasks, tags=[GraalTags.test_quickbuild]) as t:
if t:
truffle_args = ['--build-args', '--macro:truffle',
'-H:MaxRuntimeCompileMethods=5000',
'-H:+TruffleCheckBlackListedMethods',
'--run-args', '--very-verbose', '--enable-timing']

with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
# ContextPreInitializationNativeImageTest can only run with its own image.
# See class javadoc for details.
native_unittest(['com.oracle.truffle.api.test.polyglot.ContextPreInitializationNativeImageTest'] + truffle_args)
native_unittests_task(DEVMODE_FLAGS)

# Regular Truffle tests that can run with isolated compilation
native_unittest(['com.oracle.truffle.api.test.TruffleSafepointTest',
'com.oracle.truffle.api.staticobject.test',
'com.oracle.truffle.api.test.polyglot.ContextPolicyTest'] + truffle_args)
with Task('Run Truffle unittests with SVM image', tasks, tags=["svmjunit"]) as t:
if t:
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
truffle_unittest_task()

# White Box Truffle compilation tests that need access to compiler graphs.
compiler_args = truffle_args + ['-H:-SupportCompileInIsolates']
native_unittest(['org.graalvm.compiler.truffle.test.ContextLookupCompilationTest'] + compiler_args)
with Task('Run Truffle unittests with SVM image with quickbuild', tasks, tags=["svmjunit_quickbuild"]) as t:
if t:
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
truffle_unittest_task(quickbuild=True)

with Task('Run Truffle NFI unittests with SVM image', tasks, tags=["svmjunit"]) as t:
if t:
Expand All @@ -376,6 +406,17 @@ def svm_gate_body(args, tasks):
'--run-args', testlib, isolation_testlib, '--very-verbose', '--enable-timing']
native_unittest(native_unittest_args)

with Task('Run Truffle NFI unittests with SVM image with quickbuild', tasks, tags=["svmjunit_quickbuild"]) as t:
if t:
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
testlib = mx_subst.path_substitutions.substitute('-Dnative.test.lib=<path:truffle:TRUFFLE_TEST_NATIVE>/<lib:nativetest>')
isolation_testlib = mx_subst.path_substitutions.substitute('-Dnative.isolation.test.lib=<path:truffle:TRUFFLE_TEST_NATIVE>/<lib:isolationtest>')
native_unittest_args = ['com.oracle.truffle.nfi.test', '--build-args', '--language:nfi',
'-H:MaxRuntimeCompileMethods=2000',
'-H:+TruffleCheckBlackListedMethods'] + DEVMODE_FLAGS + [
'--run-args', testlib, isolation_testlib, '--very-verbose', '--enable-timing']
native_unittest(native_unittest_args)

with Task('Musl static hello world and JVMCI version check', tasks, tags=[GraalTags.muslcbuild]) as t:
if t:
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
Expand Down Expand Up @@ -406,12 +447,21 @@ def help_stdout_check(output):
test_run([get_js_launcher(jslib), '-e', 'print("hello:" + Array.from(new Array(10), (x,i) => i*i ).join("|"))'], 'hello:0|1|4|9|16|25|36|49|64|81\n')
test_js(jslib, [('octane-richards', 1000, 100, 300)])

with Task('JavaScript with quickbuild', tasks, tags=[GraalTags.js_quickbuild]) as t:
if t:
config = GraalVMConfig.build(primary_suite_dir=join(suite.vc_dir, 'vm'), # Run from `vm` to clone the right revision of `graal-js` if needed
dynamicimports=['/' + svm_suite().name, '/graal-js'])
with native_image_context(IMAGE_ASSERTION_FLAGS + DEVMODE_FLAGS, config=config) as native_image:
jslib = build_js_lib(native_image)
test_run([get_js_launcher(jslib), '-e', 'print("hello:" + Array.from(new Array(10), (x,i) => i*i ).join("|"))'], 'hello:0|1|4|9|16|25|36|49|64|81\n')
test_js(jslib, [('octane-richards', 1000, 100, 300)])

with Task('module build demo', tasks, tags=[GraalTags.hellomodule]) as t:
if t:
hellomodule([])


def native_unittests_task():
def native_unittests_task(extra_build_args=None):
if mx.is_windows():
# GR-24075
mx_unittest.add_global_ignore_glob('com.oracle.svm.test.ProcessPropertiesTest')
Expand All @@ -420,6 +470,8 @@ def native_unittests_task():
'-H:AdditionalSecurityProviders=com.oracle.svm.test.SecurityServiceTest$NoOpProvider',
'-H:AdditionalSecurityServiceTypes=com.oracle.svm.test.SecurityServiceTest$JCACompliantNoOpService'
]
if extra_build_args is not None:
additional_build_args += extra_build_args

if get_jdk().javaCompliance == '17':
if mx.is_windows():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
package com.oracle.svm.core.graal.aarch64;

import org.graalvm.compiler.core.aarch64.AArch64SuitesCreator;
import org.graalvm.compiler.core.phases.CommunityCompilerConfiguration;
import org.graalvm.compiler.core.phases.EconomyCompilerConfiguration;
import org.graalvm.compiler.phases.schedule.SchedulePhase;

Expand All @@ -36,7 +35,7 @@

public class SubstrateAArch64SuitesCreatorProvider extends SubstrateSuitesCreatorProvider {
public SubstrateAArch64SuitesCreatorProvider() {
super(new AArch64SuitesCreator(new CommunityCompilerConfiguration(), Arrays.asList(SchedulePhase.class)),
super(new AArch64SuitesCreator(getHostedCompilerConfiguration(), Arrays.asList(SchedulePhase.class)),
new AArch64SuitesCreator(new EconomyCompilerConfiguration(), Arrays.asList(SchedulePhase.class)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
package com.oracle.svm.core.graal.amd64;

import org.graalvm.compiler.core.amd64.AMD64SuitesCreator;
import org.graalvm.compiler.core.phases.CommunityCompilerConfiguration;
import org.graalvm.compiler.core.phases.EconomyCompilerConfiguration;

import com.oracle.svm.core.graal.code.SubstrateSuitesCreatorProvider;

public class SubstrateAMD64SuitesCreatorProvider extends SubstrateSuitesCreatorProvider {
public SubstrateAMD64SuitesCreatorProvider() {
super(new AMD64SuitesCreator(new CommunityCompilerConfiguration()),
super(new AMD64SuitesCreator(getHostedCompilerConfiguration()),
new AMD64SuitesCreator(new EconomyCompilerConfiguration()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private void llvmCompile(DebugContext debug, String outputPath, String inputPath
args.add("--trap-unreachable");
args.add("-march=" + LLVMTargetSpecific.get().getLLVMArchName());
args.addAll(LLVMTargetSpecific.get().getLLCAdditionalOptions());
args.add("-O" + SubstrateOptions.Optimize.getValue());
args.add("-O" + SubstrateOptions.optimizationLevel());
args.add("-filetype=obj");
args.add("-o");
args.add(outputPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ public enum ParsingReason {
JITCompilation,
EarlyClassInitializerAnalysis,
UnsafeSubstitutionAnalysis;

public boolean isForHosted() {
return this != JITCompilation;
}
}
Loading