| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
This works more like llvm's unreachable handler in that is preserves
information even in release builds.
|
|
|
|
|
|
|
|
| |
We always enable assertions by default, but this options allows for
a build without them.
Fix all errors in the ASSERTIONS=OFF build, even though we don't
normally build this its good to keep it building.
|
|
|
| |
This like was mistakenly removed as part of the BYN_TRACE conversion.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
That was needed for super-old wasm type system, where we allowed
(block $x
(br_if $x
(unreachable)
(nop)
)
)
That is, we differentiated "taken" branches from "named" ones (just
referred to by name, but not actually taken as it's in unreachable code).
We don't need to differentiate those any more. Remove the ReFinalize
code that considered it, and also remove the named/taken distinction in
other places.
|
|
|
| |
This is line with modern cmake conventions is much less SHOUTY!
|
|
|
|
|
|
| |
This means that debugging/tracing can now be enabled and controlled
centrally without managing and passing state around the codebase.
|
|
|
|
|
|
|
|
|
| |
This allows for debug trace message to be split my channel. So you
can pass `--debug` to simply debug everything, or `--debug=opt`
to only debug wasm-opt.
This change is the initial introduction but as a followup I hope to
convert all tracing over to this new system so we can more easily
control the debug output.
|
|
|
|
|
|
|
|
|
|
|
|
| |
We already have exports for _malloc and _free in the Emscripten build, but there
is no way yet to initialize the data without resorting to JS. Hence this PR
adds a few additional memory helpers to the Emscripten build so it becomes
possible to manipulate Binaryen memory without the need for extra glue code, for
example when Binaryen is a WebAssembly import, and one is allocating strings to
be used by / reading strings returned by Binaryen.
I expect this to be a bit controversial because the use case is relatively
specific, but it makes sense for us because we are consuming the C-API directly
(from JS and eventually Wasm) and don't rely on binaryen.js-post.js.
|
|
|
|
|
|
|
|
|
|
|
| |
This creates utility functions for removing module elements: removing
one element by name, and removing multiple elements using a predicate
function. And makes other parts of code use it. I think this is a
light-handed approach than calling `Module::updateMaps` after removing
only a part of module elements.
This also fixes a bug in the inlining pass: it didn't call
`Module::updateMaps` after removing functions. After this patch callers
don't need to additionally call it anyway.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This updates spec test suite to that of the current up-to-date version
of https://github.com/WebAssembly/spec repo.
- All failing tests are added in `BLACKLIST` in shared.py with reasons.
- For tests that already existed and was passing and started failing
after the update, we add the new test to the blacklist and preserve
the old file by renaming it to 'old_[FILENAME].wast' not to lose test
coverage. When the cause of the error is fixed or the unsupported
construct gets support so the new test passes, we can delete the
corresponding 'old_[FILENAME].wast' file.
- Adds support for `spectest.print_[type] style imports.
|
|
|
|
|
|
|
|
|
| |
using the `$<TARGET_OBJECTS:objlib>` syntax. Use this variable when
adding `libbinaryen` as static or shared library. Additionally, use the
variable with the object files to simplify the `TARGET_LINK_LIBRARIES`
commands: add the object libraries to the sources of executables and
drop the use of our libraries in `TARGET_LINK_LIBRARIES`. (Object
libraries cannot be linked but must be used as sources. See
https://cmake.org/pipermail/cmake/2018-June/067721.html)
|
|
|
|
|
|
|
|
|
|
| |
Create a new ParallelFunctionAnalysis helper, which lets us
run in parallel on all functions and collect info from them,
without manually handling locks etc.
Use that in the binary writing code's type collection logic,
avoiding a lock for each type increment.
Also add Signature printing which was useful to debug this.
|
|
|
|
|
|
|
|
|
| |
We were only updating the imported Function's type name
field and failing to update its params and results. This caused the
binary writer to start using the wrong types after #2466.
This PR fixes the code to update both type representations on the
imported function. This double bookkeeping will be removed entirely in
an upcoming PR.
|
|
|
|
| |
This improves typechecking by verifying that user passes pointers of correct types.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Current `<<` operator on `Literal` prints `[type].const` with it. But
`[type].const` is rather an instruction than a literal itself, and
printing it with the literals makes less sense when we later have
literals whose type don't have `const` instructions (such as reference
types).
This patch
- Makes `<<` operator on `Literal` print only its value
- Makes wasm-shell's shell interface comply with the spec interpreter's
printing format (`value : type`).
- Prints wasm-shell's `[trap]` message to stderr
These make all `fix_` routines for spec tests in check.py unnecessary.
|
|
|
|
|
| |
(#2474)
This reverts commit bf8f36c31c0b8e6213bce840be66937dd6d0f6af.
|
|
|
|
|
|
|
|
|
| |
This is the start of a larger refactoring to remove FunctionType entirely and
store types and signatures directly on the entities that use them. This PR
updates BrOnExn and Events to remove their use of FunctionType and makes the
BinaryWriter traverse the module and collect types rather than using the global
FunctionType list. While we are collecting types, we also sort them by frequency
as an optimization. Remaining uses of FunctionType in Function, CallIndirect,
and parsing will be removed in a future PR.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Transform libraries created in subdirectories from statically linked
libraries to CMake object libraries.
* Link object libraries as `PRIVATE` to `libbinaryen`.
According to CMake documentation: "Libraries and targets following
PRIVATE are linked to, but are not made part of the link interface."
This is exactly what we want, as we only want the C API to be part of
the interface.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adds the ability to create multivalue types from vectors of concrete value
types. All types are transparently interned, so their representation is still a
single uint32_t. Types can be extracted into vectors of their component parts,
and all the single value types expand into vectors containing themselves.
Multivalue types are not yet used in the IR, but their creation and inspection
functionality is exposed and tested in the C and JS APIs.
Also makes common type predicates methods of Type and improves the ergonomics of
type printing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
clang/llvm introduce __original_main as a workaround for
the fact that main may have different signatures. A downside
to that is that users get it in stack traces, which is confusing.
In -O2 and above we normally inline __original_main anyhow,
but as this is for debugging, non-optimized builds matter too,
so add a pass for this.
The implementation is trivial, just call doInling. However we
must check some corner cases first.
Bonus minor fixes to FindAllPointers, which unnecessarily
created an object to get the class Id (which is not valid
for all classes), and that it didn't take the input by
reference properly, which meant we couldn't get the
pointer to the function body's toplevel.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This pass strips DWARF debug sections, but not other debug
sections. This is useful when emitting source maps, as we do
need the SourceMapURL section, but the DWARF sections are
not longer necessary (and we've seen a testcase where they
are massively large, so big the wasm can't even be loaded in
a browser...).
Also contains a trivial one-line fix in --extract-function which
was necessary to create the testcase here: that pass extracts
a function from a wasm file (like llvm-extract) but it didn't check
if an export already existed for the function.
|
|
|
|
|
| |
Adds the AssemblyScript-specific passes post-assemblyscript
and post-assemblyscript-finalize, eliminating redundant ARC-style
retain/release patterns conservatively emitted by the compiler.
|
|
|
|
|
|
|
|
|
|
|
|
| |
When we see invoke_ calls in emscripten-generated code, we know
they call into JS just to do a try-catch for exceptions. If the target being
called cannot throw, which we check in a whole-program manner, then
we can simply skip the invoke.
I confirmed that this fixes the regression in emscripten-core/emscripten#9817 (comment)
(that is, with this optimization, upstream is around as fast as fastcomp).
When we have native wasm exception handling, this can be
extended to optimize that as well.
|
|
|
|
|
|
|
|
|
|
|
| |
This moves code out of Asyncify into a general helper class. The class
automates scanning the functions for a property, then propagating it to
functions that call them. In Asyncify, the property is "may call something
that leads to sleep", and we propagate backwards to callers, to find
all those that may sleep.
This will be useful in a future exceptions-optimizing pass I want to write,
where the property will be "may throw". We will then be able to remove
exceptions overhead in cases that definitely do not throw.
|
| |
|
|
|
|
|
|
|
|
| |
If wasm-opt is run with no passes, warn, as we've gotten reports that people
assume a tool called "wasm-opt" should optimize automatically (but we follow
llvm's opt convention of not doing so).
Add a --quiet (-q) flag that suppresses this minor warning, and the other minor
warning where there is no output file.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is an alternative to #2361 in that it only implements reusing BINARYEN_API
so we don't have to list all the functions in build-js.sh. Differs in that it
keeps the sh file relatively straight forward without going overboard with bash
functionality. Also adds various quotes in case of whitespace in paths and makes
it so that *.sh files always use LF line endings to ease Windows support. For
instance, I am pulling the repository in Windows but compile in WSL, which, if
Git isn't properly configured to check out line endings as-is, would otherwise
break the sh files.
Fixes #2361.
|
|
|
|
|
|
|
|
|
| |
The plan is to extend `Type` to represent arbitrary multivalue types,
and as a prerequisite for that it is necessary to make it a class
instead of an enum. This PR bends over backwards to add all the
automatic conversions and constants necessary to allow the rest of the
code to compile unmodified, but in the future it should be possible to
standardize usage across the code base and remove some of these
utilities.
|
|
|
|
|
| |
(#2432)
`uint32_t` instead of `int64_t` as return type for `GetMemorySegmentByteOffset` and minor fixes on tests.
|
|
|
|
| |
Fixes #2430
|
|
|
|
|
|
| |
This will allow us to pass pass args to
wasm-emscripten-finalize, which runs
legalize-js-interface internally, which recently
added an optional argument.
|
|
|
|
|
| |
The original is necessary if we want to pass it to wasm, where it will be called
directly, without JS legalization. For example the JS dynamic loader in
emscripten needs this, emscripten-core/emscripten#9562
|
|
|
|
|
|
|
| |
- When a catch body is a block, call its `finalize` function with the
correct type
- Don't create a block when there's one instruction in a catch body
- Remove `makeCatch` from gen-s-parser.py; it's not necessary
- Fix a test case that has a `catch` without `try`
|
| |
|
|
|
|
|
|
|
|
|
| |
- Adds `items` function for `FeatureOptions` so we can get a vector of
eligible types
- Replaces hardcoded enumeration of MVP types with `getConcreteTypes`,
which also adds v128 type to the list if SIMD is enabled
- Removes `getType()` function; this does not seem to be used anywhere
- Renames `vectorPick` with `pick`
- Use the absolute path for d8 in the fuzzer
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since we switched the using memory addresses for asm const indexes
and stopping trying to modify the code we can no loner de-duplicate
the asm const strings here.
If we want to de-duplicate in the strings in emscripten we could do that
but it seems like a marginal benefit.
This fixes the test_html5_gamepad failures which is currently showing
up on the emscripten waterfall.
|
|
|
|
|
| |
This experimental instruction is specified in
https://github.com/WebAssembly/simd/pull/127 and is being implemented
to enable further investigation of its performance impact.
|
|
|
| |
Fixes #2417
|
|
|
| |
PostWalker traversal should visit its value.
|
|
|
| |
As proposed in https://github.com/WebAssembly/simd/pull/27.
|
|
|
|
| |
Like an `If`, `Try` construct is reachable when either its try body or
catch body is reachable. This adds support for that.
|
|
|
|
|
| |
Previously RemoveUnusedModuleElements pass only preserved exported
events and did not preserve events used in `throw` and `br_on_exn`
instructions. This fixes it.
|
|
|
|
|
|
|
|
|
|
| |
Before we used 0-based indexes which meant that we needed to modify the
code calling the emasm function to replace the first argument.
Now we use the string address itself as the index/code for the emasm
constant. This allows use code to go unmodifed as the emscripten side
will accept the memory address as the index/code.
See: https://github.com/emscripten-core/emscripten/issues/9013
|
|
|
| |
This fixes a crash when programs containing load_splats are optimized.
|
|
|
| |
This fixes a compiler error when trying to compile code calling this function with a C++ compiler.
|
|
|
|
|
|
| |
renamed (#2382)
Fixes https://github.com/WebAssembly/binaryen/issues/2180
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These passes are meant to be run after Asyncify has been run, they modify the
output. We can assume that we will always unwind if we reach an import, or
that we will never unwind, etc.
This is meant to help with lazy code loading, that is, the ability for an
initially-downloaded wasm to not contain all the code, and if code not present
there is called, we download all the rest and continue with that. That could
work something like this:
* The wasm is created. It contains calls to a special import for lazy code
loading.
* Asyncify is run on it.
* The initially downloaded wasm is created by running
--mod-asyncify-always-and-only-unwind: if the special import for lazy code
loading is called, we will definitely unwind, and we won't rewind in this binary.
* The lazily downloaded wasm is created by running --mod-asyncify-never-unwind:
we will rewind into this binary, but no longer need support for unwinding.
(Optionally, there could also be a third wasm, which has not had Asyncify run
on it, and which we'd swap to for max speed.)
These --mod-asyncify passes allow the optimizer to do a lot of work, especially
for the initially downloaded wasm if we have lots of calls to the lazy code
loading import. In that case the optimizer will see that those calls unwind,
which means the code after them is not reached, potentially making lots of code
dead and removable.
|
|
|
|
| |
This fixes #2396. This converts the use of the old Pointer_stringify to the new
UTF8ToString. Added a js test in kitchen-sink.js to cover this.
|
| |
|
|
|
| |
Adds functionality to the C API for getting the number of items in a module and fetching them out by index.
|