summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2019-11-25 15:46:56 -0800
committerGitHub <noreply@github.com>2019-11-25 15:46:56 -0800
commit8a70121a421204e05d020c67294e7e517c2d15d2 (patch)
treeda493f5ee5c8a3dfd18fba7518e05d25b1a71fba /src/wasm/wasm-validator.cpp
parentd90583cf509c3f21b3b5136d3872b097c5f2800c (diff)
downloadbinaryen-8a70121a421204e05d020c67294e7e517c2d15d2.tar.gz
binaryen-8a70121a421204e05d020c67294e7e517c2d15d2.tar.bz2
binaryen-8a70121a421204e05d020c67294e7e517c2d15d2.zip
Remove FunctionType from Event (#2466)
This is the start of a larger refactoring to remove FunctionType entirely and store types and signatures directly on the entities that use them. This PR updates BrOnExn and Events to remove their use of FunctionType and makes the BinaryWriter traverse the module and collect types rather than using the global FunctionType list. While we are collecting types, we also sort them by frequency as an optimization. Remaining uses of FunctionType in Function, CallIndirect, and parsing will be removed in a future PR.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 05cb45d25..d3f03b76c 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -1703,14 +1703,15 @@ void FunctionValidator::visitThrow(Throw* curr) {
if (!shouldBeTrue(!!event, curr, "throw's event must exist")) {
return;
}
- if (!shouldBeTrue(curr->operands.size() == event->params.size(),
+ if (!shouldBeTrue(curr->operands.size() == event->sig.params.size(),
curr,
"event's param numbers must match")) {
return;
}
+ const std::vector<Type>& paramTypes = event->sig.params.expand();
for (size_t i = 0; i < curr->operands.size(); i++) {
if (!shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type,
- event->params[i],
+ paramTypes[i],
curr->operands[i],
"event param types must match") &&
!info.quiet) {
@@ -1731,10 +1732,10 @@ void FunctionValidator::visitRethrow(Rethrow* curr) {
void FunctionValidator::visitBrOnExn(BrOnExn* curr) {
Event* event = getModule()->getEventOrNull(curr->event);
shouldBeTrue(event != nullptr, curr, "br_on_exn's event must exist");
- shouldBeTrue(event->params == curr->eventParams,
+ shouldBeTrue(event->sig.params == curr->sent,
curr,
"br_on_exn's event params and event's params are different");
- noteBreak(curr->name, curr->getSingleSentType(), curr);
+ noteBreak(curr->name, curr->sent, curr);
shouldBeTrue(curr->exnref->type == unreachable ||
curr->exnref->type == exnref,
curr,
@@ -2110,23 +2111,19 @@ static void validateEvents(Module& module, ValidationInfo& info) {
"Module has events (event-handling is disabled)");
}
for (auto& curr : module.events) {
- info.shouldBeTrue(
- curr->type.is(), curr->name, "Event should have a valid type");
- FunctionType* ft = module.getFunctionType(curr->type);
- info.shouldBeEqual(
- ft->result, none, curr->name, "Event type's result type should be none");
info.shouldBeEqual(curr->attribute,
(unsigned)0,
curr->attribute,
"Currently only attribute 0 is supported");
- for (auto type : curr->params) {
+ info.shouldBeEqual(curr->sig.results,
+ Type(Type::none),
+ curr->name,
+ "Event type's result type should be none");
+ for (auto type : curr->sig.params.expand()) {
info.shouldBeTrue(type.isInteger() || type.isFloat(),
curr->name,
"Values in an event should have integer or float type");
}
- info.shouldBeTrue(curr->params == ft->params,
- curr->name,
- "Event's function type and internal type should match");
}
}