Bug 1507106 - add atomic.notify as an alias for atomic.wake. r=jseward
authorLars T Hansen <lhansen@mozilla.com>
Wed, 14 Nov 2018 13:22:39 +0100
changeset 446241 26862c8c9db982119676a63482d9ae51e59e1534
parent 446240 ea1da7c247ea61c752334deca1c2c060eeb971e8
child 446242 ca52fc2566624ed83e968fa89c39986c3e75d05b
push id35039
push userrmaries@mozilla.com
push dateWed, 14 Nov 2018 22:17:41 +0000
treeherdermozilla-central@b0a40093b6b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjseward
bugs1507106
milestone65.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 1507106 - add atomic.notify as an alias for atomic.wake. r=jseward
js/src/jit-test/tests/wasm/atomic.js
js/src/wasm/WasmTextToBinary.cpp
--- a/js/src/jit-test/tests/wasm/atomic.js
+++ b/js/src/jit-test/tests/wasm/atomic.js
@@ -50,40 +50,41 @@ for (let [type,view] of [['i32','8_u'],[
 for (let type of ['i32', 'i64']) {
     let text = (shared) => `(module (memory 1 1 ${shared})
 			     (func (result i32) (${type}.atomic.wait (i32.const 0) (${type}.const 1) (i64.const -1)))
 			     (export "" 0))`;
     assertEq(valText(text(SHARED)), true);
     assertEq(valText(text(UNSHARED)), false);
 }
 
-{
+// 'wake' remains a backwards-compatible alias for 'notify'
+for ( let notify of ['wake', 'notify']) {
     let text = (shared) => `(module (memory 1 1 ${shared})
-			     (func (result i32) (atomic.wake (i32.const 0) (i32.const 1)))
+			     (func (result i32) (atomic.${notify} (i32.const 0) (i32.const 1)))
 			     (export "" 0))`;
     assertEq(valText(text(SHARED)), true);
     assertEq(valText(text(UNSHARED)), false);
 }
 
 // Required explicit alignment for WAIT is the size of the datum
 
 for (let [type,align,good] of [['i32',1,false],['i32',2,false],['i32',4,true],['i32',8,false],
 			       ['i64',1,false],['i64',2,false],['i64',4,false],['i64',8,true]])
 {
     let text = `(module (memory 1 1 shared)
 		 (func (result i32) (${type}.atomic.wait align=${align} (i32.const 0) (${type}.const 1) (i64.const -1)))
 		 (export "" 0))`;
     assertEq(valText(text), good);
 }
 
-// Required explicit alignment for WAKE is 4
+// Required explicit alignment for NOTIFY is 4
 
 for (let align of [1, 2, 4, 8]) {
     let text = `(module (memory 1 1 shared)
-		 (func (result i32) (atomic.wake align=${align} (i32.const 0) (i32.const 1)))
+		 (func (result i32) (atomic.notify align=${align} (i32.const 0) (i32.const 1)))
 		 (export "" 0))`;
     assertEq(valText(text), align == 4);
 }
 
 function valText(text) {
     return WebAssembly.validate(wasmTextToBinary(text));
 }
 
@@ -461,17 +462,17 @@ var BoundsAndAlignment =
 		}
 	    }
 	}
     }
 }
 
 BoundsAndAlignment.run();
 
-// Bounds and alignment checks on wait and wake
+// Bounds and alignment checks on wait and notify
 
 assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
 					(func (param i32) (result i32)
 					 (i32.atomic.wait (get_local 0) (i32.const 1) (i64.const -1)))
 					(export "" 0))`).exports[""](65536),
 		   RuntimeError, oob);
 
 assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
@@ -489,25 +490,25 @@ assertErrorMessage(() => wasmEvalText(`(
 assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
 					(func (param i32) (result i32)
 					 (i64.atomic.wait (get_local 0) (i64.const 1) (i64.const -1)))
 					(export "" 0))`).exports[""](65501),
 		   RuntimeError, unaligned);
 
 assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
 					(func (param i32) (result i32)
-					 (atomic.wake (get_local 0) (i32.const 1)))
+					 (atomic.notify (get_local 0) (i32.const 1)))
 					(export "" 0))`).exports[""](65536),
 		   RuntimeError, oob);
 
-// Minimum run-time alignment for WAKE is 4
+// Minimum run-time alignment for NOTIFY is 4
 for (let addr of [1,2,3,5,6,7]) {
     assertErrorMessage(() => wasmEvalText(`(module (memory 1 1 shared)
 					    (func (export "f") (param i32) (result i32)
-					     (atomic.wake (get_local 0) (i32.const 1))))`).exports.f(addr),
+					     (atomic.notify (get_local 0) (i32.const 1))))`).exports.f(addr),
 		       RuntimeError, unaligned);
 }
 
 // Ensure alias analysis works even if atomic and non-atomic accesses are
 // mixed.
 assertErrorMessage(() => wasmEvalText(`(module
   (memory 0 1 shared)
   (func (export "main")
--- a/js/src/wasm/WasmTextToBinary.cpp
+++ b/js/src/wasm/WasmTextToBinary.cpp
@@ -1001,18 +1001,21 @@ WasmTokenStream::next()
         }
         if (consume(u"anyfunc")) {
             return WasmToken(WasmToken::AnyFunc, begin, cur_);
         }
         if (consume(u"anyref")) {
             return WasmToken(WasmToken::ValueType, ValType::AnyRef, begin, cur_);
         }
 #ifdef ENABLE_WASM_THREAD_OPS
-        if (consume(u"atomic.wake")) {
-            return WasmToken(WasmToken::Wake, ThreadOp::Wake, begin, cur_);
+        if (consume(u"atomic.")) {
+            if (consume(u"wake") || consume(u"notify")) {
+                return WasmToken(WasmToken::Wake, ThreadOp::Wake, begin, cur_);
+            }
+            break;
         }
 #endif
         break;
 
       case 'b':
         if (consume(u"block")) {
             return WasmToken(WasmToken::Block, begin, cur_);
         }