| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
| |
Previously we tried to export it if the memory was exported, even if growth was not on, which caused an error.
|
|
|
|
|
| |
Add assertions on stack overflow in all 4 Bysyncify API calls (previously only 2 did it).
Also add a check that those assertions are hit.
|
|
|
|
|
|
|
|
| |
Gets fuzzing support for Bysyncify working.
* Add the python to run the fuzzing on bysyncify.
* Add a JS script to load and run a testcase with bysyncify support. The code has all the runtime support for sleep/resume etc., which it does on calls to imports at random in a deterministic manner.
* Export memory from fuzzer so JS can access it.
* Fix tiny builder bug with makeExport.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
| |
As decided in the recent in-person CG meeting.
|
|
|
|
|
| |
We assigned it to a local, but didn't run maybeSkip on it. As a result, it was executed during rewinding, which broke restoring the saved value.
Found by the fuzzer.
|
|
|
|
|
| |
We need memory in order to read and write rewinding info, so add it if the module didn't have any memory at all.
Found by the fuzzer.
|
|
|
|
|
|
|
|
|
| |
(#2183)
This results in better code sizes on many testcases, sometimes much better. For example, on SQLite the 150K function has only 27 locals instead of 3,874 which it had before (!). This also reduces total code size on SQLite by 15%.
The key issue is that after instrumenting control flow we have a lot bigger live ranges.
This must be done rather carefully, as we need to introduce some temp locals early on (for breaking up ifs, for call return values, etc.).
|
|
|
|
| |
This prevents RemoveImports from producing an invalid module that
references functions that no longer exist.
|
|
|
|
|
| |
Those functions are assumed to be part of the runtime. Instrumenting them would mean nothing can work.
With this fix, bysyncify is useful with pure wasm, and not just through imports.
|
|
|
| |
ignore-imports makes it not assume that any import may unwind/rewind the stack. ignore-indirect makes it not assume any indirect call can reach an unwind/rewind (which means, it assumes there is not an indirect call on the stack while unwinding).
|
|
|
| |
Add a method to note the stopping of an unwind. This is enough to implement coroutines. Includes an example of coroutine usage in the test suite.
|
|
|
|
|
|
|
|
|
| |
This adds a new pass, Bysyncify, which transforms code to allow unwind and rewinding the call stack and local state. This allows things like coroutines, turning synchronous code asynchronous, etc.
The new pass file itself has a large comment on top with docs.
So far the tests here seem to show this works, but this hasn't been tested heavily yet. My next step is to hook this up to emscripten as a replacement for asyncify/emterpreter, see emscripten-core/emscripten#8561
Note that this is completely usable by itself, so it could be useful for any language that needs coroutines etc., and not just ones using LLVM and/or emscripten. See docs on the ABI in the pass source.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes in Relooper merge consecutive blocks:
Entry block getting removed when it is part of a loop:
bb1->AddBranchTo(bb2, nullptr);
bb1->AddBranchTo(bb3, ...);
bb2->AddBranchTo(bb1, nullptr);
bb3->AddBranchTo(bb4, nullptr);
relooper.AddBlock(bb1);
relooper.AddBlock(bb2);
relooper.AddBlock(bb3);
relooper.AddBlock(bb4);
relooper.Calculate(bb1);
Branches memory leak
|
|
|
|
|
| |
This prevents the optimizer from producing v128.const instructions,
which are not supported by V8 at this time.
|
|
|
|
|
|
|
| |
This should be small enough to work in a 512K stack on Linux, which may then be small enough to work on all common OSes.
I had to update some spec tests which actually did more recursive calls, but I don't think the change reduces any relevant amount of test coverage.
This may fix the Mac bot finally, as with this it passes for me on the stack size I think Macs have by default.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This adds support for the event and the event section, as specified in
https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model.
Wasm events are features that suspend the current execution and transfer
the control flow to a corresponding handler. Currently the only
supported event kind is exceptions.
For events, this includes support for
- Binary file reading/writing
- Wast file reading/writing
- Binaryen.js API
- Fuzzer
- Validation
- Metadce
- Passes: metrics, minify-imports-and-exports,
remove-unused-module-elements
|
|
|
|
|
|
|
|
|
|
| |
* work
* fix
* fix
* format
|
|
|
|
| |
This adds `Features.MVP` and `Features.All` to binaryen.js and make test
cases use it.
|
|
|
|
|
| |
This pattern-matches towers of blocks + a br_table into a JS switch. This is much smaller in code size and also avoids heavy nesting that can exceed the recursion limits of JS parsers.
This is not enough yet, because it pattern-matches very specifically. In reality, switches can look slightly different. Followup PRs will extend this. For now, this passes the test suite (what passed before - not including the massive-switch tests) + fuzzing so it's a good start.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Refactored & fixed typeuse parsing rules so now the rules more closely
follow the spec. There have been multiple parsing rules that were
different in subtle ways, which are supposed to be the same according
to the spec.
- Duplicate types, i.e., types with the same signature, in the type
section are allowed as long as they don't have the same given name.
If a name is given, we use it; if type name is not given, we
generate one in the form of `$FUNCSIG$` + signature string. If the
same generated name already exists in the type section, we append
`_` at the end. This causes most of the changes in the autogenerated
type names in test outputs.
- A typeuse has to be in the order of (type) -> (param) -> (result),
if more than one of them exist. In case of function definitions,
(local) has to be after all of these. Fixed some test cases that
violate this rule.
- When only (param)/(result) are given, its type will be the type with
the smallest existing type index whose parameter and result are the
same. If there's no such type, a new type will be created and
inserted.
- Added a test case `duplicate_types.wast` to test type namings for
duplicate types.
- Refactored `parseFunction` function.
- Add more overrides to helper functions: `getSig` and
`ensureFunctionType`.
|
|
|
|
|
| |
We have `getFunction`, but not `getGlobal` because its name clashed with
APIs for the deprecated instruction `get_global`. Now we have reflected
instruction renaming in code, we can add it for consistency.
|
| |
|
|
|
|
|
| |
(#2106)
Fixes #2103.
|
|
|
| |
Windows filenames can't contain colons. Use @ instead for passing arguments to passes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Reflected new renamed instruction names in code and tests:
- `get_local` -> `local.get`
- `set_local` -> `local.set`
- `tee_local` -> `local.tee`
- `get_global` -> `global.get`
- `set_global` -> `global.set`
- `current_memory` -> `memory.size`
- `grow_memory` -> `memory.grow`
- Removed APIs related to old instruction names in Binaryen.js and added
APIs with new names if they are missing.
- Renamed `typedef SortedVector LocalSet` to `SetsOfLocals` to prevent
name clashes.
- Resolved several TODO renaming items in wasm-binary.h:
- `TableSwitch` -> `BrTable`
- `I32ConvertI64` -> `I32WrapI64`
- `I64STruncI32` -> `I64SExtendI32`
- `I64UTruncI32` -> `I64UExtendI32`
- `F32ConvertF64` -> `F32DemoteI64`
- `F64ConvertF32` -> `F64PromoteF32`
- Renamed `BinaryenGetFeatures` and `BinaryenSetFeatures` to
`BinaryenModuleGetFeatures` and `BinaryenModuleSetFeatures` for
consistency.
|
|
|
|
|
|
| |
* fix
* fix style
|
|
|
| |
This happened on wasm2js, where implicit traps are off by default, and this bug is specific to that (less-tested) mode.
|
|
|
| |
After s2wasm was removed, these tests don't seem to be used anymore.
|
| |
|
|
|
|
|
| |
gets (#2118)
In unreachable code, a get may have a single set that assigns to it, and that set may be assigned to by that very get.
|
|
|
|
|
| |
Add feature handling to the C/JS APIs. No features are enabled by
default, so all used features will have to be explicitly enabled in
order for modules to validate.
|
|
|
|
|
|
| |
This is useful for front-ends which wish to selectively enable or
disable coloring.
Also expose these APIs from the C API.
|
| |
|
| |
|
| |
|
| |
|
|
|
| |
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).
|
|
|
| |
This happens on e.g. an i32 load of a constant offset, then we have constant >> 2.
|
|
|
|
|
| |
- Print `globals` array in the tracing mode like other arrays
(`functions`, `exports`, `imports`, ...)
- Add accessor functions for globals
|
|
|
| |
This helps quite a lot on wasm2js.
|
|
|
|
|
| |
In JS a reinterpret is especially expensive, as we implement it as a write to a temp buffer and a read using another view. This finds places where we load a value from memory, then reinterpret it later - in that case, we can load it using another view, at the cost of another load and another local.
This is helpful on things like Box2D, where there are many reinterprets due to the main 2D vector class being an union over two floats/ints, and LLVM likes to do a single i64 load of them.
|
|
|
|
| |
This adds except_ref type, which is a part of the exception handling
proposal.
|
| |
|
|
|
| |
This only adds the feature and its flag and not the instructions yet.
|
|
|
|
| |
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.
|
|
|
| |
Without this PR, wasm2js0.test_printf in emscripten took an extremely long time to compile.
|
|
|
| |
A minifier would probably remove them later anyhow, but they make reading the code annoying and hard.
|
|
|
|
|
| |
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.
|