Bug 1391636 - Move a guard from TestingFunctions into Wasm proper. r=me
authorLars T Hansen <lhansen@mozilla.com>
Wed, 22 Nov 2017 10:29:24 +0100
changeset 701935 2d62270047217e43ce7a8c4931b5c95b0f7b0f0c
parent 701934 bb88efd97a282d4ec1c517903a684360497d848f
child 701936 dbdbddba5e0ea229b36da64b07cdf0635f3f90db
child 701990 136dcbbcb3226a6986f65a670ded060b962d560c
child 702092 0b60a5360f799570d0aa8d2a2deca78067286f6a
push id90308
push userbmo:lhansen@mozilla.com
push dateWed, 22 Nov 2017 12:45:04 +0000
reviewersme
bugs1391636
milestone59.0a1
Bug 1391636 - Move a guard from TestingFunctions into Wasm proper. r=me
js/src/builtin/TestingFunctions.cpp
js/src/wasm/WasmJS.cpp
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -27,17 +27,16 @@
 #include "builtin/Promise.h"
 #include "builtin/SelfHostingDefines.h"
 #ifdef DEBUG
 #include "frontend/TokenStream.h"
 #include "irregexp/RegExpAST.h"
 #include "irregexp/RegExpEngine.h"
 #include "irregexp/RegExpParser.h"
 #endif
-#include "jit/AtomicOperations.h"
 #include "jit/InlinableNatives.h"
 #include "js/Debug.h"
 #include "js/HashTable.h"
 #include "js/StructuredClone.h"
 #include "js/UbiNode.h"
 #include "js/UbiNodeBreadthFirst.h"
 #include "js/UbiNodeShortestPaths.h"
 #include "js/UniquePtr.h"
@@ -546,26 +545,16 @@ static bool
 WasmThreadsSupported(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 #ifdef ENABLE_WASM_THREAD_OPS
     bool isSupported = wasm::HasSupport(cx);
 #else
     bool isSupported = false;
 #endif
-
-    // NOTE!  When we land thread support, the following test and its comment
-    // should be moved into wasm::HasSupport() or wasm::HasCompilerSupport().
-
-    // Wasm threads require 8-byte lock-free atomics.  This guard will
-    // effectively disable Wasm support for some older devices, such as early
-    // ARMv6 and older MIPS.
-
-    isSupported = isSupported && jit::AtomicOperations::isLockfree8();
-
     args.rval().setBoolean(isSupported);
     return true;
 }
 
 static bool
 WasmCompileMode(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
--- a/js/src/wasm/WasmJS.cpp
+++ b/js/src/wasm/WasmJS.cpp
@@ -20,16 +20,17 @@
 
 #include "mozilla/CheckedInt.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/RangedPtr.h"
 
 #include "jsprf.h"
 
 #include "builtin/Promise.h"
+#include "jit/AtomicOperations.h"
 #include "jit/JitOptions.h"
 #include "vm/Interpreter.h"
 #include "vm/String.h"
 #include "vm/StringBuffer.h"
 #include "wasm/WasmCompile.h"
 #include "wasm/WasmInstance.h"
 #include "wasm/WasmModule.h"
 #include "wasm/WasmSignalHandlers.h"
@@ -62,16 +63,22 @@ wasm::HasCompilerSupport(JSContext* cx)
         return false;
 
     if (!cx->jitSupportsUnalignedAccesses())
         return false;
 
     if (!wasm::HaveSignalHandlers())
         return false;
 
+#ifdef ENABLE_WASM_THREAD_OPS
+    // Wasm threads require 8-byte lock-free atomics.
+    if (!jit::AtomicOperations::isLockfree8())
+        return false;
+#endif
+
 #if defined(JS_CODEGEN_NONE) || defined(JS_CODEGEN_ARM64)
     return false;
 #else
     return true;
 #endif
 }
 
 bool