Bug 1532714: Add a wasmUsesCranelift() function to check usage of Cranelift; r=lth
authorBenjamin Bouvier <benj@benj.me>
Wed, 06 Mar 2019 09:56:08 +0000
changeset 520450 9d953c8003c66ffc9c7bf505bc12a6d18a6b2189
parent 520449 475c7fe27919b7e336fada5c9733dfb13c0aea53
child 520451 c1bd622a40930a735928229b7c1aeb130c24122b
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1532714
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532714: Add a wasmUsesCranelift() function to check usage of Cranelift; r=lth Bulk memory operations can be enabled at the same time Cranelift is, in which case partial initialization of elements/segments/etc. implementation is statically implemented, but dynamically controlled by wasmBulkMemoryOps(). Cranelift doesn't implement bulk memory operations yet, so wasmBulkMemoryOps() returns false, while the static behavior is there. Thus, we have to temporarily disable partial initialization tests when running with Cranelift. This will go away when Cranelift supports bulk memory operations. Differential Revision: https://phabricator.services.mozilla.com/D22271
js/src/builtin/TestingFunctions.cpp
js/src/jit-test/tests/wasm/import-export.js
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -649,16 +649,27 @@ static bool WasmStreamingIsSupported(JSC
 }
 
 static bool WasmCachingIsSupported(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
   args.rval().setBoolean(wasm::HasCachingSupport(cx));
   return true;
 }
 
+static bool WasmUsesCranelift(JSContext* cx, unsigned argc, Value* vp) {
+  CallArgs args = CallArgsFromVp(argc, vp);
+#ifdef ENABLE_WASM_CRANELIFT
+  bool usesCranelift = cx->options().wasmCranelift();
+#else
+  bool usesCranelift = false;
+#endif
+  args.rval().setBoolean(usesCranelift);
+  return true;
+}
+
 static bool WasmThreadsSupported(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
   bool isSupported = wasm::HasSupport(cx);
 #ifdef ENABLE_WASM_CRANELIFT
   if (cx->options().wasmCranelift()) {
     isSupported = false;
   }
 #endif
@@ -5978,16 +5989,22 @@ gc::ZealModeHelpText),
     JS_FN_HELP("wasmStreamingIsSupported", WasmStreamingIsSupported, 0, 0,
 "wasmStreamingIsSupported()",
 "  Returns a boolean indicating whether WebAssembly caching is supported by the runtime."),
 
     JS_FN_HELP("wasmCachingIsSupported", WasmCachingIsSupported, 0, 0,
 "wasmCachingIsSupported()",
 "  Returns a boolean indicating whether WebAssembly caching is supported by the runtime."),
 
+    JS_FN_HELP("wasmUsesCranelift", WasmUsesCranelift, 0, 0,
+"wasmUsesCranelift()",
+"  Returns a boolean indicating whether Cranelift is currently enabled for backend\n"
+"  compilation. This doesn't necessarily mean a module will be compiled with \n"
+"  Cranelift (e.g. when baseline is also enabled)."),
+
     JS_FN_HELP("wasmThreadsSupported", WasmThreadsSupported, 0, 0,
 "wasmThreadsSupported()",
 "  Returns a boolean indicating whether the WebAssembly threads proposal is\n"
 "  supported on the current device."),
 
     JS_FN_HELP("wasmBulkMemSupported", WasmBulkMemSupported, 0, 0,
 "wasmBulkMemSupported()",
 "  Returns a boolean indicating whether the WebAssembly bulk memory proposal is\n"
--- a/js/src/jit-test/tests/wasm/import-export.js
+++ b/js/src/jit-test/tests/wasm/import-export.js
@@ -547,17 +547,17 @@ var tbl = new Table({initial:2, element:
 assertErrorMessage(() => new Instance(m, {a:{mem, tbl, memOff:1, tblOff:2}}),
                    LinkError,
                    /elem segment does not fit/);
 if (wasmBulkMemSupported()) {
     // The first active element segment is applied, but the second active
     // element segment is completely OOB.
     assertEq(typeof tbl.get(0), "function");
     assertEq(tbl.get(1), null);
-} else {
+} else if (!wasmUsesCranelift()) {
     assertEq(tbl.get(0), null);
     assertEq(tbl.get(1), null);
 }
 assertEq(mem8[0], 0);
 assertEq(mem8[1], 0);
 
 tbl.set(0, null);
 tbl.set(1, null);
@@ -566,17 +566,17 @@ assertErrorMessage(() => new Instance(m,
                    LinkError,
                    /data segment does not fit/);
 if (wasmBulkMemSupported()) {
     // The first and second active element segments are applied fully.  The
     // first active data segment applies, but the second one is completely OOB.
     assertEq(typeof tbl.get(0), "function");
     assertEq(typeof tbl.get(1), "function");
     assertEq(mem8[0], 1);
-} else {
+} else if (!wasmUsesCranelift()) {
     assertEq(tbl.get(0), null);
     assertEq(tbl.get(1), null);
     assertEq(mem8[0], 0);
 }
 
 tbl.set(0, null);
 tbl.set(1, null);
 mem8[0] = 0;