summaryrefslogtreecommitdiff
path: root/test/wasm2js
Commit message (Collapse)AuthorAgeFilesLines
...
* wasm2js: fix printing of negated negative constants (#2034)Alon Zakai2019-04-222-0/+58
| | | It is invalid to print --5, we need to add a space - -5 so that it is valid JS to parse.
* wasm2js: use scratch memory properly (#2033)Alon Zakai2019-04-2212-2104/+2388
| | | | | | | This replaces all uses of __tempMemory__, the old scratch space location, with calls to function imports for scratch memory access. This lets us then implement those in a way that does not use the same heap as main memory. This avoids possible bugs with scratch memory overwriting something, or just in general that it has observable side effects, which can confuse fuzzing etc. The intrinsics are currently implemented in the glue. We could perhaps emit them inline instead (but that might limit asm.js optimizations, so I wanted to keep our options open for now - easy to change later). Also fixes some places where we used 0 as the scratch space address.
* wasm2js2 import fixes (#2031)Alon Zakai2019-04-1958-1002/+11250
| | | | | | * Don't assume function types exist in legalize-js-interface. * Properly handle (ignore) imports in RemoveNonJSOps - do not try to recurse into them. * Run legalize-js-interface and remove-unused-module-elements in wasm2js, the first is necessary, the last is nice to have.
* wasm2js: handle unreachable select and global.set (#2029)Alon Zakai2019-04-186-8/+41
|
* wasm2js: do not try to be smart with not emitting if braces, the corner ↵Alon Zakai2019-04-1838-4002/+6288
| | | | | cases are tricky (#2026) leave them for later optimizers/minifiers
* wasm2js: remove "use asm", we are not asm.js anymore (#2020)Alon Zakai2019-04-1857-104/+278
| | | Also emit the memory growth code based on memory growth, and not whether we are "use asm" or not.
* Wasm2js: support i64 globals (#2021)Alon Zakai2019-04-182-0/+60
| | | Split them into two i32 globals.
* wasm2js: fix br_table to loop (#2018)Alon Zakai2019-04-172-0/+83
|
* Fix if else JS printing when if body is a labelled block (#2017)Alon Zakai2019-04-1723-571/+637
| | | | | | | | | | | | Before, we'd print if (..) label: { .. }; else .. But that is wrong, as it ends the if too early. After this, we print if (..) label: { .. } else .. The bug was we checked if the if body was a block, but not if it was a labelled block.
* wasm2js: support memory imports properly, updating their buffer too (#2013)Alon Zakai2019-04-162-2/+41
| | | | | * Emit an import statement for the memory. * Update the imported memory's buffer when we grow.
* Use a single table in wasm2js (#2005)Alon Zakai2019-04-1555-65/+118
| | | | | This replaces the multiple asm.js tables (of power-of-2 size) with a single simple table. Also supports importing the table.
* Wasm2js memory fixes (#2003)Alon Zakai2019-04-1216-402/+8860
| | | | | | | | * I64ToI32Lowering - don't assume address 0 is a hardcoded location for scratch memory. Import __tempMemory__ for that. * RemoveNonJSOps - also use __tempMemory__. Oddly here the address was a hardcoded 1024 (perhaps where the rust program put a static global?). * Support imported ints in wasm2js, coercing them as needed. * Add "env" import support in the tests, since now we emit imports from there. * Make wasm2js tests split out multi-module tests using split_wast which is more robust and avoids emitting multiple outputs in one file (which makes no sense for ES6 modules)
* wasm2js memory improvements (#2002)Alon Zakai2019-04-123-26/+44
| | | | | * Refactor memory code to share it between the two emitting modes. * Get memory emitting set up in the emscripten mode.
* wasm2js: emscripten glue option (#2000)Alon Zakai2019-04-112-0/+110
| | | | | | Add a wasm2js option for the glue to be in emscripten-compatible format (as opposed to ES6). This does a few things so far: * Emit START_FUNCTIONS, END_FUNCTIONS markers in the code, for future use in the optimizer. * Emit the glue as a function to be called from emscripten.
* Wasm2js refactoring (#1997)Alon Zakai2019-04-1154-0/+54
| | | | | | | | | | | | | Early work for #1929 * Leave core wasm module - the "asm.js function" - to Wasm2JSBuilder, and add Wasm2JSGlue which emits the code before and after that. Currently that's some ES6 code, but we may want to change that later. * Add add AssertionEmitter class for the sole purpose of emitting modules + assertions for testing. This avoids some hacks from before like starting from index 1 (assuming the module at first position was already parsed and printed) and printing of the f32Equal etc. functions not at the very top (which was due to technical limitations before). Logic-wise, there should be no visible change, except some whitespace and reodering, and that I made the exceptions print out the source of the assertion that failed from the wast: -if (!check2()) fail2(); +if (!check2()) throw 'assertion failed: ( assert_return ( call add ( i32.const 1 ) ( i32.const 1 ) ) ( i32.const 2 ) )'; (fail2 etc. did not exist, and seems to just have given a unique number for each assertion?)
* Minor wasm2js cleanups (#1995)Alon Zakai2019-04-105-10/+10
| | | | | * Only look at the sign of loads when they actually matter. * Prepare for imported globals (just refactoring/cleanup).
* Update test/spec/memory.wast to latest upstream (#1801)Alon Zakai2019-04-031-0/+2
| | | | | | | Minus multi-memory which we don't support yet. Improve validator. Fix some minor validation issues in our tests.
* Optimize away sets of the same local (#1940)Alon Zakai2019-03-0733-878/+84
|
* Optimize added constants with propagation only if we see we will remove all ↵Alon Zakai2019-03-0612-50/+37
| | | | uses of the original add, as otherwise we may just be adding work (both an offset, and an add). Refactor local-utils.h, and make UnneededSetRemover also check for side effects, so it cleanly removes all traces of unneeded sets.
* Validate unique local names, and use validation in wasm2js. Fixes #1885 (#1886)Alon Zakai2019-01-232-3/+3
| | | | | * Also fixes some bugs in wasm2js tests that did not validate. * Rename FeatureOptions => ToolOptions, as they now contain all the basic stuff each tool needs for commandline options (validation yes or no, and which features if so).
* Massive renaming (#1855)Thomas Lively2019-01-0720-271/+271
| | | | | | Automated renaming according to https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
* Fix i64 select lowering. (#1773)Yury Delendik2018-12-174-9/+85
|
* Reject all nonexistent instructions in sexp format (#1756)Thomas Lively2018-11-191-2/+2
|
* Generate sexp instruction parser (#1754)Thomas Lively2018-11-191-1/+1
| | | Also fix broken tests surfaced by the new parser.
* ReFinalize fix (#1742)Alon Zakai2018-11-141-10/+6
| | | | | | | Handle a corner case in ReFinalize, which incrementally re-types code after changes. The problem is that if we need to figure out the type of a block, we look to the last element flowing out, or to breaks with values. If there is no such last element, and the breaks are not taken - they have unreachable values - then they don't tell us the block's proper type. We asserted that in such a case the block still had a type, and didn't handle this. To fix it, we could look on the parent to see what type would fit. However, it seem simpler to just remove untaken breaks/switches as part of ReFinalization - they carry no useful info anyhow. After removing them, if the block has no other signal of a concrete type, it can just be unreachable. This bug existed for at least 1.5 years - I didn't look back further. I think it was noticed by the fuzzer now due to recent fuzzing improvements and optimizer improvements, as I just saw this bug found a second time.
* Support 4GB Memories (#1702)Alon Zakai2018-10-152-2/+2
| | | This fixes asm2wasm parsing of the max to allow 4GB, and also changes the internal Memory::kMaxValue values to reflect that. We used to use kMaxValue to also represent "no limit", so I split that out into kUnlimitedValue.
* [wasm2js] Fix base64 encoding (#1670)Yury Delendik2018-09-052-0/+51
| | | The static std::string base64Encode(std::vector<char> &data) { uses signed char in input data. The ((int)data[0]) converts it the signed int, making '\xFF' char into -1. The patch fixes casting.
* [wasm2js] Fix nested selects (#1671)Yury Delendik2018-09-052-0/+62
| | | | In wasmjs, the nested selects are trying to use the same temporary locals. The patch reserves temporaries "at right time" to avoid overriding the values.
* Rename `wasm2asm` to `wasm2js`, emit ESM by default (#1642)Alex Crichton2018-08-3069-0/+119538
* Rename the `wasm2asm` tool to `wasm2js` This commit performs a relatively simple rename of the `wasm2asm` tool to `wasm2js`. The functionality of the tool doesn't change just yet but it's intended that we'll start generating an ES module instead of just an `asm.js` function soon. * wasm2js: Support `*.wasm` input files Previously `wasm2js` only supported `*.wast` files but to make it a bit easier to use in tooling pipelines this commit adds support for reading in a `*.wasm` file directly. Determining which parser to use depends on the input filename, where the binary parser is used with `*.wasm` files and the wast parser is used for all other files. * wasm2js: Emit ESM imports/exports by default This commit alters the default behavior of `wasm2js` to emit an ESM by default, either importing items from the environment or exporting. Items like initialization of memory are also handled here.