diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/binaryen-c.h | 28 | ||||
-rw-r--r-- | src/gen-s-parser.inc | 39 | ||||
-rw-r--r-- | src/js/binaryen.js-post.js | 20 | ||||
-rw-r--r-- | src/passes/Print.cpp | 6 | ||||
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 8 |
5 files changed, 56 insertions, 45 deletions
diff --git a/src/binaryen-c.h b/src/binaryen-c.h index c185b59f4..45beb3657 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -1404,47 +1404,47 @@ BinaryenAtomicCmpxchgSetReplacement(BinaryenExpressionRef expr, // AtomicWait -// Gets the pointer expression of an `atomic.wait` expression. +// Gets the pointer expression of an `memory.atomic.wait` expression. BINARYEN_API BinaryenExpressionRef BinaryenAtomicWaitGetPtr(BinaryenExpressionRef expr); -// Sets the pointer expression of an `atomic.wait` expression. +// Sets the pointer expression of an `memory.atomic.wait` expression. BINARYEN_API void BinaryenAtomicWaitSetPtr(BinaryenExpressionRef expr, BinaryenExpressionRef ptrExpr); -// Gets the expression representing the expected value of an `atomic.wait` -// expression. +// Gets the expression representing the expected value of an +// `memory.atomic.wait` expression. BINARYEN_API BinaryenExpressionRef BinaryenAtomicWaitGetExpected(BinaryenExpressionRef expr); -// Sets the expression representing the expected value of an `atomic.wait` -// expression. +// Sets the expression representing the expected value of an +// `memory.atomic.wait` expression. BINARYEN_API void BinaryenAtomicWaitSetExpected(BinaryenExpressionRef expr, BinaryenExpressionRef expectedExpr); -// Gets the timeout expression of an `atomic.wait` expression. +// Gets the timeout expression of an `memory.atomic.wait` expression. BINARYEN_API BinaryenExpressionRef BinaryenAtomicWaitGetTimeout(BinaryenExpressionRef expr); -// Sets the timeout expression of an `atomic.wait` expression. +// Sets the timeout expression of an `memory.atomic.wait` expression. BINARYEN_API void BinaryenAtomicWaitSetTimeout(BinaryenExpressionRef expr, BinaryenExpressionRef timeoutExpr); -// Gets the expected type of an `atomic.wait` expression. +// Gets the expected type of an `memory.atomic.wait` expression. BINARYEN_API BinaryenType BinaryenAtomicWaitGetExpectedType(BinaryenExpressionRef expr); -// Sets the expected type of an `atomic.wait` expression. +// Sets the expected type of an `memory.atomic.wait` expression. BINARYEN_API void BinaryenAtomicWaitSetExpectedType(BinaryenExpressionRef expr, BinaryenType expectedType); // AtomicNotify -// Gets the pointer expression of an `atomic.notify` expression. +// Gets the pointer expression of an `memory.atomic.notify` expression. BINARYEN_API BinaryenExpressionRef BinaryenAtomicNotifyGetPtr(BinaryenExpressionRef expr); -// Sets the pointer expression of an `atomic.notify` expression. +// Sets the pointer expression of an `memory.atomic.notify` expression. BINARYEN_API void BinaryenAtomicNotifySetPtr(BinaryenExpressionRef expr, BinaryenExpressionRef ptrExpr); -// Gets the notify count expression of an `atomic.notify` expression. +// Gets the notify count expression of an `memory.atomic.notify` expression. BINARYEN_API BinaryenExpressionRef BinaryenAtomicNotifyGetNotifyCount(BinaryenExpressionRef expr); -// Sets the notify count expression of an `atomic.notify` expression. +// Sets the notify count expression of an `memory.atomic.notify` expression. BINARYEN_API void BinaryenAtomicNotifySetNotifyCount(BinaryenExpressionRef expr, BinaryenExpressionRef notifyCountExpr); diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc index 87a19fb82..a62d9fdc6 100644 --- a/src/gen-s-parser.inc +++ b/src/gen-s-parser.inc @@ -50,17 +50,9 @@ switch (op[0]) { default: goto parse_error; } } - case 't': { - switch (op[7]) { - case 'f': - if (strcmp(op, "atomic.fence") == 0) { return makeAtomicFence(s); } - goto parse_error; - case 'n': - if (strcmp(op, "atomic.notify") == 0) { return makeAtomicNotify(s); } - goto parse_error; - default: goto parse_error; - } - } + case 't': + if (strcmp(op, "atomic.fence") == 0) { return makeAtomicFence(s); } + goto parse_error; default: goto parse_error; } } @@ -1224,9 +1216,6 @@ switch (op[0]) { default: goto parse_error; } } - case 'w': - if (strcmp(op, "i32.atomic.wait") == 0) { return makeAtomicWait(s, Type::i32); } - goto parse_error; default: goto parse_error; } } @@ -1976,9 +1965,6 @@ switch (op[0]) { default: goto parse_error; } } - case 'w': - if (strcmp(op, "i64.atomic.wait") == 0) { return makeAtomicWait(s, Type::i64); } - goto parse_error; default: goto parse_error; } } @@ -2676,6 +2662,25 @@ switch (op[0]) { } case 'm': { switch (op[7]) { + case 'a': { + switch (op[14]) { + case 'n': + if (strcmp(op, "memory.atomic.notify") == 0) { return makeAtomicNotify(s); } + goto parse_error; + case 'w': { + switch (op[18]) { + case '3': + if (strcmp(op, "memory.atomic.wait32") == 0) { return makeAtomicWait(s, Type::i32); } + goto parse_error; + case '6': + if (strcmp(op, "memory.atomic.wait64") == 0) { return makeAtomicWait(s, Type::i64); } + goto parse_error; + default: goto parse_error; + } + } + default: goto parse_error; + } + } case 'c': if (strcmp(op, "memory.copy") == 0) { return makeMemoryCopy(s); } goto parse_error; diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index c35c6ed29..b78fdd996 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -629,6 +629,17 @@ function wrapModule(module, self = {}) { }, 'fill'(dest, value, size) { return Module['_BinaryenMemoryFill'](module, dest, value, size); + }, + 'atomic': { + 'notify'(ptr, notifyCount) { + return Module['_BinaryenAtomicNotify'](module, ptr, notifyCount); + }, + 'wait32'(ptr, expected, timeout) { + return Module['_BinaryenAtomicWait'](module, ptr, expected, timeout, Module['i32']); + }, + 'wait64'(ptr, expected, timeout) { + return Module['_BinaryenAtomicWait'](module, ptr, expected, timeout, Module['i64']); + } } } @@ -889,9 +900,6 @@ function wrapModule(module, self = {}) { return Module['_BinaryenAtomicCmpxchg'](module, 2, offset, ptr, expected, replacement, Module['i32']) }, }, - 'wait'(ptr, expected, timeout) { - return Module['_BinaryenAtomicWait'](module, ptr, expected, timeout, Module['i32']); - } }, 'pop'() { return Module['_BinaryenPop'](module, Module['i32']); @@ -1193,9 +1201,6 @@ function wrapModule(module, self = {}) { return Module['_BinaryenAtomicCmpxchg'](module, 4, offset, ptr, expected, replacement, Module['i64']) }, }, - 'wait'(ptr, expected, timeout) { - return Module['_BinaryenAtomicWait'](module, ptr, expected, timeout, Module['i64']); - } }, 'pop'() { return Module['_BinaryenPop'](module, Module['i64']); @@ -2132,9 +2137,6 @@ function wrapModule(module, self = {}) { }; self['atomic'] = { - 'notify'(ptr, notifyCount) { - return Module['_BinaryenAtomicNotify'](module, ptr, notifyCount); - }, 'fence'() { return Module['_BinaryenAtomicFence'](module); } diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index e653e85bd..e512d398f 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -317,13 +317,15 @@ struct PrintExpressionContents } void visitAtomicWait(AtomicWait* curr) { prepareColor(o); - o << forceConcrete(curr->expectedType) << ".atomic.wait"; + Type type = forceConcrete(curr->expectedType); + assert(type == Type::i32 || type == Type::i64); + o << "memory.atomic.wait" << (type == Type::i32 ? "32" : "64"); if (curr->offset) { o << " offset=" << curr->offset; } } void visitAtomicNotify(AtomicNotify* curr) { - printMedium(o, "atomic.notify"); + printMedium(o, "memory.atomic.notify"); if (curr->offset) { o << " offset=" << curr->offset; } diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 6c552781b..34e1eb8a6 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -1463,11 +1463,12 @@ Expression* SExpressionWasmBuilder::makeAtomicWait(Element& s, Type type) { } else if (type == Type::i64) { expectedAlign = 8; } else { - WASM_UNREACHABLE("Invalid prefix for atomic.wait"); + WASM_UNREACHABLE("Invalid prefix for memory.atomic.wait"); } size_t i = parseMemAttributes(s, ret->offset, align, expectedAlign); if (align != expectedAlign) { - throw ParseException("Align of atomic.wait must match size", s.line, s.col); + throw ParseException( + "Align of memory.atomic.wait must match size", s.line, s.col); } ret->ptr = parseExpression(s[i]); ret->expected = parseExpression(s[i + 1]); @@ -1482,7 +1483,8 @@ Expression* SExpressionWasmBuilder::makeAtomicNotify(Element& s) { Address align; size_t i = parseMemAttributes(s, ret->offset, align, 4); if (align != 4) { - throw ParseException("Align of atomic.notify must be 4", s.line, s.col); + throw ParseException( + "Align of memory.atomic.notify must be 4", s.line, s.col); } ret->ptr = parseExpression(s[i]); ret->notifyCount = parseExpression(s[i + 1]); |