diff options
Diffstat (limited to 'src/wasm')
-rw-r--r-- | src/wasm/literal.cpp | 3 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 18 | ||||
-rw-r--r-- | src/wasm/wasm-ir-builder.cpp | 4 | ||||
-rw-r--r-- | src/wasm/wasm-stack.cpp | 4 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 3 |
5 files changed, 21 insertions, 11 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index f13ea504f..20b6b7234 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -57,7 +57,8 @@ Literal::Literal(Type type) : type(type) { return; } - if (type.isRef() && type.getHeapType() == HeapType::i31) { + if (type.isRef() && type.getHeapType().isBasic() && + type.getHeapType().getBasic(Unshared) == HeapType::i31) { assert(type.isNonNullable()); i32 = 0; return; diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 78470324c..74d74f473 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -7244,13 +7244,19 @@ void WasmBinaryReader::visitCallRef(CallRef* curr) { } bool WasmBinaryReader::maybeVisitRefI31(Expression*& out, uint32_t code) { - if (code != BinaryConsts::RefI31) { - return false; + Shareability share; + switch (code) { + case BinaryConsts::RefI31: + share = Unshared; + break; + case BinaryConsts::RefI31Shared: + share = Shared; + break; + default: + return false; } - auto* curr = allocator.alloc<RefI31>(); - curr->value = popNonVoidExpression(); - curr->finalize(); - out = curr; + auto* value = popNonVoidExpression(); + out = Builder(wasm).makeRefI31(value, share); return true; } diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp index 63f5df4c0..3db6238c4 100644 --- a/src/wasm/wasm-ir-builder.cpp +++ b/src/wasm/wasm-ir-builder.cpp @@ -1605,10 +1605,10 @@ Result<> IRBuilder::makeTupleDrop(uint32_t arity) { return Ok{}; } -Result<> IRBuilder::makeRefI31() { +Result<> IRBuilder::makeRefI31(Shareability share) { RefI31 curr; CHECK_ERR(visitRefI31(&curr)); - push(builder.makeRefI31(curr.value)); + push(builder.makeRefI31(curr.value, share)); return Ok{}; } diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index 40a50706a..cd0a9928e 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -2114,7 +2114,9 @@ void BinaryInstWriter::visitTupleExtract(TupleExtract* curr) { } void BinaryInstWriter::visitRefI31(RefI31* curr) { - o << int8_t(BinaryConsts::GCPrefix) << U32LEB(BinaryConsts::RefI31); + o << int8_t(BinaryConsts::GCPrefix) + << U32LEB(curr->type.getHeapType().isShared() ? BinaryConsts::RefI31Shared + : BinaryConsts::RefI31); } void BinaryInstWriter::visitI31Get(I31Get* curr) { diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 8a2b4755c..c4f02128e 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -964,7 +964,8 @@ void RefI31::finalize() { if (value->type == Type::unreachable) { type = Type::unreachable; } else { - type = Type(HeapType::i31, NonNullable); + assert(type.isRef() && type.getHeapType().isBasic() && + type.getHeapType().getBasic(Unshared) == HeapType::i31); } } |