summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* Relax bulk memory rules (#2186)Thomas Lively2019-06-301-17/+6
| | | As decided in the recent in-person CG meeting.
* Bysyncify: allow wildcard endings in import list (#2190)Alon Zakai2019-06-303-9/+82
| | | This allows us to do things in emscripten like note that all env.invoke_* functions are important.
* Bysyncify: fix skipping of flattened if condition (#2187)Alon Zakai2019-06-301-2/+5
| | | | | We assigned it to a local, but didn't run maybeSkip on it. As a result, it was executed during rewinding, which broke restoring the saved value. Found by the fuzzer.
* wip (#2189)Alon Zakai2019-06-301-1/+1
|
* Bysyncify: ensure memory exists (#2188)Alon Zakai2019-06-301-0/+5
| | | | | We need memory in order to read and write rewinding info, so add it if the module didn't have any memory at all. Found by the fuzzer.
* Bysyncify: optimize better by coalescing before instrumenting control flow ↵Alon Zakai2019-06-251-28/+138
| | | | | | | | | (#2183) This results in better code sizes on many testcases, sometimes much better. For example, on SQLite the 150K function has only 27 locals instead of 3,874 which it had before (!). This also reduces total code size on SQLite by 15%. The key issue is that after instrumenting control flow we have a lot bigger live ranges. This must be done rather carefully, as we need to introduce some temp locals early on (for breaking up ifs, for call return values, etc.).
* Skip imports in table during RemoveImports (#2181)Thomas Lively2019-06-241-1/+12
| | | | This prevents RemoveImports from producing an invalid module that references functions that no longer exist.
* Bysyncify: Don't instrument functions that call bysyncify_* directly (#2179)Alon Zakai2019-06-211-12/+52
| | | | | Those functions are assumed to be part of the runtime. Instrumenting them would mean nothing can work. With this fix, bysyncify is useful with pure wasm, and not just through imports.
* Bysyncify: add ignore-imports and ignore-indirect options (#2178)Alon Zakai2019-06-212-35/+65
| | | ignore-imports makes it not assume that any import may unwind/rewind the stack. ignore-indirect makes it not assume any indirect call can reach an unwind/rewind (which means, it assumes there is not an indirect call on the stack while unwinding).
* Make feature section errors into warnings (#2175)Alon Zakai2019-06-181-14/+18
| | | | Otherwise there is no way to view a wasm object file in binaryen.
* Bysyncify: bysyncify_stop_unwind (#2173)Alon Zakai2019-06-161-13/+30
| | | Add a method to note the stopping of an unwind. This is enough to implement coroutines. Includes an example of coroutine usage in the test suite.
* Bysyncify: async transform for wasm (#2172)Alon Zakai2019-06-159-5/+981
| | | | | | | | | This adds a new pass, Bysyncify, which transforms code to allow unwind and rewinding the call stack and local state. This allows things like coroutines, turning synchronous code asynchronous, etc. The new pass file itself has a large comment on top with docs. So far the tests here seem to show this works, but this hasn't been tested heavily yet. My next step is to hook this up to emscripten as a replacement for asyncify/emterpreter, see emscripten-core/emscripten#8561 Note that this is completely usable by itself, so it could be useful for any language that needs coroutines etc., and not just ones using LLVM and/or emscripten. See docs on the ABI in the pass source.
* Fix BinaryenRemoveEvent naming in binaryen-c.h (#2171)Daniel Wirtz2019-06-121-1/+1
| | | | | | * Fix BinaryenRemoveEvent naming in binaryen-c.h * Enable ERROR_ON_UNDEFINED_SYMBOLS=1 in build-js.sh
* Enable compiling on GCC < 5 (#2149)Matt Topol2019-06-121-1/+1
| | | _ISOC11_SOURCE is the preprocessor flag that specifies whether or not aligned_alloc is defined and exists. While GCC versions lower than 5 do include C++11 and C++14 constructs, they do not include std::aligned_alloc, so this check allows compiling on those versions of GCC by defaulting down to posix_memalign in those situations appropriately.
* Refactor -g param parsing (#2167)Alon Zakai2019-06-073-15/+9
| | | | | Use one shared location in optimization-options as much as possible. This also allows tools like wasm2js to receive that flag.
* Copy debug info when inlining (#2168)Alon Zakai2019-06-072-6/+70
|
* Fix bug and leak in relooper merge consecutive blocks (#2159)hobby82019-06-071-2/+9
| | | | | | | | | | | | | | | | | | Fixes in Relooper merge consecutive blocks: Entry block getting removed when it is part of a loop: bb1->AddBranchTo(bb2, nullptr); bb1->AddBranchTo(bb3, ...); bb2->AddBranchTo(bb1, nullptr); bb3->AddBranchTo(bb4, nullptr); relooper.AddBlock(bb1); relooper.AddBlock(bb2); relooper.AddBlock(bb3); relooper.AddBlock(bb4); relooper.Calculate(bb1); Branches memory leak
* Use splatted zero vector in makeZero (#2164)Thomas Lively2019-06-051-0/+8
| | | | | This prevents the optimizer from producing v128.const instructions, which are not supported by V8 at this time.
* 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.
* Use BinaryIndexes instead of copies in BinaryWriter (NFC) (#2161)Heejin Ahn2019-06-043-29/+13
|
* 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.
* Add event section (#2151)Heejin Ahn2019-05-3124-16/+810
| | | | | | | | | | | | | | | | | | This adds support for the event and the event section, as specified in https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model. Wasm events are features that suspend the current execution and transfer the control flow to a corresponding handler. Currently the only supported event kind is exceptions. For events, this includes support for - Binary file reading/writing - Wast file reading/writing - Binaryen.js API - Fuzzer - Validation - Metadce - Passes: metrics, minify-imports-and-exports, remove-unused-module-elements
* Add --print-function-map to print out a map of function index to name (#2155)Alon Zakai2019-05-314-0/+50
| | | | | | | | | | * work * fix * fix * format
* Un-recursify OptimizeInstructions::optimizeAddedConstants (#2157)Alon Zakai2019-05-311-16/+27
| | | | | This helps avoid issues with smaller stack sizes on some OSes. Should fix the last Mac test failure on emscripten-releases CI (other.test_js_function_names_are_minified, which happens to have massively-nested additions of constants).
* Refactor typeuse parsing more (NFC) (#2146)Heejin Ahn2019-05-291-10/+18
| | | | | Now `parseTypeUse` always returns `FunctionType*` and params/return pair and makes sure the two are consistent, so the caller does not have to populate params/results when only `(type)` is specified.
* Add Features.MVP and Features.All to binaryen.js (#2148)Heejin Ahn2019-05-293-0/+10
| | | | This adds `Features.MVP` and `Features.All` to binaryen.js and make test cases use it.
* Simplify function lists in RemoveUnusedModuleElements (NFC) (#2147)Heejin Ahn2019-05-281-9/+1
| | | | It looks there's no need to maintain `functions` and `functionImports` separately.
* wasm2js: Switch optimizations (#2141)Alon Zakai2019-05-281-8/+202
| | | | | This pattern-matches towers of blocks + a br_table into a JS switch. This is much smaller in code size and also avoids heavy nesting that can exceed the recursion limits of JS parsers. This is not enough yet, because it pattern-matches very specifically. In reality, switches can look slightly different. Followup PRs will extend this. For now, this passes the test suite (what passed before - not including the massive-switch tests) + fuzzing so it's a good start.
* Refactor type and function parsing (#2143)Heejin Ahn2019-05-246-210/+242
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Refactored & fixed typeuse parsing rules so now the rules more closely follow the spec. There have been multiple parsing rules that were different in subtle ways, which are supposed to be the same according to the spec. - Duplicate types, i.e., types with the same signature, in the type section are allowed as long as they don't have the same given name. If a name is given, we use it; if type name is not given, we generate one in the form of `$FUNCSIG$` + signature string. If the same generated name already exists in the type section, we append `_` at the end. This causes most of the changes in the autogenerated type names in test outputs. - A typeuse has to be in the order of (type) -> (param) -> (result), if more than one of them exist. In case of function definitions, (local) has to be after all of these. Fixed some test cases that violate this rule. - When only (param)/(result) are given, its type will be the type with the smallest existing type index whose parameter and result are the same. If there's no such type, a new type will be created and inserted. - Added a test case `duplicate_types.wast` to test type namings for duplicate types. - Refactored `parseFunction` function. - Add more overrides to helper functions: `getSig` and `ensureFunctionType`.
* Add `getGlobal` to binaryen.js (#2142)Heejin Ahn2019-05-243-2/+16
| | | | | We have `getFunction`, but not `getGlobal` because its name clashed with APIs for the deprecated instruction `get_global`. Now we have reflected instruction renaming in code, we can add it for consistency.
* Show line/col for parsing exceptions in gen-s-parser (#2138)Heejin Ahn2019-05-241-1/+1
|
* Inlining: exposed inlining thresholds as command-line parameters. (#2125)Wouter van Oortmerssen2019-05-233-23/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Inlining: exposed inlining thresholds as command-line parameters. This will allow easier experimentation with optimal settings. Also tweaked the default logic slightly to always inline single caller functions up to a certain size. The command-line arguments were tested to have the desired effect for example by the Makefile change in this commit: https://github.com/aardappel/lobster/commit/39ae393e27ff363ab095bbb26c90d6fe17570104 which in turn relies on: https://github.com/emscripten-core/emscripten/pull/8635 * Grouped inlining options & reverted defaults. Now uses same defaults for inlining as before for the sake of not having to redo a lot of tests. Added FIXME to indicate that the current inlining logic needs fixing. * Fixed default values now pulled from code. * clang-format
* Factor out elementStartsWith (NFC) (#2137)Heejin Ahn2019-05-233-32/+38
| | | | | Checking if a first string matches a certain string within a list element appears many times within the parser, so extracted it as a helper function.
* Add BinaryenModuleWriteSExpr to write a module to a string in s-expr format ↵Siddharth2019-05-212-0/+49
| | | | | (#2106) Fixes #2103.
* Don't use colons in filenames (#2134)Derek Schuff2019-05-212-4/+4
| | | Windows filenames can't contain colons. Use @ instead for passing arguments to passes.
* Reflect instruction renaming in code (#2128)Heejin Ahn2019-05-2180-1061/+1049
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* Remove old import/export parsing routines (NFC) (#2127)Heejin Ahn2019-05-211-26/+1
| | | These formats don't seem to be used now.
* Refactor type/signature/local parsing methods (NFC) (#2129)Heejin Ahn2019-05-212-89/+111
| | | | | - Created `parseParamOrLocals`, `parseNamedParamOrLocals`, `parseResult`, and `parseTypeRef` and make other methods use them - Deleted some unnecessary member variables
* Fix AvoidReinterprets on reinterpreted loads of fewer than the full size (#2123)Alon Zakai2019-05-171-3/+13
| | | | | | * fix * fix style
* Fix a vacuum bug with loads changing the type (#2124)Alon Zakai2019-05-171-1/+4
| | | This happened on wasm2js, where implicit traps are off by default, and this bug is specific to that (less-tested) mode.
* Fix misc. things for globals (#2119)Heejin Ahn2019-05-172-3/+2
|
* rename some C++ locals to camelCase for consistency (#2122)Alon Zakai2019-05-171-15/+15
|
* fix a dae fuzz bug (#2121)Alon Zakai2019-05-171-0/+2
|
* Fix an infinite loop in avoid-reinterprets in unreachable code with loops of ↵Alon Zakai2019-05-171-0/+7
| | | | | gets (#2118) In unreachable code, a get may have a single set that assigns to it, and that set may be assigned to by that very get.
* Features C/JS API (#2049)Thomas Lively2019-05-174-3/+78
| | | | | Add feature handling to the C/JS APIs. No features are enabled by default, so all used features will have to be explicitly enabled in order for modules to validate.
* Allow color API to enable and disable colors (#2111)Siddharth2019-05-1714-15/+27
| | | | | | This is useful for front-ends which wish to selectively enable or disable coloring. Also expose these APIs from the C API.
* Add a fuzzer option to not emit code with OOB loads/indirect calls (#2113)Alon Zakai2019-05-172-2/+15
| | | | | This is useful for wasm2js, as we don't emit traps for OOB loads etc. like wasm (like we don't trap on bad float-to-int, as it's too hard in JS, and it's undefined behavior in C anyhow). It may also help general fuzzing, as those traps may make other interesting patterns less likely. Also add more wasm2js support in the fuzzer, which includes using this no-OOB option.
* Add globals to metrics (#2110)Heejin Ahn2019-05-161-2/+2
|
* wasm2js: more coercion optimization (#2109)Alon Zakai2019-05-151-18/+39
|
* wasm2js: remove unnecessary labels (#2108)Alon Zakai2019-05-151-1/+32
|