| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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)
|
|
|
|
|
| |
Now that we have C++17 we don't need our own string_view class anymore.
Depends on #1825
|
|
|
|
| |
Remove test/binary/bad-function-missing-end.txt which is now
covered upstream: https://github.com/WebAssembly/spec/pull/1405
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rather than spocial casing them in the reader we now use the same
instruction callbacks for instruction that appear in init expressions as
instructions that appear in normal functions.
The result of this change is the validation of init expressions is pushed
further up the stack. For example, objdump will now quite happily dump
modules that use arbitrary instructions in thier init expressions even
though they are not valid. To me, this makes sense since objdump does
not do instruction validation elsewhere.
The change is pre-cursor to allowing a wider variety of instruction
to be present in init expressions.
See https://github.com/WebAssembly/extended-const
|
| |
|
|
|
|
| |
We already have EndFunctionBody, and this extra distinction
doesn't seem like it is needed.
|
| |
|
| |
|
|
|
|
| |
We have the more specific OnFunctionSymbol, OnGlobalSymbol family
of callbacks that is used by objdump.
|
|
|
|
| |
supported call_ref (#1691)
|
|
|
| |
`unwind` was removed. See WebAssembly/exception-handling#156.
|
|
|
|
|
|
|
|
|
|
|
| |
We recently decided to change 'event' to 'tag', and 'event section' to
'tag section', out of the rationale that the section contains a
generalized tag that references a type, which may be used for something
other than exceptions, and the name 'event' can be confusing in the web
context.
See
- https://github.com/WebAssembly/exception-handling/issues/159#issuecomment-857910130
- https://github.com/WebAssembly/exception-handling/pull/161
|
| |
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Give `catch_all` its own opcode:
Previously `catch_all` shared an opcode with `else`, but
the spec now allocates it the 0x19 opcode.
Adjust rethrow depth semantics:
Previously this had interpreted the rethrow depth argument
as counting only catch blocks, but the spec has clarified that
it should count all blocks (in a similar fashion as `br` and
related instructions).
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
The reference-types proposal adds a select instruction with a type
vector, but any number greater than 1 is invalid.
Fixes #1577.
|
|
|
|
|
|
|
|
| |
See: https://github.com/WebAssembly/extended-name-section
Although this is only a phase 1 proposal its seems pretty
straight forward, and is already being implemented in
binaryen.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We add relocations for table numbers on each place where we reify a
table number (call_indirect, table.get, table.set...), but only if
reference types are enabled.
Also, fix symbol table generation with unnamed definitions, to allow for
relocating references to anonymous functions or tables.
As tests, add variants of the relocations and symbol-tables dump tests,
with and without all features enabled. Enabling reference types causes
relocs to be emitted. We also add --details to the relocations dump
tests, so that we can see the target symbols for the relocations.
|
|
|
|
| |
Fixes: #1520
|
| |
|
|
|
|
|
|
|
|
|
| |
See https://github.com/WebAssembly/reference-types/issues/99.
This change also updates the testsuite, so the spec tests pass too.
In addition, the behavior of `br_table` is no longer different from MVP,
and has a text to confirm this. That is now fixed in `type-checker.cc`
too.
|
|
|
|
|
|
|
|
| |
Main changes:
* Rename `anyref` -> `externref`
* Remove `nullref`
* Rename `hostref` -> `externref`
* `ref.null` and `ref.is_null` now have "ref kind" parameter
* Add ref kind keywords: `func`, `extern`, `exn`
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
The following formats are supported:
* (type (array i32))
* (type (array (field i32)))
* (type (array (field (mut i32))))
This PR adds support for reading/writing binary and text, but no
interpreter support yet.
|
|
|
|
|
|
|
|
|
|
|
| |
This allows the following field formats:
* `(struct (field $name i32))`
* `(struct (field $name (mut i32)))`
* `(struct (field i32))`
* `(struct (field (mut i32)))`
* `(struct (mut i32))`
* `(struct i32)`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This parses just the format `(struct)` as a new type. I added a test for
this using `wat2wasm`, but that requires a rudimentary binary format.
The test runner automatically attempts to rountrip all wat2wasm tests,
so this required implementing the wat writing and binary reading too.
Here's a summary of the changes:
* binary-reader:h: Rename `BinaryReader::OnType` callbacks to `OnFuncType`
* binary-reader.h: Add `BinaryReader::OnStructType`
* binary-reader.cc: Use a switch after reading the type form to
determine whether we're reading a function or struct.
* tokens.def: Add new `TokenType::Struct`
* lexer-keywords.txt: Add new `struct` keyword
* type.h: Add `Type::Struct` type form
* wast-parser.cc: Parse `(struct)` in text format
* wat-writer.cc: Write Func or Struct type forms
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The new table-sub test, checks whether the subtyping is handled
properly w/ table.init and table.copy instructions.
The BeginElemSegment callback can't pass the element type anymore, since
it's not known yet. The callback also can't be deferred, since the
BeginElemSegmentInitExpr callback has to happen after the
BeginElemSegment callback, but the reference type is not always known
until after the initializer expression is read. To work around this, I
added a new OnElemSegmentElemType callback.
Other element segment changes:
* The element type must be tracked in the SharedValidator
* A subtle fix: when writing out the segment flags, we need to take into
account whether the element type of the segment is not funcref, even
if there are no element expressions. In that case, we have to use flag
bit 0x4 (SegUseElemExprs).
In addition, the TableCopy and TableInit instructions weren't handling
table indexes fully.
* TableCopy variables are read in the parser (both optional)
* TableCopy names are now resolved + applied
* TableCopy indexes are now validated
* TableInit table variables are read in the parser; this is subtle,
since the text format has order $table $segment, but the $table is
optional.
|
| |
|
| |
|
|
|
|
|
|
|
| |
This change adds most of the tests from the reference-types proposal.
There are two tests that require new instructions (`table.fill` and
`select_t`) which will be followup changes.
See: #1223
|
|
|
|
|
|
|
|
|
|
|
| |
This is in preparation for updating to latest version reference-types
proposal where there is an additional flag and they can be combined.
See: https://github.com/WebAssembly/bulk-memory-operations/issues/98
Also, add ERROR_IF to binary-reader.cc as logical corollary to the
existing ERROR_UNLESS.
|
|
|
|
|
|
|
|
|
|
| |
This involved plumbing the table argument for `table.init` and
`table.copy` all the way through rather than assuming they were
always zero.
Update the rather complex logic for assigning names to elem segments to
handle active elem segments which both name themselves and the table
they apply too.
|
|
|
|
| |
- Implement ref.func everywhere.
- Implement table.get and table.set in the interpreter.
|
| |
|
|
|
|
|
|
|
|
|
| |
As per the reference-types spec, ref.null is a constant expression.
I did try to add support for ref.func at the same time, but I didn't
really understand the strategy of wabt and reference types; there seems
to be strong intertwingliness between func.ref and the element section,
whereas it does seem possible for a func.ref to be global. Oh well, I
didn't need it :)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
| |
This way you can see the contents of just one custom section by using:
```
wasm-objdump -j section_name -x
```
Where `section_name` is the name of the custom section.
|
| |
|
|
|
|
|
|
|
|
|
| |
* Implement bulk memory in interpreter
* Read/Write elem_type in element segments
* Binary format
* Text format (`(elem passive funcref...)`)
* Add DataSegment runtime objects
* Only initialize active data segments when instantiating
|
|
|
|
|
| |
* Store element segments as a vector of `ElemExpr`, instead of func index
* Read/write binary format for each element expression
* Read/write text format for each element expression
|
|
|
|
|
|
| |
* Added except_ref to be legal in a block type signature
* Added more support for event symbols.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
An event has a type-section index, like a function definition. The
current proposal doesn't specify the text format, so I assumed that it
would match the format of the other sections that reference function
types. This means that the following declaration styles are allowed:
```
(type $t (func (param i32)))
(event $e1 (type $t))
(event $e2 (param f32))
```
|
| |
|
|
|
|
| |
It is no longer part of the exception proposal.
|
|
|
| |
Carrying over renames from WebAssembly/bulk-memory-operations#46
|
| |
|