summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Fuzz fix for DuplicateFunctionElimination (#3204)Alon Zakai2020-10-081-1/+3
| | | | The replaceFunctions utility replaced exports by name, but did not check the kind, so it could get confused when names happen to overlap.
* Add static guards for cast and dynCast (#3201)Max Graey2020-10-081-1/+13
|
* Remove RelooperJumpThreading pass, which was just for fastcomp (#3199)Alon Zakai2020-10-084-286/+0
| | | See emscripten-core/emscripten#11860
* Remove old attempted DSL beginnings from OptimizeInstructions (#3200)Alon Zakai2020-10-083-73/+0
| | | | | | Wasm turned out to not be that good for a DSL for such peephole optimizations, so that never made progress. Meanwhile we have the new matcher stuff which works well.
* Add optimization rules for some shift operations (#3099)Max Graey2020-10-072-0/+42
| | | Specifically, truncates constant shift values that are greater than the number of bits available and optimizes out explicit masking of the shift value that is redundant with the implicit masking performed by shift operations.
* Revert some changes for #3193 (#3197)Max Graey2020-10-061-15/+14
| | | `(signed)x % (i32|i64).min_s ==> (x & (i32|i64).max_s)` is not valid unless compared to zero.
* refactor makeFromUInt64 to makeFromInt64 (#3194)Max Graey2020-10-053-6/+9
| | | For consistency with `makeFromInt32`.
* fast-math: Fold `fp * -1` to `-fp` (#3189)Max Graey2020-10-051-2/+5
|
* Generalize transforms for #3153 (#3193)Max Graey2020-10-052-11/+97
| | | | | | | | | | | | | | Implement a more general (additional) version of #3153 which also handles negative constant divisors: `(int32)x % -4 == 0` --> `(x & 3) == 0` `x % -C_pot == 0` --> `(x & (abs(C_pot) - 1)) == 0` and special two-complement values as well: `(int32)x % 0x80000000 == 0` --> `(x & 0x7fffffff) == 0` `(int64)x % 0x8000000000000000 == 0` --> `(x & 0x7fffffffffffffff) == 0` as separete rules: `(int32)x % 0x80000000` --> `x & 0x7fffffff` `(int64)x % 0x8000000000000000` --> `x & 0x7fffffffffffffff` The [previous pr](https://github.com/WebAssembly/binaryen/pull/3153) didn't use these possibilities.
* Ordering correction fix in OptimizeInstructions for #3047 (#3195)Alon Zakai2020-10-051-2/+12
| | | | | | | | | | | | (found by the fuzzer) It is not valid to replace x | (y | x) ==> y | x, if x, y cannot be reordered. It is also not valid to replace x ^ (y ^ x) ==> y, if x, y cannot be reordered, for a more subtle reason: if they cannot be reordered then y can affect the value of x (the opposite is not possible as we checked x for side effects so that we could remove one copy). If so, then the second appearance of x could be different, if e.g. it reads a local y writes to. Whereas, if it's ok to reorder, then it's ok to do x ^ (y ^ x) ==> x ^ (x ^ y) ==> y.
* Let GenerateDynCalls generate dynCalls for invokes (#3192)Heejin Ahn2020-10-023-76/+87
| | | | | | This moves dynCall generating functionaity for invokes from `EmscriptenGlueGenerator` to `GenerateDynCalls` pass. So now `GenerateDynCalls` pass will take care of all cases we need dynCalls: functions in tables and invokes.
* Simplify some numeric code (#3186)Max Graey2020-10-014-19/+7
|
* Optimize "clear bit mask" combination to cyclic rotation over preinverted ↵Max Graey2020-10-012-0/+24
| | | | mask (#3184)
* Add comment about signed => unsigned lowering (#3187)Max Graey2020-10-011-0/+5
|
* Stop generating __growWasmMemory (#3180)Sam Clegg2020-10-015-17/+0
| | | This depends on https://github.com/emscripten-core/emscripten/pull/12391
* Add C and JS APIs for fast math (#3188)Max Graey2020-10-013-0/+26
| | | Adds `BinaryenGetFastMath` and `BinaryenSetFastMath` to the C API, respectively `binaryen.getFastMath` and `binaryen.setFastMath` to the JS API.
* wasm2js: override incoming memory's grow method (#3185)Sam Clegg2020-09-301-6/+40
| | | | | | | | | | This will allow for the completely removal of `__growWasmMemory` as a followup. We currently unconditionally generate this function in `generateMemoryGrowthFunction`. See #3180
* Clean up support/bits.h (#3177)Thomas Lively2020-09-308-90/+93
| | | | | Use overloads instead of templates where applicable and change function names from PascalCase to camelCase. Also puts the functions in the Bits namespace to avoid naming conflicts.
* Remove unnecessary "new" on Table generation in wasm2js (#3163)Alon Zakai2020-09-301-2/+1
| | | It's not an actual constructor, just a JS function that returns the object.
* Add --fast-math mode (#3155)Alon Zakai2020-09-304-46/+27
| | | | | | | | | | | | Similar to clang and gcc, --fast-math makes us ignore corner cases of floating-point math like NaN changes and (not done yet) lack of associativity and so forth. In the future we may want to have separate fast math flags for each specific thing, like gcc and clang do. This undoes some changes (#2958 and #3096) where we assumed it was ok to not change NaN bits, but @binji corrected us. We can only do such things in fast math mode. This puts those optimizations behind that flag, adds tests for it, and restores the interpreter to the simpler code from before with no special cases.
* Fold i32.eqz(wrap_i64(x)) -> i64.eqz(x) where possible (#3181)Max Graey2020-09-301-0/+12
| | | Specifically, when `x` has at most 32 bits so that wrapping doesn't change its value.
* Simplify signed remainders compared with zero (#3153)Max Graey2020-09-291-9/+29
| | | | | | Specifically when the divisor is a power of two. `eqz((signed)x % C_pot)` -> `eqz(x & (C_pot - 1))` `(signed)x % C_pot != 0` -> `x & (C_pot - 1) != 0`
* Fix applying default / unify SExpr and Wasm builder names (#3179)Daniel Wirtz2020-09-301-5/+7
| | | SExpressionWasmBuilder was not applying default memory and table import names on the memory and table, unlike on functions, globals and events, where it applies them. Also aligns default import names to use the same shorter forms as in binary parsing.
* GC: Add stubs for the remaining instructions (#3174)Daniel Wirtz2020-09-2924-44/+1513
| | | NFC, except adding most of the boilerplate for the remaining GC instructions. Each implementation site is marked with a respective `TODO (gc): theInstruction` in between the typical boilerplate code.
* Add also non-equal with zero simplification for boolean context (#3178)Max Graey2020-09-291-2/+3
|
* GC: Fuzzing support for i31 (#3169)Daniel Wirtz2020-09-297-31/+61
| | | Integrates `i31ref` types and instructions into the fuzzer, by assuming that `(i31.new (i32.const N))` is constant and hence suitable to be used in global initializers.
* Prototype extended-name-section proposal (#3162)Daniel Wirtz2020-09-292-26/+182
| | | Implements the parts of the Extended Name Section Proposal that are trivially applicable to Binaryen, in particular table, memory and global names. Does not yet implement label, type, elem and data names.
* Refactor literal equality and hashing to not depend on getBits (#3159)Daniel Wirtz2020-09-292-33/+107
| | | Comparing and hashing literals previously depended on `getBits`, which was fine while there were only basic numeric types, but doesn't map well to reference types anymore. Hence this change limits the use of `getBits` to basic numeric types, and implements reference types-aware comparisons and hashing do deal with the newer types.
* Fix regression in memory.fill due to Memory64 (#3176)Wouter van Oortmerssen2020-09-283-8/+23
| | | details: https://github.com/WebAssembly/binaryen/issues/3149
* Lower signed binops to unsigned binops when possible (#2988)Max Graey2020-09-282-12/+61
| | | This can unlock further instruction optimizations that do not apply to signed operations.
* Fix low_pc updating when the expression is right at the start (#3175)Alon Zakai2020-09-281-1/+1
| | | | | In that case LLVM emits the address of the declarations area (where locals are declared) of the function, which is even earlier than the instructions actual first byte. I'm not sure why it does this, but it's easy to handle.
* Allow atomics to validate with unshared memory (#3172)Thomas Lively2020-09-251-21/+0
| | | | This relaxation has made it to Chrome stable, so it makes sense that we would allow it in the tools.
* Fix missing feature validations (#3171)Daniel Wirtz2020-09-251-0/+25
| | | Instructions `ref.null`, `ref.is_null`, `ref.func`, `try`, `throw`, `rethrow` and `br_on_exn` were previously missing explicit feature checks, and this change adds them. Note that some of these already didn't validate before for other reasons, like requiring the use of a type checked otherwise, but `ref.null` and `try` validated even in context of FeatureSet::MVP, so better to be sure.
* Add new unary and binary matchers (#3168)Thomas Lively2020-09-241-34/+82
| | | | | Adds new matchers that allow for matching any unary or binary operation and optionally extracting it. The previous matchers only allowed matching specific unary and binary operations. This should help simplify #3132.
* wasm2js: Skip heap creation in the absence of wasm memory. NFC (#3167)Sam Clegg2020-09-241-57/+64
| | | | | Also, format the asmFunc call to make it more readable in the ES6 modules case.
* GC: Add i31 instructions (#3154)Daniel Wirtz2020-09-2426-502/+925
| | | Adds the `i31.new` and `i31.get_s/u` instructions for creating and working with `i31ref` typed values. Does not include fuzzer integration just yet because the fuzzer expects that trivial values it creates are suitable in global initializers, which is not the case for trivial `i31ref` expressions.
* Remove unused stack-pointer and emscripten-sbrk-ptr pass args from ↵Sam Clegg2020-09-221-52/+0
| | | | | PostEmscripten (#3161) These were removed completely from the emscripten side in #12057
* Fix build after semantic merge conflict (#3160)Thomas Lively2020-09-222-6/+3
| | | Removes even more uses of allocators.
* Remove redundant allocator in Builder (#3144)Thomas Lively2020-09-224-69/+65
| | | | | | Builders gained a `Module` field in #3130 because they now require extra context to properly finalize some Expressions. Since modules contain allocators, the old allocator field on the builder became redundant after that change. This PR removes the redundant allocator field.
* ir/bits.h cleanups after #2879 (#3156)Alon Zakai2020-09-221-19/+11
| | | | Improve some comments, and remove fast paths that are just optimizations for compile time (code clarity matters more here).
* Fuzz with negative zero more often (#3133)Alon Zakai2020-09-211-2/+4
| | | | We did so earlier sometimes, as we would pick 0 and then tweak it with a negation. But that favored positive 0. This makes coverage symmetric.
* wasm2js: Support exported tables (#3152)Sam Clegg2020-09-211-55/+150
|
* Fix i64 type checking in getMaxBitsForLocal of DummyLocalInfoProvider (#3150)Max Graey2020-09-211-2/+1
| | | | | The problem existed for a very long time, but since the DummyLocalInfoProvider is almost never used, this did not create problems.
* Add Memory64 feature flag to the C and JS APIs (#3148)Daniel Wirtz2020-09-213-0/+5
|
* GC: Add ref.eq instruction (#3145)Daniel Wirtz2020-09-2126-4/+239
| | | With `eqref` now integrated, the `ref.eq` instruction can be implemented. The only valid LHS and RHS value is `(ref.null eq)` for now, but implementation and fuzzer integration is otherwise complete.
* GC: Integrate eqref and i31ref types (#3141)Daniel Wirtz2020-09-1924-25/+242
| | | Adds the `eqref` and `i31ref` types to their respective code locations. Implements what can be implemented trivially and otherwise traps with a TODO for now. Integration of `eqref` is mostly complete due to it being nullable, just like `anyref`, but `i31ref` needs to remain disabled in the fuzzer because we are lacking the functionality to create trivial `i31ref` values, i.e. `(i31.new (i32.const 0))`, which is left for follow-ups to implement.
* Expression matching API (#3134)Thomas Lively2020-09-183-358/+1170
| | | | | | | | | | | Provides an easily extensible layered API for matching expression patterns and extracting their components. The low-level API provides modular building blocks for creating matchers for any data type and the high-level API provides a succinct and flexible interface for matching expressions and extracting useful information from them. Matchers are currently provided for Const, Unary, Binary, and Select instructions. Adding a matcher for a new type of expression is straightforward enough that I expect to add them as they become useful as part of other changes.
* Initial implementation of "Memory64" proposal (#3130)Wouter van Oortmerssen2020-09-1826-258/+430
| | | Also includes a lot of new spec tests that eventually need to go into the spec repo
* Update JS API function wrapper (#3128)Daniel Wirtz2020-09-181-19/+49
| | | Updates the JS API `Function` wrapper introduced in #3115 with bindings for more C API functions. Also adds additional comments to describe the inner workings of wrappers in more detail.
* Optimize binary operations with 1-bit on lhs and 1 const on rhs (#2948)Max Graey2020-09-171-10/+45
| | | | | | | `expr | 1` --> `1` `expr & 1` --> `expr` `expr == 1` --> `expr` `expr != 1` --> `!expr` where `maxBits(expr) == 1` i.e `expr` is boolean