diff options
author | Heejin Ahn <aheejin@gmail.com> | 2019-05-31 20:02:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-31 20:02:37 -0700 |
commit | fe99e3458f11d1a01fa3ad5b68883dbcba3903af (patch) | |
tree | 6f5eda61c7c7cba9c3b16be5e361cdc148d8b315 /src/tools/fuzzing.h | |
parent | 7306f60a4474ca1fa948bddee5c068e7c2f635f6 (diff) | |
download | binaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.tar.gz binaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.tar.bz2 binaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.zip |
Add event section (#2151)
This adds support for the event and the event section, as specified in
https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model.
Wasm events are features that suspend the current execution and transfer
the control flow to a corresponding handler. Currently the only
supported event kind is exceptions.
For events, this includes support for
- Binary file reading/writing
- Wast file reading/writing
- Binaryen.js API
- Fuzzer
- Validation
- Metadce
- Passes: metrics, minify-imports-and-exports,
remove-unused-module-elements
Diffstat (limited to 'src/tools/fuzzing.h')
-rw-r--r-- | src/tools/fuzzing.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index f7dd20e76..0a7128e3e 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -197,6 +197,9 @@ public: } setupTable(); setupGlobals(); + if (wasm.features.hasExceptionHandling()) { + setupEvents(); + } addImportLoggingSupport(); // keep adding functions until we run out of input while (!finishedInput) { @@ -397,6 +400,28 @@ private: } } + void setupEvents() { + Index num = upTo(3); + for (size_t i = 0; i < num; i++) { + // Events should have void return type and at least one param type + Type type = pick(i32, i64, f32, f64); + std::string sig = std::string("v") + getSig(type); + std::vector<Type> params; + params.push_back(type); + Index numValues = upToSquared(MAX_PARAMS - 1); + for (Index i = 0; i < numValues; i++) { + type = pick(i32, i64, f32, f64); + sig += getSig(type); + params.push_back(type); + } + auto* event = builder.makeEvent(std::string("event$") + std::to_string(i), + WASM_EVENT_ATTRIBUTE_EXCEPTION, + ensureFunctionType(sig, &wasm)->name, + std::move(params)); + wasm.addEvent(event); + } + } + void finalizeTable() { wasm.table.initial = wasm.table.segments[0].data.size(); wasm.table.max = |