summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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-221-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* 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.
* 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.
* 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
|
* a stacky value in the middle of a block may be consumed (#1267)Alon Zakai2017-11-131-1/+20
|
* notation change: AST => IR (#1245)Alon Zakai2017-10-241-2/+2
| | | 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-201-0/+22
|
* Add Builder::makeGlobal for nicer global creation (#1221)Alon Zakai2017-10-101-6/+8
|
* 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
* 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
* Add support for sign-extension operators from threading proposal (#1167)Derek Schuff2017-09-061-0/+11
| | | 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-061-6/+5
| | | | validation that was from when we differentiated reachable from unreachable breaks (#1166)
* Add support for atomic wait and wake operators (#1140)Derek Schuff2017-08-241-0/+55
| | | According to spec at https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wait-and-wake-operators
* 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.
* 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
|
* fix proper wasm emitting of untaken br_tablesAlon Zakai2017-08-011-1/+9
|
* Merge remote-tracking branch 'origin/master' into fuzzAlon Zakai (kripken)2017-07-311-1/+33
|\
| * Polymophic stack support (#1117)Alon Zakai2017-07-311-1/+33
| | | | | | | | | | | | | | Emit valid wasm binaries even for corner cases of unreachable code. * emit an unreachable after a node that pushes a value that has unreachable type (where wasm type checking would have pushed a concrete type) * conversely, as a hack, emulate the wasm polymorphic stack mode by not emptying the stack when it has one element and that element is unreachable. this lets further pops work (all returning an unreachable element)
* | review commentsAlon Zakai (kripken)2017-07-311-1/+1
| |
* | fix binary emitting of untaken branches, and also handle reading of ↵Alon Zakai (kripken)2017-07-291-3/+10
|/ | | | unreachable stacky code which may introduce concrete elements in non-final block positoins
* add the option to seek named breaks, not just taken breaks; refactor headers ↵Alon Zakai (kripken)2017-07-111-3/+4
| | | | to make this practical
* Add IR, parsing, printing, and binary for atomic cmpxchg (#1083)Derek Schuff2017-07-101-0/+64
|
* Add IR, parsing and binary support for AtomicRMW instructions from wasm ↵Derek Schuff2017-07-061-0/+90
| | | | | threads proposal (#1082) Also leave a stub (but valid) visitAtomicRMW in the visitor template so that not all visitors need to implement this function yet.
* show a clear error on nulls in inline strings in binary format (#1068)Alon Zakai2017-07-051-1/+5
| | | | * show a clear error on nulls in inline strings (which we don't support, and in general are not seen in practice, but are technically valid wasm) in binary format reading
* Add atomic loads and stores (#1077)Derek Schuff2017-06-281-71/+162
| | | | | 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.
* Add shared memories (#1069)Derek Schuff2017-06-271-12/+24
| | | | | Begin to implement wasm threading proposal in https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md This PR just has shared memory attribute with wast and binary support.
* Change char to auto to avoid type-limits warn on some arches (#1066)Jakub Jirutka2017-06-221-1/+1
| | | Fixes #1059
* handle the wrong number of functions being provided in binary formatAlon Zakai (kripken)2017-06-011-0/+8
|
* Exporting/importing debug location information from .wast/.asm.js/.s formats ↵Yury Delendik2017-06-011-0/+206
| | | | | | | | (#1017) * Extends wasm-as, wasm-dis and s2wasm to consume debug locations. * Exports source map from asm2wasm
* afl-fuzz bug fixes (#1018)Alon Zakai2017-05-201-0/+4
| | | | | | | | * values cannot flow through an if without an else, they never return a value * check pass tests in pass-debug mode too * add missing finalization in binary reading
* Unreachable typing fixes (#1004)Alon Zakai2017-05-091-2/+9
| | | | | | | | | | | | * 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
* optimize duplication checks in binary format reading (#995)Alon Zakai2017-05-041-7/+5
|
* make function name duplicate testing handle the case of just some functions ↵Alon Zakai2017-05-031-5/+8
| | | | being named, and colliding with others' original names (#994)
* Parsing fixes (#990)Alon Zakai2017-05-021-34/+126
| | | | | | | | | | * properly catch a bunch of possible parse errors, found by afl-fuzz * clean up wasm-interpreter, use WASM_UNREACHABLE instead of abort * detect duplicate names in function names section * detect duplicate export names
* Extensible name section (#933)pipcet2017-04-131-19/+43
| | | | | | | | | | | | | See https://github.com/WebAssembly/binaryen/issues/914. * extensible name section support: read function names, too * c-api-unused-mem.txt: change expected size to match new name section * * check subsection size matches * print warning for unknown name subsections (including the local section)
* fix emitting of unreachable ifs (#944)Alon Zakai2017-03-141-13/+11
|
* Wasm h to cpp (#926)jgravelle-google2017-03-101-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | * Move WasmType function implementations to wasm.cpp * Move Literal methods to wasm.cpp * Reorder wasm.cpp shared constants back to top * Move expression functions to wasm.cpp * Finish moving things to wasm.cpp * Split out Literal into its own .h/.cpp. Also factor out common wasm-type module * Remove unneeded/transitive includes from wasm.h * Add comment to try/check methods * Rename tryX/checkX methods to getXOrNull * Add missing include that should fix appveyor build breakage * More appveyor
* read unknown users sections as binary data stored on the Module (#918)Alon Zakai2017-02-211-3/+13
|
* clean up raw pointer import->functionType, make it a Name like everything ↵Alon Zakai2017-02-171-4/+4
| | | | else (#915)
* Fix emitting of unreachable block/if/loop (#911)Alon Zakai2017-02-161-2/+38
| | | | | | | | | | | | | | | | | | | | | | * an unreachable block is one with an unreachable child, plus no breaks * document new difference between binaryen IR and wasm * fix relooper missing finalize * add a bunch of tests * don't assume that test/*.wast files print to themselves exactly; print to from.wast. this allows wast tests with comments in them * emit unreachable blocks as (block .. unreachable) unreachable * if without else and unreachable ifTrue is still not unreachable, it should be none * update wasm.js * cleanups * empty blocks have none type
* Merge pull request #865 from WebAssembly/fix-abAlon Zakai2017-01-101-6/+24
|\ | | | | Fix AngryBots parsing