summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Fast validation (#1204)Alon Zakai2017-10-023-377/+481
| | | | | | | This makes wasm validation parallel (the function part). This makes loading+validating tanks (a 12MB wasm file) 2.3x faster on a 4-core machine (from 3.5 to 1.5 seconds). It's a big speedup because most of loading+validating was actually validating. It's also noticeable during compilation, since we validate by default at the end. 8% faster on -O2 and 23% on -O0. So actually fairly significant on -O0 builds. As a bonus, this PR also moves the code from being 99% in the header to be 1% in the header.
* Share trap mode between asm2wasm and s2wasm (#1168)jgravelle-google2017-10-0213-300/+546
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Extract Asm2WasmBuilder::TrapMode to shared FloatTrapMode * Extract makeTrappingI32Binary * Extract makeTrappingI64Binary * Extract asm2wasm test script into scripts/test/asm2wasm.py This matches s2wasm.py, and makes iterating on asm2wasm slightly faster. * Simplify callsites with an arg struct * Combine func adding across i32 and i64 * Support f32-to-int in asm2wasm * Add BinaryenTrapMode pass, run pass from s2wasm * BinaryenTrapMode pass takes trap context as a parameter * Pass fully supports non-trapping binary ops * Defer adding functions until after iteration (hackily) * Update asm2wasm to work with deferred function adding, rebuild tests * Extract makeTrappingFloatToInt32 * Extract makeTrappingFloatToInt64 * Add unary conversions to trap pass * Add functions in the pass itself * Set s2wasm trap mode with command-line arguments * Print BINARYEN_PASS_DEBUG state when testing * Get asm2wasm using the BinaryenTrapMode pass instead of handling it inline * Also handle f32 to int in asm2wasm * Make BinaryenTrapMode only need a FloatTrapMode from the caller * Just pass the current binary Expression directly * Combine makeTrappingI32Binary with makeTrappingI64Binary * Pass Unary expr to makeTrappingFloatToInt32 * Unify makeTrappingFloatToInt32 & 64 * Move makeTrapping* functions inside BinaryenTrapMode, make addedFunctions non-static * Remove FloatTrapContext * Minor cleanups * Extract some smaller subfunctions * Emit name switch/casing, rename is32Bit to isI64 for consistency * Rename BinaryenTrapMode to FloatTrap, make trap mode a nested enum * Add some comments explaining why FloatTrap is non-parallel * Rename addedFunctions to generatedFunctions for precision * Rename move and split float-clamp.h to passes/FloatTrap.(h|cpp) * Use builder instead of allocator * Instantiate trap handling passes via the pass manager * Move passes/FloatTrap.h to ast/trapping.h * Add helper function to add trap-handling passes * Add trap mode pass tests * Rename FloatTrap.cpp to TrapMode.cpp * Add s2wasm trap mode tests. Force float->int conversion to be signed * Add trapping_sint_div_s test to unit.asm.js * Fix flake8 issues with test scripts * Update pass description comment * Extract building functions methods * Make generate functions into top-level functions * Add GeneratedTrappingFunctions class to manage function/import additions * Move ensure/makeTrapping functions outside class scope * Use GeneratedTrappingFunctions to add immediately in asm2wasm mode * Remove trapping_sint_div_s test We only added it to test that trapping divisions would get constant-folded at the correct time. Now that we're not changing the timing of trapping modes, the test is unneeded (and problematic). * Review feedback, add validator/*.wasm to .gitignore * Add support for unsigned float-to-int conversion * Use opcode directly instead of bools * Update s2wasm clamp test for unsigned ftoi
* fix regression from 45d88e3ef5f895b2fde77e3588f84d66e67bdd88 - left may not ↵Alon Zakai2017-10-021-1/+1
| | | | exist, need to return curr->left, after that change (#1207)
* fix optimize-instructions handling of shifts by a zero or of a zero when ↵Alon Zakai2017-10-021-2/+3
| | | | combining added constants (#1206)
* Thread fixes (#1205)Alon Zakai2017-10-021-1/+8
| | | | | | * don't use multiple threads in torture tests, which are parallel anyhow * if we fail to create a thread, don't use multiple threads
* Optimize wasm reading (#1202)Alon Zakai2017-09-282-2/+10
| | | * optimize wasm reading: use a set of the breaks we've seen, don't rescan blocks to see if they have breaks to them
* fix ExpressionAnalyzer::equals on consts, they need to be bitwise equal, ↵Alon Zakai2017-09-271-1/+3
| | | | i.e., 0 != -0
* fuzzing improvements:Alon Zakai2017-09-272-4/+31
| | | | | | | | * randomize initial memory * low chance to have tiny blocks * decent chance to have a branch back to the loop top
* fix dce bug with not updating the parent when turning a node unreachable (#1198)Alon Zakai2017-09-252-23/+36
|
* wasm2asm fixes for coercion on rotl/rotr/ctz/popcnt calls, and refactor the ↵Alon Zakai2017-09-233-29/+48
| | | | name of constants to include the WASM_ prefix so as not to collide with constants for the unprefixed values (#1199)
* Refactor i64 lowering to use RAII temp vars (#1177)Thomas Lively2017-09-231-173/+190
| | | | | | * Refactor i64 lowering to use RAII temp vars * Always generate trampoline blocks for Switch lowering
* Make localNames into a map (#1189)Thomas Lively2017-09-234-16/+20
|
* when we re-finalize a function body, we may have changed it from unreachable ↵Alon Zakai2017-09-221-0/+9
| | | | to none. that is bad if the function has a return value, as unreachable was ok but none is not. in that case, we must add an unreachable (#1193)
* Update text syntax for shared memory limits (#1197)Derek Schuff2017-09-224-16/+23
| | | | Following WebAssembly/threads#58 e.g. (memory $0 23 256 shared) is now (memory $0 (shared 23 256))
* remove implicit fallthroughs (#1194) (#1196)Jeremy Day2017-09-202-3/+12
|
* Expressions should not appear twice in the ast (#1191)Alon Zakai2017-09-183-1/+23
|
* Add missing finalize() call to C API for call_indirect (#1184)Sergey Pepyakin2017-09-141-0/+1
|
* Add missing prototypes for globals in binaryen-c.h (#1183)Sergey Pepyakin2017-09-132-2/+8
| | | | | | * Add missing prototypes for globals in binaryen-c.h * Use int8_t for mutable_
* disambiguate hash usage (#1182)Alon Zakai2017-09-132-3/+3
|
* Avoid new blocks in binary reading/writing (#1165)Alon Zakai2017-09-122-23/+39
| | | | | | * don't emit a toplevel block if we don't need to, as in wasm it is a list context * don't create unnecessary blocks in wasm reading
* precompute-propagate pass (#1179)Alon Zakai2017-09-1213-276/+624
| | | | | | | Implements #1172: this adds a variant of precompute, "precompute-propagate", which also does constant propagation. Precompute by itself just runs the interpreter on each expression and sees if it is in fact a constant; precompute-propagate also looks at the graph of connections between get and set locals, and propagates those constant values. This helps with cases as noticed in #1168 - while in most cases LLVM will do this already, it's important when inlining, e.g. inlining of the clamping math functions. This new pass is run when inlining, and otherwise only in -O3/-Oz, as it does increase compilation time noticeably if run on everything (and for almost no benefit if LLVM has run). Most of the code here is just refactoring out from the ssa pass the get/set graph computation, so it can now be used by both the ssa pass and precompute-propagate.
* Make several derived classes final (#1180)Derek Schuff2017-09-122-7/+6
| | | | | | | Recent versions of clang turn on -Wdelete-non-virtual-dtor at our warning level, which fires when deleting a non-final class that has virtual functions but a non-virtual destructor. Pre-C++11 standard rule of thumb is to just always have a virtual destructor if there are virtual functions, but C++11 final is even better since it may allow for devirtualization optimizations.
* Const hoisting (#1176)Alon Zakai2017-09-1211-9/+174
| | | A pass that hoists repeating constants to a local, and replaces their uses with a get of that local. This can reduce binary size, but can also *increase* gzip size, so it's mostly for experimentation and not used by default.
* asm2wasm atomics (#1171)Alon Zakai2017-09-115-2/+168
| | | | | | | | | | * translate asm.js atomics into wasm atomics * fix wasm-builder atomic load emitting, the alignment is the loaded size, not the output size * don't require code for each node type in vaccuum, for non-mentioned nodes, assume we can't optimize them out * support atomics in hashing, comparing, and copying
* Merge pull request #1175 from WebAssembly/fuzzAlon Zakai2017-09-104-14/+113
|\ | | | | Fuzzer improvements + fixes
| * code-folding must propagate types when it optimizes somethingAlon Zakai2017-09-091-3/+6
| |
| * more special constants classes in fuzzingAlon Zakai2017-09-061-3/+24
| |
| * when if arms are identical, merging them may change the type of the if, if ↵Alon Zakai2017-09-061-6/+23
| | | | | | | | it has a forced type
| * initial call_indirect support in ttf modeAlon Zakai2017-09-062-2/+60
| |
* | Add support for sign-extension operators from threading proposal (#1167)Derek Schuff2017-09-068-4/+49
| | | | | | These are not atomic operations, but are added with the atomic operations to keep from having to define atomic versions of all the sign-extending loads (an atomic zero-extending load + signext operation can be used instead).
* | clean up untaken => unreachable, as well as unnecessary named stuff in ↵Alon Zakai2017-09-067-28/+21
|/ | | | validation that was from when we differentiated reachable from unreachable breaks (#1166)
* Return to more structured type rules for block and if (#1148)Alon Zakai2017-09-059-89/+123
| | | | | | | | * if a block has a concrete final element (or a break with a value), then even if it has an unreachable child, keep it with that concrete type. this means we no longe allow the silly case of a block with an unreachable in the middle and a concrete as the final element while the block is unreachable - after this change, the block would have the type of the final element * if an if has a concrete element in one arm, make it have that type as a result, even if the if condition is unreachable, to parallel block * make type rules for brs and switches simpler, ignore whether they are reachable or not. whether they are dead code should not affect how they influence other types in our IR.
* wasm-reduce tool (#1139)Alon Zakai2017-09-018-11/+711
| | | Reduce an interesting wasm to a smaller still interesting wasm. This takes an arbitrary command to run, and reduces the wasm as much as it can while keeping the behavior of that command fixed. This can be used to reduce compiler bugs in an arbitrary VM, etc.
* i64 to i32 lowering for wasm2asm (#1134)Thomas Lively2017-09-019-118/+1435
|
* Fix uninitialized members in Wasm2AsmBuilder::Flags (#1152)Sam Clegg2017-08-291-2/+2
|
* Merge pull request #1154 from WebAssembly/fuzzAlon Zakai2017-08-283-10/+21
|\ | | | | Fuzz fixes
| * improve fuzzing of functions with unreachable bodyAlon Zakai (kripken)2017-08-281-7/+7
| |
| * fix an inlining bug where a void function has an unreachable bodyAlon Zakai (kripken)2017-08-281-1/+10
| |
| * fix remove-unused-brs bug with merging br_ifs with unreachable codeAlon Zakai2017-08-281-2/+4
| |
* | Safe heap pass (#1145)Alon Zakai2017-08-285-0/+362
|/ | | Adds --safe-heap which instruments the code to check heap loads and stores for validity (null pointer derefs, within range of valid sbrk memory, and alignment). Used in SAFE_HEAP in emscripten.
* fix flow of values stopping in remove-unused-brs: we must remove all flows ↵Alon Zakai2017-08-251-5/+21
| | | | with a value from the current state, not just set the global state as to whether we can flow or not (as it will be set later by other things)
* avoid trying to optimize ifs with unreachable conditions in ↵Alon Zakai2017-08-251-2/+5
| | | | remove-unused-brs, as they are dead code anyhow, and it is pointless to work hard to handle the type changes
* quickly avoid all unreachable branching in ifsAlon Zakai2017-08-251-0/+5
|
* don't turn unreachable ifs into br_ifs, they are dead anyhow, and would need ↵Alon Zakai2017-08-251-0/+2
| | | | special handling to emit valid code
* set the type of a set_local properly when it is unreachableAlon Zakai2017-08-252-2/+6
|
* add an option to run an extra command when fuzzing in wasm-optAlon Zakai2017-08-251-13/+56
| | | | for now this is linux-only as it uses popen etc.
* add a chance to make a get_local in makeTrivial, so that hang-check returns ↵Alon Zakai (kripken)2017-08-251-5/+11
| | | | etc. don't always return a constant, but may return the result of computation
* increase fuzz hang limit (to basically the point where the spec interpreter ↵Alon Zakai (kripken)2017-08-251-1/+1
| | | | almost fails)
* Add support for atomic wait and wake operators (#1140)Derek Schuff2017-08-2412-2/+221
| | | According to spec at https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wait-and-wake-operators
* Initial asm.js output for binaryen-c / binaryen.js (#1136)Daniel Wirtz2017-08-246-7/+42
| | | | * Added BinaryenModulePrintAsmjs (using wasm2asm) + Module#emitAsmjs JS binding