| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
This pull request implements EHv4. Binary is mostly untested until
interp is working.
|
|
|
| |
This makes things easier for users and packagers of libwabt.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
See https://github.com/WebAssembly/tool-conventions/blob/main/CodeMetadata.md for the specification.
In particular this pr implements the following:
- Parsing code metadata sections in BinaryReader, providing appropriate callbacks that a BinaryReaderDelegate can implement:
- BinaryReaderObjdump: show the sections in a human-readable form
- BinaryReaderIr: add code metadata in the IR as expressions
- Parsing code metadata annotations in text format, adding them in the IR like the BinaryReaderIR does
- Writing the code metadata present in the IR in the proper sections when converting IR to binary
- Support in wasm-decompiler for showing code metadata as comments in the pseudo-code
All the features have corresponding tests.
Support for code metadata is gated through the --enable-code-metadata feature. For reading/writing in the text format, --enable-annotations is also required.
Missing features:
Support for function-level code metadata (offset 0)
Extensive validation in validator.cc (like making sure that all metadata instances are at the same code offset of an instruction)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This applies clang-format to the whole codebase.
I noticed we have .clang-format in wabt but the codebase is not very
well formatted. This kind of mass-formatting PR has fans and skeptics
because it can mess with `git blame`, but we did a similar thing in
Binaryen a few years ago (WebAssembly/binaryen#2048, which was merged in
WebAssembly/binaryen#2059) and it was not very confusing after all.
If we are ever going to format the codebase, I think it is easier to do
it in a single big PR than dozens of smaller PRs.
This is using the existing .clang-format file in this repo, which
follows the style of Chromium. If we think this does not suit the
current formatting style, we can potentially tweak .clang-format too.
For example, I noticed the current codebase puts many `case` statements
within a single line when they are short, but the current .clang-format
does not allow that.
This does not include files in src/prebuilt, because they are generated.
This also manually fixes some comment lines, because mechanically
applying clang-format to long inline comments can look weird.
I also added a clang-format check hook in the Github CI in #1683, which
I think can be less controversial, given that it only checks the diff.
---
After discussions, we ended up reverting many changes, especially
one-liner functions and switch-cases, which are too many to wrap in
`// clang-format off` and `// clang-format on`. I also considered fixing
`.clang-format` to allow those one-liners but it caused a larger churn
in other parts. So currently the codebase does not conform to
`.clang-format` 100%, but we decided it's fine.
|
|
|
|
| |
supported call_ref (#1691)
|
|
|
|
|
|
| |
Matches recent changes in the exception handling spec that allowed
this case to reduce special cases in the syntax:
https://github.com/WebAssembly/exception-handling/pull/157
|
|
|
| |
`unwind` was removed. See WebAssembly/exception-handling#156.
|
| |
|
|
|
|
|
|
|
|
|
| |
This is a new kind of ir/ast node/instruction. It has 3 immediates:
memarg align, memarg offset, and lane index. This required new visitor
functions in all the places.
Drive-by cleanup to share the simd lane parsing logic between shuffle,
lane op and this new load lane instructions. This requires rebasing some
tests because the error messages are slightly different now.
|
|
|
|
| |
This requires a new ir type, and the relevant implementation of virtual
mthods in the various visitors.
|
|
|
|
|
|
|
|
|
|
| |
This PR updates the support of exception handling to the latest proposal (that is compatible with future 2-phase exception handling) described in https://github.com/WebAssembly/exception-handling/pull/137 and https://github.com/WebAssembly/exception-handling/pull/143.
* Adds back tagged `catch $e`, `catch_all`, and `rethrow N` from a previous version of wabt, but with updates to match the current spec (e.g., `catch_all` shares an opcode with `else`, `rethrow`'s depth indexes only catch blocks, etc).
* Adds `unwind` and `delegate` instructions.
* Removes `exnref` and `br_on_exn`.
* Updates relevant tests.
There are some details that could still change (e.g., maybe how `delegate`'s depth is validated), but I'd be happy to submit further PRs if the spec details change.
|
|
|
|
|
| |
See https://github.com/WebAssembly/threads/pull/141 for the binary
encoding. This patch does add a field to AtomicFenceExpr for the
consistency model, though without a type for the time being.
|
| |
|
|
|
|
| |
- Implement ref.func everywhere.
- Implement table.get and table.set in the interpreter.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The current visitor does not visit `catch` itself when its body is
empty. So even if the attached test with an empty `catch` body is
supposed to be a validation failure (because an `exnref` value is left
on the stack in the `catch` body), it passed the validator.
In more detail, in the current code,
Input: (should be a validation failure)
```
try
catch ;; this pushes an exnref value onto the stack
end
```
Output: (wrong, `catch` is missing)
```
try
end
```
Now we correctly visit `catch` even when its body is empty, this test
correctly causes a validation failure.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add support for v8x16.shuffle1 and v8x16.shuffle2_imm.
v8x16.shuffle2_imm is a rename of the previous v8x16.shuffle, but I add a copy of the code as if it were a new instruction in case the spec proposal makes further changes. The tests for old v8x16.shuffle remain in place and while there are new tests for the new v8x16.shuffle1, there are not for v8x16.shuffle2_imm. The behaviour and implementation are the same as for v8x16.shuffle, so we should simply search and replace the existing tests at some point, leaving one of them untested, probably the deprecated v8x16.shuffle.
I did test v8x16.shuffle1 against the SIMD spec test from WAVM and it passes. The WAVM spec tests for v8x16.shuffle2_imm parse but it has no invocations of the instruction.
* Rename v8x16.shuffle1 and x8v16.shuffle2_imm to v8x16.swizzle and v8x16.shuffle_imm.
* Update SIMD operands.
* Swizzle is just a binary operator.
* Shuffle is named "v8x16.shuffle".
* Add 4 new opcodes for load_splat.
* Remove legacy 0xfd 0x03 opcode for shuffle.
* Test all four load splats.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add support for the reference types proposal
This commit adds support for the reference types proposal to wabt.
Namely it adds new opcodes like `table.{get,set,grow}` as well as adds a
new `anyref` type. These are plumbed throughout for various operations
in relatively simple fashions, no support was added for a subtyping
relationship between `anyref` and `anyfunc` just yet.
This also raises the restriction that multiple tables are disallowed,
allowing multiple tables to exist when `--enable-reference-types` is
passed.
* Allow nonzero table indices in `call_indirect`
Plumb support throughout for the `call_indirect` instruction (and
`return_call_indirect`) to work with multi-table modules according to
the reference types proposal.
|
|
|
|
|
|
| |
It takes two u32 immediates: the branch depth and an exception index. The
stack signature is `[expect_ref] -> [except_ref]`, so the `except_ref`
can be tested easily against multiple exception types.
|
|
|
|
| |
It is no longer part of the exception proposal.
|
|
|
| |
Carrying over renames from WebAssembly/bulk-memory-operations#46
|
|
|
|
|
|
|
|
| |
This huge PR does all the renaming as described in issue #933. It also
updates to the latest testsuite so the new names are used.
The old names of the MVP instructions are still supported for
convenience (though we should remove those too at some point), but the
old simd and atomic instruction names are no longer supported.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit starts to add support in wabt's various tools for the
upcoming [bulk memory proposal][1]. This is based off the current
proposal's overview, although these may get tweaked over time!
This is also the first time I've significantly contributed to wabt, and
what I thought would be a relatively simple addition ended up being much
larger than I imagined! I didn't add many negative tests yet but if more
tests are desired please let me know!
[1]: https://github.com/webassembly/bulk-memory-operations
|
|
|
|
|
|
|
|
|
|
|
|
| |
This doesn't do any of the real work yet, it just adds the
ReturnCall/ReturnCallIndirect Expr and Opcode types, and the
"--enable-tail-call" flag.
Still TODO:
* Parse the opcodes in binary-reader.cc
* Validate the opcodes in validator.cc and type-checker.cc
* Implement the opcodes in interp.cc
* Write standard wabt tests, and enable the spec proposal tests too
|
|
|
|
|
|
|
|
|
| |
`grow_memory` -> `memory.grow`
`current_memory` -> `memory.size`
This could have been a smaller change, but I took the opportunity to
rename the Token types, Expr types, and callback functions too. Many of
these are sorted alphabetically, so I resorted based on their new names.
|
|
|
|
| |
I also fixed some for/if to use braces if I noticed it. This is a
non-functional change.
|
| |
|
|
|
|
|
| |
Including:
1. All necessary code for SIMD lanes accessing.
2. i8x16.extract_lane_s implementation.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Implemented:
* Parsing `try`, `if_except`, `throw`, `rethrow`
* Validation
* Binary and text output
Still missing:
* `except_ref` for locals
* Interpreter implementation
|
|
|
|
|
|
| |
This will help with wasm modules that have very deeply nested blocks.
See issue #752.
|
| |
|
|
|
|
| |
This was recently changed in the spec.
|
|
|
| |
This implements everything except the interpreter.
|
|
|
|
|
|
|
|
| |
This adds support for all atomic instructions, enabled via the
`--enable-threads` flag.
It supports all tools: parsing text, decoding binary, validation, and
interpreting. It does not currently ensure that the memory is marked as
shared; that flag is not supported in wabt yet.
|
|
|
| |
This way the names won't conflict with other headers with the same name.
|
|
|
|
|
|
|
| |
* Unify all uses of `CHECK_RESULT`
* Use `CHECK_RESULT` in a few more places
* Add `operator|` and `operator|=` to `Result`, use it instead of
`COMBINE_RESULT`
* Change a few occurrences of `!Succeeded` to `Failed`
|
|
|
|
|
|
|
|
| |
* Nicer static constructors for Const (e.g. `Const::F32()`)
* Protect `type` member when used as discriminant in type hierarchy
(e.g. `Expr`, `ModuleField`, etc.)
* Remove pointer member fields where possible. Where not, use `std::unique_ptr` instead.
* Remove nearly all uses of unions (`Var` and `Const` still use them)
* Rename `make_unique` to `MakeUnique` so to not conflict with `std::make_unique` when found by ADL.
|
|
|
|
|
|
| |
Nothing much special here, but it is becoming increasingly annoying that
the parser Token cannot have value types (so everything must be moved
then deleted).
|
|
|
|
|
|
|
|
| |
* Remove WABT_ZERO_MEMORY WABT_FAILED and WABT_SUCCEEDED macros.
* Add source generated files.
* Add pod check.
|
|
|
|
|
|
|
| |
Also added LLVM-style casting free functions:
- isa<T>: returns true if the object is of type T
- cast<T>: converts object to T* or asserts
- dyn_cast<T>: converts object to T* or returns nullptr
|
|
|
|
|
|
|
|
| |
This has the benefit of making things much more type-safe, as well as
simplifying destroying member variables.
For now, many of the members are still raw pointers, but they probably
should become unique_ptrs or ordinary values.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Save state.
* Add exception declaration syntax.
* Extend validator to handle exception declarations.
* Fix binary writer to handle exception declarations.
* Fix code to handle external exception kind.
* Regenerate lexer.
* Fix bug with last merge.
* Add exception declarations, and add examples.
* Fix nits.
* Initial extensions for expr visitor.
* Save state.
* Fix issues with master merge.
* Reconcile issues with merge of tools wast2wasm and wast-desugar.
* Save state.
* Save work to move to mtv.
* Fix resolving names on try/throw constructs.
* Completed implementation of validation for exception handling.
* Fix nits.
* Combine Catch and CatchAll in IR.
* Remove tryblock visitors.
* Clean up to only use one visitor for each catch.
* Rework the structure of try blocks and catches.
* Remove the need for common CLI options.
* Fix issues raised by binji.
* Fix re2c generated file.
* Fix memory leak, and fix nits.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Update grammar to recognize try blocks.
* Fix parenthesized version of try blocks.
* Add test file.
* Add parsing of try blocks to wast parser.
* Remove debugging comment.
* Fix help test and handling null parser flags pointer.
* Fix formatting of try wast case.
* Clean up model for exceptions and fix tests.
* Fix typo in bad-try.txt test case.
* Fix nits of binji.
|
|
Add ExprVisitor::Delegate for callbacks, and ExprVisitor::DelegateNop
when some functions aren't implemented (similar to BinaryReader).
|