Bug 1759909 - Enable AVX support for Wasm SIMD by default in Nightly. r=lth

Differential Revision: https://phabricator.services.mozilla.com/D141265
This commit is contained in:
Yury Delendik 2022-03-18 15:07:31 +00:00
Родитель 56ef111fbd
Коммит 6c4cf3e439
8 изменённых файлов: 81 добавлений и 6 удалений

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

@ -833,6 +833,54 @@ def wasm_simd(value, jit_enabled, simulator, cranelift_enabled, target):
set_config("ENABLE_WASM_SIMD", wasm_simd)
set_define("ENABLE_WASM_SIMD", wasm_simd)
# Support for Intel AVX instruction.
#
# AVX is exclusively used in WebAssembly SIMD instructions at the moment:
# set direct dependency on "--enable-wasm-simd".
# =====================================================
@depends(milestone.is_nightly, "--enable-wasm-simd", "--enable-simulator", target)
def default_wasm_avx(is_nightly, wasm_simd_enabled, simulator, target):
if not wasm_simd_enabled:
return
if simulator:
return
if target.cpu in ("x86_64", "x86"):
return is_nightly
option(
"--enable-wasm-avx",
default=default_wasm_avx,
help="{Enable|Disable} AVX support for WebAssembly SIMD",
)
@depends("--enable-wasm-avx", "--enable-wasm-simd", "--enable-simulator", target)
def wasm_avx(value, wasm_simd_enabled, simulator, target):
if not value:
return
if not wasm_simd_enabled:
die("--enable-wasm-avx requires --enable-wasm-simd")
if simulator:
die("--enable-wasm-avx is not supported for simulators")
if target.cpu in ("x86_64", "x86"):
return True
die("--enable-wasm-avx only possible when targeting the x86_64/x86 jits")
set_config("ENABLE_WASM_AVX", wasm_avx)
set_define("ENABLE_WASM_AVX", wasm_avx)
# Wormhole opcodes are Intel-only. They are private to Firefox, but we need them for some
# experiments on release and so they ride the trains.

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

@ -179,7 +179,7 @@ extern JS_PUBLIC_API void JS_ShutDown(void);
namespace JS {
// Enable support for AVX instructions in the JIT/Wasm backend on x86/x64
// platforms. Must be called before JS_Init*.
void SetAVXEnabled();
void SetAVXEnabled(bool enabled);
} // namespace JS
#endif

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

@ -203,7 +203,11 @@ AssemblerX86Shared::DoubleCondition AssemblerX86Shared::InvertCondition(
CPUInfo::SSEVersion CPUInfo::maxSSEVersion = UnknownSSE;
CPUInfo::SSEVersion CPUInfo::maxEnabledSSEVersion = UnknownSSE;
bool CPUInfo::avxPresent = false;
#ifdef ENABLE_WASM_AVX
bool CPUInfo::avxEnabled = true;
#else
bool CPUInfo::avxEnabled = false;
#endif
bool CPUInfo::popcntPresent = false;
bool CPUInfo::bmi1Present = false;
bool CPUInfo::bmi2Present = false;

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

@ -263,6 +263,10 @@ class CPUInfo {
SetMaxEnabledSSEVersion(SSE4_1);
avxEnabled = false;
}
static void SetAVXDisabled() {
MOZ_ASSERT(!FlagsHaveBeenComputed());
avxEnabled = false;
}
static void SetAVXEnabled() {
MOZ_ASSERT(!FlagsHaveBeenComputed());
avxEnabled = true;

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

@ -12197,11 +12197,20 @@ int main(int argc, char** argv) {
'\0', "no-sse42",
"Pretend CPU does not support SSE4.2 instructions "
"to test JIT codegen (no-op on platforms other than x86 and x64).") ||
#ifdef ENABLE_WASM_AVX
!op.addBoolOption('\0', "enable-avx",
"No-op. AVX is enabled by default, if available.") ||
!op.addBoolOption(
'\0', "no-avx",
"Pretend CPU does not support AVX or AVX2 instructions "
"to test JIT codegen (no-op on platforms other than x86 and x64).") ||
#else
!op.addBoolOption('\0', "enable-avx",
"AVX is disabled by default. Enable AVX. "
"(no-op on platforms other than x86 and x64).") ||
!op.addBoolOption('\0', "no-avx",
"No-op. AVX is currently disabled by default.") ||
#endif
!op.addBoolOption('\0', "more-compartments",
"Make newGlobal default to creating a new "
"compartment.") ||
@ -12389,6 +12398,12 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
}
if (op.getBoolOption("no-avx")) {
js::jit::CPUInfo::SetAVXDisabled();
if (!sCompilerProcessFlags.append("--no-avx")) {
return EXIT_FAILURE;
}
}
if (op.getBoolOption("enable-avx")) {
js::jit::CPUInfo::SetAVXEnabled();
if (!sCompilerProcessFlags.append("--enable-avx")) {

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

@ -329,7 +329,13 @@ JS_PUBLIC_API bool JS_SetICUMemoryFunctions(JS_ICUAllocFn allocFn,
#if defined(ENABLE_WASM_SIMD) && \
(defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_X86))
void JS::SetAVXEnabled() { js::jit::CPUInfo::SetAVXEnabled(); }
void JS::SetAVXEnabled(bool enabled) {
if (enabled) {
js::jit::CPUInfo::SetAVXEnabled();
} else {
js::jit::CPUInfo::SetAVXDisabled();
}
}
#endif
JS_PUBLIC_API void JS::DisableJitBackend() {

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

@ -6802,7 +6802,7 @@
# Changing these prefs requires a restart.
- name: javascript.options.wasm_simd_avx
type: bool
value: false
value: @IS_NIGHTLY_BUILD@
mirror: always
#endif
#endif

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

@ -256,9 +256,7 @@ static void InitializeJS() {
(defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_X86))
// Update static engine preferences, such as AVX, before
// `JS_InitWithFailureDiagnostic` is called.
if (mozilla::StaticPrefs::javascript_options_wasm_simd_avx()) {
JS::SetAVXEnabled();
}
JS::SetAVXEnabled(mozilla::StaticPrefs::javascript_options_wasm_simd_avx());
#endif
const char* jsInitFailureReason = JS_InitWithFailureDiagnostic();