| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* memory64: when enabled, offset range check is at validation-time
Before memory64, the "offset" in a load/store expression was
a u32, and we enforced this in the WastParser and BinaryReader.
After memory64, the "offset" becomes a u64 syntactically, and the
validator checks that it's <= UINT32_MAX for i32 memories.
We hadn't been correctly allowing these very large offsets
in the text format (even when memory64 was enabled and the memory
was i64).
(This change also eliminates the "memories" member in the
BinaryReader. The BinaryReader no longer needs to keep track
of the memories and their types to check well-formedness.)
|
|
|
|
| |
- Rebase test output to match new location tracking on Vars
- Eliminate single-argument Var() constructor.
|
|
|
|
| |
(#1895)
|
|
|
|
| |
I think it was always intended to work this way but was
left as a TODO.
|
| |
|
| |
|
|
|
|
|
|
|
| |
Includes the three merged proposals (nontrapping-float-to-int,
sign-extension, multi-value).
It also has one bug fix when parsing table limits (when the min or max
size does not fit in a 32-bit int).
|
|
|
|
| |
* Add i{8x16,16x8,32x4}.abs instructions
* Implement IntAbs in interp-math.h
|
|
|
|
|
|
|
| |
Validation should only happen in ValidateModule, BinaryReader should
only check whether the binary is malformed.
This change also fixes a few places in BinaryReaderIR where an index is
assumed to be valid.
|
|
|
|
|
|
| |
The major change to the error output is showing the max value instead of
max value - 1. It's a bit weird to see "out of range: 0 (max 0)" but
seeing 4294967295 is strictly worse.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The TypeChecker was already shared, but the rest of the other validation
logic was duplicated. This change creates a SharedValidator which is
used by both the Validator and the BinaryReaderInterp classes.
The validator is structured similarly to TypeChecker as a collection of
functions. It's assumed that the functions will be called in the same
order as sections occur in the binary format. The IR valiator does this
too, even though it's possible to validate components out-of-order in
that case.
This change also splits Module validation and Script validation into two
different classes. It should have been written this way in the first
place, and it's nice to do as part of this change since the module
validator logic is mostly moved into the SharedValidator anyway.
Next steps:
* Remove all validation from BinaryReader and move it into the
SharedValidator.
* Move the TypeChecker into the SharedValidator (maybe not necessary)
* Ensure that validation occurs before creating IR from binary (use
SharedValidator in BinaryReaderIR? or maybe create
BinaryReaderValidator passthru that both BinaryReaderIR and
BinaryReaderInterp use?)
* Rename Validator -> IRValidator, SharedValidator -> Validator
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
The newest testsuite update enables mutable globals by default, which
matches the v1 WebAssembly spec.
This change changes the default for all wabt tools, and changes the flag
to `--disable-mutable-globals` in case you need the previous behavior.
This flag will likely be removed in the future.
|
|
|
|
|
|
|
|
|
| |
`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.
|
|
|
|
| |
* Fix edge case elem segment bounds checking
* Fix bounds checking when importing spectest table
|
|
|
|
|
| |
The spectest module's functions and globals are no longer overloaded, so
their implementations in `spectest-interp` and `spec-wasm2c-prefix.c`
have to be changed as well.
|
|
|
|
|
|
| |
Many of the `test/run-*` Python scripts are essentially the python
equivalent of shell scripts. They require tedious maintenance whenever
the tools change, and have a significant amount of copied code. This CL
removes `run-interp.py` as a relatively simple initial example.
|
|
|
|
|
|
|
|
|
|
| |
Each test should be run with its own directory of outputs, so the tests
can be run in parallel without clobbering results. Since I added wasm2c,
the spec `.wast` files were being used twice, but using the same output
directory. This would often work properly in a full run, but was flaky,
since they both write `.json` and `.wasm` files with the same names.
This fix gives them their own directories by always using the directory
name of the test.
|
|
|
| |
Fixes #668.
|
|
|
|
|
|
| |
This is a conservative check that we can do in the binary
reader itself. More extensive checking is still done in the
interpreter (i.e. vefiying the type of the global).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Remove Bison dependency
* Remove pre-generated parser files
* Rename build config from no-re2c-bison to no-re2c
* Add a simple make_unique implementation
* Move handling of module bindings into ir.cc
* Simplify lexer
- Remove lookahead, the parser handles this now
- Unify Token/LexerToken, it only contains terminal values now
- Refactor setting token type and value into one function (e.g.
LITERAL, RETURN => RETURN_LITERAL)
* New Parser
- Uses two tokens of lookahead (use Peek(0) or Peek(1))
- Consume() consumes one token of any kind
- Match(t) consumes the current token if it matches
- PeekMatch(t) returns true iff the token matches, but doesn't consume
- Basic error synchronization; plenty of room for improvement here
|
|
|
|
|
|
|
| |
Since SourceErrorHandler can support binary locations, it doesn't make
much sense to have two different error handlers. There is now only an
ErrorHandler base class, and the first argument specifies whether the
error handler is expecting text or binary locations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add support for quoted modules: `(module quote "...")`
* Binary modules must be annotated: `(module binary "...")`
* Multiple result blocks are no longer a parser error:
`(func (result i32) (result i32) ...)`
* Function types can specify unused bind variables:
`(type (func (param $foo)))`
* Rename `RawModule` -> `ScriptModule`. This encapsulates a module that
may not be parsed yet, whether binary or "quoted".
* Validate load/store offsets and alignment in the parser, not in the
validator. The spec tests assume that you can catch these errors with
`assert_malformed`.
* Parse wast files in `wasm-interp` when checking malformed/invalid/etc.
modules. This allows us to run all assertions at the same time, which
is nice. `wasm-interp` should probably be renamed, though.
* Two tests in `type.wast` fail because they use:
`(assert_invalid (module quote "..."))`. I'd prefer that we don't
support this, since it's unnecessary, and additional work. I'll fix in
a follow-up CL if we decide this is worth keeping.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This adds a few new classes:
* BinaryReader: the abstract base class
* BinaryReaderNop: implements all of BinaryReader, but does nothing
* BinaryReaderLogging: logs calls through BinaryReader, and forwards to
another BinaryReader
Typically this means we can remove the Context structs from these
implementations, since that data can just move into the BinaryReader
subclasses.
I also took the opportunity to rename the new member functions to
MixedCase instead of snake_case, since that's more common in C++.
|
|
|
|
|
|
|
|
| |
Now that assert_invalid is checked by wasm-interp, all spec assertions
can be handled by the interpreter. Having a subset that are also handled
by wast2wasm is not useful.
Also, there was a bug in the option parser where passing an option that
didn't match could still work if a prefix was valid.
|
| |
|
| |
|
|
|
|
|
|
|
| |
Also:
* Check all data/elem segments before updating memory/tables
* assert_exhaustion should check for call stack or value stack
exhaustion.
* Don't allow out-of-bound size 0 data segments
|
|
|
|
|
| |
* Write all intermediate output to out/
* Use real paths for all test names (i.e. include "test/")
* A few Python3 fixes
|
| |
|
|
|
|
|
|
|
| |
* Non-imported globals can not be used in initializer expressions
* block/loop/if labels can be repeated at the end
* get_global index in initializer expression should reference use module
index space, not "defined" global index space
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Properly handle registering an unnamed module (most recently read) in
AST parser
* register command has optional name in spec JSON format
* Implement spectest_import_{table,memory,global}
* Implement on_register_command in wasm-interp (wires up module binding)
* Implement assert_unlinkable
* Set module's table_index and memory_index when importing table/memory
* Translate {get,set}_global index from module -> environment index
space
* Don't close the environment's istream writer if the module read fails;
this will destroy the output buffer. Just leave it as is, with extra
unused data in the environment
* Add registered_module_bindings hash; this has the registered name of
the module (not to be confused with the module name, which is internal
only)
* Add {GET,SET}_GLOBAL opcodes to wasm_trace_pc and wasm_disassemble
* Add new trap when calling a function via call_indirect, when the table
element hasn't been initialized (via an elem segment)
* Check the limits of tables + memories when importing
* Check the function signature when importing
* Use callback for printing errors from a host import; this lets us
redirect the output the same way other errors are
* Add environment "marks". Similar to allocator marks, allows you to
backup to a previous state when an operation fails (such as
successfully reading a module that was supposed to fail)
|
|
|
|
|
|
|
| |
* `offset=` and `align=` can now specify hex values
* data and elem segment offsets are now not checked; they can be out of
order or overlapping, and even out-of-bounds if the size is zero
* added the new tests `skip-stack-guard-page` and `unwind`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The only ones that are failing are imports, exports, linking and start.
Fixes:
* Make sure to assign loc_ for WasmVar
* Imports must occur before any definition, not just a definition of the
same kind
* Check that load/store alignment is not larger than natural alignment
* Always check type stack at the end of the check_block; that way an
empty block is still validated
* Only allow one memory or table, including imports
* Don't allow importing or exporting mutable globals
* Loop label signature is for the fallthrough at the bottom, not the
branch target. This was implemented properly in the AST checker, but
not in binary-reader-interpreter
* `top_type_is_any` will check if there is ANY anywhere on the type
stack; previously this check did not look past the top label's type
stack limit
* `drop_types_for_return` may be called without having enough values on
the type stack; for example, at the end of a function the ends with
return
* properly handle cleaning up the type stack for the interpreter when
branching to the implicit function label
* rename invoke -> action a few places
|
| |
|
|
|
|
|
| |
Mostly just requires proper implementation of drop/tee_local in
wasm-binary-reader-interpreter.c and wasm-interpreter.c.
|
|
|
|
|
| |
It's not really the appropriate place to handle it. Now that we have
wasm-wast and wasm-interp, we can at least verify that the tools are
internally consistent.
|
|
|
|
|
|
|
|
|
| |
* Parse memory pages as uint64, as we need to check whether it's invalid
in assert_invalid, and one of the spec tests uses the value 2**32.
* Update WASM_MAX_PAGES to 65535 (not 65536)
* Add the new spec tests: binary.wast, break-drop.wast and
typecheck.wast. A couple of these were added before, but weren't added
as .txt files in the test directory.
|
| |
|
|
|
|
|
|
|
|
|
| |
* run-tests.py now takes a `--d8-executable` flag
* Added a `TOOL` directive to tests to reduce boilerplate
* Change all tests to use the new `TOOL` directive
* Factor out executable searching with fallback to find_exe.py
This fixes issue #43.
|
|
|
|
|
| |
spec/switch.txt is still failing because we don't yet support br_table
passing an argument.
|
|
|
|
| |
Also allow TODO/NOTE directives in test file format.
|
| |
|
| |
|
|
|
|
| |
block nodes now always create a new scope
|