diff options
author | Heejin Ahn <aheejin@gmail.com> | 2021-01-23 04:27:20 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-23 04:27:20 +0900 |
commit | 27a5a7101d20ce5fc51648e775587ab3d640114e (patch) | |
tree | bd8427f8b01a998d708847be0cfd08052b57a9ee | |
parent | 69952a98c7c86286518d559958e35cd3639bd3a0 (diff) | |
download | binaryen-27a5a7101d20ce5fc51648e775587ab3d640114e.tar.gz binaryen-27a5a7101d20ce5fc51648e775587ab3d640114e.tar.bz2 binaryen-27a5a7101d20ce5fc51648e775587ab3d640114e.zip |
Reorder i31ref and dataref (#3509)
The binary spec
(https://docs.google.com/document/d/1yAWU3dbs8kUa_wcnnirDxUu9nEBsNfq0Xo90OWx6yuo/edit#)
lists `dataref` after `i31ref`, and `dataref` also comes after `i31ref`
in its binary code in the value-increasing order. This reorders these
two in wasm-type.h and other places, although in most of those places
the order is irrelevant.
This also adds C and JS API for `dataref`.
-rw-r--r-- | src/binaryen-c.cpp | 1 | ||||
-rw-r--r-- | src/binaryen-c.h | 1 | ||||
-rw-r--r-- | src/ir/abstract.h | 4 | ||||
-rw-r--r-- | src/js/binaryen.js-post.js | 7 | ||||
-rw-r--r-- | src/literal.h | 2 | ||||
-rw-r--r-- | src/passes/FuncCastEmulation.cpp | 8 | ||||
-rw-r--r-- | src/passes/InstrumentLocals.cpp | 28 | ||||
-rw-r--r-- | src/wasm-builder.h | 4 | ||||
-rw-r--r-- | src/wasm-interpreter.h | 4 | ||||
-rw-r--r-- | src/wasm-type.h | 8 | ||||
-rw-r--r-- | src/wasm/literal.cpp | 26 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 6 | ||||
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 26 | ||||
-rw-r--r-- | src/wasm/wasm-type.cpp | 18 | ||||
-rw-r--r-- | src/wasm/wasm-validator.cpp | 4 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js | 4 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 10 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 6 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.txt | 3 | ||||
-rw-r--r-- | test/gc.wast | 6 | ||||
-rw-r--r-- | test/gc.wast.from-wast | 6 | ||||
-rw-r--r-- | test/gc.wast.fromBinary | 6 | ||||
-rw-r--r-- | test/gc.wast.fromBinary.noDebugInfo | 34 | ||||
-rw-r--r-- | test/passes/instrument-locals_all-features_disable-typed-function-references.txt | 6 |
24 files changed, 128 insertions, 100 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 93c8693c6..1845d39f3 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -144,6 +144,7 @@ BinaryenType BinaryenTypeExternref(void) { return Type::externref; } BinaryenType BinaryenTypeAnyref(void) { return Type::anyref; } BinaryenType BinaryenTypeEqref(void) { return Type::eqref; } BinaryenType BinaryenTypeI31ref(void) { return Type::i31ref; } +BinaryenType BinaryenTypeDataref(void) { return Type::dataref; } BinaryenType BinaryenTypeUnreachable(void) { return Type::unreachable; } BinaryenType BinaryenTypeAuto(void) { return uintptr_t(-1); } diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 6337fadd8..f2d433fc4 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -103,6 +103,7 @@ BINARYEN_API BinaryenType BinaryenTypeExternref(void); BINARYEN_API BinaryenType BinaryenTypeAnyref(void); BINARYEN_API BinaryenType BinaryenTypeEqref(void); BINARYEN_API BinaryenType BinaryenTypeI31ref(void); +BINARYEN_API BinaryenType BinaryenTypeDataref(void); BINARYEN_API BinaryenType BinaryenTypeUnreachable(void); // Not a real type. Used as the last parameter to BinaryenBlock to let // the API figure out the type instead of providing one. diff --git a/src/ir/abstract.h b/src/ir/abstract.h index 4c8d556cb..e5dfd57e0 100644 --- a/src/ir/abstract.h +++ b/src/ir/abstract.h @@ -117,8 +117,8 @@ inline UnaryOp getUnary(Type type, Op op) { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: { return InvalidUnary; @@ -290,8 +290,8 @@ inline BinaryOp getBinary(Type type, Op op) { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: { return InvalidBinary; diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 1ae7b11b2..8c6730e9e 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -38,6 +38,7 @@ function initializeConstants() { ['anyref', 'Anyref'], ['eqref', 'Eqref'], ['i31ref', 'I31ref'], + ['dataref', 'Dataref'], ['unreachable', 'Unreachable'], ['auto', 'Auto'] ].forEach(entry => { @@ -2090,6 +2091,12 @@ function wrapModule(module, self = {}) { } }; + self['dataref'] = { + 'pop'() { + return Module['_BinaryenPop'](module, Module['dataref']); + } + }; + self['ref'] = { 'null'(type) { return Module['_BinaryenRefNull'](module, type); diff --git a/src/literal.h b/src/literal.h index c85701a48..e49946814 100644 --- a/src/literal.h +++ b/src/literal.h @@ -781,8 +781,8 @@ template<> struct less<wasm::Literal> { case wasm::Type::externref: case wasm::Type::anyref: case wasm::Type::eqref: - case wasm::Type::dataref: case wasm::Type::i31ref: + case wasm::Type::dataref: case wasm::Type::none: case wasm::Type::unreachable: return false; diff --git a/src/passes/FuncCastEmulation.cpp b/src/passes/FuncCastEmulation.cpp index 7f7721706..a9302fb65 100644 --- a/src/passes/FuncCastEmulation.cpp +++ b/src/passes/FuncCastEmulation.cpp @@ -65,8 +65,8 @@ static Expression* toABI(Expression* value, Module* module) { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: - case Type::i31ref: { + case Type::i31ref: + case Type::dataref: { WASM_UNREACHABLE("reference types cannot be converted to i64"); } case Type::none: { @@ -111,8 +111,8 @@ static Expression* fromABI(Expression* value, Type type, Module* module) { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: - case Type::i31ref: { + case Type::i31ref: + case Type::dataref: { WASM_UNREACHABLE("reference types cannot be converted from i64"); } case Type::none: { diff --git a/src/passes/InstrumentLocals.cpp b/src/passes/InstrumentLocals.cpp index cc1234fc5..85da3bd9b 100644 --- a/src/passes/InstrumentLocals.cpp +++ b/src/passes/InstrumentLocals.cpp @@ -55,25 +55,25 @@ Name get_i32("get_i32"); Name get_i64("get_i64"); Name get_f32("get_f32"); Name get_f64("get_f64"); +Name get_v128("get_v128"); Name get_funcref("get_funcref"); Name get_externref("get_externref"); Name get_anyref("get_anyref"); Name get_eqref("get_eqref"); -Name get_dataref("get_dataref"); Name get_i31ref("get_i31ref"); -Name get_v128("get_v128"); +Name get_dataref("get_dataref"); Name set_i32("set_i32"); Name set_i64("set_i64"); Name set_f32("set_f32"); Name set_f64("set_f64"); +Name set_v128("set_v128"); Name set_funcref("set_funcref"); Name set_externref("set_externref"); Name set_anyref("set_anyref"); Name set_eqref("set_eqref"); -Name set_dataref("set_dataref"); Name set_i31ref("set_i31ref"); -Name set_v128("set_v128"); +Name set_dataref("set_dataref"); struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { void visitLocalGet(LocalGet* curr) { @@ -107,12 +107,12 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { case Type::eqref: import = get_eqref; break; - case Type::dataref: - import = get_dataref; - break; case Type::i31ref: import = get_i31ref; break; + case Type::dataref: + import = get_dataref; + break; case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -167,12 +167,12 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { case Type::eqref: import = set_eqref; break; - case Type::dataref: - import = set_dataref; - break; case Type::i31ref: import = set_i31ref; break; + case Type::dataref: + import = set_dataref; + break; case Type::unreachable: return; // nothing to do here default: @@ -221,6 +221,10 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { curr, get_eqref, {Type::i32, Type::i32, Type::eqref}, Type::eqref); addImport( curr, set_eqref, {Type::i32, Type::i32, Type::eqref}, Type::eqref); + addImport( + curr, get_i31ref, {Type::i32, Type::i32, Type::i31ref}, Type::i31ref); + addImport( + curr, set_i31ref, {Type::i32, Type::i32, Type::i31ref}, Type::i31ref); addImport(curr, get_dataref, {Type::i32, Type::i32, Type::dataref}, @@ -229,10 +233,6 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { set_dataref, {Type::i32, Type::i32, Type::dataref}, Type::dataref); - addImport( - curr, get_i31ref, {Type::i32, Type::i32, Type::i31ref}, Type::i31ref); - addImport( - curr, set_i31ref, {Type::i32, Type::i32, Type::i31ref}, Type::i31ref); } } if (curr->features.hasSIMD()) { diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 0bfa317d3..da74f47ef 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -1028,10 +1028,10 @@ public: case Type::anyref: case Type::eqref: return ExpressionManipulator::refNull(curr, curr->type); - case Type::dataref: - WASM_UNREACHABLE("TODO: dataref"); case Type::i31ref: return makeI31New(makeConst(0)); + case Type::dataref: + WASM_UNREACHABLE("TODO: dataref"); case Type::none: return ExpressionManipulator::nop(curr); case Type::unreachable: diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 1336a8d10..44173d395 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -2016,8 +2016,8 @@ public: case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -2075,8 +2075,8 @@ public: case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); diff --git a/src/wasm-type.h b/src/wasm-type.h index 6b3fdb08f..bf3dd69de 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -74,10 +74,10 @@ public: externref, anyref, eqref, - dataref, i31ref, + dataref, }; - static constexpr BasicType _last_basic_type = i31ref; + static constexpr BasicType _last_basic_type = dataref; Type() : id(none) {} @@ -295,10 +295,10 @@ public: ext, any, eq, - data, i31, + data, }; - static constexpr BasicHeapType _last_basic_type = i31; + static constexpr BasicHeapType _last_basic_type = data; // BasicHeapType can be implicitly upgraded to HeapType constexpr HeapType(BasicHeapType id) : id(id) {} diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 6d870ec55..dc6d90ef9 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -114,8 +114,8 @@ Literal::Literal(const Literal& other) : type(other.type) { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: WASM_UNREACHABLE("invalid type"); } } @@ -331,8 +331,8 @@ void Literal::getBits(uint8_t (&buf)[16]) const { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: WASM_UNREACHABLE("invalid type"); } } @@ -370,8 +370,8 @@ bool Literal::operator==(const Literal& other) const { case Type::funcref: case Type::externref: case Type::anyref: - case Type::dataref: case Type::eqref: + case Type::dataref: return compareRef(); case Type::unreachable: break; @@ -510,8 +510,8 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { case HeapType::i31: o << "i31ref(" << literal.geti31() << ")"; break; - case HeapType::data: case HeapType::func: + case HeapType::data: WASM_UNREACHABLE("type should have been handled above"); } } @@ -547,8 +547,8 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } @@ -771,8 +771,8 @@ Literal Literal::eqz() const { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -795,8 +795,8 @@ Literal Literal::neg() const { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -819,8 +819,8 @@ Literal Literal::abs() const { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -960,8 +960,8 @@ Literal Literal::add(const Literal& other) const { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -984,8 +984,8 @@ Literal Literal::sub(const Literal& other) const { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -1079,8 +1079,8 @@ Literal Literal::mul(const Literal& other) const { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -1315,8 +1315,8 @@ Literal Literal::eq(const Literal& other) const { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -1339,8 +1339,8 @@ Literal Literal::ne(const Literal& other) const { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 5a78bfc42..cc289e7ec 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1413,12 +1413,12 @@ Type WasmBinaryBuilder::getType(int initial) { case BinaryConsts::EncodedType::nonnullable: // FIXME: for now, force all inputs to be nullable return Type(getHeapType(), Nullable); - case BinaryConsts::EncodedType::dataref: - // FIXME: for now, force all inputs to be nullable - return Type(HeapType::BasicHeapType::data, Nullable); case BinaryConsts::EncodedType::i31ref: // FIXME: for now, force all inputs to be nullable return Type(HeapType::BasicHeapType::i31, Nullable); + case BinaryConsts::EncodedType::dataref: + // FIXME: for now, force all inputs to be nullable + return Type(HeapType::BasicHeapType::data, Nullable); case BinaryConsts::EncodedType::rtt_n: { auto depth = getU32LEB(); auto heapType = getHeapType(); diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index d34698131..857c0143b 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -864,14 +864,14 @@ Type SExpressionWasmBuilder::stringToType(const char* str, if (strncmp(str, "eqref", 5) == 0 && (prefix || str[5] == 0)) { return Type::eqref; } - if (strncmp(str, "dataref", 7) == 0 && (prefix || str[7] == 0)) { - // FIXME: for now, force all inputs to be nullable - return Type(HeapType::BasicHeapType::data, Nullable); - } if (strncmp(str, "i31ref", 6) == 0 && (prefix || str[6] == 0)) { // FIXME: for now, force all inputs to be nullable return Type(HeapType::BasicHeapType::i31, Nullable); } + if (strncmp(str, "dataref", 7) == 0 && (prefix || str[7] == 0)) { + // FIXME: for now, force all inputs to be nullable + return Type(HeapType::BasicHeapType::data, Nullable); + } if (allowError) { return Type::none; } @@ -880,9 +880,10 @@ Type SExpressionWasmBuilder::stringToType(const char* str, HeapType SExpressionWasmBuilder::stringToHeapType(const char* str, bool prefix) { - if (str[0] == 'a') { - if (str[1] == 'n' && str[2] == 'y' && (prefix || str[3] == 0)) { - return HeapType::any; + if (str[0] == 'f') { + if (str[1] == 'u' && str[2] == 'n' && str[3] == 'c' && + (prefix || str[4] == 0)) { + return HeapType::func; } } if (str[0] == 'e') { @@ -894,17 +895,16 @@ HeapType SExpressionWasmBuilder::stringToHeapType(const char* str, return HeapType::ext; } } + if (str[0] == 'a') { + if (str[1] == 'n' && str[2] == 'y' && (prefix || str[3] == 0)) { + return HeapType::any; + } + } if (str[0] == 'i') { if (str[1] == '3' && str[2] == '1' && (prefix || str[3] == 0)) { return HeapType::i31; } } - if (str[0] == 'f') { - if (str[1] == 'u' && str[2] == 'n' && str[3] == 'c' && - (prefix || str[4] == 0)) { - return HeapType::func; - } - } if (str[0] == 'd') { if (str[1] == 'a' && str[2] == 't' && str[3] == 'a' && (prefix || str[4] == 0)) { diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index fc8f84f6f..b433c050c 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -306,8 +306,8 @@ struct TypeStore : Store<TypeInfo> { return Type::anyref; case HeapType::eq: return Type::eqref; - case HeapType::data: case HeapType::i31: + case HeapType::data: break; } } else { @@ -443,8 +443,8 @@ unsigned Type::getByteSize() const { case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: case Type::unreachable: break; @@ -491,8 +491,8 @@ FeatureSet Type::getFeatures() const { switch (heapType.getBasic()) { case HeapType::BasicHeapType::any: case HeapType::BasicHeapType::eq: - case HeapType::BasicHeapType::data: case HeapType::BasicHeapType::i31: + case HeapType::BasicHeapType::data: return FeatureSet::ReferenceTypes | FeatureSet::GC; default: {} } @@ -544,10 +544,10 @@ HeapType Type::getHeapType() const { return HeapType::any; case Type::eqref: return HeapType::eq; - case Type::dataref: - return HeapType::data; case Type::i31ref: return HeapType::i31; + case Type::dataref: + return HeapType::data; } WASM_UNREACHABLE("Unexpected type"); } else { @@ -882,10 +882,10 @@ std::ostream& operator<<(std::ostream& os, Type type) { return os << "anyref"; case Type::eqref: return os << "eqref"; - case Type::dataref: - return os << "dataref"; case Type::i31ref: return os << "i31ref"; + case Type::dataref: + return os << "dataref"; } } return os << *getTypeInfo(type); @@ -974,10 +974,10 @@ std::ostream& operator<<(std::ostream& os, HeapType heapType) { return os << "any"; case HeapType::eq: return os << "eq"; - case HeapType::data: - return os << "data"; case HeapType::i31: return os << "i31"; + case HeapType::data: + return os << "data"; } } return os << *getHeapTypeInfo(heapType); diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index e4a70a347..7cddf5a86 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -1396,8 +1396,8 @@ void FunctionValidator::validateMemBytes(uint8_t bytes, case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: WASM_UNREACHABLE("unexpected type"); } @@ -2514,8 +2514,8 @@ void FunctionValidator::validateAlignment( case Type::externref: case Type::anyref: case Type::eqref: - case Type::dataref: case Type::i31ref: + case Type::dataref: case Type::none: WASM_UNREACHABLE("invalid type"); } diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 160054fde..9655d5607 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -83,6 +83,9 @@ function test_types() { console.log(" // BinaryenTypeI31ref: " + binaryen.i31ref); console.log(" //", binaryen.expandType(binaryen.i31ref).join(",")); + console.log(" // BinaryenTypeDataref: " + binaryen.dataref); + console.log(" //", binaryen.expandType(binaryen.dataref).join(",")); + console.log(" // BinaryenTypeAuto: " + binaryen.auto); var i32_pair = binaryen.createType([binaryen.i32, binaryen.i32]); @@ -590,6 +593,7 @@ function test_core() { module.anyref.pop(), module.eqref.pop(), module.i31ref.pop(), + module.dataref.pop(), // Memory module.memory.size(), diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index f73990493..1b1a29de6 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -20,7 +20,9 @@ // 9 // BinaryenTypeEqref: 10 // 10 - // BinaryenTypeI31ref: 12 + // BinaryenTypeI31ref: 11 + // 11 + // BinaryenTypeDataref: 12 // 12 // BinaryenTypeAuto: -1 // 2,2 @@ -1936,6 +1938,9 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (pop i31ref) ) (drop + (pop dataref) + ) + (drop (memory.size) ) (drop @@ -3795,6 +3800,9 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (pop i31ref) ) (drop + (pop dataref) + ) + (drop (memory.size) ) (drop diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index d70ad11eb..c4973d317 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -223,6 +223,12 @@ void test_types() { BinaryenTypeExpand(i31ref, &valueType); assert(valueType == i31ref); + BinaryenType dataref = BinaryenTypeDataref(); + printf(" // BinaryenTypeDataref: %d\n", dataref); + assert(BinaryenTypeArity(dataref) == 1); + BinaryenTypeExpand(dataref, &valueType); + assert(valueType == dataref); + printf(" // BinaryenTypeAuto: %d\n", BinaryenTypeAuto()); BinaryenType pair[] = {i32, i32}; diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index 350c5555f..8b06c1109 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -9,7 +9,8 @@ // BinaryenTypeExternref: 8 // BinaryenTypeAnyref: 9 // BinaryenTypeEqref: 10 - // BinaryenTypeI31ref: 12 + // BinaryenTypeI31ref: 11 + // BinaryenTypeDataref: 12 // BinaryenTypeAuto: -1 BinaryenFeatureMVP: 0 BinaryenFeatureAtomics: 1 diff --git a/test/gc.wast b/test/gc.wast index b4a45421a..c3a814c38 100644 --- a/test/gc.wast +++ b/test/gc.wast @@ -18,8 +18,8 @@ (local $local_i32 i32) (local $local_anyref anyref) (local $local_eqref eqref) - (local $local_dataref dataref) (local $local_i31ref i31ref) + (local $local_dataref dataref) ;; Test types for local.get/set (local.set $local_anyref (local.get $local_anyref)) @@ -71,9 +71,9 @@ ) (func $test-variants - (local $local_datarefnull (ref null data)) - (local $local_datarefnonnull (ref data)) (local $local_i31refnull (ref null i31)) (local $local_i31refnonnull (ref i31)) + (local $local_datarefnull (ref null data)) + (local $local_datarefnonnull (ref data)) ) ) diff --git a/test/gc.wast.from-wast b/test/gc.wast.from-wast index f9892b417..f38c7416d 100644 --- a/test/gc.wast.from-wast +++ b/test/gc.wast.from-wast @@ -16,8 +16,8 @@ (local $local_i32 i32) (local $local_anyref anyref) (local $local_eqref eqref) - (local $local_dataref (ref null data)) (local $local_i31ref (ref null i31)) + (local $local_dataref (ref null data)) (local.set $local_anyref (local.get $local_anyref) ) @@ -150,10 +150,10 @@ ) ) (func $test-variants - (local $local_datarefnull (ref null data)) - (local $local_datarefnonnull (ref null data)) (local $local_i31refnull (ref null i31)) (local $local_i31refnonnull (ref null i31)) + (local $local_datarefnull (ref null data)) + (local $local_datarefnonnull (ref null data)) (nop) ) ) diff --git a/test/gc.wast.fromBinary b/test/gc.wast.fromBinary index c68900c38..066928de4 100644 --- a/test/gc.wast.fromBinary +++ b/test/gc.wast.fromBinary @@ -16,8 +16,8 @@ (local $local_i32 i32) (local $local_anyref anyref) (local $local_eqref eqref) - (local $local_dataref (ref null data)) (local $local_i31ref (ref null i31)) + (local $local_dataref (ref null data)) (local.set $local_anyref (local.get $local_anyref) ) @@ -150,10 +150,10 @@ ) ) (func $test-variants - (local $local_datarefnull (ref null data)) - (local $local_datarefnonnull (ref null data)) (local $local_i31refnull (ref null i31)) (local $local_i31refnonnull (ref null i31)) + (local $local_datarefnull (ref null data)) + (local $local_datarefnonnull (ref null data)) (nop) ) ) diff --git a/test/gc.wast.fromBinary.noDebugInfo b/test/gc.wast.fromBinary.noDebugInfo index aff17028b..77f520257 100644 --- a/test/gc.wast.fromBinary.noDebugInfo +++ b/test/gc.wast.fromBinary.noDebugInfo @@ -16,8 +16,8 @@ (local $0 i32) (local $1 anyref) (local $2 eqref) - (local $3 (ref null data)) - (local $4 (ref null i31)) + (local $3 (ref null i31)) + (local $4 (ref null data)) (local.set $1 (local.get $1) ) @@ -36,13 +36,13 @@ (local.set $2 (ref.null eq) ) - (local.set $4 - (local.get $4) + (local.set $3 + (local.get $3) ) - (local.set $4 + (local.set $3 (global.get $global$2) ) - (local.set $4 + (local.set $3 (i31.new (i32.const 0) ) @@ -57,7 +57,7 @@ (ref.null eq) ) (local.set $1 - (local.get $4) + (local.get $3) ) (local.set $1 (global.get $global$2) @@ -68,7 +68,7 @@ ) ) (local.set $2 - (local.get $4) + (local.get $3) ) (local.set $2 (global.get $global$2) @@ -97,7 +97,7 @@ (ref.null eq) ) (global.set $global$2 - (local.get $4) + (local.get $3) ) (global.set $global$2 (global.get $global$2) @@ -117,7 +117,7 @@ (ref.null eq) ) (global.set $global$0 - (local.get $4) + (local.get $3) ) (global.set $global$0 (global.get $global$2) @@ -128,7 +128,7 @@ ) ) (global.set $global$1 - (local.get $4) + (local.get $3) ) (global.set $global$1 (global.get $global$2) @@ -140,20 +140,20 @@ ) (local.set $0 (i31.get_s - (local.get $4) + (local.get $3) ) ) (local.set $0 (i31.get_u - (local.get $4) + (local.get $3) ) ) ) (func $1 - (local $0 (ref null data)) - (local $1 (ref null data)) - (local $2 (ref null i31)) - (local $3 (ref null i31)) + (local $0 (ref null i31)) + (local $1 (ref null i31)) + (local $2 (ref null data)) + (local $3 (ref null data)) (nop) ) ) diff --git a/test/passes/instrument-locals_all-features_disable-typed-function-references.txt b/test/passes/instrument-locals_all-features_disable-typed-function-references.txt index 18bd1a10d..edd927851 100644 --- a/test/passes/instrument-locals_all-features_disable-typed-function-references.txt +++ b/test/passes/instrument-locals_all-features_disable-typed-function-references.txt @@ -8,8 +8,8 @@ (type $i32_i32_externref_=>_externref (func (param i32 i32 externref) (result externref))) (type $i32_i32_anyref_=>_anyref (func (param i32 i32 anyref) (result anyref))) (type $i32_i32_eqref_=>_eqref (func (param i32 i32 eqref) (result eqref))) - (type $i32_i32_dataref_=>_dataref (func (param i32 i32 dataref) (result dataref))) (type $i32_i32_i31ref_=>_i31ref (func (param i32 i32 i31ref) (result i31ref))) + (type $i32_i32_dataref_=>_dataref (func (param i32 i32 dataref) (result dataref))) (type $none_=>_none (func)) (type $i32_=>_none (func (param i32))) (import "env" "get_i32" (func $get_i32 (param i32 i32 i32) (result i32))) @@ -28,10 +28,10 @@ (import "env" "set_anyref" (func $set_anyref (param i32 i32 anyref) (result anyref))) (import "env" "get_eqref" (func $get_eqref (param i32 i32 eqref) (result eqref))) (import "env" "set_eqref" (func $set_eqref (param i32 i32 eqref) (result eqref))) - (import "env" "get_dataref" (func $get_dataref (param i32 i32 dataref) (result dataref))) - (import "env" "set_dataref" (func $set_dataref (param i32 i32 dataref) (result dataref))) (import "env" "get_i31ref" (func $get_i31ref (param i32 i32 i31ref) (result i31ref))) (import "env" "set_i31ref" (func $set_i31ref (param i32 i32 i31ref) (result i31ref))) + (import "env" "get_dataref" (func $get_dataref (param i32 i32 dataref) (result dataref))) + (import "env" "set_dataref" (func $set_dataref (param i32 i32 dataref) (result dataref))) (import "env" "get_v128" (func $get_v128 (param i32 i32 v128) (result v128))) (import "env" "set_v128" (func $set_v128 (param i32 i32 v128) (result v128))) (event $e (attr 0) (param i32)) |