Skip to content

Commit df3910c

Browse files
eregonfniephaus
authored andcommitted
[GR-66817] [GR-65404] Make --polyglot the default in AbstractLanguageLauncher and remove PolyglotLauncher
PullRequest: graal/21786
2 parents 28cef2a + bf93eb7 commit df3910c

File tree

11 files changed

+53
-768
lines changed

11 files changed

+53
-768
lines changed

sdk/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This changelog summarizes major changes between GraalVM SDK versions. The main f
66
* GR-65048: GR-65048: Introduced the `-Dpolyglot.engine.allowUnsupportedPlatform=true` system property to enable Truffle to run on unsupported platforms. If this property is enabled then the failure will be suppressed. Please see follow-up errors and warnings for instructions on how to continue. Note that using an unsupported platform will also force the fallback runtime without runtime optimization.
77
* GR-66515 If neither a log handler nor the `log.file` option is set on the `Engine.Builder` or `Context.Builder`, Truffle and language log messages will be written to the Context’s error output stream by default. The `log.file` option is now also supported on `Context.Builder`.
88
* GR-63588 A new entry (`Invalidated`) was added to the `opt deopt` truffle compilation logs. It is `true` or `false` depending on whether the compilation was also invalidated.
9+
* GR-66817 Make `--polyglot` the default for language launchers, so there is no need to specify it anymore to use other languages in standalones. As a result, `AbstractLanguageLauncher#getDefaultLanguages()` and `Launcher#canPolyglot()` have been deprecated.
10+
* GR-65404 Remove `PolyglotLauncher` as it is no longer used.
911

1012
## Version 25.0.0
1113
* GR-60636 Truffle now stops compiling when the code cache fills up on HotSpot. A warning is printed when that happens.

sdk/mx.sdk/mx_sdk_vm.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,13 @@
8282

8383

8484
class AbstractNativeImageConfig(object, metaclass=ABCMeta):
85-
def __init__(self, destination, jar_distributions, build_args, use_modules=None, links=None, is_polyglot=False, dir_jars=False, home_finder=False, build_time=1, build_args_enterprise=None): # pylint: disable=super-init-not-called
85+
def __init__(self, destination, jar_distributions, build_args, use_modules=None, links=None, dir_jars=False, home_finder=False, build_time=1, build_args_enterprise=None): # pylint: disable=super-init-not-called
8686
"""
8787
:type destination: str
8888
:type jar_distributions: list[str]
8989
:type build_args: list[str]
9090
:param str | None use_modules: Run (with 'launcher') or run and build image with module support (with 'image').
9191
:type links: list[str] | None
92-
:type is_polyglot: bool
9392
:param bool dir_jars: If true, all jars in the component directory are added to the classpath.
9493
:type home_finder: bool
9594
:type build_time: int
@@ -100,7 +99,6 @@ def __init__(self, destination, jar_distributions, build_args, use_modules=None,
10099
self.build_args = build_args
101100
self.use_modules = use_modules
102101
self.links = [mx_subst.path_substitutions.substitute(link) for link in links] if links else []
103-
self.is_polyglot = is_polyglot
104102
self.dir_jars = dir_jars
105103
self.home_finder = home_finder
106104
self.build_time = build_time
@@ -184,7 +182,7 @@ def __init__(self, destination, jar_distributions, main_class, build_args, langu
184182
:param str language
185183
"""
186184
super(LanguageLauncherConfig, self).__init__(destination, jar_distributions, main_class, build_args,
187-
is_sdk_launcher=is_sdk_launcher, is_polyglot=False, **kwargs)
185+
is_sdk_launcher=is_sdk_launcher, **kwargs)
188186
self.language = language
189187

190188
# Ensure the language launcher can always find the language home

