| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
| |
else (#915)
|
| |
|
|
|
| |
Emscripten's mmap2 syscall started using memalign instead of malloc with kripken/emscripten#4874, so we need to export that as well.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Handle importing globals in s2wasm
* Make importedGlobals a set of Names, make Names hashable
* Revert "Make importedGlobals a set of Names, make Names hashable"
This reverts commit 1d0ca7a5e3839b15ca60593330979864c9c3ed60.
* Refactor relocation parsing to handle expressions directly
* PR Feedback
- Move comment where it belongs
- Add comment about ownership to addRelocation
- Remove do-nothing parseImportGlobal
* Reword "imported globals" to "imported objects"
- Flip isObjectImported to isObjectImplemented, for consistency
* Add tests for s2wasm globals.
Also implement import relocation expression handling
* Simplify globals.s test
* Fix memory leak of relocation
* Use unique_ptr instead of delete in getRelocatableExpression
|
|
|
|
|
| |
The emscripten JS module code creates the memory using the native wasm
APIs, and imports that into the wasm module.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Refine tables to explicitly exist or not. Previously they were printed
or encoded if it had any segments, or an initial or max size. However
tables can be defined but empty, so we had a special hack that defined
an empty segment when we really just wanted an empty table. Now, just
make the existence explicit.
Update Function table encoding for 0xc (Table and Element sections)
Add end opcodes after function bodies (these are consumed by
getMaybeBlock with the same behavior that it had before when it reached
the function end, so no explicit decode)
Update call_indirect encoding for 0xc (no arity, call target is last)
|
| |
|
|
|
|
|
|
|
| |
Previously a table was only created if there were any address-taken
functions. New module validation rules require the existence of
a table for any call-indirects to validate (even if they are dead and
never called). However this use case seems common enough that we might
want to make it continue to work. So the linker now always creates an empty table segment (indicating an empty table).
|
|
|
|
|
|
|
|
|
|
|
| |
Several updates for s2wasm and its tests:
Add explicit drops where they are emitted by LLVM already
Convert loops (which are still modeled in the old way by LLVM) to wrap them in an explicit block (for the exit label). This also allows simplifying the loop creation (no need to post-process the implicit block which is the loop's body). After the engines update to 0xc we should update LLVM to model loops in the 0xc way, but for now it remains compatible with 0xb and 0xc.
Fix the order of the calls to setTee() when creating tee_locals
Add an explicit drop when creating the _start entry function wrapper if needed
Update dot_s and llvm_autogenerated tests to remove store-results optimization (and few other minor updates)
Fix the test auto-updater to fail if subprocesses fail
There still seems to be a validation failure when building libc (I think it's from the stricter drop rules, but it may be in the source rather than the compiler), but this at least makes Binaryen's tests pa
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add a flag to s2wasm to export grow_memory
Binaryen's wasm.js-post.js calls back in to wasm in order to grow the
linear memory, via a function that asm2wasm exports called
__growWasmMemory.
This changes exposes that method through s2wasm when invoked with a
flag.
* Move AsmConstWalker from wasm-linker to wasm-emscripten
* Add test for memory growth in s2wasm
* Move makeDynCallThunks into wasm-emscripten module
* Move mutation in getTableSegment into a separate method
* Move emscripten metadata generation into wasm-emscripten
Also make AsmConstWalker internal to the wasm-emscripten module, as it's only used for the metadata pass.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
This needs to export realloc as well, in addition to malloc and free
handled in #4469. To support asm.js style setjmp/longjmp, wasm
needs to export realloc as well, in addition to malloc and free
handled in #4469. saveSetjmp() uses realloc within it, and realloc is
not implemented in JS glue code.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Implement asm.js style exception handling for Wasm
Converts invoke wrapper names generated by LLVM backend to real invoke wrapper
names that are expected by JavaScript glue code.
This is required to support wasm exception handling (asm.js style).
LLVM backend lowers
invoke @func(arg1, arg2) to label %invoke.cont unwind label %lpad
into
... (some code)
call @invoke_SIG(func, arg1, arg2)
... (some code)
SIG is a mangled string generated based on the LLVM IR-level function
signature. In LLVM IR, types are not lowered yet, so this mangling scheme
simply takes LLVM's string representtion of parameter types and concatenate
them with '_'. For example, the name of an invoke wrapper for function void
foo(struct mystruct*, int) will be "__invoke_void_%struct.mystruct*_int". This
function converts the names of invoke wrappers based on their lowered argument
types and a return type. In the example above, the resulting new wrapper name
becomes "invoke_vii".
* Address comments
Change variable names to camelcase
Add a small (semi-)handwritten test case
* Export malloc and free from wasm when available
* Add a test case for exporting malloc/free feature
+ cosmetic 'file' name change in text_before_type.s
* fixInvokeWrapper -> fixEmExceptionInvoke
* Add a TODO
|
|
|
| |
Resolves WebAssembly/spec#312
|
|
|
| |
This patch adds support for an ".indidx" primitive that pre-assigns table indexes for functions that are called indirectly. It is used by the upstream LLVM WebAssembly backend to support fine-grained control-flow integrity for indirect function calls by emitting instrumentation at each indirect call site to check that the destination index is within certain ranges that correspond to disjoint equivalence classes of indirect call targets. The reason that this primitive is necessary is because the layout of the table section isn't determined until the WebAssembly linker is executed, but indirect function to table index mappings need to be known when opt is executed to generate the correct range checking in the LLVM IR.
|
| |
|
|
|
| |
Adds support for aliases to objects, to go along with the existing support for aliases to functions.
|
|
|
|
| |
exist, let functions be created in a way independent from global state
|
| |
|
| |
|
|
|
|
|
|
| |
Dyncall thunks are meant to be used with emscripten on the web; however
on the web, functions with i64 results or params are not allowed to be
exported.
|
|
|
|
| |
Add an s2wasm option `--no-validate` to disable validation for debugging purposes.
Also fix several validation errors by adding calls to `finalize()` after creating expressions, and ensuring that an import is created earlier in `Linker::getImportThunk`.
|
|
|
|
|
| |
Previously every address-take of an import would cause a new thunk to be
generated. Now check in getImportThunk if the thunk exists already and
just return it if so.
|
|
|
|
|
|
|
|
|
|
|
| |
Under emscripten, C code can take the address of a function implemented
in Javascript (which is exposed via an import in wasm). Because imports
do not have linear memory address in wasm, we need to generate a thunk
to be the target of the indirect call; it call the import directly.
This is facilited by a new .s directive (.functype) which declares the
types of functions which are declared but not defined.
Fixes https://github.com/WebAssembly/binaryen/issues/392
|
|
|
|
| |
that is clearer where it should be overridden (#551)
|
| |
|
|
|
|
|
|
|
|
|
| |
* Avoid double dollarsigns in s2wasm local names.
Recognize '$' as part of the .s syntax for register names, and exclude it
when forming the wasm local name. This changes names like "$$0" to "$0".
* Fix a comment.
|
| |
|
|
|
|
|
|
|
| |
We've been using size_t (and other things) for addresses, which is
generally wrong because it depends on the host, when it should in fact
depend on the target. This is a partial fix for #278 (i.e. it's the
right fix, I don't think it's applied quite everywhere yet).
|
|
|
|
|
|
|
|
|
| |
An archive member can depend on any other archive member, so adding a
member to the link can introduce new undefined references that must be
satisfied. The linker must continue to iterate over the members until
nothing new is added to the link.
|
|
|
|
|
|
|
|
| |
Add a class to parse archive files.
Support linking archive files, with archive semantics (i.e. an archive
member is linked in if it satisfies an undefined reference).
Archive files must be gnu-format archives containing .s files.
Add tests for linking semantics.
|
| |
|
|
|
|
| |
types, can more simply be held by unique_ptrs on the owning module. this avoids need to coordinate arena allocation for their elements, and only the far more plentiful expression nodes are a perf factor anyhow
|
|
|
|
|
|
|
|
|
|
|
| |
Instead of doing all of the S2Wasm work in the constructor, split
construction, scanning (to determine implemented functions) and building
of the wasm module.
This allows the linker to get the symbol information (e.g. implemented
functions) without having to build an entire module (which will be
useful for archives) and to allow the linker to link a new object into
the existing one by building the wasm module in place on the existing
module.
|
| |
|
|
|
|
|
|
|
|
|
| |
* make EffectAnalyzer a little more fun to use
* create a convert() method that can turn a node into a smaller node, reusing its memory, and use that in nop()
* use convert in wasm-linker
|
|
|
| |
s2wasm currently creates a Call AST node if the target is implemented in the current object (thus far assumed to be the final executable) and a CallImport node if not. In preparation for adding additional objects to the link before layout time, we make only Call nodes until link time, and then convert them to CallImport if they are undefined at that time.
|
|
|
|
|
| |
Create the LinkerObject class, which has a wasm Module and represents the module plus the information needed to relocate and lay it out. Each Linker owns a "main executable" LinkerObject, and S2WasmBuilder requires a LinkerObject instead of just a Module because LLVM asm files require relocation/linking before they represent a full wasm module.
No merging support yet, but the real functionality for #370 is coming soon.
|
|
|
|
| |
Also defer address assignment until layout time in preparation for
separating linker objects out from Linker
|
|
Still making things nicer for #370
Pulling wasm-linker into its own file also necessitated pulling asm_v_wasm.h into a cpp file. It goes into a new lib directory, src/asmjs.
No actual code changes in this PR.
|