summaryrefslogtreecommitdiff
path: root/test/wasm2js/emscripten.2asm.js
Commit message (Collapse)AuthorAgeFilesLines
* Remove AutoDrop (#7106)Thomas Lively2024-11-221-0/+1
| | | | The only internal use was in wasm2js, which doesn't need it. Fix API tests to explicitly drop expressions as necessary.
* Partially revert #6026 (#6043)Alon Zakai2023-10-231-1/+5
| | | That optimization uncovered some LLVM and Binaryen bugs.
* RemoveUnusedModuleElements: Make exports skip trampolines (#6026)Alon Zakai2023-10-191-5/+1
| | | | | | | | | | | | | | | | | | | If we export a function that just calls another function, we can export that one instead. Then the one in the middle may be unused, function foo() { return bar(); } export foo; // can be an export of bar This saves a few bytes in rare cases, but probably more important is that it saves the trampoline, so if this is on a hot path, we save a call. Context: emscripten-core/emscripten#20478 (comment) In general this is not needed as inlining helps us out by inlining foo() into the caller (since foo is tiny, that always ends up happening). But exports are a case the inliner cannot handle, so we do it here.
* wasm2js: Stop emitting nan and infinity (#5391)Will Cohen2023-01-041-2/+0
| | | | | | | As noted in #4739, legacy language emitting nan and infinity exists, with the observation that it can be removed once asm.js is no longer used and global NaN is available. This commit removes that asm.js-specific code accordingly.
* wasm2js: Support for flexible module import naming (#5114)Sam Clegg2022-10-051-3/+3
| | | | | | | | The previous code was making emscripten-specific assumptions about imports basically all coming from the `env` module. I can't find a way to make this backwards compatible so may do a combined roll with the emscripten-side change: https://github.com/emscripten-core/emscripten/pull/17806
* wasm2js: Don't assume that `env.abort` can always be impored. (#5049)Sam Clegg2022-09-161-4/+5
| | | | | | This import was being injected and then used to implement trapping. Rather than injecting an import that doesn't exist in the original module we instead use the existing mechanism to implement this as an internal helper.
* wasm2js: Have instantiate function take standard import object (#5018)Sam Clegg2022-09-141-3/+4
| | | | | | | | | | | Previously we were assuming asmLibraryArg which is what emscripten passes as the `env` import object but using this method is more flexible and should allow wasm2js to work with import that are not all form a single object. The slight size increase here is just temporary until emscripten gets updated. See https://github.com/emscripten-core/emscripten/pull/17737
* wasm2js: Declare data segments before calling asmFunc (#3337)Sam Clegg2020-11-111-26/+29
| | | | | | | | | This is because we maybe need to reference the segments during the start function. For example in the case of pthreads we conditionally load passive segments during start. Tested in emscripten with: tests/runner.py wasm2js1
* wasm2js: Support for exported memory (#3323)Sam Clegg2020-11-101-5/+7
| | | | | The asmFunc now sets the outer scope's `bufferView` variable as well as its own internal views.
* [wasm2js] Use native JavaScript Math.trunc (#3329)Max Graey2020-11-101-0/+1
|
* Canonicalize subtraction with constant on the right to addition (#3321)Max Graey2020-11-101-1/+1
| | | | | | | Using addition in more places is better for gzip, and helps simplify the optimizer as well. Add a FinalOptimizer phase to do optimizations like our signed LEB tweaks, to reduce binary size in the rare case when we do want a subtraction.
* wasm2js: Remove global dict arguments to asmFunc (#3325)Sam Clegg2020-11-051-36/+21
|
* MemoryPacking: Properly notice zeroFilledMemory (#3306)Alon Zakai2020-11-021-3/+1
| | | We can only pack memory if we know it is zero-filled before us.
* wasm2js: override incoming memory's grow method (#3185)Sam Clegg2020-09-301-1/+2
| | | | | | | | | | This will allow for the completely removal of `__growWasmMemory` as a followup. We currently unconditionally generate this function in `generateMemoryGrowthFunction`. See #3180
* wasm2js: Support exported tables (#3152)Sam Clegg2020-09-211-3/+2
|
* wasm2js: coerce function pointer indexes (#2979)Alon Zakai2020-07-221-1/+1
| | | | | | | | | | | | | | | | | We emit FUNCTION_TABLE[ptr], where FUNCTION_TABLE is a JS array. That is a rare case where true is handled differently than 1 (a typed array or an add would cast, etc.), so we must explicitly cast there. Fixes an issue that existed before, but became a problem due to #2869 which optimized some selects into a form that emitted a true or a false, and if that was a function pointer, it could be bad, see https://app.circleci.com/pipelines/github/emscripten-core/emscripten/6699/workflows/0c4da49c-75d0-4b0a-8fac-686a8330a3fe/jobs/336520 The new test/wasm2js/indirect-select.2asm.js.opt output shows what happened there. Verified as passing emscripten's wasm2js1 wasm2js2 test suites.
* wasm2js: Bulk memory support (#2923)Alon Zakai2020-06-221-2/+3
| | | | | | | | | | | | | | Adds a special helper functions for data.drop etc., as unlike most wasm instructions these are too big to emit inline. Track passive segments at runtime in var memorySegments whose indexes are the segment indexes. Emit var bufferView even if the memory exists even without memory segments, as we do still need the view in order to operate on it. Also adds a few constants for atomics that will be useful in future PRs (as this PR updates the constant lists anyhow).
* Micro-optimize base64Decode (#2897)juj2020-06-061-7/+5
| | | | | * Micro-optimize base64Decode * Update test expectations
* Fix missing newline after // EMSCRIPTEN_START_FUNCS and // ↵juj2020-02-101-2/+4
| | | | | | | | | | EMSCRIPTEN_END_FUNCS markers. (#2626) * Fix missing newline after // EMSCRIPTEN_START_FUNCS and // EMSCRIPTEN_END_FUNCS markers. * Flake * Update tests
* Optimize base64 decoding (#2623)juj2020-02-091-18/+22
| | | | | | | | | | | | | | * Optimize base64 decoding (about 7x-10x faster and temporary garbage-free compared to the original version) * new Uint8Array * Reuse Uint8Array view * Fix end handling * Code format * Update tests
* [wasm2js] Fix memory.size (#2330)Alon Zakai2019-09-051-0/+4
| | | | | | | We emitted the __wasm_memory_size function only when memory growth was enabled, but it can be used without that too. In theory we could only emit it if either memory growth or memory.size is used, but I think we can expect JS minifiers to do that later. Also fix a test suite bug - the check/auto_update script didn't run all the wasm2js tests when you run it with argument wasm2js (it used that as the list of tests, instead of the list of files, which confused me here for a while...).
* Followup to workaround for minification of wasm2js mem init (#2318)Brion Vibber2019-08-301-3/+3
| | | | | | | | | | | | | Emscripten's minifier mis-minifies a couple bits in the memory init function that's used with wasm2js when not using an external memory init file: https://github.com/emscripten-core/emscripten/issues/8886 Previous fix worked around the bug in one place but failed to account for another. Have now confirmed that it works with this change in place. Updated test cases to match.
* Stop emitting "almost asm" in wasm2js output (#2221)Alon Zakai2019-07-121-1/+0
| | | We don't ever emit "use asm" anymore, so this similar annotation is not really useful, it just increases size.
* Workaround for wasm2js output minification issue with emscripten (#2185)Brion Vibber2019-07-011-2/+3
| | | | | | | | | | | | | | * Workaround for wasm2js output minification issue with emscripten When using emscripten with -O2 and --memory-init-file 0, the JS minification breaks on this function for memory initialization setup, causing an exception to be thrown during module setup. Moving from two 'var' declarations for the same variable to one should avoid hitting this with no change in functionality (the var gets hoisted anyway). https://github.com/emscripten-core/emscripten/issues/8886
* wasm2js: more coercion optimization (#2109)Alon Zakai2019-05-151-0/+42
|
* wasm2js: optimize away unneeded load coercions (#2107)Alon Zakai2019-05-151-0/+37
|
* wasm2js: Emit table in a way that is friendly to emscripten minification (#2102)Alon Zakai2019-05-131-1/+2
| | | Set it to a local in the asmFunc scope, so that minifiers can easily see it's a simple local value (instead of using it as an upvar from the parameters higher up, which was how the emscripten glue was emitting it).
* wasm2js: optimize booleans (#2090)Alon Zakai2019-05-071-0/+8
|
* wasm2js: optimize loads (#2085)Alon Zakai2019-05-031-2/+13
| | | | When loading a boolean, prefer the signed heap (which is more commonly used, and may be faster). We never use HEAPU32 (HEAP32 is always enough), just remove it.
* wasm2js: ignore implicit traps (#2079)Alon Zakai2019-05-021-1/+8
| | | | | We don't actually try to emit traps for loads, stores, invalid float to ints, etc., so when optimizing we may as well do so under the assumption those traps do not exist. This lets us emit nice code for a select whose operands are loads, for example - otherwise, the values seem to have side effects.
* wasm2js: don't run coalesce-locals if not optimizing (#2076)Alon Zakai2019-05-011-12/+12
| | | That pass is very slow on unoptimized code (super-linear on the number of locals, which if unoptimized can be massive due to flatten).
* wasm2js: run more optimizations (#2073)Alon Zakai2019-05-011-12/+12
| | | In particular, coalesce-locals is useful even if closure is run later (apparently it finds stuff closure can't).
* wasm2js: run full optimizations during the pipeline (#2071)Alon Zakai2019-04-301-14/+15
| | | | | We flatten for the i64 lowering etc. passes, and it is worth optimizing afterwards, to clean up stuff they created. That is run if the user ran wasm2js with an optimization level (like wasm2js -O3). Split the test files to check both optimized and unoptimized code.
* wasm2js: optimize away casts going into a suitable store (#2069)Alon Zakai2019-04-301-0/+5
|
* wasm2js2: optimize call_indirect and select operands (#2056)Alon Zakai2019-04-251-2/+1
| | | Don't use temp vars to reorder them unless we need to.
* wasm2js: more js optimization (#2050)Alon Zakai2019-04-241-6/+31
| | | | | | * Emit ints as signed, so -1 isn't a big unsigned number. * x - -c (where c is a constant) is larger than x + c in js (but not wasm) * +(+x) => +x * Avoid unnecessary coercions on calls, return, load, etc. - we just need coercions when entering or exiting "wasm" (not internally), and on actual operations that need them.
* wasm2js: start to optionally optimize the JS (#2046)Alon Zakai2019-04-241-2/+5
| | | Removes redundant | 0s and similar things. (Apparently closure compiler doesn't do that, so makes sense to do here.)
* wasm2js: emit quoted properties for the exports, to support closure compiler ↵Alon Zakai2019-04-231-3/+3
| | | | (#2043)
* wasm2js: emit calls for memory growth helper only if memory growth is used ↵Alon Zakai2019-04-231-1/+1
| | | | (#2042)
* wasm2js: avoid non-ES5 stuff like "let" (#2041)Alon Zakai2019-04-231-6/+6
| | | Also fix the fuzzer's handling of feature flags so that wasm2js can work.
* wasm2js: get rid of some non-flat code assumptions (#2036)Alon Zakai2019-04-221-2/+1
| | | We run flatten there, which lets us simplify things a lot. Turns out that for assertions we didn't run it, which is why we still needed the old non-flat code paths. This adds flatten there and removes that old code and assumptions.
* wasm2js2 import fixes (#2031)Alon Zakai2019-04-191-2/+0
| | | | | | * 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: remove "use asm", we are not asm.js anymore (#2020)Alon Zakai2019-04-181-26/+0
| | | Also emit the memory growth code based on memory growth, and not whether we are "use asm" or not.
* wasm2js: support memory imports properly, updating their buffer too (#2013)Alon Zakai2019-04-161-2/+35
| | | | | * 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-151-3/+4
| | | | | 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-121-16/+13
| | | | | | | | * 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-121-0/+18
| | | | | * 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-111-0/+78
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.