| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
| |
Adds support for the bulk memory proposal's passive segments. Uses a
new (data passive ...) s-expression syntax to mark sections as
passive.
|
| |
|
|
|
| |
Emscripten runs wasm-emscripten-finalize before running wasm-opt, so the target features section is stripped out before optimizations are run. One option would have been to add another wasm-opt invocation at the very end to strip the target features section, but dumping the features as metadata avoids the extra tool invocation. In the long run, it would be nice to have only as single binaryen invocation to do all the work that needs doing.
|
|
|
|
|
|
| |
This key is used by emscripten when building with MAIN_MODULE in order
to export global variables from the main module to the side modules.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Convert PIC code generated by llvm to work with the current emscripten
ABI for dynamic linking:
- Convert mutable global imports from GOT.mem and GOT.func into
internal globals.
- Initialize these globals on started up in g$foo and f$foo imported functions
to calculate addresses at runtime.
Also:
- Add a test case for linking and finalizing a shared library
- Allow __stack_pointer global to be non-existent as can be case for
a shared library.
- Allow __stack_pointer global to be an import, as can be the case for
a shared library.
|
|
|
|
|
|
|
|
|
| |
(#1944)
We expect the stack pointer to be of a certain type. This fixes
a segfault we are seeing when passed a binary which doesn't quite
meet our expectations.
|
|
|
|
| |
We now implement addFunction by creating a wasm module to wrap
that JS function and simply adding it to the table.
|
|
|
|
|
| |
This can happen in emscripten if we run fpcast-emu after previous passes created dynCalls already. If so, it's fine to just do nothing.
Fixes emscripten-core/emscripten#8229
|
| |
|
|
|
|
|
| |
We should emit a file with only the data segments, starting from the global base, and not starting from zero (the data before is unneeded, and the emscripten loading code assumes it isn't there).
Also fix the auto updater to work properly on .mem test updating.
|
|
|
| |
Before this, we just did not emit illegal dynCalls. This was wrong as we do need them (e.g. if a function with a setjmp call calls a function with an i64 param - we'll have an invoke with that signature there). We just need to legalize them. This fixes that by first emitting them, and second by running legalization late, after dynCalls have been generated, so it legalizes them too.
|
|
|
|
|
|
|
| |
See emscripten-core/emscripten#7928 - we have been optimizing all wasms until now, and noticed this when the wasm object file path did not do so. When not optimizing, our methods of handling EM_ASM and EM_JS fail since the patterns are different.
Specifically, for EM_ASM we hunt for emscripten_asm_const(X, where X is a constant, but without opts it may be a get of a local. For EM_JS, the function body may not just contain a const, but a block with a set of the const and a return of a get later.
This adds logic to track gets and sets in basic blocks, which is sufficient to handle this.
|
|
|
|
|
|
| |
This takes advantage of the recent memory simplification in emscripten, where JS static allocation is done at compile time. That means we know the stack's initial location at compile time, and can apply it. This is the binaryen side of that:
* asm2wasm support for asm.js globals with an initial value var X = Y; where Y is not 0 (which is what the stack now is).
* wasm-emscripten-finalize support for a flag --initial-stack-pointer=X, and remove the old code to import the stack's initial location.
|
|
|
|
|
|
|
| |
(#1828)
This fixes a crash where startSave/stackRestore could be created
while iterating through `module.functions`.
|
|
|
|
| |
This allows emscripten to generate table of the correct size.
Right now is simply defaults to creating a table to size 1024.
|
|
|
|
|
|
| |
input (#1825)
|
| |
|
| |
|
|
|
| |
And use it in wasm-emscripten
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The wasm backend uses a wasm global (__stack_pointer) for the shadow
stack location. In order to make this work with shared libraries the
main module would have to export this global and shared libraries would
need to import it. This means we'd be relying of mutable globals which
are not yet implemented in all browsers.
This change allows is to move forward with shared libraries without
mutable global support by replacing all stack pointer access in shared
libraries with functions calls.
|
|
|
|
| |
In this case we won't want generate any of the normal memory
helper functions (they come from the main module).
|
|
|
|
|
| |
Not at all sure why we're seeing any there, but it's easy enough to
handle that we might as well.
|
|
|
|
| |
This writes the data section into a file suitable for use with emscripten's
--memory-init-file flag
|
|
|
|
| |
actual support) (#1711)
|
|
|
| |
While debugging to fix the waterfall regressions I noticed that wasm-reduce regressed. We need to be more careful with visitFunction which now may visit an imported function - I found a few not-well-tested passes that also regressed that way.
|
|
|
| |
Fixes the 3 regressions mentioned in a comment on #1678
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes #1649
This moves us to a single object for functions, which can be imported or nor, and likewise for globals (as a result, GetGlobals do not need to check if the global is imported or not, etc.). All imported things now inherit from Importable, which has the module and base of the import, and if they are set then it is an import.
For convenient iteration, there are a few helpers like
ModuleUtils::iterDefinedGlobals(wasm, [&](Global* global) {
.. use global ..
});
as often iteration only cares about imported or defined (non-imported) things.
|
|
|
|
|
| |
We're about to rewrite both names anyway.
This fixes LLVM's c++ invokes, which get escaped to not match as of
PR #1646
|
|
|
|
| |
This ensures that 64-bit values are correctly handled on the
JS boundary.
|
|
|
|
|
| |
Allowing duplicates here was causes emscripten to generate a JS
object with duplicate keys.
|
|
|
|
| |
s2wasm is no longer used my emscripten and as far as I know now
as no other users.
|
|
|
|
| |
This check is supposed to check if rename is needed so it
need to compare to the original.
|
|
|
|
|
|
| |
We ran into an issue recently where wasm-emscripten-finalize
was being passed input without any debug names and this is not
currently supported.
|
|
|
|
| |
jsCallStartIndex (#1579)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
implementFunctions should use the export names, not the
internal/debug name for a function. This is especially
imported with lld where the debug names are demanagled.
implementFunctions should only contain functions that are
accessible from outside the module. i.e. those that have
been exported. There is no point in adding internal-only
functions to this list as they won't be accessible from
outside anyway.
Tesed with emscripten using: ./tests/runner.py binaryen2.test_time
|
|
|
|
|
|
|
|
|
| |
wasm-emscripten (#1539)
This allows the same functionality to be used also in
wasm-emscripten-finalize (i.e. the lld path).
|
|
This adds a pass that implements "function pointer cast emulation" - allows indirect calls to go through even if the number of arguments or their types is incorrect. That is undefined behavior in C/C++ but in practice somehow works in native archs. It is even relied upon in e.g. Python.
Emscripten already has such emulation for asm.js, which also worked for asm2wasm. This implements something like it in binaryen which also allows the wasm backend to use it. As a result, Python should now be portable using the wasm backend.
The mechanism used for the emulation is to make all indirect calls use a fixed number of arguments, all of type i64, and a return type of also i64. Thunks are then placed in the table which translate the arguments properly for the target, basically by reinterpreting to i64 and back. As a result, receiving an i64 when an i32 is sent will have the upper bits all zero, and the reverse would truncate the upper bits, etc. (Note that this is different than emscripten's existing emulation, which converts (as signed) to a double. That makes sense for JS where double's can contain all numeric values, but in wasm we have i64s. Also, bitwise conversion may be more like what native archs do anyhow. It is enough for Python.)
Also adds validation for a function's type matching the function's actual params and result (surprised we didn't have that before, but we didn't, and there was even a place in the test suite where that was wrong).
Also simplifies the build script by moving two cpp files into the wasm/ subdir, so they can be built once and shared between the various tools.
|