summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 6cb837296..09d3287b0 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -19,6 +19,7 @@
#include "ir/module-utils.h"
#include "ir/table-utils.h"
+#include "ir/type-updating.h"
#include "support/bits.h"
#include "support/debug.h"
#include "wasm-binary.h"
@@ -1595,12 +1596,10 @@ bool WasmBinaryBuilder::getBasicType(int32_t code, Type& out) {
out = Type::eqref;
return true;
case BinaryConsts::EncodedType::i31ref:
- // FIXME: for now, force all inputs to be nullable
- out = Type(HeapType::i31, Nullable);
+ out = Type(HeapType::i31, NonNullable);
return true;
case BinaryConsts::EncodedType::dataref:
- // FIXME: for now, force all inputs to be nullable
- out = Type(HeapType::data, Nullable);
+ out = Type(HeapType::data, NonNullable);
return true;
default:
return false;
@@ -1647,9 +1646,9 @@ Type WasmBinaryBuilder::getType(int initial) {
case BinaryConsts::EncodedType::Empty:
return Type::none;
case BinaryConsts::EncodedType::nullable:
- case BinaryConsts::EncodedType::nonnullable:
- // FIXME: for now, force all inputs to be nullable
return Type(getHeapType(), Nullable);
+ case BinaryConsts::EncodedType::nonnullable:
+ return Type(getHeapType(), NonNullable);
case BinaryConsts::EncodedType::rtt_n: {
auto depth = getU32LEB();
auto heapType = getIndexedHeapType();
@@ -1790,16 +1789,18 @@ void WasmBinaryBuilder::readTypes() {
switch (typeCode) {
case BinaryConsts::EncodedType::nullable:
case BinaryConsts::EncodedType::nonnullable: {
- // FIXME: for now, force all inputs to be nullable
+ auto nullability = typeCode == BinaryConsts::EncodedType::nullable
+ ? Nullable
+ : NonNullable;
int64_t htCode = getS64LEB(); // TODO: Actually s33
HeapType ht;
if (getBasicHeapType(htCode, ht)) {
- return Type(ht, Nullable);
+ return Type(ht, nullability);
}
if (size_t(htCode) >= numTypes) {
throwError("invalid type index: " + std::to_string(htCode));
}
- return builder.getTempRefType(size_t(htCode), Nullable);
+ return builder.getTempRefType(size_t(htCode), nullability);
}
case BinaryConsts::EncodedType::rtt_n:
case BinaryConsts::EncodedType::rtt: {
@@ -2172,6 +2173,9 @@ void WasmBinaryBuilder::readFunctions() {
throwError("binary offset at function exit not at expected location");
}
}
+
+ TypeUpdating::handleNonNullableLocals(func, wasm);
+
std::swap(func->epilogLocation, debugLocation);
currFunction = nullptr;
debugLocation.clear();
@@ -6072,8 +6076,8 @@ void WasmBinaryBuilder::visitRefFunc(RefFunc* curr) {
functionRefs[index].push_back(curr); // we don't know function names yet
// To support typed function refs, we give the reference not just a general
// funcref, but a specific subtype with the actual signature.
- // FIXME: for now, emit a nullable type here
- curr->finalize(Type(HeapType(getSignatureByFunctionIndex(index)), Nullable));
+ curr->finalize(
+ Type(HeapType(getSignatureByFunctionIndex(index)), NonNullable));
}
void WasmBinaryBuilder::visitRefEq(RefEq* curr) {