Bug 1686626 - Enable Ion by default for wasm on AArch64. r=lth.

This patch enables Ion by default as the optimising compiler for wasm on
AArch64, and disables Cranelift.  Cranelift is still available if the build is
configured with --enable-cranelift.  In that case, *only* Cranelift is
available.  There are no configuration flags to enable both Ion and Cranelift
simultaneously.

This mostly reverts the Phase 0 and Phase 1 patches that are bug 1678097
D102420 and D101867 respectively.

The command line option --wasm-force-ion has been removed.

With this patch in place, users of the shell should specify
`--wasm-compiler=optimizing` to get an optimising wasm compiler.  Which one is
provided depends on the configuration options as described above.
`--wasm-compiler=cranelift` and `--wasm-compiler=ion` are now only accepted
when the relevant compiler has been enabled, and so neither is a "safe" way to
request an optimising tier.

For that reason, test directories that previously requested
also-with-Ion-please by stating `test-also=--wasm-compiler=ion;` in their
`directives.txt` file, have been changed to use
`test-also=--wasm-compiler=optimizing;`.

In places where the JSContextOptions are set, the non-selected compiler (Ion
or CL) is explicitly set to `false` (eg, `.setWasmIon(false)`).  This may be
overly conservative, but seems wise given that it's not immediately obvious
what the previous value of that flag is, and given the recent difficulties
with incorrect option propagation/handling (eg, bug 1697560).

Differential Revision: https://phabricator.services.mozilla.com/D101695
This commit is contained in:
Julian Seward 2021-04-12 15:46:46 +00:00
Родитель 3271b9d803
Коммит 2288cd2d95
25 изменённых файлов: 73 добавлений и 125 удалений

Просмотреть файл

@ -555,30 +555,42 @@ set_define("MOZ_RUST_SIMD", rust_simd)
# Support for wasm code generation with Cranelift
# ==============================================================
option(
"--enable-cranelift",
default=False,
help="{Enable|Disable} Cranelift code generator for wasm",
)
@depends(
milestone.is_nightly,
"--enable-cranelift",
"--enable-jit",
"--enable-simulator",
target,
target_is_windows,
)
def cranelift_default(is_nightly, jit_enabled, simulator, target, is_windows):
if is_nightly and jit_enabled and not is_windows:
if target.cpu == "aarch64":
return True
if simulator and simulator[0] == "arm64":
return True
def enable_cranelift(value, jit_enabled, simulator, target, is_windows):
if not value:
return
if not jit_enabled:
die("--enable-cranelift requires --enable-jit")
if not (
target.cpu == "aarch64"
or (target.cpu == "x86_64" and simulator and simulator[0] == "arm64")
):
die("--enable-cranelift is only supported on arm64")
if is_windows:
die("--enable-cranelift is not supported on windows")
return True
option(
"--enable-cranelift",
default=cranelift_default,
help="{Enable|Disable} Cranelift code generator for wasm",
)
set_config("ENABLE_WASM_CRANELIFT", enable_cranelift)
set_define("ENABLE_WASM_CRANELIFT", enable_cranelift)
set_config("ENABLE_WASM_CRANELIFT", depends_if("--enable-cranelift")(lambda x: True))
set_define("ENABLE_WASM_CRANELIFT", depends_if("--enable-cranelift")(lambda x: True))
# Telemetry to measure compile time and generated-code runtime
# ============================================================

Просмотреть файл

