summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.h
Commit message (Collapse)AuthorAgeFilesLines
...
* QFMA/QFMS instructions (#2328)Thomas Lively2019-09-031-8/+14
| | | | | | | | | Renames the SIMDBitselect class to SIMDTernary and adds the new {f32x4,f64x2}.qfm{a,s} ternary instructions. Because the SIMDBitselect class is no more, this is a backwards-incompatible change to the C interface. The new instructions are not yet used in the fuzzer because they are not yet implemented in V8. The corresponding LLVM commit is https://reviews.llvm.org/rL370556.
* Add atomic.fence instruction (#2307)Heejin Ahn2019-08-271-0/+6
| | | | | | | This adds `atomic.fence` instruction: https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#fence-operator This also fix bugs in `atomic.wait` and `atomic.notify` instructions in binaryen.js and adds tests for them.
* Add initial support for anyref as an opaque type (#2294)Jay Phelps2019-08-201-0/+2
| | | | | | | | | | | | | Another round of trying to push upstream things from my fork. This PR only adds support for anyref itself as an opaque type. It does NOT implement the full [reference types proposal](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md)--so no table.get/set/grow/etc or ref.null, ref.func, etc. Figured it was easier to review and merge as we go, especially if I did something fundamentally wrong. *** I did put it under the `--enable-reference-types` flag as I imagine that even though this PR doesn't complete the full feature set, it probably is the right home. Lmk if not. I'll also be adding a few github comments to places I want to point out/question.
* Add basic exception handling support (#2282)Heejin Ahn2019-08-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds basic support for exception handling instructions, according to the spec: https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md This PR includes support for: - Binary reading/writing - Wast reading/writing - Stack IR - Validation - binaryen.js + C API - Few IR routines: branch-utils, type-updating, etc - Few passes: just enough to make `wasm-opt -O` pass - Tests This PR does not include support for many optimization passes, fuzzer, or interpreter. They will be follow-up PRs. Try-catch construct is modeled in Binaryen IR in a similar manner to that of if-else: each of try body and catch body will contain a block, which can be omitted if there is only a single instruction. This block will not be emitted in wast or binary, as in if-else. As in if-else, `class Try` contains two expressions each for try body and catch body, and `catch` is not modeled as an instruction. `exnref` value pushed by `catch` is get by `pop` instruction. `br_on_exn` is special: it returns different types of values when taken and not taken. We make `exnref`, the type `br_on_exn` pushes if not taken, as `br_on_exn`'s type.
* Finalize tail call support (#2246)Thomas Lively2019-07-231-2/+22
| | | | Adds tail call support to fuzzer and makes small changes to handle return calls in multiple utilities and passes. Makes larger changes to DAE and inlining passes to properly handle tail calls.
* Rename except_ref type to exnref (#2224)Heejin Ahn2019-07-141-2/+2
| | | | In WebAssembly/exception-handling#79 we agreed to rename `except_ref` type to `exnref`.
* Minimal Push/Pop support (#2207)Alon Zakai2019-07-031-0/+21
| | | | | | | This is the first stage of adding support for stacky/multivaluey things. It adds new push/pop instructions, and so far just shows that they can be read and written, and that the optimizer doesn't do anything immediately wrong on them. No fuzzer support, since there isn't a "correct" way to use these yet. The current test shows some "incorrect" usages of them, which is nice to see that we can parse/emit them, but we should replace them with proper usages of push/pop once we actually have those (see comments in the tests). This should be enough to unblock exceptions (which needs a pop in try-catches). It is also a step towards multivalue (I added some docs about that), but most of multivalue is left to be done.
* Limit interpreter depth in precompute, but not when running whole modules ↵Alon Zakai2019-07-011-15/+25
| | | | | | | (#2191) Keep limiting in precompute as before: that is useful since that pass is run as part of normal compilation, and we want to avoid native stack limits on all platforms. Also that pass is not likely to find any pattern of size 50 of higher that it can't precompute as a sum of smaller pieces. Restore the 250 limit from before for interpreting entire modules, as without that the fuzzer will sometimes hit the limit and cause a false positive.
* Relax bulk memory rules (#2186)Thomas Lively2019-06-301-17/+6
| | | As decided in the recent in-person CG meeting.
* Reduce interpreter recursion limit (#2162)Alon Zakai2019-06-041-1/+1
| | | | | | | This should be small enough to work in a 512K stack on Linux, which may then be small enough to work on all common OSes. I had to update some spec tests which actually did more recursive calls, but I don't think the change reduces any relevant amount of test coverage. This may fix the Mac bot finally, as with this it passes for me on the stack size I think Macs have by default.
* Add a recursion limit for the interpreter's expression runner (#2160)Alon Zakai2019-06-031-2/+11
| | | | | We previously had one for calls (the spec tests check for infinite recursion). This is an internal limit of the interpreter, until we un-recursify it, which may make sense at some point - but it's unlikely interpreting massively-recursive things will be beneficial in the optimizer anyhow, since if it could do something with them, it could also do so on the smaller pieces iteratively.
* Reflect instruction renaming in code (#2128)Heejin Ahn2019-05-211-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Reflected new renamed instruction names in code and tests: - `get_local` -> `local.get` - `set_local` -> `local.set` - `tee_local` -> `local.tee` - `get_global` -> `global.get` - `set_global` -> `global.set` - `current_memory` -> `memory.size` - `grow_memory` -> `memory.grow` - Removed APIs related to old instruction names in Binaryen.js and added APIs with new names if they are missing. - Renamed `typedef SortedVector LocalSet` to `SetsOfLocals` to prevent name clashes. - Resolved several TODO renaming items in wasm-binary.h: - `TableSwitch` -> `BrTable` - `I32ConvertI64` -> `I32WrapI64` - `I64STruncI32` -> `I64SExtendI32` - `I64UTruncI32` -> `I64UExtendI32` - `F32ConvertF64` -> `F32DemoteI64` - `F64ConvertF32` -> `F64PromoteF32` - Renamed `BinaryenGetFeatures` and `BinaryenSetFeatures` to `BinaryenModuleGetFeatures` and `BinaryenModuleSetFeatures` for consistency.
* Add except_ref type (#2081)Heejin Ahn2019-05-071-0/+2
| | | | This adds except_ref type, which is a part of the exception handling proposal.
* clang-tidy braces changes (#2075)Alon Zakai2019-05-011-85/+170
| | | Applies the changes in #2065, and temprarily disables the hook since it's too slow to run on a change this large. We should re-enable it in a later commit.
* Apply format changes from #2048 (#2059)Alon Zakai2019-04-261-456/+830
| | | Mass change to apply clang-format to everything. We are applying this in a PR by me so the (git) blame is all mine ;) but @aheejin did all the work to get clang-format set up and all the manual work to tidy up some things to make the output nicer in #2048
* Finish bulk memory support (#2030)Thomas Lively2019-04-221-17/+72
| | | | | | | Implement interpretation of remaining bulk memory ops, add bulk memory spec tests with light modifications, fix bugs preventing the fuzzer from running correctly with bulk memory, and fix bugs found by the fuzzer.
* Refactor interpreter initialization to use bulk memory (#2025)Thomas Lively2019-04-181-254/+346
| | | | | | | | | | This corresponds to changes made to the initialization procedure in the spec. It also removes all the heavy initialization work from the external interface of the interpreter, which is a nice encapsulation win. Implementation of the interpretation of the remaining bulk memory operations and more rigorous tests of that interpretation will come in a follow-up PR.
* Use OverriddenVisitor in ExpressionRunner (#2024)Alon Zakai2019-04-171-16/+20
| | | Should prevent surprises in the future.
* Rename atomic wait/notify instructions (#1972)Heejin Ahn2019-03-301-3/+3
| | | | | | | | This renames the following: - `i32.wait` -> `i32.atomic.wait` - `i64.wait` -> `i64.atomic.wait` - `wake` -> `atomic.notify` to match the spec.
* Bulk memory operations (#1892)Thomas Lively2019-02-051-0/+24
| | | | | | Bulk memory operations The only parts missing are the interpreter implementation and spec tests.
* Code style improvements (#1868)Alon Zakai2019-01-151-1/+1
| | | | * Use modern T p = v; notation to initialize class fields * Use modern X() = default; notation for empty class constructors
* Rename `idx` to `index` in SIMD code for consistency (#1836)Thomas Lively2018-12-181-14/+14
|
* Fuzzing v128 and associated bug fixes (#1827)Thomas Lively2018-12-141-1/+1
| | | | * Fuzzing v128 and associated bug fixes
* SIMD (#1820)Thomas Lively2018-12-131-3/+199
| | | | | | | | | Implement and test the following functionality for SIMD. - Parsing and printing - Assembling and disassembling - Interpretation - C API - JS API
* Update wrap and demote literal op names (#1817)Thomas Lively2018-12-121-5/+5
| | | | | | * Update literal op names * Remove `demoteToF32` in favor of `demote`
* Implement nontrapping float-to-int instructions (#1780)Thomas Lively2018-12-041-4/+12
|
* Add v128 type (#1777)Thomas Lively2018-11-291-1/+2
|
* standardize on 'template<' over 'template <' (i.e., remove a space) (#1782)Alon Zakai2018-11-291-1/+1
|
* Remove default cases (#1757)Thomas Lively2018-11-271-6/+11
| | | | | | Where reasonable from a readability perspective, remove default cases in switches over types and instructions. This makes future feature additions easier by making the compiler complain about each location where new types and instructions are not yet handled.
* Unify imported and non-imported things (#1678)Alon Zakai2018-09-191-12/+11
| | | | | | | | | | | | | | Fixes #1649 This moves us to a single object for functions, which can be imported or nor, and likewise for globals (as a result, GetGlobals do not need to check if the global is imported or not, etc.). All imported things now inherit from Importable, which has the module and base of the import, and if they are set then it is an import. For convenient iteration, there are a few helpers like ModuleUtils::iterDefinedGlobals(wasm, [&](Global* global) { .. use global .. }); as often iteration only cares about imported or defined (non-imported) things.
* remove PageSize and HasFeature, which wasm removed a while back (#1667)Alon Zakai2018-09-121-6/+0
| | | From #1665 (a fuzz bug noticed they were not handled in stack.h).
* Mark arguments const in callExport (#1626)Alex Beregszaszi2018-07-211-6/+5
| | | The arguments is read only and therefore could be const. The immediate benefit is callers do not need to define it as a local variable (see Literal callExport(Name name)).
* Refactor interpreter (#1508)Alon Zakai2018-04-131-187/+165
| | | | | | * Move more logic to the Literal class. We now leave all the work to there, except for handling traps. * Avoid switching on the type, then the opcode, then Literal method usually switches on the type again - instead, do one big switch for the opcodes (then the Literal method is unchanged) which is shorter and clearer, and avoids that first switching.
* fix typo [ci skip]Alon Zakai (kripken)2018-04-111-1/+1
|
* Rename WasmType => Type (#1398)Alon Zakai2018-02-021-9/+9
| | | | * rename WasmType to Type. it's in the wasm:: namespace anyhow, and without Wasm- it fits in better alongside Index, Address, Expression, Module, etc.
* support i*.extend* instructions in interpreter (#1322)Alon Zakai2017-12-061-13/+18
| | | * also fixes optimizing them in Precompute
* Atomics support in interpreter + optimizer + fuzz fixes for that (#1227)Alon Zakai2017-10-201-14/+150
|
* remove unneeded code in interpreterAlon Zakai (kripken)2017-06-011-1/+0
|
* fix call depth detection in wasm-opt interpretingAlon Zakai (kripken)2017-06-011-1/+1
|
* Parsing fixes (#990)Alon Zakai2017-05-021-13/+13
| | | | | | | | | | * properly catch a bunch of possible parse errors, found by afl-fuzz * clean up wasm-interpreter, use WASM_UNREACHABLE instead of abort * detect duplicate names in function names section * detect duplicate export names
* ctor evaller (#982)Alon Zakai2017-04-281-25/+111
| | | | | Add wasm-ctor-eval, which evaluates functions at compile time - typically static constructor functions - and applies their effects into memory, saving work at startup. If we encounter something we can't evaluate at compile time in our interpreter, stop there. This is similar to ctor_evaller.py in emscripten (which was for asm.js).
* Wasm h to cpp (#926)jgravelle-google2017-03-101-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | * Move WasmType function implementations to wasm.cpp * Move Literal methods to wasm.cpp * Reorder wasm.cpp shared constants back to top * Move expression functions to wasm.cpp * Finish moving things to wasm.cpp * Split out Literal into its own .h/.cpp. Also factor out common wasm-type module * Remove unneeded/transitive includes from wasm.h * Add comment to try/check methods * Rename tryX/checkX methods to getXOrNull * Add missing include that should fix appveyor build breakage * More appveyor
* Minor improvements to the wasm-interpreter debug messages (#784)jgravelle-google2016-10-181-8/+43
| | | | | | | | | | | * Minor improvements to the wasm-interpreter debug messages 1. Indent nested blocks for more readable structure (with numeric labels to make it even clearer) 2. Print the names of the variables used for NOTE_EVALs 3. Print the values of arguments when entering a function call * Move Indenter class to wasm-interpreter.cpp
* refactor wasm.h to remove numericIndex hacks, and move indexing to the parsersAlon Zakai2016-09-211-6/+6
|
* support spectest.globalAlon Zakai2016-09-201-1/+5
|
* support module operations in shell testsAlon Zakai2016-09-171-0/+11
|
* br_if returns its valueAlon Zakai2016-09-161-3/+4
|
* use globals in asm2wasmAlon Zakai2016-09-071-4/+14
|
* get_global and set_global use a Name instead of an Index, to be more ↵Alon Zakai2016-09-071-10/+10
| | | | consistent with refering to other global objects; e.g. this avoids ordering issues with imported vs non-imported globals
* grow_memory no longer trapsAlon Zakai2016-09-071-3/+4
|