| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
| |
The tag name subsection currently has the speculative ID of 10.
However, the extended-name-section proposal has now been updated to
use an ID of 11 for the tag name section. This updates the
NameSectionSubsection enum accordingly, as well as adding a field
name section with the ID of 10.
|
| |
|
| |
|
|
|
|
| |
Reflects change in the multi-memory proposal:
https://github.com/WebAssembly/multi-memory/pull/29
|
|
|
|
|
|
| |
This continues the work from #1783 and reduces special handling of elem
exprs, by treating them the same as other const expressions (init
expressions).
|
| |
|
| |
|
|
|
|
| |
used (#2226)
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
Rationale: clang (compiled to Wasm) uses a label nesting depth of >1400,
which is greater than the limit of 1024 created in PR #2169.
In practice, with a debug build, values up to about 40,000 appear
sufficient to keep the stack within an 8 MiB limit. On release builds
it's more frugal and we could probably afford an even bigger limit. But,
"16384 ought to be enough nesting depth for anybody."
|
|
|
|
| |
Fixes #2151
Fixes oss-fuzz #53958
|
| |
|
|
|
| |
Fixes #2039
|
|
|
| |
This makes things easier for users and packagers of libwabt.
|
|
|
|
| |
Fixes #1687
|
| |
|
| |
|
|
|
|
| |
- Rebase test output to match new location tracking on Vars
- Eliminate single-argument Var() constructor.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#1783)
Previously we has special cases for initializer expressions (constant
expressions). This change paves the way for adding support for
extended constant expressions that support a wider range of
instructions.
This change removes twice as many lines as it adds which shows that
this simplification is probably worthwhile even without the pending
extensions.
|
|
|
|
|
|
|
|
|
| |
Tag names are not officially part of the extended-name-section proposal
(because it only deals with naming things that are in the spec already).
However, I think its reasonable (and useful) to include these names
under a speculative subsection ID, on the basis that tags can only exist
when exceptions are enabled and that engines should ignore unknown name
types.
|
|
|
|
| |
In #1770 I introduced these (duplicate) checks but it turns
out neither were necessary in the final version of the patch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The name of this argument was recently changed from func_index
to type_index, but I think that might have been incorrect.
The immediate that read in the binary reader is (IIRC) a function
index:
```
case Opcode::RefFunc: {
Index func;
CHECK_RESULT(ReadIndex(&func, "func index"));
CALLBACK(OnRefFuncExpr, func);
CALLBACK(OnOpcodeUint32, func);
break;
}
```
and not a type index. Indeed the interpreter seems to treat it
as a function index too:
```
Result BinaryReaderInterp::OnRefFuncExpr(Index func_index) {
CHECK_RESULT(validator_.OnRefFunc(loc, Var(func_index)));
istream_.Emit(Opcode::RefFunc, func_index);
return Result::Ok;
}
```
|
| |
|
|
|
|
| |
blocks. (#1695)
|
|
|
|
| |
We already have EndFunctionBody, and this extra distinction
doesn't seem like it is needed.
|
|
|
|
|
|
|
|
| |
This can happen if we don't stop on first error, and we get a malformed
module where the func counts don't match.
It's hard to write a test for this, since the kStopOnFirstError is fixed
(not set by command line), but this case is quite easy for fuzzers to
catch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Doing validation at parse time means we cannot run tests which
included invalid instruction in the elem init expressions.
For example. the updated test suite repo contains tests such as this:
```
(assert_invalid
(module
(table 1 funcref)
(elem (i32.const 0) funcref (item (i32.add (i32.const 0) (i32.const 1))))
)
"constant expression required"
)
```
There we have an illegal instruction sequence in the init expresssion.
However, in order to run this test we need to be able to process it with
wast2json first which means it at least has to parse correctly.
This change removes the `ElemExpr` and `ElemExprKind` types from the IR
and instead just stores elem init expressions as `ExprList` like we do
for global init expressions. This expression list can then be validated
but crucially can also be invalid.
This technique matches the existing `OnDataSegmentInitExpr_Other` and
`OnGlobalInitExpr_Other` and indeed it seem that it was indented to
work this way since the `OnElemSegmentElemExpr_Other` already existed
(unused) in the codebase.
|
|
|
|
|
|
|
|
|
| |
The alignment value in binary format is log2, so we need to shift it in
binary-reader-ir before it is validated (since validation requires that
it is shifted to be the number of bytes). We correctly did that for some
Simd instructions (like load splat) but did not do it for load/store
lane.
Fixes #1674.
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
| |
I noticed we lacked support here while debugging #1651.
|
| |
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
Found by oss-fuzz.
|
|
|
|
|
|
|
|
|
| |
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.
|