summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2020-11-13 15:54:08 -0800
committerGitHub <noreply@github.com>2020-11-13 15:54:08 -0800
commit75e61204b67e921464af14fd13ff768d88755e8c (patch)
tree969ddb2e4e2870fef662375914f16fc50713cd4c /src
parentcc2b3e4175a6edc53487eec06da13b39eb66716b (diff)
downloadbinaryen-75e61204b67e921464af14fd13ff768d88755e8c.tar.gz
binaryen-75e61204b67e921464af14fd13ff768d88755e8c.tar.bz2
binaryen-75e61204b67e921464af14fd13ff768d88755e8c.zip
Rename atomic.notify and *.atomic.wait (#3353)
- atomic.notify -> memory.atomic.notify - i32.atomic.wait -> memory.atomic.wait32 - i64.atomic.wait -> memory.atomic.wait64 See WebAssembly/threads#149. This renames instruction name printing but not the internal data structure names, such as `AtomicNotify`, which are not always the same as printed instruction names anyway. This also does not modify C API. But this fixes interface functions in binaryen.js because it seems binaryen.js's interface functions all follow the corresponding instruction names.
Diffstat (limited to 'src')
-rw-r--r--src/binaryen-c.h28
-rw-r--r--src/gen-s-parser.inc39
-rw-r--r--src/js/binaryen.js-post.js20
-rw-r--r--src/passes/Print.cpp6
-rw-r--r--src/wasm/wasm-s-parser.cpp8
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]);