diff --git a/js/src/asmjs/AsmJSValidate.cpp b/js/src/asmjs/AsmJSValidate.cpp
--- a/js/src/asmjs/AsmJSValidate.cpp
+++ b/js/src/asmjs/AsmJSValidate.cpp
@@ -9222,16 +9222,21 @@ CheckModule(ExclusiveContext* cx, AsmJSP
     if (!CheckModuleProcessingDirectives(m))
         return false;
 
     if (!CheckModuleGlobals(m))
         return false;
 
     m.startFunctionBodies();
 
+#if !defined(ENABLE_SHARED_ARRAY_BUFFER)
+    if (m.module().hasArrayView() && m.module().isSharedView())
+        return m.fail(nullptr, "shared views not supported by this build");
+#endif
+
     if (!CheckFunctions(m))
         return false;
 
     m.finishFunctionBodies();
 
     if (!CheckFuncPtrTables(m))
         return false;
 
diff --git a/js/src/jit-test/tests/asm.js/gating.js b/js/src/jit-test/tests/asm.js/gating.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/asm.js/gating.js
@@ -0,0 +1,73 @@
+// Check gating of shared memory features in asm.js (bug 1171540).
+//
+// When run with -w this should produce a slew of warnings if shared
+// memory is not enabled.  There are several cases here because there
+// are various checks within Odin.
+//
+// Note code is not run, so the only issue here is whether it compiles
+// properly as asm.js.
+
+/*
+
+// Commented out until we can fix bug #1172517, which makes this fail
+// for other reasons.
+
+function module_a(stdlib, foreign, heap) {
+    "use asm";
+
+    // Without shared memory, this will be flagged as illegal view type
+    var view = stdlib.SharedInt32Array;
+    var i32a = new view(heap);
+    var ld = stdlib.Atomics.load;
+
+    function do_load() {
+	var v = 0;
+	v = ld(i32a, 0)|0;
+	return v|0;
+    }
+
+    return { load: do_load };
+}
+
+if (this.SharedArrayBuffer)
+    assertEq(isAsmJSModule(module_a), true);
+
+*/
+
+function module_b(stdlib, foreign, heap) {
+    "use asm";
+
+    // Without shared memory, this will be flagged as illegal view type
+    var i32a = new stdlib.SharedInt32Array(heap);
+    var ld = stdlib.Atomics.load;
+
+    function do_load() {
+	var v = 0;
+	v = ld(i32a, 0)|0;
+	return v|0;
+    }
+
+    return { load: do_load };
+}
+
+if (this.SharedArrayBuffer)
+    assertEq(isAsmJSModule(module_b), true);
+
+function module_d(stdlib, foreign, heap) {
+    "use asm";
+
+    var i32a = new stdlib.Int32Array(heap);
+    var ld = stdlib.Atomics.load;
+
+    function do_load() {
+	var v = 0;
+	// This should be flagged as a type error (needs shared view) regardless
+	// of whether shared memory is enabled.
+	v = ld(i32a, 0)|0;
+	return v|0;
+    }
+
+    return { load: do_load };
+}
+
+// module_d should never load properly.
