summaryrefslogtreecommitdiff
path: root/src/wasm-builder.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Atomic wait/wake fixes (#1383)Alon Zakai2018-01-221-2/+4
| | | | | | | | * fix wait and wake binary format support, they have alignments and offsets * don't emit unreachable parts of atomic operations, for simplicity and to avoid special handling * don't emit atomic waits by default in the fuzzer, they hang in native vm support
* br_if-to-table (#1313)Alon Zakai2017-12-041-0/+1
| | | | | | | | | | | | | | | Implements #1309: subsequent br_ifs that compare the same value to various constants are converted into a br_table in a block, (br_if $x (i32.eq (get_local $a) (i32.const 0))) (br_if $y (i32.eq (get_local $a) (i32.const 1))) (br_if $z (i32.eq (get_local $a) (i32.const 2))) ==> (block $tablify (br_table $x $y $z $tablify (get_local $a) ) ) The constants for when to apply this (e.g., not if the range of values would make a huge jump table) are fairly conservative, I think, but hard to tell. Probably should be tweaked based on our experience with the pass in practice later on.
* Fix if copying (#1278)Alon Zakai2017-11-161-0/+32
| | | | * fix if copying - we should preserve the forced explicit type if there is one, and not just infer it from the arms. this adds a builder method for makeIf that receives a type to apply to the if, and for blocks a method that makes a block from a list, also with a variant with a provided type
* notation change: AST => IR (#1245)Alon Zakai2017-10-241-1/+1
| | | The IR is indeed a tree, but not an "abstract syntax tree" since there is no language for which it is the syntax (except in the most trivial and meaningless sense).
* Atomics support in interpreter + optimizer + fuzz fixes for that (#1227)Alon Zakai2017-10-201-7/+5
|
* Add Builder::makeGlobal for nicer global creation (#1221)Alon Zakai2017-10-101-0/+15
|
* fix wasm-builder set_global creation - we must call finalize, as the value ↵Alon Zakai2017-10-101-0/+1
| | | | may be unreachable (#1216)
* Make localNames into a map (#1189)Thomas Lively2017-09-231-7/+11
|
* Const hoisting (#1176)Alon Zakai2017-09-121-0/+6
| | | 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-111-1/+1
| | | | | | | | | | * 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
* i64 to i32 lowering for wasm2asm (#1134)Thomas Lively2017-09-011-6/+3
|
* set the type of a set_local properly when it is unreachableAlon Zakai2017-08-251-2/+2
|
* Add support for atomic wait and wake operators (#1140)Derek Schuff2017-08-241-0/+18
| | | According to spec at https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wait-and-wake-operators
* wasm2asm i32 arithmetic support (#1120)Thomas Lively2017-08-071-0/+5
| | | * Rotations, popcnt, ctz, etc
* Get wasm2asm building again (#1107)Thomas Lively2017-08-021-3/+3
| | | | | | | | | | | | | | | | | | * Get wasm2asm building again Updates CMakeLists.txt to have wasm2asm built by default, updates wasm2asm.h to account for recent interface changes, and restores JSPrinter functionality. * Implement splice for array values * Clean up wasm2asm testing * Print semicolons after statements in blocks * Cleanups and semicolons for condition arms * Prettify semicolon emission
* Optimizer support for atomic instructions (#1094)Derek Schuff2017-07-211-0/+35
| | | | | | * Teach EffectAnalyzer not to reorder atomics wrt other memory operations. * Teach EffectAnalyzer not to reorder host operations with memory operations * Teach various passes about the operands of AtomicRMW and AtomicCmpxchg * Factor out some functions in DeadCodeElimination and MergeBlocks
* fix blockifyMerge logic - it needs to not skip code in the block we merge ↵Alon Zakai2017-07-171-22/+0
| | | | to. since that's a fairly specific functionality needed in removeUnusedBrs, move it to there
* Add atomic loads and stores (#1077)Derek Schuff2017-06-281-0/+2
| | | | | Add IR, wast and binary support for atomic loads and stores. Currently all IR generated by means other than parsing wast and binary files always generates non-atomic accesses, and optimizations have not yet been made aware of atomics, so they are certainly not ready to be used yet.
* Validate finalization (#1014)Alon Zakai2017-05-181-1/+21
| | | | | | | * validate that types are properly finalized, when in pass-debug mode (BINARYEN_PASS_DEBUG env var): check after each pass is run that the type of each node is equal to the proper type (when finalizing it, i.e., fully recomputing the type). * fix many fuzz bugs found by that. * in particular, fix dce bugs with type changes not being fully updated during code removal. add a new TypeUpdater helper class that lets a pass update types efficiently, by the helper tracking deps between blocks and branches etc., and updating/propagating type changes only as necessary.
* Flatten control flow pass (#999)Alon Zakai2017-05-101-0/+5
| | | | | | | | | | | This pass flattens out control flow in order to achieve 2 properties: * Control flow structures (block, loop, if) and control flow operations (br, br_if, br_table, return, unreachable) may only be block children, a loop body, or an if-true or if-false. (I.e., they cannot be nested inside an i32.add, a drop, a call, an if-condition, etc.) * Disallow block, loop, and if return values, i.e., do not use control flow to pass around values. As a result, expressions cannot contain control flow, and overall control flow is simpler, more structured, and more "flat". This should make things like re-relooping wasm code much easier, as they can run after the cfg is flattened
* Unreachable typing fixes (#1004)Alon Zakai2017-05-091-3/+3
| | | | | | | | | | | | * fix type of drop, set_local, set_global, load, etc: when operand is unreachable, so is the node itself * support binary tests properly in test/passes * fix unreachable typing of blocks with no name and an unreachable child * fix continue emitting in asm2wasm * properly handle emitting of unreachable load
* Make header guards consistent (#997)Sam Clegg2017-05-041-3/+3
|
* Optimize away copies through an if (#816)Alon Zakai2016-10-311-0/+6
|
* add an inlining pass (#814)Alon Zakai2016-10-291-0/+4
|
* asm2wasm i64 support (#723)Alon Zakai2016-09-301-4/+23
| | | | | | | | | | | | * support i64 intrinsics from fastcomp, adding --wasm-only flag * refactor callImport logic in asm2wasm to avoid recomputing wasm types again * legalize illegal i64 params in exports and imports * do safe i64 binary ops depending on precision * fix addVar, only assert on names if we are using a name
* precompute breaks and returns (#715)Alon Zakai2016-09-251-3/+3
|
* br_if returns its valueAlon Zakai2016-09-161-0/+6
|
* optimize loop endings in RemoveUnusedBrsAlon Zakai2016-09-091-0/+48
| | | | | * rotate an if near the end of a loop as it can let a break out flow naturally and be removable * turn a br_if into an if it allows such an optimization in cases where it helps remove other structures
* get_global and set_global use a Name instead of an Index, to be more ↵Alon Zakai2016-09-071-4/+4
| | | | consistent with refering to other global objects; e.g. this avoids ordering issues with imported vs non-imported globals
* SetGlobal should not return a valueAlon Zakai2016-09-071-1/+0
|
* loops no longer have an out label and other upstream loop updatesAlon Zakai2016-09-071-3/+17
|
* add drop and tee expressionsAlon Zakai2016-09-071-3/+21
|
* support wasm globals (#650)Alon Zakai2016-07-211-0/+13
|
* simplify wasm-builder: it has an allocator, and should never need to access ↵Alon Zakai2016-06-271-23/+24
| | | | a module (#605)
* make makeCallImport more similar to makeCall; do not assume all imports ↵Alon Zakai2016-06-261-2/+2
| | | | exist, let functions be created in a way independent from global state
* expression copying utilityAlon Zakai2016-06-261-7/+37
|
* add a precompute passAlon Zakai2016-06-181-0/+1
|
* s2wasm: Validate the result module (#574)Derek Schuff2016-06-101-17/+18
| | | | Add an s2wasm option `--no-validate` to disable validation for debugging purposes. Also fix several validation errors by adding calls to `finalize()` after creating expressions, and ensuring that an import is created earlier in `Linker::getImportThunk`.
* make call_indirect type a name, so that it is not a dependency on the ↵Alon Zakai2016-06-031-1/+1
| | | | module, which would break consistency and make some parallel passes tricky (#568)
* Generate thunks for address-taken imports (#554)Derek Schuff2016-06-021-2/+7
| | | | | | | | | | | Under emscripten, C code can take the address of a function implemented in Javascript (which is exposed via an import in wasm). Because imports do not have linear memory address in wasm, we need to generate a thunk to be the target of the indirect call; it call the import directly. This is facilited by a new .s directive (.functype) which declares the types of functions which are declared but not defined. Fixes https://github.com/WebAssembly/binaryen/issues/392
* spec test updates, and many validation fixesAlon Zakai2016-05-181-38/+1
|
* Import emscripten's relooper, port it to the binaryen AST, and provide a C ↵Alon Zakai2016-05-051-5/+22
| | | | | API (#434) also ignore libstdc++ bug in ubsan
* Harmonize the internal opcodes with the binary format (#433)Alon Zakai2016-05-031-24/+38
| | | | | | * harmonize the internal opcodes with the binary format, so they clearly parallel, and also this helps us avoid needing the type to disambiguate * comment on GetLocal in C API
* makeLoop and makeBreakAlon Zakai2016-05-021-2/+12
|
* allocate only expressions in arenas - functions, imports, exports, function ↵Alon Zakai2016-04-271-1/+1
| | | | types, can more simply be held by unique_ptrs on the owning module. this avoids need to coordinate arena allocation for their elements, and only the far more plentiful expression nodes are a perf factor anyhow
* add an ArenaVector for internal array allocations in expression nodesAlon Zakai2016-04-261-3/+3
|
* block helper utilsAlon Zakai2016-04-211-1/+14
|
* remove the AllocatingModule class, and just make Module have allocations. ↵Alon Zakai2016-04-181-1/+1
| | | | the distinction is not really that useful, and passes do need to allocate, so we would need to pass around AllocatingModules all around anyhow. (#361)
* index locals, so that get_local and set_local have just an index, and local ↵Alon Zakai2016-04-181-8/+67
| | | | names are kept on the Function object (#354)
* rename function locals, to params and vars, which together are all the ↵Alon Zakai2016-04-141-2/+2
| | | | locals. preparation for #336 (#349)