commit 338cdae51c4db122cb9a9fcacce7f13efdd98940
parent f77375ba41acc4f5ea4ec581b1060a6dac5d888b
Author: Asumu Takikawa <asumu@igalia.com>
Date: Mon, 8 Dec 2025 16:02:52 +0000
Bug 1977854 - Wasm custom page sizes part 1: add flag/config. r=rhunt,bvisness
Differential Revision: https://phabricator.services.mozilla.com/D257727
Diffstat:
4 files changed, 70 insertions(+), 3 deletions(-)
diff --git a/js/moz.configure b/js/moz.configure
@@ -1046,6 +1046,50 @@ def wasm_branch_hinting(value, no_experimental):
set_config("ENABLE_WASM_BRANCH_HINTING", wasm_branch_hinting)
set_define("ENABLE_WASM_BRANCH_HINTING", wasm_branch_hinting)
+# Support for WebAssembly Custom Page Sizes
+# =====================================================
+
+
+@depends(milestone.is_nightly, "--enable-simulator", target)
+def default_wasm_custom_page_sizes(is_nightly, simulator, target):
+ if simulator and (simulator[0] != "arm64"):
+ return
+
+ if is_nightly and target.cpu in ("x86_64", "x86", "aarch64"):
+ return True
+
+
+option(
+ "--enable-wasm-custom-page-sizes",
+ default=default_wasm_custom_page_sizes,
+ help="{Enable|Disable} WebAssembly Custom Page Sizes",
+)
+
+
+@depends(
+ "--enable-wasm-custom-page-sizes",
+ "--enable-simulator",
+ target,
+ "--wasm-no-experimental",
+)
+def wasm_custom_page_sizes(value, simulator, target, no_experimental):
+ if no_experimental or not value:
+ return
+
+ if simulator and (simulator[0] != "arm64"):
+ return
+
+ if target.cpu in ("x86_64", "x86", "aarch64"):
+ return True
+
+ die(
+ "--enable-wasm-custom-page-sizes only possible when targeting the x86_64/x86/arm64 jits"
+ )
+
+
+set_config("ENABLE_WASM_CUSTOM_PAGE_SIZES", wasm_custom_page_sizes)
+set_define("ENABLE_WASM_CUSTOM_PAGE_SIZES", wasm_custom_page_sizes)
+
# Enable static checking using sixgill
# ====================================
diff --git a/js/public/WasmFeatures.h b/js/public/WasmFeatures.h
@@ -62,6 +62,11 @@
#else
# define WASM_BRANCH_HINTING_ENABLED 0
#endif
+#ifdef ENABLE_WASM_CUSTOM_PAGE_SIZES
+# define WASM_CUSTOM_PAGE_SIZES_ENABLED 1
+#else
+# define WASM_CUSTOM_PAGE_SIZES_ENABLED 0
+#endif
// clang-format off
#define JS_FOR_WASM_FEATURES(FEATURE) \
@@ -118,7 +123,16 @@
/* flag predicate */ true, \
/* flag force enable */ false, \
/* flag fuzz enable */ true, \
- /* preference name */ branch_hinting)
+ /* preference name */ branch_hinting) \
+ FEATURE( \
+ /* capitalized name */ CustomPageSizes, \
+ /* lower case name */ customPageSizes, \
+ /* compile predicate */ WASM_CUSTOM_PAGE_SIZES_ENABLED, \
+ /* compiler predicate */ BaselineAvailable(cx), \
+ /* flag predicate */ !IsFuzzingIon(cx), \
+ /* flag force enable */ false, \
+ /* flag fuzz enable */ true, \
+ /* preference name */ custom_page_sizes)
// clang-format on
diff --git a/js/src/wasm/WasmFeatures.cpp b/js/src/wasm/WasmFeatures.cpp
@@ -165,7 +165,6 @@ bool wasm::IonAvailable(JSContext* cx) {
MOZ_ALWAYS_TRUE(IonDisabledByFeatures(cx, &isDisabled));
return !isDisabled;
}
-
bool wasm::WasmCompilerForAsmJSAvailable(JSContext* cx) {
return IonAvailable(cx);
}
@@ -198,13 +197,17 @@ bool wasm::IonDisabledByFeatures(JSContext* cx, bool* isDisabled,
JSStringBuilder* reason) {
// Ion has no debugging support.
bool debug = WasmDebuggerActive(cx);
+ bool customPageSizes = WasmCustomPageSizesFlag(cx);
if (reason) {
char sep = 0;
if (debug && !Append(reason, "debug", &sep)) {
return false;
}
+ if (customPageSizes && !Append(reason, "custom-page-sizes", &sep)) {
+ return false;
+ }
}
- *isDisabled = debug;
+ *isDisabled = debug || customPageSizes;
return true;
}
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
@@ -9237,6 +9237,12 @@
mirror: always
set_spidermonkey_pref: always
+- name: javascript.options.wasm_custom_page_sizes
+ type: bool
+ value: false
+ mirror: always
+ set_spidermonkey_pref: startup
+
#if defined(ENABLE_WASM_SIMD)
#if defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_X86)
# Enables AVX instructions support on X86/X64 platforms.