@ -871,13 +871,6 @@ static bool WasmCompilersPresent(JSContext* cx, unsigned argc, Value* vp) {
}
strcat(buf, "cranelift");
}
// Cranelift->Ion transition
if (wasm::IonPlatformSupport()) {
if (*buf) {
strcat(buf, ",");
}
strcat(buf, "ion");
}
#else
if (wasm::IonPlatformSupport()) {
if (*buf) {

Просмотреть файл

@ -144,13 +144,8 @@ static int testWasmFuzz(const uint8_t* buf, size_t size) {
// that may have been enabled.
bool enableWasmBaseline = ((optByte & 0xF0) == (1 << 7));
bool enableWasmOptimizing = false;
#ifdef JS_CODEGEN_ARM64
// Cranelift->Ion transition
bool forceWasmIon = false;
#endif
#ifdef ENABLE_WASM_CRANELIFT
// Cranelift->Ion transition
forceWasmIon = IonPlatformSupport() && ((optByte & 0xF0) == (1 << 6));
enableWasmOptimizing =
CraneliftPlatformSupport() && ((optByte & 0xF0) == (1 << 5));
#else
@ -188,9 +183,10 @@ static int testWasmFuzz(const uint8_t* buf, size_t size) {
JS::ContextOptionsRef(gCx)
.setWasmBaseline(enableWasmBaseline)
#ifdef ENABLE_WASM_CRANELIFT
.setWasmCranelift(enableWasmOptimizing && !forceWasmIon)
.setWasmIon(forceWasmIon)
.setWasmCranelift(enableWasmOptimizing)
.setWasmIon(false)
#else
.setWasmCranelift(false)
.setWasmIon(enableWasmOptimizing)
#endif
.setTestWasmAwaitTier2(enableWasmAwaitTier2);

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; include:wasm.js
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; include:wasm.js

Просмотреть файл

@ -1,5 +1,14 @@
// |jit-test| skip-if: !wasmCompilersPresent().match("ion") || wasmIonDisabledByFeatures(); --wasm-compiler=optimizing
// |jit-test| skip-if: wasmIonDisabledByFeatures() || (!wasmCompilersPresent().match("ion") && !wasmCompilersPresent().match("cranelift")); --wasm-compiler=optimizing
// When we land wasm-via-Ion/aarch64 phase 2, this can be changed back to
// testing only for Ion.
assertEq(true, wasmCompileMode() === "ion" || wasmCompileMode() === "cranelift");
// Although we may build the system with both Cranelift and Ion present, only
// one may be used, hence:
//
// * If the system is built with Cranelift enabled, then Ion may not be used.
//
// * If the system is built without Cranelift enabled, then generally Ion is
// enabled, and so only that may be used.
assertEq(true,
(wasmCompilersPresent().match("ion") && wasmCompileMode() === "ion") ||
(wasmCompilersPresent().match("cranelift") &&
wasmCompileMode() === "cranelift"));

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js

Просмотреть файл

@ -1 +1 @@
|jit-test| --wasm-exceptions; test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; include:wasm.js; skip-if: !wasmExceptionsEnabled()
|jit-test| --wasm-exceptions; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; include:wasm.js; skip-if: !wasmExceptionsEnabled()

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline --wasm-function-references; include:wasm.js
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline --wasm-function-references; include:wasm.js

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-function-references --wasm-gc; include:wasm.js
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-function-references --wasm-gc; include:wasm.js

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--no-wasm-simd; test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--wasm-compiler=optimizing; include:wasm.js
|jit-test| test-also=--no-wasm-simd; test-also=--wasm-compiler=baseline; test-also=--wasm-compiler=optimizing; include:wasm.js

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--wasm-compiler=optimizing; test-also=--no-wasm-simd; skip-if: !wasmSimdEnabled()
|jit-test| test-also=--wasm-compiler=baseline; test-also=--wasm-compiler=optimizing; test-also=--no-wasm-simd; skip-if: !wasmSimdEnabled()

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm-testharness.js; local-include:harness/sync_index.js
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm-testharness.js; local-include:harness/sync_index.js

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm-testharness.js; local-include:harness/sync_index.js
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm-testharness.js; local-include:harness/sync_index.js

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm-testharness.js; local-include:harness/sync_index.js
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm-testharness.js; local-include:harness/sync_index.js

Просмотреть файл

@ -1 +1 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm-testharness.js; local-include:harness/sync_index.js; skip-if: !wasmThreadsEnabled()
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm-testharness.js; local-include:harness/sync_index.js; skip-if: !wasmThreadsEnabled()

Просмотреть файл

@ -1,2 +1,2 @@
|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported();
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported();

Просмотреть файл

@ -79,9 +79,6 @@
--arm-asm-nop-fill=1
--arm-hwcap=vfp
# aarch64 specific, no-ops on other platforms.
--wasm-force-ion
# Profiling, code coverage, and debugging
# --dump-bytecode option implies --code-coverage
--dump-bytecode

Просмотреть файл

@ -590,11 +590,6 @@ bool shell::enableWasm = false;
bool shell::enableSharedMemory = SHARED_MEMORY_DEFAULT;
bool shell::enableWasmBaseline = false;
bool shell::enableWasmOptimizing = false;
#ifdef JS_CODEGEN_ARM64
// Cranelift->Ion transition. The right value for fuzzing-but-not-enabled is
// 'false'; when we land for phase 2, we remove this flag.
bool shell::forceWasmIon = false;
#endif
#define WASM_DEFAULT_FEATURE(NAME, ...) bool shell::enableWasm##NAME = true;
#define WASM_EXPERIMENTAL_FEATURE(NAME, ...) \
@ -10871,9 +10866,6 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
enableWasmBaseline = true;
enableWasmOptimizing = true;
bool commandLineRequestedWasmIon = false;
bool commandLineRequestedWasmCranelift = false;
if (const char* str = op.getStringOption("wasm-compiler")) {
if (strcmp(str, "none") == 0) {
enableWasm = false;
@ -10892,20 +10884,17 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
} else if (strcmp(str, "cranelift") == 0) {
enableWasmBaseline = false;
enableWasmOptimizing = true;
commandLineRequestedWasmCranelift = true;
} else if (strcmp(str, "baseline+cranelift") == 0) {
MOZ_ASSERT(enableWasmBaseline);
enableWasmOptimizing = true;
commandLineRequestedWasmCranelift = true;
#endif
#else
} else if (strcmp(str, "ion") == 0) {
enableWasmBaseline = false;
enableWasmOptimizing = true;
commandLineRequestedWasmIon = true;
} else if (strcmp(str, "baseline+ion") == 0) {
MOZ_ASSERT(enableWasmBaseline);
enableWasmOptimizing = true;
commandLineRequestedWasmIon = true;
#endif
} else {
return OptionFailure("wasm-compiler", str);
}
@ -10946,36 +10935,16 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
enableTopLevelAwait = op.getBoolOption("enable-top-level-await");
useOffThreadParseGlobal = op.getBoolOption("off-thread-parse-global");
// ifdeffing the defs and uses of these two so as to avoid unused-variable
// complaints on all targets is difficult. Simpler just to create fake uses.
mozilla::Unused << commandLineRequestedWasmIon;
mozilla::Unused << commandLineRequestedWasmCranelift;
#ifdef JS_CODEGEN_ARM64
// Cranelift->Ion transition. When we land for phase 1, this becomes
// wasm-force-ion (be sure to update below around line 11500), and the default
// value of the flag is flipped to false, see comments above. When we land
// for phase 2, this goes away.
MOZ_ASSERT(
!(commandLineRequestedWasmIon && commandLineRequestedWasmCranelift));
if (commandLineRequestedWasmIon) {
forceWasmIon = true;
} else if (commandLineRequestedWasmCranelift) {
forceWasmIon = false;
} else {
forceWasmIon = op.getBoolOption("wasm-force-ion");
}
#endif
JS::ContextOptionsRef(cx)
.setAsmJS(enableAsmJS)
.setWasm(enableWasm)
.setWasmForTrustedPrinciples(enableWasm)
.setWasmBaseline(enableWasmBaseline)
#if defined(ENABLE_WASM_CRANELIFT) && defined(JS_CODEGEN_ARM64)
// Cranelift->Ion transition
.setWasmCranelift(enableWasmOptimizing && !forceWasmIon)
.setWasmIon(enableWasmOptimizing && forceWasmIon)
#if defined(ENABLE_WASM_CRANELIFT)
.setWasmCranelift(enableWasmOptimizing)
.setWasmIon(false)
#else
.setWasmCranelift(false)
.setWasmIon(enableWasmOptimizing)
#endif
@ -11368,11 +11337,11 @@ static void SetWorkerContextOptions(JSContext* cx) {
.setAsmJS(enableAsmJS)
.setWasm(enableWasm)
.setWasmBaseline(enableWasmBaseline)
#if defined(ENABLE_WASM_CRANELIFT) && defined(JS_CODEGEN_ARM64)
// Cranelift->Ion transition
.setWasmCranelift(enableWasmOptimizing && !forceWasmIon)
.setWasmIon(enableWasmOptimizing && forceWasmIon)
#if defined(ENABLE_WASM_CRANELIFT)
.setWasmCranelift(enableWasmOptimizing)
.setWasmIon(false)
#else
.setWasmCranelift(false)
.setWasmIon(enableWasmOptimizing)
#endif
#define WASM_FEATURE(NAME, ...) .setWasm##NAME(enableWasm##NAME)
@ -11891,13 +11860,6 @@ int main(int argc, char** argv, char** envp) {
"Enable wasm SIMD wormhole (UTSL)") ||
#else
!op.addBoolOption('\0', "wasm-simd-wormhole", "No-op") ||
#endif
#ifdef JS_CODEGEN_ARM64
// Cranelift->Ion transition. This disappears at Phase 2 of the landing.
// See sundry comments above.
!op.addBoolOption(
'\0', "wasm-force-ion",
"Temporary: Force Ion in builds with both Cranelift and Ion") ||
#endif
!op.addBoolOption('\0', "no-native-regexp",
"Disable native regexp compilation") ||
@ -12454,7 +12416,7 @@ int main(int argc, char** argv, char** envp) {
// presented in the same order that they exist in the parent's `argv[]`.
// That could be a problem in the case where two flags with contradictory
// meanings are given, and they are presented to the child in the opposite
// order. For example: --wasm-compiler=cranelift --wasm-force-ion.
// order. For example: --wasm-compiler=optimizing --wasm-compiler=baseline.
#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64)
if (op.getBoolOption("no-sse3")) {
@ -12516,11 +12478,7 @@ int main(int argc, char** argv, char** envp) {
// Feature selection options
"--wasm-simd-wormhole",
// Compiler selection options
"--test-wasm-await-tier2",
#ifdef JS_CODEGEN_ARM64
"--wasm-force-ion",
#endif
NULL};
"--test-wasm-await-tier2", NULL};
for (const char** p = &to_propagate[0]; *p; p++) {
if (op.getBoolOption(&(*p)[2] /* 2 => skip the leading '--' */)) {
if (!sCompilerProcessFlags.append(*p)) {

Просмотреть файл

@ -112,10 +112,6 @@ extern bool enableWasm;
extern bool enableSharedMemory;
extern bool enableWasmBaseline;
extern bool enableWasmOptimizing;
#ifdef JS_CODEGEN_ARM64
// Cranelift->Ion transition
extern bool forceWasmIon;
#endif
#define WASM_FEATURE(NAME, ...) extern bool enableWasm##NAME;
JS_FOR_WASM_FEATURES(WASM_FEATURE, WASM_FEATURE);

Просмотреть файл

@ -915,10 +915,6 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
Preferences::GetBool(JS_OPTIONS_DOT_STR "wasm_trustedprincipals");
bool useWasmOptimizing =
Preferences::GetBool(JS_OPTIONS_DOT_STR "wasm_optimizingjit");
#ifdef ENABLE_WASM_CRANELIFT
// Cranelift->Ion transition. When we land for phase 2, this goes away.
bool forceWasmIon = Preferences::GetBool(JS_OPTIONS_DOT_STR "wasm_force_ion");
#endif
bool useWasmBaseline =
Preferences::GetBool(JS_OPTIONS_DOT_STR "wasm_baselinejit");
@ -1004,10 +1000,10 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
.setWasm(useWasm)
.setWasmForTrustedPrinciples(useWasmTrustedPrincipals)
#ifdef ENABLE_WASM_CRANELIFT
// Cranelift->Ion transition
.setWasmCranelift(useWasmOptimizing && !forceWasmIon)
.setWasmIon(useWasmOptimizing && forceWasmIon)
.setWasmCranelift(useWasmOptimizing)
.setWasmIon(false)
#else
.setWasmCranelift(false)
.setWasmIon(useWasmOptimizing)
#endif
.setWasmBaseline(useWasmBaseline)

Просмотреть файл

@ -5662,15 +5662,6 @@
#endif
mirror: always
#if defined(MOZ_AARCH64)
# Cranelift->Ion transition. Temporary switch. When we land Phase 2
# of the transition, this switch will disappear altogether.
- name: javascript.options.wasm_force_ion
type: bool
value: false
mirror: always
#endif
# SIMD is supported only on x86 and x64, with arm64 support imminent.
#if defined(ENABLE_WASM_SIMD)
- name: javascript.options.wasm_simd