summaryrefslogtreecommitdiff
path: root/src/wasm
Commit message (Collapse)AuthorAgeFilesLines
...
* More misc ASAN fixes (#1882)Alon Zakai2019-01-222-0/+6
| | | | | | | | | | * fix buffer overflow in simple_ast.h printing. * check wasm binary format reading of function export indexes for errors. * check if s-expr format imports have a non-empty module and base. Fixes #1876 Fixes #1877 Fixes #1879
* Show a proper error on an invalid type in binary reading ; fixes #1872 (#1874)Alon Zakai2019-01-191-2/+2
|
* Emscripten stack simplification (#1870)Alon Zakai2019-01-161-12/+2
| | | | | | This takes advantage of the recent memory simplification in emscripten, where JS static allocation is done at compile time. That means we know the stack's initial location at compile time, and can apply it. This is the binaryen side of that: * asm2wasm support for asm.js globals with an initial value var X = Y; where Y is not 0 (which is what the stack now is). * wasm-emscripten-finalize support for a flag --initial-stack-pointer=X, and remove the old code to import the stack's initial location.
* Misc minor ASAN fixes (#1869)Alon Zakai2019-01-162-7/+14
| | | | | | | | | | * handle end of input in skipWhitespace in s-parser. fixes #1863 * ignore debug locations when not in a function ; fixes #1867 * error properly on invalid user section sizes ; fixes #1866 * throw a proper error on invalid call offsets in binary reading ; fixes #1865
* Code style improvements (#1868)Alon Zakai2019-01-151-2/+2
| | | | * Use modern T p = v; notation to initialize class fields * Use modern X() = default; notation for empty class constructors
* Require unique_ptr to Module::addFunctionType() (#1672)Paweł Bylica2019-01-103-7/+9
| | | | | This fixes the memory leak in WasmBinaryBuilder::readSignatures() caused probably the exception thrown there before the FunctionType object is safe. This also makes it clear that the Module becomes the owner of the FunctionType objects.
* Massive renaming (#1855)Thomas Lively2019-01-074-24/+24
| | | | | | Automated renaming according to https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
* Refactor Features code (#1848)Alon Zakai2019-01-021-3/+3
| | | Add features.h which centralizes all the feature detection code. (I'll need this in another place than the validator which is where it was til now.)
* Minor code style cleanups (#1844)Alon Zakai2019-01-021-1/+1
|
* Fix fuzzing JS glue code (#1843)Alon Zakai2018-12-271-0/+3
| | | | | | | | | After we added logging to the fuzzer, we forgot to add to the JS glue code the necessary imports so it can be run there too. Also adds legalization for the JS glue code imports and exports. Also adds a missing validator check on imports having a function type (the fuzzing code was missing one). Fixes #1842
* Rename `idx` to `index` in SIMD code for consistency (#1836)Thomas Lively2018-12-184-53/+53
|
* Fuzzing v128 and associated bug fixes (#1827)Thomas Lively2018-12-142-2/+10
| | | | * Fuzzing v128 and associated bug fixes
* wasm-emscripten-finalize: Delay function creation until after module walk ↵Sam Clegg2018-12-141-2/+11
| | | | | | | (#1828) This fixes a crash where startSave/stackRestore could be created while iterating through `module.functions`.
* wasm-emscripten-finalize: Add tableSize to metadata (#1826)Sam Clegg2018-12-141-0/+1
| | | | This allows emscripten to generate table of the correct size. Right now is simply defaults to creating a table to size 1024.
* wasm-emscripten-finalize: Don't add a table max if none is present in the ↵Sam Clegg2018-12-141-3/+6
| | | | | | input (#1825)
* SIMD (#1820)Thomas Lively2018-12-135-32/+1402
| | | | | | | | | Implement and test the following functionality for SIMD. - Parsing and printing - Assembling and disassembling - Interpretation - C API - JS API
* Don't error on too many locals - just oom (#1822)Alon Zakai2018-12-131-8/+0
| | | I think I added this error for fuzzing, but it is harmful as it prevents a module with too many locals from being loaded - if we could load it, we might be able to optimize it to have fewer locals...
* Update wrap and demote literal op names (#1817)Thomas Lively2018-12-121-11/+6
| | | | | | * Update literal op names * Remove `demoteToF32` in favor of `demote`
* wasm-emscripten-finalize: import env.STACKTOP, like asm2wasm doesAlon Zakai2018-12-111-5/+23
|
* wasm-emscripten-finalize: Fix type in JSON output (#1812)Sam Clegg2018-12-071-1/+1
|
* Add function rename utility (#1805)Alon Zakai2018-12-051-21/+1
| | | And use it in wasm-emscripten
* Format metadata json using mutliple lines for readability (#1804)Sam Clegg2018-12-051-56/+60
|
* Warn if linking section is present, as we cannot handle it yet (#1798)Alon Zakai2018-12-042-1/+4
|
* Implement nontrapping float-to-int instructions (#1780)Thomas Lively2018-12-044-29/+193
|
* Feature options (#1797)Thomas Lively2018-12-031-9/+9
| | | | Add feature flags and struct interface. Default feature set has all feature enabled.
* Add --strip that removes debug info (#1787)Alon Zakai2018-12-031-0/+15
| | | | This is sort of like --strip on a native binary. The more specific use case for us is e.g. you link with a library that has -g in its CFLAGS, but you don't want debug info in your final executable (I hit this with poppler now). We can make emcc pass this to binaryen if emcc is not building an output with intended debug info.
* wasm-emscripten-finalize: Remove stack pointer global from shared libs (#1791)Sam Clegg2018-11-301-8/+63
| | | | | | | | | | | | | The wasm backend uses a wasm global (__stack_pointer) for the shadow stack location. In order to make this work with shared libraries the main module would have to export this global and shared libraries would need to import it. This means we'd be relying of mutable globals which are not yet implemented in all browsers. This change allows is to move forward with shared libraries without mutable global support by replacing all stack pointer access in shared libraries with functions calls.
* Fuzzing: log values during execution (#1779)Alon Zakai2018-11-301-1/+1
| | | | | | | | Before we just looked at function return values when looking for differences before and after running some passes, while fuzzing. This adds logging of values during execution, which can represent control flow, monitor locals, etc., giving a lot more opportunities for the fuzzer to find problems. Also: * Clean up the sigToFunctionType function, which allocated a struct and returned it. This makes it safer by returning the struct by value, which is also easier to use in this PR. * Fix printing of imported function calls without a function type - turns out we always generate function types in loading, so we didn't notice this was broken, but this new fuzzer feature hit it.
* Add support for a mutable globals as a Feature (#1785)Sam Clegg2018-11-303-4/+14
| | | | | This picks up from #1644 and indeed borrows the test case from there.
* Cleanup shared constants (#1784)Sam Clegg2018-11-291-0/+2
|
* Add v128 type (#1777)Thomas Lively2018-11-293-0/+18
|
* standardize on 'template<' over 'template <' (i.e., remove a space) (#1782)Alon Zakai2018-11-291-2/+2
|
* Remove default cases (#1757)Thomas Lively2018-11-275-22/+42
| | | | | | 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.
* initialize binary writer debug info even without a source map, as debug info ↵Alon Zakai2018-11-261-1/+5
| | | | may exist without a source map (#1733)
* Generate sexp instruction parser (#1754)Thomas Lively2018-11-191-290/+12
| | | Also fix broken tests surfaced by the new parser.
* wasm-emscripten-finalize: Initial support for handling shared libraries (#1746)Sam Clegg2018-11-151-9/+10
| | | | In this case we won't want generate any of the normal memory helper functions (they come from the main module).
* Fix segment size validation for imported memories (#1745)Sam Clegg2018-11-151-2/+7
| | | | | | | | | | | Without this wasm-opt can't operation on emscripten-produced SIDE_MODULES's which have zero sized memory imports. Technically is not a validation failure if you have segments that are larger than your initial memory, regardless of whether you import them. For non-imported memories it can be helpful though, so leaving it in to catch those errors.
* Handle EM_ASM functions in Tables (#1739)Jacob Gravelle2018-11-141-7/+27
| | | | | Not at all sure why we're seeing any there, but it's easy enough to handle that we might as well.
* clean up unnecessary type setting in binary format loading - finalize() will ↵Alon Zakai2018-11-141-62/+61
| | | | do it properly later (#1744)
* Add wasm-emscripten-finalize flag to separate data segments into a file (#1741)Derek Schuff2018-11-141-0/+15
| | | | This writes the data section into a file suitable for use with emscripten's --memory-init-file flag
* Fix alignment in MixedAllocator (#1740)Alon Zakai2018-11-131-1/+1
| | | Necessary for simd, as we add a type with alignment >8. We were just broken on that before this PR.
* Rename tableBase/memoryBase to __table_base/__memory_base (#1731)Sam Clegg2018-11-081-2/+2
|
* add support for new call_indirect syntax ; fixes #1724 (#1725)Alon Zakai2018-11-051-8/+29
|
* Expand asmConsts metadata to fit the shape of proxying async EM_ASMs (no ↵Jacob Gravelle2018-10-251-0/+6
| | | | actual support) (#1711)
* Support 4GB Memories (#1702)Alon Zakai2018-10-153-11/+14
| | | This fixes asm2wasm parsing of the max to allow 4GB, and also changes the internal Memory::kMaxValue values to reflect that. We used to use kMaxValue to also represent "no limit", so I split that out into kUnlimitedValue.
* properly handle unreachable atomic operations, fixes a regression from #1693 ↵Alon Zakai2018-10-111-2/+2
| | | | (#1696)
* No atomic float operations (#1693)Alon Zakai2018-10-051-1/+7
| | | | | SafeHeap was emitting them, but it looks like they are invalid according to the wasm-threads spec. Fixes kripken/emscripten#7208
* More #1678 fixes (#1685)Alon Zakai2018-09-201-0/+3
| | | While debugging to fix the waterfall regressions I noticed that wasm-reduce regressed. We need to be more careful with visitFunction which now may visit an imported function - I found a few not-well-tested passes that also regressed that way.
* fix an iterator invalidation regression from #1678 (#1684)Alon Zakai2018-09-201-5/+24
| | | Fixes the 3 regressions mentioned in a comment on #1678
* Unify imported and non-imported things (#1678)Alon Zakai2018-09-195-393/+254
| | | | | | | | | | | | | | 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.