Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/binary-reader-ir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,13 @@ Result BinaryReaderIR::OnFuncType(Index index,
std::any_of(func_type->sig.result_types.begin(),
func_type->sig.result_types.end(),
[](auto x) { return x == Type::V128; });
module_->features_used.exceptions |=
std::any_of(func_type->sig.param_types.begin(),
func_type->sig.param_types.end(),
[](auto x) { return x == Type::ExnRef; }) ||
std::any_of(func_type->sig.result_types.begin(),
func_type->sig.result_types.end(),
[](auto x) { return x == Type::ExnRef; });

field->type = std::move(func_type);
module_->AppendField(std::move(field));
Expand All @@ -553,6 +560,7 @@ Result BinaryReaderIR::OnStructType(Index index,
struct_type->fields[i].type = fields[i].type;
struct_type->fields[i].mutable_ = fields[i].mutable_;
module_->features_used.simd |= (fields[i].type == Type::V128);
module_->features_used.exceptions |= (fields[i].type == Type::ExnRef);
}
field->type = std::move(struct_type);
module_->AppendField(std::move(field));
Expand All @@ -565,6 +573,7 @@ Result BinaryReaderIR::OnArrayType(Index index, TypeMut type_mut) {
array_type->field.type = type_mut.type;
array_type->field.mutable_ = type_mut.mutable_;
module_->features_used.simd |= (type_mut.type == Type::V128);
module_->features_used.exceptions |= (type_mut.type == Type::ExnRef);
field->type = std::move(array_type);
module_->AppendField(std::move(field));
return Result::Ok;
Expand Down Expand Up @@ -638,6 +647,7 @@ Result BinaryReaderIR::OnImportGlobal(Index import_index,
module_->AppendField(
std::make_unique<ImportModuleField>(std::move(import), GetLocation()));
module_->features_used.simd |= (type == Type::V128);
module_->features_used.exceptions |= (type == Type::ExnRef);
return Result::Ok;
}

Expand Down Expand Up @@ -685,6 +695,7 @@ Result BinaryReaderIR::OnTable(Index index,
Table& table = field->table;
table.elem_limits = *elem_limits;
table.elem_type = elem_type;
module_->features_used.exceptions |= (elem_type == Type::ExnRef);
module_->AppendField(std::move(field));
return Result::Ok;
}
Expand Down Expand Up @@ -721,6 +732,7 @@ Result BinaryReaderIR::BeginGlobal(Index index, Type type, bool mutable_) {
global.mutable_ = mutable_;
module_->AppendField(std::move(field));
module_->features_used.simd |= (type == Type::V128);
module_->features_used.exceptions |= (type == Type::ExnRef);
return Result::Ok;
}

Expand Down Expand Up @@ -787,6 +799,7 @@ Result BinaryReaderIR::OnLocalDecl(Index decl_index, Index count, Type type) {
}

module_->features_used.simd |= (type == Type::V128);
module_->features_used.exceptions |= (type == Type::ExnRef);
return Result::Ok;
}

Expand Down Expand Up @@ -1125,6 +1138,7 @@ Result BinaryReaderIR::OnRefFuncExpr(Index func_index) {
}

Result BinaryReaderIR::OnRefNullExpr(Type type) {
module_->features_used.exceptions |= (type == Type::ExnRef);
return AppendExpr(std::make_unique<RefNullExpr>(type));
}

Expand Down Expand Up @@ -1169,6 +1183,7 @@ Result BinaryReaderIR::OnStoreExpr(Opcode opcode,
}

Result BinaryReaderIR::OnThrowExpr(Index tag_index) {
module_->features_used.exceptions = true;
return AppendExpr(std::make_unique<ThrowExpr>(Var(tag_index, GetLocation())));
}

Expand Down
Loading