summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Fix: set_global on immutable global is invalid (#895)Ben Smith2018-08-151-1/+12
| | | | | | | | There is a spec test for this, but spectest-interp only runs the validator in `binary-reader-interp.cc`, which is different than the validator in `validator.cc`. This is necessarily so, since some checks only make sense when the module is linked or instantiated. This fixes issue #894.
* [interp] Add rot13 interpreter example (#890)Ben Smith2018-08-141-3/+187
| | | | | This demonstrates sharing memory between a WebAssembly module and the embedder.
* [interp] Simplify host module imports (#889)Ben Smith2018-08-137-376/+338
| | | | | | | | | | | | | | | | | | | | Importing from host modules used to be handled by a delegate, which is a powerful enough solution to allow for all host import behaviors, but makes the common case difficult and clunky. It also assumed that every imported function/global/etc. needed to be newly created and added to the environment, which is OK (though wasteful) for functions, but is incorrect for mutable values like memories and globals. This change simplifies the common case by providing a set of functions on `HostModule` that can be used to add exports, e.g. AppendFuncExport("add", {{Type::I32, Type::I32}, {Type::I32}}, AddFunc); A generic interface for functions is provided as well, to allow for automatically generating functions as needed. This is currently used for functions like "host.print" in `wasm-interp`.
* Pass Option structs by const reference (#888)Ben Smith2018-08-0731-116/+114
|
* [interp] Add test for trapping host functions (#887)Ben Smith2018-08-061-0/+132
| | | | | The previous change fixed a bug that occurs if a host function traps. This change adds a test for that case, both for when the host function is called directly and via `call_indirect`.
* handle traps in host functions (#886)Paul D2018-08-031-2/+2
|
* Update testsuite; enable mut. globals by default (#884)Ben Smith2018-08-035-28/+62
| | | | | | | | 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.
* Remove short option for --help (#877)Raphael Graf2018-08-022-5/+2
| | | Resolves #872
* [emscripten] Use long instead of int for ssize_t (#880)Ben Smith2018-07-251-1/+1
| | | This was recently changed in emscripten. It seems that ssize_t can be used directly now, so defining it is only necessary for MSVC.
* Fix typo in BinaryReaderLogging::OnFunctionSymbol (#867)Ben Smith2018-06-251-1/+1
| | | Fixes #866.
* Relax the check for alloca (#865)Raphael Graf2018-06-181-3/+1
| | | Resolves #864
* 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-1422-349/+545
| | | | | | | | | | | | | | | 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
* Use named offset type and clean up PushRep doc (#860)ahorn2018-06-061-3/+3
|
* Fix GCC 8 error due to `-Werror=class-memaccess`. (#858)Marvin Löbel2018-06-052-2/+4
| | | Closes #857
* Better type-check errors locs @ end of block (#856)Ben Smith2018-06-054-12/+69
| | | | | | | | | | | | | | | | | | | Some type-checking only occurs at the end of a block, but the location that is generated uses the last expression of that block. This can be confusing if there are nested blocks, e.g. ``` 1 block (result i32) 2 block 3 nop 4 end 5 end ``` This should produce an error at line 5, not line 3. This PR stores the locations of the end of a block (either the `end` or the closing parenthesis) so its easier to understand where the error occurred.
* Fix emscripten build (#855)Ben Smith2018-06-042-32/+2
| | | | | | | | | It's not correct to use `--pre-js` and `--post-js` to wrap the module in a function instance; instead we're supposed to use `-s MODULARIZE=1`. This still keeps the build as (almost) asm.js, as switching to wasm is a bit more work (we need to preload the wasm binary module). This fixes issue #853.
* [objdump] Include elem segment offset when printing table elements (#851)Sam Clegg2018-06-041-52/+60
|
* Add support for new relocation types used in DWARF sections (#846)Sam Clegg2018-05-299-8/+88
|
* Update spec tests; rename {grow,current}_memory (#849)Ben Smith2018-05-2722-8582/+8500
| | | | | | | | | `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 token enum/string mismatch; move to token.def (#845)Ben Smith2018-05-213-206/+142
| | | This fixes issue #844.
* Remove old sub-sections types from linking section (#840)Sam Clegg2018-05-177-34/+0
|
* Print "warning" for ignored custom section errors (#843)Ben Smith2018-05-1613-46/+96
| | | | | | | 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.
* wasm-objdump: Clearly distinguish undefined symbols in symbol table (#839)Sam Clegg2018-05-141-8/+7
|
* 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 some documentation for wasm2c (#803)Ben Smith2018-05-092-4/+0
| | | Also remove `WASM_RT_DEFINE_EXTERNAL`, as it doesn't seem to be used.
* Display module name in wasm-objdump (#834)Ben Smith2018-05-081-3/+19
| | | | Also Put `<>` around other names (functions, locals).
* Add flag to ignore errors in custom sections (#833)Ben Smith2018-05-078-25/+88
| | | | | | | | | | | | | 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.
* Fix one bug for converting v128.shuffle from wasm format to wat format. (#832)lizhengxing2018-05-071-1/+1
| | | | | | | | | When converting v128.shuffle from wasm format to wat format, the '$' char must be removed as the const value in v128.shuffle instruction expects a valid simd v128 const format, i.e. 0xXXX 0xXXX 0xXXX 0xXXX or Int32 Int32 Int32 Int32 otherwise it will encounter errors when converting v128.shuffle from wat format back to wasm format again.
* Refer to target section by index in relocation section (#830)Sam Clegg2018-05-037-47/+33
| | | | Also add parsing of linking metadata version.
* Read and write module names in the names section (#831)Ben Smith2018-05-019-3/+67
|
* Don't allow a local decl count of 0 (#827)Ben Smith2018-04-105-12/+22
| | | | | | 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!
* Error on running wasm2c with `--enable-*` flags (#825)Ben Smith2018-04-061-0/+12
| | | None of the feature flags are currently supported. Fixes issue #823.
* 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.
* Store local types as Type+Count pairs (#820)Ben Smith2018-03-289-60/+124
| | | | | | | | | | | | | | Since the binary format stores locals as Type+Count pairs, it is easy to generate a function with a huge number of locals. The text format has no way to compress this, so the resulting file will be huge. However, if the binary file has an error, it would be useful to be able to catch it without allocating a huge number of locals. To do so, we store all locals as Type+Count pairs in the IR as well, and provide accessor functions for getting the number of local types, the type of a particular local index, etc. This fixes issue #819.
* Windows remove _Check_Return_ annotation (#817)Michael Ferris2018-03-221-1/+1
| | | | Remove _Check_Return_ annotation on Windows because that annotation must be a prefix to the function not a suffix which was breaking the code analysis on binary-reader.cc. Couldn't find a way to reconcile clang/gcc/msvc to all use a prefix or suffix for that annotation, furthermore it is not used a lot in the project anyway.
* Add SIMD tests to {logging,tracing}-all-opcodes (#816)Ben Smith2018-03-211-6/+6
| | | | Also fix tracing for *.splat opcodes.
* Separate out wasm-rt.h and wasm-rt-impl.{c,h} (#813)Ben Smith2018-03-202-104/+2
| | | This makes it easier to use outside of running wasm2c spec tests.
* Fix typo introduced in the previous commitBen Smith2018-03-201-1/+1
|
* Realign opcode tableBen Smith2018-03-191-405/+406
| | | | Non-functional change.
* Run clang-format over all the files (#814)Ben Smith2018-03-1651-396/+436
| | | | I also fixed some for/if to use braces if I noticed it. This is a non-functional change.
* objdump: Report elem count for each elem segment (#812)Sam Clegg2018-03-161-2/+11
|
* Small cleanup to simd extract/replace lane (#810)Ben Smith2018-03-163-76/+55
| | | Also add a typecheck test.
* SIMD v8x16.shuffle implementation. (#811)lizhengxing2018-03-1526-4281/+4504
|
* Simd Replace Lane instructions implementation. (#809)lizhengxing2018-03-159-3243/+3747
| | | | | | | | | Including: i8x16.replace_lane i16x8.replace_lane i32x4.replace_lane i64x2.replace_lane f32x4.replace_lane f64x2.replace_lane
* Print locals in objdump disassembly (#808)Ben Smith2018-03-151-0/+39
| | | | Fixes issue #807.
* Simd remaining Extract Lane instructions implementation. (#806)lizhengxing2018-03-159-2896/+3304
| | | | | | | | | | 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-1326-2356/+2599
| | | | | Including: 1. All necessary code for SIMD lanes accessing. 2. i8x16.extract_lane_s implementation.