summaryrefslogtreecommitdiff
path: root/src/wasm
Commit message (Collapse)AuthorAgeFilesLines
* Fuzz fix: if global does not exist, report error and don't run the rest of ↵Alon Zakai2018-03-071-37/+38
| | | | the checks (#1461)
* ensure unique import names for each type, by giving them a prefix, avoiding ↵Alon Zakai2018-02-221-1/+7
| | | | collisions between say a global import and a function with a name from the name section that happens to match it (#1424)
* Fold wasm-link-metadata into wasm-emscripten-finalize (#1408)Jacob Gravelle2018-02-141-5/+20
| | | | | | | * wasm-link-metadata: Use `__data_end` symbol. * Add --global-base param to emscripten-wasm-finalize to compute staticBump properly * Let ModuleWriter write to a provided Output object
* Dedupe function names when reading a binary (#1396)Jacob Gravelle2018-02-061-8/+9
| | | | | | | | * Dedupe function names when reading a binary * More robust name deduplication, use .s instead of _s * Add name-duplicated wasm binaries
* Fix -Wcatch-value from GCC 8 (#1400)Josh Stone2018-02-051-2/+2
| | | These instances may simply be caught by reference instead.
* Rename WasmType => Type (#1398)Alon Zakai2018-02-026-266/+266
| | | | * rename WasmType to Type. it's in the wasm:: namespace anyhow, and without Wasm- it fits in better alongside Index, Address, Expression, Module, etc.
* Don't write sourceMappingURL section if URL is empty. (#1390)Yury Delendik2018-01-261-1/+1
|
* Atomic wait/wake fixes (#1383)Alon Zakai2018-01-221-7/+36
| | | | | | | | * 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
* First pass at LLD support for Emscripten (#1346)Jacob Gravelle2018-01-222-6/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Skeleton of a beginning of o2wasm, WIP and probably not going to be used * Get building post-cherry-pick * ast->ir, remove commented out code, include a debug module print because linking * Read linking section, print emscripten metadata json * WasmBinaryWriter emits user sections on Module * Remove debugging prints, everything that isn't needed to build metadata * Rename o2wasm to lld-metadata * lld-metadata support for outputting to file * Use tables index instead of function index for initializer functions * Add lld-emscripten tool to add emscripten-runtime functions to wasm modules (built with lld) * Handle EM_ASM in lld-emscripten * Add a list of functions to forcibly export (for initializer functions) * Disable incorrect initializer function reading * Add error printing when parsing .o files in lld-metadata * Remove ';; METADATA: ' prefix from lld-metadata, output is now standalone json * Support em_asm consts that aren't at the start of a segment * Initial test framework for lld-metadata tool * Add em_asm test * Add support for WASM_INIT_FUNCS in the linking section * Remove reloc section parsing because it's unused * lld-emscripten can read and write text * Add test harness for lld-emscripten * Export all functions for now * Add missing lld test output * Add support for reading object files differently Only difference so far is in importing mutable globals being an object file representation for symbols, but invalid wasm. * Update help strings * Update linking tests for stackAlloc fix * Rename lld-emscripten,lld-metadata to wasm-emscripten-finalize,wasm-link-metadata * Add help text to header comments * auto& instead of auto & * Extract LinkType to abi/wasm-object.h * Remove special handling for wasm object file reading, allow mutable globals * Add braces around default switch case * Fix flake8 errors * Handle generating dyncall thunks for imports as well * Use explicit bool for stackPointerGlobal * Use glob patterns for lld file iteration * Use __wasm_call_ctors for all initializer functions
* Global optimization fixes (#1360)Alon Zakai2018-01-171-1/+11
| | | | | | | | | | | | | | | | * run dfe at the very end, as it may be more effective after inlining * optimize reorder-functions * do a final dfe in asm2wasm after all other opts * make inlining deterministic: std::atomic<T> values are not zero-initialized * do global post opts at the end of asm2wasm, and don't also do them in the module builder * fix function type removing * don't inline+optimize when preserving debug info
* Function metrics pass (#1353)Alon Zakai2018-01-121-0/+1
| | | Emits binary size and opcode counts for each function, which helps investigating what's taking up space in a wasm binary.
* Do not emit 100k data segments, browsers reject it (#1350)Alon Zakai2018-01-091-4/+78
| | | | | Instead merge constant-offset segments if we must in order to stay under the limit. If we can't - too many non-constant-offset segments - then issue a warning.
* Validation fixes for #1317 (#1347)Alon Zakai2018-01-031-0/+16
| | | | | | | * add get_global/set_global validation * validate get_local index * update builds * fix tests
* Fix 2 binary fuzz bugs (#1323)Alon Zakai2017-12-141-1/+6
| | | | | | * Check if there is a currFunction before using it (we need it for some stacky code; a valid wasm wouldn't need a function in that location anyhow, as what can be put in a memory/table offset is very limited). * Huge alignment led us to do a power of 2 shift that is undefined behavior. Also adds a test facility to check we don't crash on testcases.
* allow exporting an import (#1326)Alon Zakai2017-12-081-9/+6
|
* Binary fuzz fix: disallow popping from outside a block (#1305)Alon Zakai2017-11-281-0/+6
| | | | | | * remove unneeded code to handle a br to the return from the function. Now that we use getBlockOrSingleton there, it does that for us anyhow * fix a fuzz bug of popping from outside a block
* Fix reading breaks to the function exit (#1304)Alon Zakai2017-11-211-17/+5
| | | | * remove unneeded code to handle a br to the return from the function. Now that we use getBlockOrSingleton there, it does that for us anyhow
* name function imports using name section (#1290)Alon Zakai2017-11-211-19/+31
|
* accept overlapping segments (#1289)Alon Zakai2017-11-141-5/+2
|
* a stacky value in the middle of a block may be consumed (#1267)Alon Zakai2017-11-131-1/+20
|
* Update call_indirect text syntax to match spec update (#1281)Derek Schuff2017-11-131-1/+3
| | | | Function type gets its own element rather than being a part of the call_indirect (see WebAssembly/spec#599)
* Restrict validation output to just validation errors in the API (#1253)Daniel Wirtz2017-11-011-2/+0
| | | Do not print the entire and possibly very large module when validation fails. Leave printing to tools using the validator, instead of always doing it in the validator where it can't be overridden.
* Add Features enum to IR (#1250)Derek Schuff2017-10-271-1/+10
| | | | | | | | | | | | This enum describes which wasm features the IR is expected to include. The validator should reject operations which require excluded features, and passes should avoid producing IR which requires excluded features. This makes it easier to catch possible errors in Binaryen producers (e.g. emscripten). Asm2wasm has a flag to enable or disable atomics. Other tools currently just accept all features (as, dis and opt are just for inspecting or modifying existing modules, so it would be annoying to have to use flags with those tools and I expect the risk of accidentally introducing atomics to be low).
* notation change: AST => IR (#1245)Alon Zakai2017-10-244-6/+6
| | | 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).
* Emit binary function index in comment in text format, for convenience (#1232)Alon Zakai2017-10-201-28/+4
|
* Move pointer positioning outside of vector access operator to avoid MSVC ↵Mark A. Ropper2017-10-201-2/+2
| | | | complaining about out-of-range values (#1233)
* Atomics support in interpreter + optimizer + fuzz fixes for that (#1227)Alon Zakai2017-10-203-3/+28
|
* Add Builder::makeGlobal for nicer global creation (#1221)Alon Zakai2017-10-101-6/+8
|
* Refactor validator API to use enums (#1209)Alon Zakai2017-10-031-5/+5
| | | | * refactor validator API to use enums
* Fast validation (#1204)Alon Zakai2017-10-021-192/+476
| | | | | | | 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.
* Optimize wasm reading (#1202)Alon Zakai2017-09-281-2/+9
| | | * optimize wasm reading: use a set of the breaks we've seen, don't rescan blocks to see if they have breaks to them
* Make localNames into a map (#1189)Thomas Lively2017-09-231-7/+8
|
* Update text syntax for shared memory limits (#1197)Derek Schuff2017-09-222-13/+17
| | | | 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-201-0/+1
|
* Expressions should not appear twice in the ast (#1191)Alon Zakai2017-09-181-0/+18
|
* Avoid new blocks in binary reading/writing (#1165)Alon Zakai2017-09-121-21/+35
| | | | | | * 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-121-0/+6
| | | | | | | 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.
* Const hoisting (#1176)Alon Zakai2017-09-121-3/+3
| | | 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.
* Add support for sign-extension operators from threading proposal (#1167)Derek Schuff2017-09-064-4/+32
| | | 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-062-12/+6
| | | | 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-052-26/+45
| | | | | | | | * 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-012-7/+22
| | | 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.
* set the type of a set_local properly when it is unreachableAlon Zakai2017-08-251-0/+4
|
* Add support for atomic wait and wake operators (#1140)Derek Schuff2017-08-244-0/+105
| | | 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-241-0/+7
| | | | * Added BinaryenModulePrintAsmjs (using wasm2asm) + Module#emitAsmjs JS binding
* Ignore unreachable code in wasm binaries (#1122)Alon Zakai2017-08-221-8/+60
| | | Ignoring unreachable code in wasm binaries lets us avoid corner cases with unstructured code in wasm binaries that is a poor fit for Binaryen's structured IR.
* wasm2asm test generation (#1124)Thomas Lively2017-08-161-1/+1
| | | | | | | | | | | | | | | | | * Translate assert_return invokes to asm * Translate assert_trap tests to JS * Enable wasm2asm tests * Fix wasm2asm translation of store * Update ubuntu nodejs in Travis * Free JSPrinter buffer * Use unique_ptr for Functions to prevent leaks * Add tests for assert translation
* Emit optimal-size LEBs in section/subsection/function body sizes (#1128)Alon Zakai2017-08-151-8/+20
| | | | * emit optimal-size LEBs in section/subsection/function body sizes, instead of preallocating 5 bytes
* emit an unreachable if an unreachable block context does not end in an ↵Alon Zakai2017-08-051-0/+5
| | | | unreachable
* fix reading of stacky unreadable code with elements we need to dropAlon Zakai (kripken)2017-08-051-16/+16
|