summaryrefslogtreecommitdiff
path: root/src/binary-reader.cc
Commit message (Collapse)AuthorAgeFilesLines
* Allow a local type count of 0 (#1039)Ben Smith2019-03-081-1/+0
| | | | | It's legal in the wasm format to have a local type count of 0. I originally made it illegal to fix a wabt bug, and didn't notice because there were no spec tests for this behavior.
* Rename anyfunc -> funcref; parse reference types (#1026)Ben Smith2019-02-251-2/+3
| | | | | | | | | Also: * Add feature limits on using v128 and anyref types (requires --enable-simd and --enable-reference-types respectively). * Separate out ParseValueType (used for params, locals, global types) from ParseRefType (used for table types).
* Improve support for event symbols and except_ref types (#1025)Wouter van Oortmerssen2019-02-241-6/+19
| | | | | | * Added except_ref to be legal in a block type signature * Added more support for event symbols.
* Add support for the reference types proposal (#938)Alex Crichton2019-02-141-16/+79
| | | | | | | | | | | | | | | | | | | | * 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.
* Add br_on_exn instruction (#1016)Ben Smith2019-02-131-0/+10
| | | | | | 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.
* Parse updated event text and binary format (#1014)Ben Smith2019-02-121-19/+13
| | | | | | | | | | | | 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)) ```
* Rename exception -> event (#1013)Ben Smith2019-02-111-27/+27
|
* Add `Event` known section; remove `exception` (#1012)Ben Smith2019-02-111-3/+6
| | | | | | | The exception section is now a known section with code 13, and is known as the "Event" section. The structure of the section has changed too, but I'll fix that in another PR.
* Remove the `if_except` instruction (#1009)Ben Smith2019-02-101-11/+0
| | | | It is no longer part of the exception proposal.
* Rename {memory,table}.drop to {data,elem}.drop (#1000)Alex Crichton2019-01-301-5/+5
| | | Carrying over renames from WebAssembly/bulk-memory-operations#46
* Update bulk memory instruction binary encodings (#999)Alex Crichton2019-01-291-11/+18
| | | | | | This commit updates wabt wrt to two recent PRs: * WebAssembly/bulk-memory-operations#43 * WebAssembly/bulk-memory-operations#45
* Implement parsing and writing of DataCount section (#998)Ben Smith2019-01-231-6/+27
|
* Update linking metadata version (#996)Sam Clegg2019-01-171-4/+4
| | | | | Also make explicit when are showing log2 alignment. We could instead display actual byte alignment (1 << p2align)?
* The great renaming (#985)Ben Smith2018-12-191-90/+90
| | | | | | | | 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.
* Pass function body size in BinaryReader callback (#975)Ben Smith2018-12-121-1/+1
| | | This is useful for finding large functions with wasm-objdump.
* Add needed_dynlibs to dylink section (#974)Sam Clegg2018-12-121-0/+9
| | | | | This field was recently added: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md
* Handle mismatch in function/code section (#959)Ben Smith2018-11-281-0/+4
| | | | | | If the function section is present, and has a non-zero count, then if the code section is absent the module should not validate. If either section is missing, but the count is zero it is OK.
* Add support for dylink section (#955)Sam Clegg2018-11-141-0/+20
| | | | | See: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md
* Update testsuite (#942)Ben Smith2018-11-051-6/+10
| | | | Also fix bug when parsing elem/data segment; the table/memory index is stored as an LEB128, not a U8.
* Add test for disabled opcodes in binary reader (#934)Ben Smith2018-10-181-34/+18
| | | | | | It's easy to forget to add a check for unexpected opcodes, and it's tedious to have to write additional tests in `test/binary/*`. This way we can test all potentially disabled instructions at once.
* Add more tests for tail_call feature (#931)Ben Smith2018-10-161-4/+6
| | | | | | | | | | | | | | * Fix a few places where `call`/`call_indirect` are used instead of `return_call`, `return_call_indirect` * Fix `TypeChecker::CheckReturnSignature` to print a better error when the signatures don't match. * Don't allow `return_call`/`return_call_indirect` instructions in the parser unless the tail-call feature is enabled. * Support folding of `return_call`/`return_call_indirect` Fixes #929.
* Add more bulk memory tests; use vars for segments (#930)Ben Smith2018-10-151-0/+5
| | | | | | | | | | | | | | | | | | | | * Allow for names in data/elem segments: ``` (data $foo (i32.const 0) "abcdef") ``` * These names can be referenced by the memory/table instructions that operate on segments: ``` memory.drop $foo ``` * Fix running wasm-objdump with bulk-memory instructions * Check for valid data/elem segments in validation * Check that bulk-memory is enabled when parsing text Partial fix for #928; still needs interpreter checks too.
* Implemented tail call instructions: (#926)Francis McCabe2018-10-121-0/+26
| | | | | | return_call return_call_indirect with some simple tests thereof.
* Add bulk memory opcode definitions (#927)Alex Crichton2018-10-121-12/+84
| | | | | | | | | | | | This commit starts to add support in wabt's various tools for the upcoming [bulk memory proposal][1]. This is based off the current proposal's overview, although these may get tweaked over time! This is also the first time I've significantly contributed to wabt, and what I thought would be a relatively simple addition ended up being much larger than I imagined! I didn't add many negative tests yet but if more tests are desired please let me know! [1]: https://github.com/webassembly/bulk-memory-operations
* Require reserved instruction bytes to be one byte (#922)Ben Smith2018-10-051-6/+6
| | | | | The spec requires that the reserved bytes in `call_indirect`, `memory.grow`, and `memory.size` to be one zero byte. This means that we cannot accept `0x80 0x00`, or other "long" LEB128 encodings of zero.
* Replace ErrorHandler with Errors and FormatErrors*Ben Smith2018-09-041-1/+2
| | | | | | | | | | | | | `ErrorHandler` complicated all error handling in wabt, since it was callback-based. Callbacks would be useful if we ever wanted to change behavior when an error occurred, but instead all that the handler ever did was write the errors to stdout/stderr or to a buffer. This change adds a new class `Error`, which contains an `ErrorLevel`, a `Location` and an error message. It also replaces ErrorHandler with `Errors` (a typedef for `std::vector<Error>`), and adds a couple of functions that can format a list of `Errors` for output: `FormatErrorsTo{String,File}`.
* Pass Option structs by const reference (#888)Ben Smith2018-08-071-21/+21
|
* Fix integer overflow w/ too many locals (#862)Ben Smith2018-06-151-0/+4
| | | The maximum number of locals in a function is 2**32-1.
* Add support for multi-value proposal (#861)Ben Smith2018-06-141-41/+51
| | | | | | | | | | | | | | | Use the `--enable-multi-value` flag to enable. A lot of code already "worked" with multi-value, and just needed to remove the restrictions. Most of the other changes are modifying the callback APIs to be more general, e.g. taking more than 1 result type. * Types are now stored as the negative values; this works nicely with the encoding of inline function types (used for block signatures), which are always positive values. * Remove `BlockSignature` and use `BlockDeclaration` instead, which is just a typedef to `FuncSignature`. This allows for explicit or implicit type specifications on the block signatures. * Allow for >1 "keep" values in the DropKeep interpreter instruction
* Add support for new relocation types used in DWARF sections (#846)Sam Clegg2018-05-291-0/+8
|
* Update spec tests; rename {grow,current}_memory (#849)Ben Smith2018-05-271-8/+8
| | | | | | | | | `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.
* Remove old sub-sections types from linking section (#840)Sam Clegg2018-05-171-12/+0
|
* Print "warning" for ignored custom section errors (#843)Ben Smith2018-05-161-7/+20
| | | | | | | The previous message said "error", which makes it look like the output is not created, so change the message to "warning" instead. The error handling code is pretty ugly and can use a refactor, but that would be a much larger change.
* Fix broken version check on metadata section (#841)Sam Clegg2018-05-141-1/+1
|
* Fix bug with --ignore-custom-section-errors flag (#837)Ben Smith2018-05-141-1/+4
| | | | | If the `stop_on_first_error` flag was set, it would still stop reading the wasm file, even if `--ignore-custom-section-errors` flag was set.
* Add flag to ignore errors in custom sections (#833)Ben Smith2018-05-071-17/+62
| | | | | | | | | | | | | If a wasm engine fails to parse a custom section, it must not be an error. In wabt we often won't want to continue if a custom section can't be parsed, but it still may be useful to be able to continue. This change adds a new flag `--ignore-custom-section-errors` to `wasm2wat` and `wasm-validate`, which will partially parse a custom section with errors. This could lead to some strange behavior (partially completed data structures), but generally should be safe to do. See issue #378 and the discussion on pull #830 for more info.
* Refer to target section by index in relocation section (#830)Sam Clegg2018-05-031-8/+6
| | | | Also add parsing of linking metadata version.
* Read and write module names in the names section (#831)Ben Smith2018-05-011-0/+8
|
* Don't allow a local decl count of 0 (#827)Ben Smith2018-04-101-0/+1
| | | | | | Also clean up `LocalTypes` a bit, so we can ensure that `decls_` never has a count of 0. Fixes issue #826. Thanks for finding @opticaliqlusion!
* Don't allow the `v128` type without the simd flag (#824)Ben Smith2018-04-041-3/+8
| | | See issue #823.
* Use `ReadCount` function in BinaryReader (#821)Ben Smith2018-03-281-20/+38
| | | | | | | | See https://github.com/WebAssembly/wabt/issues/760 for more info. We assume that a count precedes a list of items that are at least one byte that are all contained in the same section. As a result, we can do an up-front check to prevent over-allocation. This is the same technique that the spec interpreter uses.
* Run clang-format over all the files (#814)Ben Smith2018-03-161-7/+6
| | | | I also fixed some for/if to use braces if I noticed it. This is a non-functional change.
* SIMD v8x16.shuffle implementation. (#811)lizhengxing2018-03-151-0/+9
|
* Simd Replace Lane instructions implementation. (#809)lizhengxing2018-03-151-1/+7
| | | | | | | | | Including: i8x16.replace_lane i16x8.replace_lane i32x4.replace_lane i64x2.replace_lane f32x4.replace_lane f64x2.replace_lane
* Simd remaining Extract Lane instructions implementation. (#806)lizhengxing2018-03-151-1/+8
| | | | | | | | | | Including: i8x16.extract_lane_u i16x8.extract_lane_s i16x8.extract_lane_u i32x4.extract_lane i64x2.extract_lane f32x4.extract_lane f64x2.extract_lane
* Simd i8x16.extract_lane_s instruction implementation. (#802)lizhengxing2018-03-131-0/+9
| | | | | Including: 1. All necessary code for SIMD lanes accessing. 2. i8x16.extract_lane_s implementation.
* SIMD v128.load/v128.store implementation. (#801)lizhengxing2018-03-091-2/+4
|
* SIMD Floating point to integer with saturation implementation. (#797)lizhengxing2018-03-071-0/+4
| | | | | | | Including: i32x4.trunc_s/f32x4:sat i32x4.trunc_u/f32x4:sat i64x2.trunc_s/f64x2:sat i64x2.trunc_u/f64x2:sat
* SIMD Integer to floating point conversion implementation. (#795)lizhengxing2018-03-061-0/+5
| | | | | | | Including: f32x4.convert_s/i32x4 f32x4.convert_u/i32x4 f64x2.convert_s/i64x2 f64x2.convert_u/i64x2
* SIMD (f32x4/f64x2).sqrt implementation. (#789)lizhengxing2018-03-051-0/+2
|