Skip to content

Commit

Permalink
Bug 1660944: Use Cranelift by default for wasm compilation on aarch64…
Browse files Browse the repository at this point in the history
…; r=lth

Differential Revision: https://phabricator.services.mozilla.com/D88396
  • Loading branch information
bnjbvr committed Sep 2, 2020
1 parent fdf392a commit 52fff50
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
12 changes: 7 additions & 5 deletions js/moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,16 @@ set_config('MOZ_RUST_SIMD', rust_simd)
set_define('MOZ_RUST_SIMD', rust_simd)


# Experimental support for wasm code generation with Cranelift
#
# Note, you may have to disable features not supported by Cranelift
# (multi-value, threads) to make Cranelift actually available
# Support for wasm code generation with Cranelift
# ==============================================================

@depends(milestone.is_nightly, target, simulator)
def cranelift_default(is_nightly, target, simulator):
if is_nightly or target.cpu == 'aarch64' or simulator.arm64:
return True

js_option('--enable-cranelift',
default=milestone.is_nightly,
default=cranelift_default,
help='{Enable|Disable} Cranelift code generator for wasm')

set_config('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True))
Expand Down
12 changes: 10 additions & 2 deletions js/src/shell/js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10199,22 +10199,30 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
// Default values for wasm.
enableWasm = true;
enableWasmBaseline = true;
#ifdef JS_CODEGEN_ARM64
enableWasmCranelift = true;
#else
enableWasmIon = true;
#endif
if (const char* str = op.getStringOption("wasm-compiler")) {
if (strcmp(str, "none") == 0) {
enableWasm = false;
} else if (strcmp(str, "baseline") == 0) {
// Baseline is enabled by default.
enableWasmIon = false;
enableWasmCranelift = false;
} else if (strcmp(str, "ion") == 0) {
// Ion is enabled by default.
enableWasmBaseline = false;
enableWasmIon = true;
enableWasmCranelift = false;
} else if (strcmp(str, "cranelift") == 0) {
enableWasmBaseline = false;
enableWasmIon = false;
enableWasmCranelift = true;
} else if (strcmp(str, "baseline+ion") == 0) {
// Default.
// Baseline is enabled by default.
enableWasmIon = true;
enableWasmCranelift = false;
} else if (strcmp(str, "baseline+cranelift") == 0) {
// Baseline is enabled by default.
enableWasmIon = false;
Expand Down
19 changes: 16 additions & 3 deletions modules/libpref/init/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -1090,11 +1090,24 @@ pref("javascript.options.asmjs", true);
pref("javascript.options.wasm", true);
pref("javascript.options.wasm_trustedprincipals", true);
pref("javascript.options.wasm_verbose", false);
pref("javascript.options.wasm_ionjit", true);
pref("javascript.options.wasm_baselinejit", true);
#ifdef ENABLE_WASM_CRANELIFT
pref("javascript.options.wasm_cranelift", false);

// On aarch64, Cranelift is the optimizing tier used by default for wasm
// compilation, and Ion is not available.
// On every other tier-1 platform, Ion is the default, and Cranelift is
// disabled.
#ifdef _ARM64_
#ifdef ENABLE_WASM_CRANELIFT
pref("javascript.options.wasm_cranelift", true);
#endif
pref("javascript.options.wasm_ionjit", false);
#else
#ifdef ENABLE_WASM_CRANELIFT
pref("javascript.options.wasm_cranelift", false);
#endif
pref("javascript.options.wasm_ionjit", true);
#endif

#ifdef ENABLE_WASM_REFTYPES
pref("javascript.options.wasm_reftypes", true);
pref("javascript.options.wasm_gc", false);
Expand Down

0 comments on commit 52fff50

Please sign in to comment.