summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* Add SIMD integer min and max instructions (#2416)Thomas Lively2019-11-0115-9/+455
| | | As proposed in https://github.com/WebAssembly/simd/pull/27.
* Add EH support for DCE pass (#2415)Heejin Ahn2019-11-012-1/+45
| | | | Like an `If`, `Try` construct is reachable when either its try body or catch body is reachable. This adds support for that.
* Don't remove events used in instructions (#2412)Heejin Ahn2019-11-011-0/+12
| | | | | Previously RemoveUnusedModuleElements pass only preserved exported events and did not preserve events used in `throw` and `br_on_exn` instructions. This fixes it.
* Use absolute memory addresses for emasm string indexes. (#2408)Sam Clegg2019-10-311-25/+36
| | | | | | | | | | Before we used 0-based indexes which meant that we needed to modify the code calling the emasm function to replace the first argument. Now we use the string address itself as the index/code for the emasm constant. This allows use code to go unmodifed as the emscripten side will accept the memory address as the index/code. See: https://github.com/emscripten-core/emscripten/issues/9013
* Do not precompute SIMDLoad (#2409)Thomas Lively2019-10-301-0/+1
| | | This fixes a crash when programs containing load_splats are optimized.
* Fix BinaryenModuleAllocateAndWriteText parameter type (#2406)Irmen de Jong2019-10-282-3/+2
| | | This fixes a compiler error when trying to compile code calling this function with a C++ compiler.
* When renaming functions ensure the corresponding GOT.func entry is also ↵Sam Clegg2019-10-251-0/+7
| | | | | | renamed (#2382) Fixes https://github.com/WebAssembly/binaryen/issues/2180
* Add ModAsyncify* passes (#2404)Alon Zakai2019-10-233-1/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | These passes are meant to be run after Asyncify has been run, they modify the output. We can assume that we will always unwind if we reach an import, or that we will never unwind, etc. This is meant to help with lazy code loading, that is, the ability for an initially-downloaded wasm to not contain all the code, and if code not present there is called, we download all the rest and continue with that. That could work something like this: * The wasm is created. It contains calls to a special import for lazy code loading. * Asyncify is run on it. * The initially downloaded wasm is created by running --mod-asyncify-always-and-only-unwind: if the special import for lazy code loading is called, we will definitely unwind, and we won't rewind in this binary. * The lazily downloaded wasm is created by running --mod-asyncify-never-unwind: we will rewind into this binary, but no longer need support for unwinding. (Optionally, there could also be a third wasm, which has not had Asyncify run on it, and which we'd swap to for max speed.) These --mod-asyncify passes allow the optimizer to do a lot of work, especially for the initially downloaded wasm if we have lots of calls to the lazy code loading import. In that case the optimizer will see that those calls unwind, which means the code after them is not reached, potentially making lots of code dead and removable.
* Convert usage of Pointer_stringify to UTF8ToString (#2403)Brad Morris2019-10-231-1/+1
| | | | This fixes #2396. This converts the use of the old Pointer_stringify to the new UTF8ToString. Added a js test in kitchen-sink.js to cover this.
* Fix incorrect assert in BinaryenHostGetOperand (#2393)Brad Morris2019-10-221-1/+1
|
* Ability to list each item on Exports/Data Segments/Functions (#2386)COFFEETALES2019-10-213-0/+168
| | | Adds functionality to the C API for getting the number of items in a module and fetching them out by index.
* Move WASM_DEPRECATED so that binaryen-c.h is selfcontained. Fixes #2054 (#2399)Irmen de Jong2019-10-212-4/+7
|
* Fix autoreducing when not in the binaryen directory (#2390)Alon Zakai2019-10-173-9/+37
| | | | This uses argv[0] as the default way to find the location of the wasm binaries (wasm-reduce needs to call wasm-opt).
* Use early return in wasm-opt.cpp. NFC (#2387)Sam Clegg2019-10-151-22/+23
|
* Don't add __wasm_call_ctors to startup function list in wasm standalone mode ↵Sam Clegg2019-10-141-2/+6
| | | | | (#2384) In this mode crt1 takes care of calling it.
* Add BinaryenAddCustomSection API (#2381)Daniel Wirtz2019-10-113-0/+45
| | | | This adds a new BinaryenAddCustomSection API so a generator can add arbitrary custom sections to a module.
* Add offset parameter to BinaryenSetFunctionTable (#2380)Daniel Wirtz2019-10-113-7/+10
| | | | | | This PR adds an offset parameter to BinaryenSetFunctionTable so table elements can start at the value of an (imported constant) global. Previously, the offset was fixed to zero. As usual this is a breaking change to the C-API but backwards compatible when using the JS-API.
* Enable exnref instrumentation when EH is enabled (#2379)Heejin Ahn2019-10-111-1/+3
| | | | `exnref` is enabled by not reference type feature but exception handling feature. Sorry that I missed this in #2377.
* Don't instrument pops in InstrumentLocals (#2378)Heejin Ahn2019-10-101-0/+7
| | | | | `pop` is not a real instruction and automatically generated when reading binary and deleted when writing binary, so this does not work with instrumentation.
* Only add instrumentation to reftypes when the featureset supports it (#2377)Jacob Gravelle2019-10-101-4/+7
|
* Add support for reftypes in InstrumentLocals pass (#2375)Heejin Ahn2019-10-101-4/+16
| | | This adds support for anyref and exnref types in InstrumentLocals pass.
* Add push/pop support for anyref (#2376)Heejin Ahn2019-10-102-5/+19
| | | | This adds push/pop support for anyref. This also adds missing C API tests for push/pop.
* Make try body with multiple instructions roundtrip (#2374)Heejin Ahn2019-10-092-2/+2
| | | | | | | | | Previously we didn't print an additional block when there are multiple instructions within a `try` body, so those wast files cannot be parsed correctly, because the wast parser assumes there are two bodies within a `try` scope: a try body and a catch body. We don't need to print an additional block for a `catch` body because `(catch ...)` itself serves as a scope.
* Fix case of `windows.h` include (#2372)Mike J Innes2019-10-091-1/+1
| | | | The capitalisation causes issues on case-sensitive file systems, for example when cross-compiling binaryen for windows.
* MAIN_THREAD_EM_ASM support (#2367)Jacob Gravelle2019-10-071-71/+113
| | | | | | | | | | | | * Support for sync and async main-thread EM_ASM * Fix up import names as well * update test * fix whitespace * clang-format
* v8x16.swizzle (#2368)Thomas Lively2019-10-0315-5/+56
| | | | As specified at https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#swizzling-using-variable-indices.
* Apply the sbrk/brk value at compile time (#2366)Alon Zakai2019-09-302-2/+38
| | | | | We've had an option to set the location of the sbrk ptr, but not the value. Applying the value as well is necessary for standalone wasm, as otherwise we set it in JS.
* Add feature flags and validation to wasm-metadce (#2364)Thomas Lively2019-09-271-2/+12
| | | | | | Sometimes wasm-metadce is the last tool to run over a binary in Emscripten, and in that case it needs to know what features are enabled in order to emit a valid binary. For example it needs to know whether to emit a data count section.
* Only create `_start` if it doesn't already exist (#2363)Sam Clegg2019-09-271-0/+3
|
* SIMD load and extend instructions (#2353)Thomas Lively2019-09-2415-10/+278
| | | | | | Adds support for the new load and extend instructions. Also updates from C++11 to C++17 in order to use generic lambdas in the interpreter implementation.
* v128.andnot instruction (#2355)Thomas Lively2019-09-2413-10/+42
| | | | | As specified at https://github.com/WebAssembly/simd/pull/102. Also fixes bugs in the JS API for other SIMD bitwise operators.
* vNxM.load_splat instructions (#2350)Thomas Lively2019-09-2325-56/+479
| | | | | | | Introduces a new instruction class, `SIMDLoad`. Implements encoding, decoding, parsing, printing, and interpretation of the load and splat instructions, including in the C and JS APIs. `v128.load` remains in the `Load` instruction class for now because the interpreter code expects a `Load` to be able to load any memory value type.
* Show the unescaped name in Asyncify pattern warnings (#2351)Alon Zakai2019-09-231-3/+5
| | | | | | | | | This is part of the fix for https://logs.chromium.org/logs/emscripten-releases/buildbucket/cr-buildbucket.appspot.com/8901492015302662960/+/steps/Emscripten_testsuite__upstream__other_/0/stdout Specifically it fixes that the name shown there should not be escaped. Followup for #2344
* wasm-emscripten-finalize: Add more checking of __data_end global (#2352)Sam Clegg2019-09-231-0/+3
|
* asyncify: support *-matching in whitelist and blacklist (#2344)Beuc2019-09-232-37/+76
| | | See emscripten-core/emscripten#9381 for rationale.
* Revert part of #2281 to allow the possiblity of building under python2 (#2349)Sam Clegg2019-09-231-1/+1
| | | | | | | | Even though we do support python3 and if the python in your path happens to be python3 that will work just fine, we also want to continue to support those users who still only have python2 (i.e. mac users who are relying on the default system python). See https://github.com/emscripten-core/emsdk/issues/356
* Mark C API as dllexports on Windows (#2342)Michal Strehovský2019-09-211-905/+1022
| | | | | On Windows, symbols have to be explicitly exported to make them visible/accessible in a shared library. Binaryen.dll currently doesn't export any symbols as a result. Marking all exported methods as `BINARYEN_API` that is defined as `__declspec(dllexport)` on Windows, unless building a static library.
* Fix typo in Asyncify (#2346)Beuc2019-09-191-2/+2
|
* Add a --standalone-wasm flag to wasm-emscripten-finalize (#2333)Alon Zakai2019-09-183-1/+38
| | | The flag indicates that we want to run the wasm by itself, without JS support. In that case we don't emit JS dynCalls etc., and we also emit a wasi _start if there is a main, i.e., we try to use the current conventions in the wasm-only space.
* SIMD narrowing and widening operations (#2341)Thomas Lively2019-09-1416-25/+542
|
* SimplifyGlobals: Apply known constant values in linear traces (#2340)Alon Zakai2019-09-133-14/+83
| | | | | | | | | | | | | This optimizes stuff like (global.set $x (i32.const 123)) (global.get $x) into (global.set $x (i32.const 123)) (i32.const 123) This doesn't help much with LLVM output as it's rare to use globals (except for the stack pointer, and that's already well optimized), but it may help on general wasm. It can also help with Asyncify that does use globals extensively.
* Add asserts in Asyncify (#2338)Alon Zakai2019-09-131-7/+84
| | | | | With the optional asserts, we throw if we see an unwind begin in code that we thought could never unwind (say, because the user incorrectly blacklisted it). Helps with emscripten-core/emscripten#9389
* Replace python command with python3 (#2281)Markus Koschany2019-09-131-1/+1
|
* Fix bitselect operation in C/JS APIs (#2336)Daniel Wirtz2019-09-112-1/+3
| | | In #2328 the SIMDBitselect API has been replaced with SIMDTernary that now has Bitselect as one of multiple operations, which is currently not exposed, unlike the new QFMA/QFMS operations which are exposed. This PR adds it.
* More response file support in asyncify: whitelist/blacklist (#2335)Alon Zakai2019-09-081-2/+10
|
* Properly handle fastcomp *wasm* safe heap (#2334)Alon Zakai2019-09-061-1/+6
| | | | | Properly handle fastcomp wasm safe heap: emscripten_get_sbrk_ptr is an asm.js library function, which means it is inside the wasm after asm2wasm, and exported. Find it via the export.
* Handle sbrk import by emscripten+upstream in SafeHeap (#2332)Alon Zakai2019-09-061-10/+20
| | | | | To allow #2331 to roll, I forgot that upstream and fastcomp handle sbrk differently. This fixes that, and handles the upstream case where we import sbrk itself from JS. We can simplify this after emscripten-core/emscripten#9397 lands, however, it may also be nice to keep the backwards compatibility for running on existing wasm files in the wild.
* Print custom section contents if printable (#2326)Ingvar Stepanyan2019-09-061-0/+19
| | | This helps with debugging human-readable sections like sourceMappingURL.
* SafeHeap: Prepare for emscripten_get_sbrk_ptr (#2331)Alon Zakai2019-09-051-8/+22
| | | | | | | Currently emscripten links the wasm, then links the JS, then computes the final static allocations and in particular the location of the sbrk ptr (i.e. the location in memory of the brk location). Emscripten then imports that into the asm.js or wasm as env.DYNAMICTOP_PTR. However, this didn't work in the wasm backend where we didn't have support for importing globals from JS, so we implement sbrk in JS. I am proposing that we change this model to allow us to write sbrk in C and compile it to wasm. To do so, that C code can import an extern C function, emscripten_get_sbrk_ptr(), which basically just returns that location. The PostEmscripten pass can even apply that value at compile time, so we avoid the function call, and end up in the optimal place, see #2325 and emscripten PRs will be opened once other stuff lands. However, the SafeHeap pass must be updated to handle this, or our CI will break in the middle. This PR fixes that, basically making it check if env.DYNAMICTOP_PTR exists, or if not then looking for env.emscripten_get_sbrk_ptr, so that it can handle both.
* [wasm2js] Fix memory.size (#2330)Alon Zakai2019-09-051-11/+19
| | | | | | | We emitted the __wasm_memory_size function only when memory growth was enabled, but it can be used without that too. In theory we could only emit it if either memory growth or memory.size is used, but I think we can expect JS minifiers to do that later. Also fix a test suite bug - the check/auto_update script didn't run all the wasm2js tests when you run it with argument wasm2js (it used that as the list of tests, instead of the list of files, which confused me here for a while...).