| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Do not optimize or modify public heap types in any way. Public heap types
include the types of imported or exported functions, tables, globals, etc. This
is important to maintain the public interface of a module and ensure it can
still link interact as intended with the outside world.
Also add validation error if we find any nontrivial public types that are not
the types of imported or exported functions. This error is meant to help the
user ensure that type optimizations are not silently inhibited. In the future,
we may want to add options to silence this error or downgrade it to a warning.
This commit only updates the type updating machinery to avoid updating public
types. It does not update any optimization passes accordingly. Since we avoid
modifying public signature types already, this is not expected to break
anything, but in the future once we have function subtyping or if we make the
error optional, we may have to update some of our optimization passes.
|
|
|
|
| |
This is more modern and (IMHO) easier to read than that old C typedef
syntax.
|
|
|
|
|
|
| |
In BINARYEN_PASS_DEBUG=2 we save the module before each pass, and if
validation fails afterwards, we print the module before. This PR does the same for
function-parallel passes - in that case, we can actually show the specific function
that broke validation, as opposed to the whole module.
|
|
|
|
|
|
|
|
| |
This avoids needing to add include wasm-printing if a file doesn't already have it.
To achieve that, add the std::ostream hooks in wasm.h, and also use them
when possible, removing the need for the special WasmPrinter object.
Also stop printing in "full" (print types on each line) in error messages by default. The
user can still get that, as always, using BINARYEN_PRINT_FULL=1 in the env.
|
|
|
| |
Mass change to apply clang-format to everything. We are applying this in a PR by me so the (git) blame is all mine ;) but @aheejin did all the work to get clang-format set up and all the manual work to tidy up some things to make the output nicer in #2048
|
|
|
|
|
| |
This allows us to emit a (potentially modified) target features
section and conditionally emit other sections such as the DataCount
section based on the presence of features.
|
|
|
|
| |
Add feature flags and struct interface. Default feature set has all feature enabled.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This enum describes which wasm features the IR is expected to include. The
validator should reject operations which require excluded features, and passes
should avoid producing IR which requires excluded features.
This makes it easier to catch possible errors in Binaryen producers (e.g.
emscripten). Asm2wasm has a flag to enable or disable atomics. Other
tools currently just accept all features (as, dis and opt are just for
inspecting or modifying existing modules, so it would be annoying to have to use
flags with those tools and I expect the risk of accidentally introducing
atomics to be low).
|
|
|
|
| |
* refactor validator API to use enums
|
|
|
|
|
|
|
| |
This makes wasm validation parallel (the function part). This makes loading+validating tanks (a 12MB wasm file) 2.3x faster on a 4-core machine (from 3.5 to 1.5 seconds). It's a big speedup because most of loading+validating was actually validating.
It's also noticeable during compilation, since we validate by default at the end. 8% faster on -O2 and 23% on -O0. So actually fairly significant on -O0 builds.
As a bonus, this PR also moves the code from being 99% in the header to be 1% in the header.
|
| |
|
|
|
|
| |
validation that was from when we differentiated reachable from unreachable breaks (#1166)
|
|
|
| |
Reduce an interesting wasm to a smaller still interesting wasm. This takes an arbitrary command to run, and reduces the wasm as much as it can while keeping the behavior of that command fixed. This can be used to reduce compiler bugs in an arbitrary VM, etc.
|
|
|
| |
According to spec at https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wait-and-wake-operators
|
|\
| |
| | |
More fuzz fixes
|
| |
| |
| |
| | |
shouldn't try to validate
|
|/
|
|
| |
Also fix cases where fail() had the arguments backwards. Wasn't an error because lol templates.
Also fix printModuleComponent template to SFINAE on Expression* so we properly get the specialized version.
|
|\
| |
| | |
Fuzz fixes
|
| |
| |
| |
| | |
need a stack, and break targets must exist even if they are not actually taken
|
|/ |
|
|
|
| |
Also small cleanup to CMake libraries
|
|
|
|
|
|
| |
Support both syntax formats in input since the old spec
tests still need to be parsable.
|
|
|
|
| |
should still not have returns with a value, etc. update spec tests to remove some stacky tests that do not fit these new validation rules (#1034)
|
| |
|
|
|
|
| |
error may be in a global init
|
|
|
|
|
|
| |
* validate that memory/table segment values fit in the initial range
* validate that select condition should be i32
|
| |
|
|
|
|
|
|
| |
* address review feedback for #1014
|
|
|
|
|
|
|
| |
* validate that types are properly finalized, when in pass-debug mode (BINARYEN_PASS_DEBUG env var): check after each pass is run that the type of each node is equal to the proper type (when finalizing it, i.e., fully recomputing the type).
* fix many fuzz bugs found by that.
* in particular, fix dce bugs with type changes not being fully updated during code removal. add a new TypeUpdater helper class that lets a pass update types efficiently, by the helper tracking deps between blocks and branches etc., and updating/propagating type changes only as necessary.
|
|
|
|
| |
binary with either side unreachable - then they are unreachable. this makes our usage of the unreachable type consistent
|
|
|
|
| |
contents. make s2wasm avoid outputting that as well (#992)
|
|
|
|
|
|
|
|
|
|
|
|
| |
* properly validate block endings
* blocks with a value must not have a last element that is none
* fully validate input types to binary expressions
* validate i32.eqz/i64.eqz more carefully
* if condition must be i32
|
|
|
|
| |
wasm-merge tool: combines two wasm files into a larger one, handling collisions, and aware of the dynamic linking conventions. it does not do full static linking, but may eventually.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
| |
Most module walkers use PostWalker<T, Visitor<T>>, let that pattern be
expressed as simply PostWalker<T>
|
|
|
|
| |
else (#915)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* an unreachable block is one with an unreachable child, plus no breaks
* document new difference between binaryen IR and wasm
* fix relooper missing finalize
* add a bunch of tests
* don't assume that test/*.wast files print to themselves exactly; print to from.wast. this allows wast tests with comments in them
* emit unreachable blocks as (block .. unreachable) unreachable
* if without else and unreachable ifTrue is still not unreachable, it should be none
* update wasm.js
* cleanups
* empty blocks have none type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
| |
|
|
|
| |
Previously the Print pass searched the imports for a table import and skipped printing a local table declaration if found. Instead this refactors to make importation explicit, and also create importation records (previously we were inconsistent about whether such records were created in the IR depending on the wast syntax).
|
| |
|
| |
|
| |
|
|
|
|
| |
* document and clean up validation options
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* support i64 intrinsics from fastcomp, adding --wasm-only flag
* refactor callImport logic in asm2wasm to avoid recomputing wasm types again
* legalize illegal i64 params in exports and imports
* do safe i64 binary ops depending on precision
* fix addVar, only assert on names if we are using a name
|
| |
|
|
|
|
|
|
| |
* type check using block/loop/if types provided in text and binary formats.
* print if and loop sigs which were missing.
* remove dsl from OptimizeInstructions as after those changes it needs rethinking.
|
| |
|