summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/binaryen-c.h4
-rw-r--r--src/gen-s-parser.inc38
-rw-r--r--src/js/binaryen.js-post.js6
-rw-r--r--src/passes/Print.cpp2
-rw-r--r--src/passes/RemoveUnusedBrs.cpp2
-rw-r--r--src/tools/fuzzing/fuzzing.cpp2
-rw-r--r--src/wasm/wasm-validator.cpp4
7 files changed, 39 insertions, 19 deletions
diff --git a/src/binaryen-c.h b/src/binaryen-c.h
index 4321ec452..d16f46d9a 100644
--- a/src/binaryen-c.h
+++ b/src/binaryen-c.h
@@ -2308,10 +2308,10 @@ BINARYEN_API void BinaryenTupleExtractSetIndex(BinaryenExpressionRef expr,
// RefI31
-// Gets the value expression of an `i31.new` expression.
+// Gets the value expression of a `ref.i31` expression.
BINARYEN_API BinaryenExpressionRef
BinaryenRefI31GetValue(BinaryenExpressionRef expr);
-// Sets the value expression of an `i31.new` expression.
+// Sets the value expression of a `ref.i31` expression.
BINARYEN_API void BinaryenRefI31SetValue(BinaryenExpressionRef expr,
BinaryenExpressionRef valueExpr);
diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc
index 5b812c6d1..506ec62ad 100644
--- a/src/gen-s-parser.inc
+++ b/src/gen-s-parser.inc
@@ -2984,9 +2984,17 @@ switch (buf[0]) {
case 'f':
if (op == "ref.func"sv) { return makeRefFunc(s); }
goto parse_error;
- case 'i':
- if (op == "ref.is_null"sv) { return makeRefIsNull(s); }
- goto parse_error;
+ case 'i': {
+ switch (buf[5]) {
+ case '3':
+ if (op == "ref.i31"sv) { return makeRefI31(s); }
+ goto parse_error;
+ case 's':
+ if (op == "ref.is_null"sv) { return makeRefIsNull(s); }
+ goto parse_error;
+ default: goto parse_error;
+ }
+ }
case 'n':
if (op == "ref.null"sv) { return makeRefNull(s); }
goto parse_error;
@@ -8585,13 +8593,25 @@ switch (buf[0]) {
return *ret;
}
goto parse_error;
- case 'i':
- if (op == "ref.is_null"sv) {
- auto ret = makeRefIsNull(ctx, pos);
- CHECK_ERR(ret);
- return *ret;
+ case 'i': {
+ switch (buf[5]) {
+ case '3':
+ if (op == "ref.i31"sv) {
+ auto ret = makeRefI31(ctx, pos);
+ CHECK_ERR(ret);
+ return *ret;
+ }
+ goto parse_error;
+ case 's':
+ if (op == "ref.is_null"sv) {
+ auto ret = makeRefIsNull(ctx, pos);
+ CHECK_ERR(ret);
+ return *ret;
+ }
+ goto parse_error;
+ default: goto parse_error;
}
- goto parse_error;
+ }
case 'n':
if (op == "ref.null"sv) {
auto ret = makeRefNull(ctx, pos);
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index b6ea4d490..4ff719b30 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -2370,6 +2370,9 @@ function wrapModule(module, self = {}) {
'func'(func, type) {
return preserveStack(() => Module['_BinaryenRefFunc'](module, strToStack(func), type));
},
+ 'i31'(value) {
+ return Module['_BinaryenRefI31'](module, value);
+ },
'eq'(left, right) {
return Module['_BinaryenRefEq'](module, left, right);
}
@@ -2418,9 +2421,6 @@ function wrapModule(module, self = {}) {
};
self['i31'] = {
- 'new'(value) {
- return Module['_BinaryenRefI31'](module, value);
- },
'get_s'(i31) {
return Module['_BinaryenI31Get'](module, i31, 1);
},
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 203d922d0..c47f33944 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -1959,7 +1959,7 @@ struct PrintExpressionContents
printMedium(o, "tuple.extract ");
o << curr->index;
}
- void visitRefI31(RefI31* curr) { printMedium(o, "i31.new"); }
+ void visitRefI31(RefI31* curr) { printMedium(o, "ref.i31"); }
void visitI31Get(I31Get* curr) {
printMedium(o, curr->signed_ ? "i31.get_s" : "i31.get_u");
}
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp
index a5950f2fa..fca5b7db4 100644
--- a/src/passes/RemoveUnusedBrs.cpp
+++ b/src/passes/RemoveUnusedBrs.cpp
@@ -732,7 +732,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
//
// (br_on_cast $l anyref i31ref
// (block (result anyref)
- // (i31.new ...)))
+ // (ref.i31 ...)))
//
// We could just always do the cast and leave removing the casts to
// OptimizeInstructions, but it's simple enough to avoid unnecessary
diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp
index 1aa52e70d..f776c1c9d 100644
--- a/src/tools/fuzzing/fuzzing.cpp
+++ b/src/tools/fuzzing/fuzzing.cpp
@@ -2321,7 +2321,7 @@ Expression* TranslateToFuzzReader::makeBasicRef(Type type) {
return builder.makeRefNull(HeapType::none);
}
auto nullability = getSubType(type.getNullability());
- // i31.new is not allowed in initializer expressions.
+ // ref.i31 is not allowed in initializer expressions.
HeapType subtype;
switch (upTo(3)) {
case 0:
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 0d45a4773..c1836a7ff 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2504,11 +2504,11 @@ void FunctionValidator::visitCallRef(CallRef* curr) {
void FunctionValidator::visitRefI31(RefI31* curr) {
shouldBeTrue(
- getModule()->features.hasGC(), curr, "i31.new requires gc [--enable-gc]");
+ getModule()->features.hasGC(), curr, "ref.i31 requires gc [--enable-gc]");
shouldBeSubType(curr->value->type,
Type::i32,
curr->value,
- "i31.new's argument should be i32");
+ "ref.i31's argument should be i32");
}
void FunctionValidator::visitI31Get(I31Get* curr) {