From c1bc991a46eba4a2188cf048ad9469354dfda351 Mon Sep 17 00:00:00 2001 From: Ryan Hunt Date: Fri, 30 Aug 2019 02:34:10 +0000 Subject: [PATCH] Bug 1518210 - Wasm: Don't run --wasm-disable-huge-memory if the platform doesn't support huge memory. r=lth This commit extends the jit-test runner to support 'skip-variant-if: $FLAG, $COND', and uses this to not run '--wasm-disable-huge-memory' tests when the platform doesn't support huge memory. Differential Revision: https://phabricator.services.mozilla.com/D43670 --HG-- extra : moz-landing-system : lando --- js/src/builtin/TestingFunctions.cpp | 15 +++++++++++ .../jit-test/tests/wasm/bench/directives.txt | 2 +- js/src/jit-test/tests/wasm/directives.txt | 2 +- js/src/jit-test/tests/wasm/gc/directives.txt | 2 +- .../tests/wasm/regress/directives.txt | 2 +- .../tests/wasm/timeout/directives.txt | 2 +- js/src/tests/lib/jittests.py | 25 ++++++++++++++++--- 7 files changed, 41 insertions(+), 9 deletions(-) diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 4be5cf0ce5c0..b7bba4f7b171 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -697,6 +697,16 @@ static bool WasmCachingIsSupported(JSContext* cx, unsigned argc, Value* vp) { return true; } +static bool WasmHugeMemoryIsSupported(JSContext* cx, unsigned argc, Value* vp) { + CallArgs args = CallArgsFromVp(argc, vp); +#ifdef WASM_SUPPORTS_HUGE_MEMORY + args.rval().setBoolean(true); +#else + args.rval().setBoolean(false); +#endif + return true; +} + static bool WasmUsesCranelift(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); #ifdef ENABLE_WASM_CRANELIFT @@ -6365,6 +6375,11 @@ gc::ZealModeHelpText), "wasmCachingIsSupported()", " Returns a boolean indicating whether WebAssembly caching is supported by the runtime."), + JS_FN_HELP("wasmHugeMemoryIsSupported", WasmHugeMemoryIsSupported, 0, 0, +"wasmHugeMemoryIsSupported()", +" Returns a boolean indicating whether WebAssembly supports using a large" +" virtual memory reservation in order to elide bounds checks on this platform."), + JS_FN_HELP("wasmUsesCranelift", WasmUsesCranelift, 0, 0, "wasmUsesCranelift()", " Returns a boolean indicating whether Cranelift is currently enabled for backend\n" diff --git a/js/src/jit-test/tests/wasm/bench/directives.txt b/js/src/jit-test/tests/wasm/bench/directives.txt index 56182d8f2d7b..38461c763f98 100644 --- a/js/src/jit-test/tests/wasm/bench/directives.txt +++ b/js/src/jit-test/tests/wasm/bench/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; include:wasm.js +|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemoryIsSupported(); include:wasm.js diff --git a/js/src/jit-test/tests/wasm/directives.txt b/js/src/jit-test/tests/wasm/directives.txt index 56182d8f2d7b..38461c763f98 100644 --- a/js/src/jit-test/tests/wasm/directives.txt +++ b/js/src/jit-test/tests/wasm/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; include:wasm.js +|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemoryIsSupported(); include:wasm.js diff --git a/js/src/jit-test/tests/wasm/gc/directives.txt b/js/src/jit-test/tests/wasm/gc/directives.txt index f628610c80e4..dad227c628d3 100644 --- a/js/src/jit-test/tests/wasm/gc/directives.txt +++ b/js/src/jit-test/tests/wasm/gc/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-gc; test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--wasm-gc --wasm-compiler=baseline; test-also=--disable-wasm-huge-memory; include:wasm.js +|jit-test| test-also=--wasm-gc; test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--wasm-gc --wasm-compiler=baseline; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemoryIsSupported(); include:wasm.js diff --git a/js/src/jit-test/tests/wasm/regress/directives.txt b/js/src/jit-test/tests/wasm/regress/directives.txt index 56182d8f2d7b..38461c763f98 100644 --- a/js/src/jit-test/tests/wasm/regress/directives.txt +++ b/js/src/jit-test/tests/wasm/regress/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; include:wasm.js +|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemoryIsSupported(); include:wasm.js diff --git a/js/src/jit-test/tests/wasm/timeout/directives.txt b/js/src/jit-test/tests/wasm/timeout/directives.txt index b9bfe5aa9432..9364f28bc7c8 100644 --- a/js/src/jit-test/tests/wasm/timeout/directives.txt +++ b/js/src/jit-test/tests/wasm/timeout/directives.txt @@ -1,2 +1,2 @@ -|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory +|jit-test| test-also=--wasm-compiler=ion; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemoryIsSupported(); diff --git a/js/src/tests/lib/jittests.py b/js/src/tests/lib/jittests.py index a8c35517bc17..ce7585b85267 100755 --- a/js/src/tests/lib/jittests.py +++ b/js/src/tests/lib/jittests.py @@ -86,6 +86,13 @@ def js_quote(quote, s): os.path.relpath = _relpath +def extend_condition(condition, value): + if condition: + condition += " || " + condition += "({})".format(value) + return condition + + class JitTest: VALGRIND_CMD = [] @@ -147,6 +154,7 @@ class JitTest: # Skip-if condition. We don't have a xulrunner, but we can ask the shell # directly. self.skip_if_cond = '' + self.skip_variant_if_cond = {} # Expected by the test runner. Always true for jit-tests. self.enable = True @@ -171,11 +179,15 @@ class JitTest: t.is_module = self.is_module t.is_binast = self.is_binast t.skip_if_cond = self.skip_if_cond + t.skip_variant_if_cond = self.skip_variant_if_cond return t def copy_and_extend_jitflags(self, variant): t = self.copy() t.jitflags.extend(variant) + for flags in variant: + if flags in self.skip_variant_if_cond: + t.skip_if_cond = extend_condition(t.skip_if_cond, self.skip_variant_if_cond[flags]) return t def copy_variants(self, variants): @@ -273,10 +285,15 @@ class JitTest: elif name == 'include': test.other_includes.append(value) elif name == 'skip-if': - # Ensure that skip-ifs are composable - if test.skip_if_cond: - test.skip_if_cond += " || " - test.skip_if_cond += "({})".format(value) + test.skip_if_cond = extend_condition(test.skip_if_cond, value) + elif name == 'skip-variant-if': + try: + [variant, condition] = value.split(',') + test.skip_variant_if_cond[variant] = extend_condition( + test.skip_if_cond, + condition) + except ValueError: + print("warning: couldn't parse skip-variant-if") else: print('{}: warning: unrecognized |jit-test| attribute' ' {}'.format(path, part))