| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
| |
Continuation of #2470
|
|
|
|
| |
This pull request implements EHv4. Binary is mostly untested until
interp is working.
|
|
|
|
| |
This adds support in the binary/text parsers and writers,
the validator and interpreter, and objdump (but not wasm2c).
|
|
|
|
|
| |
The memory64 `table.wast` test has started to depend on
function-references and gc (which WABT doesn't support yet), so vendor
an older version of the test.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The interpreter could overflow the stack without trapping properly in
`call_indirect` situations. While it would set the `out_trap` to the
trap reason, it would return `RunResult::Ok` and the interpreter code
would only check `RunResult::Ok` to decide whether or not to keep
running. In other words, while the stack overflow meant the interpreter
wouldn't push a frame onto the call stack, the interpreter loop would
continue advancing instructions, resulting in instructions after the
runaway `call_indirect` running.
If the offending `call_indirect` didn't have return values, it would be
as if the call returned normally. If it did have return values, nothing
would be pushed onto the value stack, yet the return types would be
pushed onto the type stack. With careful manipulation of the following
instructions, this could be used to cause all sorts of memory
corruption.
As it turns out, the function exit code, as well as a handful of other
instructions, do check the state of the value and type stacks and can
safely reproduce the bug without the memory corruption, so that's what
we made the test do.
The obvious fix was to make `call_indirect` propagate `RunResult::Trap`
properly. Additionally, we made it so `assert_exhaustion` checks both
the `RunResult` *and* the `out_trap`, and asserts if they don't match.
This should help catch similar bugs in the future.
Closes #2462
Fixes #2398
|
|
|
|
|
| |
See https://github.com/WebAssembly/memory64/issues/51
Includes workaround for #2422
|
|
|
|
|
|
|
| |
The main change here is because `comments.wast` was updated to include
a "quoted" module at the top level.
Previously quoted modules had only been used as part of invalid or
malformed assertion expressions.
|
|
|
|
|
|
| |
This continues the work from #1783 and reduces special handling of elem
exprs, by treating them the same as other const expressions (init
expressions).
|
| |
|
|
|
|
|
|
|
|
| |
This adds support for the new opcodes from the Relaxed SIMD proposal
(https://github.com/WebAssembly/relaxed-simd) behind the
"--enable-relaxed-simd" flag.
The exception is the f32x4.relaxed_dot_bf16x8_add_f32x4 instruction
which is not yet implemented.
|
|
|
|
|
|
|
|
| |
All of these checks represent cases where a validation error would
prevent the type mismatch.
When debugging #2054 this check actually worked against me since it
was resulting a false-positive "out-of-bound" error reports when really
it was an internal type inconsistency (a bug).
|
|
|
| |
This makes things easier for users and packagers of libwabt.
|
| |
|
| |
|
|
|
|
| |
The algorithm is made partially recursive.
|
|
|
|
|
|
|
|
|
|
| |
The primary changes here are to the interpreter and how it handles
initializer expressions. With this change we model these are normal
function that we run during module initialization.
I imagine we could optimize this further by creating one long function
and encoding the `global.set`/`memory.init`/`table.init` into the
function itself, but this change seems like a good first step to make
the current tests pass.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When data of element segment init fails we were reporting the size, but
we were unconditionally calling `Drop` for active segments which meant
they always get reported as zero sized in the error message.
This mismatch was only showing up with bulk memory enabled (since
without this we do a two phase initialization). The only test we have
for this error message was using `--disable-bulk-memory`, but not for
any good reason (most likely because of this very bug).
Also restore the comment about why we sometimes need to do a two phase
initialization for element and data segments. This comment was lost in
PR #1330 but seem important since I don't think we have any tests for
this older behaviour.
|
|
|
|
| |
Improves memory consumption since thread instances
are freed without running garbage collector.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
This requires `Type::GetName` to return to be dynamicllay created and
return `std::string` rather then a `const char*`
As this diff shows this type name is only used in textual output and
error messages so should this change should not have a effect of binary
parse time or the interpreter.
|
|
|
|
|
|
|
|
| |
This PR imports the spec tests from the Wasm testsuite repo and adds infrastructure to run them correctly.
* Adds test expectations for exception handling proposal spec tests.
* Adds missing tag signature matching code for import tests.
* Adds support for the `assert_exception` command used in new tests.
* Fix filename normalization for the spec test runner.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Details about the implementation approach:
* Try blocks generate metadata tracking the instruction ranges for the
handlers and which exception tags are handled (or if a `catch_all` is
present). The metadata is stored in a function's `FuncDesc`, and is
transferred into the `Frame` when a function call is executed.
* The stack is unwound when a `throw` is executed. This unwinding also
handles tag dispatch to the appropriate catch. The metadata to find
the matching handler is looked up in the call `Frame` stack.
* If a `try-delegate` is present, it is used in the stack unwinding
process to skip over to the relevant handler.
* A separate `exceptions_` stack in call frames tracks caught
exceptions that can be accessed via a `rethrow`. The stack is popped
on exit from a try block or when exiting via control instructions
like `br`.
* Because stack unwinding relies on finding metadata in the call
frame, `return_call` needs to be modified slightly to adjust the
current frame when executing the call, rather than re-using the
frame completely as-is.
|
|
|
|
|
|
|
|
|
|
|
| |
bulk-memory-operations and reference-types were completely
removed from the upstream testsuite becuase there were
merged into the upstream spec:
https://github.com/WebAssembly/testsuite/pull/44
In order to land this I had to disable several spec tests
under wasm2c because it lacks support for mutli-table and
reference types. I filed #1737 to track this.
|
|
|
|
| |
Also remove an unused transform, we are applying the unop f in the for
loop directly after it.
|
|
|
|
|
|
| |
The use of `.v` is incorrect, we should simply use array subscript
operator on the Simd type, which takes care of BE systems.
For #1670. (Not using fix as I don't have a BE system to verify.)
|
|
|
|
| |
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.
|
|
|
| |
Unskip and rebase simd_int_to_int_extend.
|
|
|
| |
Rebase and unskip simd_i64x2_cmp.
|
|
|
| |
Rebase and unskip simd_i32x4_dot_i16x8.
|
|
|
| |
Rebase and unskip simd_i16x8_q15mulr_sat_s.
|
|
|
|
|
|
|
| |
Renumber floating point rounding instructions since they overlap with
these new extmul instructions. Rebase simd_f32x4_rounding and
simd_f64x2_rounding.
Rebase and unskip simd extmul tests.
|
|
|
|
| |
Rebase and unskip simd_i16x8_extadd_pairwise_i8x16.txt and
simd_i32x4_extadd_pairwise_i16x8.
|
|
|
| |
Rebase and unskip simd_i64x2_arith2.txt.
|
|
|
|
| |
Rebase simd_i32x4_trunc_sat_f64x2.txt and
simd_i32x4_trunc_sat_f32x4.txt.
|
|
|
|
|
|
|
|
|
|
|
|
| |
4 double precision conversion instructions are implemented:
- f32x4.demote_f64x2_zero
- f64x2.demote_low_f32x4
- f64x2.convert_low_i32x4_s
- f64x2.convert_low_i32x4_u
This is now sufficient to unskip simd_conversions.txt.
Rebase a bunch of tests due to the rename from widen to extend.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* Rename all any_true to v128.any_true
* Add i64x2.bitmask and i64x2.all_true, rebase simd_boolean
* Unskip spec/simd/simd_i16x8_arith2.txt since i64x2.abs is now implemented
* Unskip spec/simd/simd_lane.txt
* Update dump interp tests, rebase
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Initial attempt at s390x port
* Second attempt at s390x port
* Fix big-endian memory fill
* Fix more memory location calculations
* Improve SIMD
* Implement big-endian memory grow
* Fill relocation with 0x00, as per spec
* Make wasm2c endianness work
* Fix shuffle
* Fix load endianness in wasm2c
* Refactor into shared code
* Clean up SwapBytesSized
* Clean up MemcpyEndianAware
* Clean up
* "Fix" opcodecnt basic test
|
|
|
|
|
|
|
|
| |
atomic.notify -> memory.atomic.notify
i32.atomic.wait -> memory.atomic.wait32
i64.atomic.wait -> memory.atomic.wait64
These were renamed upstream a while ago, but the new names were not
added to wabt.
|
|
|
|
|
| |
These uncovered some things the previous tests didn't!
Also required the switching of the location of the index as discussed in https://github.com/WebAssembly/memory64/issues/5
Also one small .py change that ensures the new tests have consistent posix paths.
|