| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
The only internal use was in wasm2js, which doesn't need it. Fix API
tests to explicitly drop expressions as necessary.
|
|
|
| |
That optimization uncovered some LLVM and Binaryen bugs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
| |
The asmFunc now sets the outer scope's `bufferView` variable
as well as its own internal views.
|
| |
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
We can only pack memory if we know it is zero-filled before us.
|
|
|
|
|
|
|
|
|
|
| |
This will allow for the completely removal of
`__growWasmMemory` as a followup. We currently
unconditionally generate this function
in `generateMemoryGrowthFunction`.
See #3180
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
* Update test expectations
|
|
|
|
|
|
|
|
|
|
| |
EMSCRIPTEN_END_FUNCS markers. (#2626)
* Fix missing newline after // EMSCRIPTEN_START_FUNCS and // EMSCRIPTEN_END_FUNCS markers.
* Flake
* Update tests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
|
|
| |
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...).
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
| |
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
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
|
| |
|
| |
|
|
|
| |
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).
|
| |
|
|
|
|
| |
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.
|
|
|
|
|
| |
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.
|
|
|
| |
That pass is very slow on unoptimized code (super-linear on the number of locals, which if unoptimized can be massive due to flatten).
|
|
|
| |
In particular, coalesce-locals is useful even if closure is run later (apparently it finds stuff closure can't).
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
Don't use temp vars to reorder them unless we need to.
|
|
|
|
|
|
| |
* 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.
|
|
|
| |
Removes redundant | 0s and similar things. (Apparently closure compiler doesn't do that, so makes sense to do here.)
|
|
|
|
| |
(#2043)
|
|
|
|
| |
(#2042)
|
|
|
| |
Also fix the fuzzer's handling of feature flags so that wasm2js can work.
|
|
|
| |
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.
|
|
|
|
|
|
| |
* 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.
|
|
|
| |
Also emit the memory growth code based on memory growth, and not whether we are "use asm" or not.
|
|
|
|
|
| |
* Emit an import statement for the memory.
* Update the imported memory's buffer when we grow.
|
|
|
|
|
| |
This replaces the multiple asm.js tables (of power-of-2 size) with a single simple table.
Also supports importing the table.
|
|
|
|
|
|
|
|
| |
* 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)
|
|
|
|
|
| |
* Refactor memory code to share it between the two emitting modes.
* Get memory emitting set up in the emscripten mode.
|
|
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.
|