Skip to content

Commit

Permalink
Set latency mode by default in TruffleSqueakLauncher
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Jul 20, 2021
1 parent 9652a1e commit f259489
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 0 additions & 3 deletions mx.trufflesqueak/mx_trufflesqueak.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@

if _COMPILER:
# Tweak GraalVM Engine
BASE_VM_ARGS.append('-Dpolyglot.engine.Mode=latency')
BASE_VM_ARGS_TESTING.append('-Dpolyglot.engine.Mode=latency')

BASE_VM_ARGS_TESTING.append('-Dpolyglot.engine.CompilationFailureAction=Diagnose')

def _graal_vm_args(args):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import de.hpi.swa.trufflesqueak.shared.SqueakLanguageOptions;

public final class TruffleSqueakLauncher extends AbstractLanguageLauncher {
private static final String ENGINE_MODE_OPTION = "engine.Mode";
private static final String ENGINE_MODE_LATENCY = "latency";

private boolean headless;
private boolean printImagePath;
private boolean quiet;
Expand All @@ -38,6 +41,7 @@ public final class TruffleSqueakLauncher extends AbstractLanguageLauncher {
private String sourceCode;
private boolean enableTranscriptForwarding;
private String logHandlerMode;
private boolean useEngineModeLatency = true;

public static void main(final String[] arguments) throws RuntimeException {
new TruffleSqueakLauncher().launch(arguments);
Expand Down Expand Up @@ -67,6 +71,9 @@ protected List<String> preprocessArguments(final List<String> arguments, final M
} else if (SqueakLanguageOptions.LOG_HANDLER_FLAG.equals(arg)) {
logHandlerMode = arguments.get(++i);
} else {
if (arg.contains(ENGINE_MODE_OPTION)) {
useEngineModeLatency = false; // engine.Mode set explicitly
}
unrecognized.add(arg);
}
}
Expand All @@ -86,10 +93,15 @@ protected int execute(final Context.Builder contextBuilder) {
println(imagePath);
return 0;
}
final String runtimeName = getRuntimeName();
useEngineModeLatency &= runtimeName.contains("Graal"); // only ever use latency on Graal
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.IMAGE_PATH, imagePath);
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.HEADLESS, Boolean.toString(headless));
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.QUIET, Boolean.toString(quiet));
contextBuilder.arguments(getLanguageId(), imageArguments);
if (useEngineModeLatency) {
contextBuilder.option(ENGINE_MODE_OPTION, ENGINE_MODE_LATENCY);
}
contextBuilder.allowAllAccess(true);
final SqueakTranscriptForwarder out;
final SqueakTranscriptForwarder err;
Expand All @@ -107,7 +119,8 @@ protected int execute(final Context.Builder contextBuilder) {
}
try (Context context = contextBuilder.build()) {
if (!quiet) {
println(String.format("[trufflesqueak] Running %s on %s...", SqueakLanguageConfig.NAME, getRuntimeName()));
final String engineModeSuffix = useEngineModeLatency ? " (" + ENGINE_MODE_LATENCY + " mode)" : "";
println(String.format("[trufflesqueak] Running %s on %s%s...", SqueakLanguageConfig.NAME, runtimeName, engineModeSuffix));
}
if (sourceCode != null) {
final Value result = context.eval(
Expand Down Expand Up @@ -177,7 +190,7 @@ protected void collectArguments(final Set<String> options) {

@Override
protected String[] getDefaultLanguages() {
return new String[0]; // Allow all languages (similar to `--polyglot`)
return new String[0]; // Allow all languages (same effect of `--polyglot`)
}

@Override
Expand Down

0 comments on commit f259489

Please sign in to comment.