sdk/mx.sdk/mx_sdk_vm_impl.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,7 @@ def _get_main_module():
20152015
def _get_extra_jvm_args():
20162016
image_config = self.subject.native_image_config
20172017
extra_jvm_args = mx.list_to_cmd_line(image_config.extra_jvm_args)
2018-
if isinstance(self.subject.component, mx_sdk.GraalVmTruffleComponent) or image_config.is_polyglot:
2018+
if isinstance(self.subject.component, mx_sdk.GraalVmTruffleComponent):
20192019
extra_jvm_args = ' '.join([extra_jvm_args, '--enable-native-access=org.graalvm.truffle'])
20202020
# GR-59703: Migrate sun.misc.* usages.
20212021
if mx.VersionSpec("23.0.0") <= mx.get_jdk(tag='default').version:
@@ -2194,8 +2194,6 @@ def get_build_args(self):
21942194
] + svm_experimental_options(experimental_build_args) + [
21952195
'--macro:' + GraalVmNativeProperties.macro_name(self.subject.native_image_config), # last to allow overrides
21962196
]
2197-
if self.subject.native_image_config.is_polyglot:
2198-
build_args += ["--macro:truffle", "--language:all"]
21992197
return build_args
22002198

22012199

sdk/src/org.graalvm.launcher/src/org/graalvm/launcher/AbstractLanguageLauncher.java

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private static Constructor<AbstractLanguageLauncher> getLauncherCtor() {
122122
protected final void launch(String[] args) {
123123
try {
124124
try {
125-
launch(new ArrayList<>(Arrays.asList(args)), null, true);
125+
launch(new ArrayList<>(Arrays.asList(args)));
126126
} catch (AbortException e) {
127127
throw e;
128128
} catch (PolyglotException e) {
@@ -260,15 +260,12 @@ protected long getNativeArgv() {
260260

261261
protected static final boolean IS_LIBPOLYGLOT = Boolean.getBoolean("graalvm.libpolyglot");
262262

263-
final void launch(List<String> args, Map<String, String> defaultOptions, boolean doNativeSetup) {
263+
final void launch(List<String> args) {
264264
List<String> originalArgs = Collections.unmodifiableList(new ArrayList<>(args));
265265

266-
Map<String, String> polyglotOptions = defaultOptions;
267-
if (polyglotOptions == null) {
268-
polyglotOptions = new HashMap<>();
269-
}
266+
Map<String, String> polyglotOptions = new HashMap<>();
270267

271-
if (isAOT() && doNativeSetup) {
268+
if (isAOT()) {
272269
System.setProperty("org.graalvm.launcher.languageId", getLanguageId());
273270
}
274271

@@ -278,9 +275,9 @@ final void launch(List<String> args, Map<String, String> defaultOptions, boolean
278275
validateVmArguments(originalArgs, unrecognizedArgs);
279276
}
280277

281-
if (isAOT() && doNativeSetup && !IS_LIBPOLYGLOT) {
278+
if (isAOT() && !IS_LIBPOLYGLOT) {
282279
assert nativeAccess != null;
283-
maybeExec(originalArgs, unrecognizedArgs, false, getDefaultVMType(), jniLaunch);
280+
maybeExec(originalArgs, unrecognizedArgs, getDefaultVMType(), jniLaunch);
284281
}
285282

286283
parseUnrecognizedOptions(getLanguageId(), polyglotOptions, unrecognizedArgs);
@@ -292,14 +289,7 @@ final void launch(List<String> args, Map<String, String> defaultOptions, boolean
292289
validateArguments(polyglotOptions);
293290
argumentsProcessingDone();
294291

295-
Context.Builder builder;
296-
if (isPolyglot()) {
297-
builder = Context.newBuilder().options(polyglotOptions);
298-
} else {
299-
builder = Context.newBuilder(getDefaultLanguages()).options(polyglotOptions);
300-
}
301-
302-
builder.allowAllAccess(true);
292+
Context.Builder builder = Context.newBuilder().allowAllAccess(true).options(polyglotOptions);
303293
setupContextBuilder(builder);
304294

305295
launch(builder);
@@ -308,16 +298,16 @@ final void launch(List<String> args, Map<String, String> defaultOptions, boolean
308298
/**
309299
* Process command line arguments by either saving the necessary state or adding it to the
310300
* {@code polyglotOptions}. Any unrecognized arguments should be accumulated and returned as a
311-
* list. VM (--jvm/--native/--polyglot/--vm.*) and polyglot options (--language.option or
312-
* --option) should be returned as unrecognized arguments to be automatically parsed and
313-
* validated by {@link Launcher#parsePolyglotOption(String, Map, boolean, String)}.
314-
*
301+
* list. VM (--jvm/--native/--vm.*) and polyglot options (--language.option or --option) should
302+
* be returned as unrecognized arguments to be automatically parsed and validated by
303+
* {@link Launcher#parsePolyglotOption(String, Map, boolean, String)}.
304+
* <p>
315305
* The {@code arguments} should not be modified, but doing so also has no effect.
316-
*
306+
* <p>
317307
* {@code polyglotOptions.put()} can be used to set launcher-specific default values when they
318308
* do not match the OptionKey's default.
319-
*
320-
* The {@code preprocessArguments} implementations can use {@link Engine} to inspect the the
309+
* <p>
310+
* The {@code preprocessArguments} implementations can use {@link Engine} to inspect the
321311
* installed {@link Engine#getLanguages() guest languages} and {@link Engine#getInstruments()
322312
* instruments}. But creating a {@link Context} or inspecting {@link Engine#getOptions() engine
323313
* options} is forbidden.
@@ -399,12 +389,15 @@ protected void runVersionAction(VersionAction action, Engine engine) {
399389
}
400390

401391
/**
402-
* The return value specifies what languages should be available by default when not using
403-
* --polyglot. Note that TruffleLanguage.Registration#dependentLanguages() should be preferred
404-
* in most cases.
392+
* The return value used to specify what languages should be available by default when not using
393+
* --polyglot. --polyglot is default since 26.0 so this is no longer used. Note that
394+
* TruffleLanguage.Registration#dependentLanguages() should be preferred in most cases.
405395
*
396+
* @deprecated no longer has any effect, all languages are always available for
397+
* AbstractLanguageLauncher.
406398
* @return an array of required language ids
407399
*/
400+
@Deprecated(since = "26.0")
408401
protected String[] getDefaultLanguages() {
409402
return new String[]{getLanguageId()};
410403
}

sdk/src/org.graalvm.launcher/src/org/graalvm/launcher/LanguageLauncherBase.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -74,7 +74,6 @@ public abstract class LanguageLauncherBase extends Launcher {
7474
private static final String WEBSITE_HEADER = "[website]";
7575

7676
private static Engine tempEngine;
77-
private boolean seenPolyglot;
7877
private VersionAction versionAction = VersionAction.None;
7978

8079
static Engine getTempEngine() {
@@ -167,14 +166,6 @@ static List<Instrument> sortedInstruments(Engine engine) {
167166
return instruments;
168167
}
169168

170-
final boolean isPolyglot() {
171-
return seenPolyglot;
172-
}
173-
174-
final void setPolyglot(boolean polyglot) {
175-
seenPolyglot = polyglot;
176-
}
177-
178169
final void setupContextBuilder(Context.Builder builder) {
179170
Path logFile = getLogFile();
180171
if (logFile != null) {
@@ -218,7 +209,7 @@ protected boolean runLauncherAction() {
218209
protected boolean parseCommonOption(String defaultOptionPrefix, Map<String, String> polyglotOptions, boolean experimentalOptions, String arg) {
219210
switch (arg) {
220211
case "--polyglot":
221-
seenPolyglot = true;
212+
// the default, just ignore it
222213
break;
223214
case "--version:graalvm":
224215
versionAction = VersionAction.PrintAndExit;

0 commit comments

Comments
 (0)