| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
(#1895)
|
|
|
|
|
|
|
|
|
|
| |
For text validation, this means the error is always correctly reported on
the final expression in the function.
For binary validation, this means that we report the byte after the last
instruction in the function as the failure location. This is in line
with other binary validation reports. For example, for `type mismatch
in i32.add` we report the validation error at the byte *after* the add
instruction.
|
|
|
|
|
|
|
|
|
|
| |
catches. NFC (#1784)
If you leave stuff on the stack at the end of an initializer
expression use the same mechanims to report the error as we
do for functions etc.
In addition, improve such errors so its more obvious what is
going on.
|
|
|
|
| |
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).
|
| |
|
|
|
|
| |
Also fix bug when parsing elem/data segment; the table/memory index is
stored as an LEB128, not a U8.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Instead of printing errors on every failure, accumulate errors for each
operation. If any fails, then print a message. It changes errors such
as:
```
error: type mismatch in i64.store, expected i32 but got f32.
error: type mismatch in i64.store, expected i64 but got i32.
```
to:
```
error: type mismatch in i64.store, expected [i32, i64] but got [f32, i32]
```
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Update testsuite; various lexing/parsing fixes
Lexer changes:
* Switch re2c parser to UTF-8 parser. This can almost be done "for
free" with a flag, but required a bit of work to allow us to catch
malformed UTF-8 as well.
* Change the re2c fill value to 0xff, since it's never a valid UTF-8 byte.
* Allow for more reserved tokens (basically any ascii aside from
parentheses, double-quote, and semi-colon)
* Remove "infinity" from lexer, only "inf" is allowed now.
* Change definition of EOF token, it was implemented incorrectly. The
correct way to handle it is to only return it from FILL when there is no
more data to fill.
* \r is a valid escape.
Parser changes:
* Changes to match the spec parser:
- block signatures use (result <type>) syntax
- func/global/table/memory can have multiple inline exports
- inline imports are handled in func definition instead of import
definition
- allow for inline modules (i.e. no "(module ...)" s-expr required)
* Remove FuncField. This was previously used for parsing
params/results/locals, but it's less code to just parse
right-recursive (i.e. backward) and insert everything at the front.
This requires reversing the indexes in the BindingHash too.
* Remove the nasty macros `APPEND_FIELD_TO_LIST`,
`APPEND_ITEM_TO_VECTOR`, `APPEND_INLINE_EXPORT`, and
`CHECK_IMPORT_ORDERING`. This behavior is all handled by
`append_module_fields` now.
* All inline imports/exports are handled by returning additional
ModuleFields in a list. This removes the need for `OptionalExport`,
`ExportedFunc`, `ExportedGlobal`, `ExportedTable`, and
`ExportedMemory`.
* Use "_opt" suffix instead of "non_empty_" prefix, e.g.:
- text_list => text_list_opt, non_empty_text_list => text_list
* The locations changed for some symbols, typically the use the name
following the LPAR now, e.g. (import
^^^^^^
* Add PPA for re2c 0.16
* add -y to skip confirmation on travis
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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++.
|
|
|
|
|
|
| |
Fixed a few typechecker errors:
* br_table must have consistent type signature for all branch targets
* if without else cannot have a signature
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The typechecking is now shared between the validator and
binary-reader-interpreter as well.
* Shared the various LabelType enumerations -> WabtLabelType.
* Fixed the "invalid depth" errors, the max value was incorrect.
* Removed some tests that aren't useful anymore:
- interp/if-then-br hasn't been useful for a while, but now is even
less so because it doesn't validate without dropping the i32.const
from the true branch
- typecheck/bad-br-multi-type isn't possible because the block must
specify the signature for the br.
- typecheck/bad-label-multi-type used to test matching signature for
fallthrough and br, but isn't possible because of block signatures.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
* Write all intermediate output to out/
* Use real paths for all test names (i.e. include "test/")
* A few Python3 fixes
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|