summaryrefslogtreecommitdiff
path: root/src/tools
Commit message (Collapse)AuthorAgeFilesLines
* wasm2js: Do not convert x >>> 0 | 0 to x >>> 0 (#2581)Alon Zakai2020-01-101-2/+10
| | | | | | | | | | | | isBinary was used where we should only accept a signed binary, as removing the | 0 from an unsigned value may be incorrect. This does regress a few small things (as can be seen in the diff). If it's important we can add more sophisticated optimizations here, perhaps like an assumption that the signedness of a local never matters. Fixes emscripten-core/emscripten#10173
* Remove implicit conversion operators from Type (#2577)Thomas Lively2020-01-084-20/+20
| | | | | | | | | | * Remove implicit conversion operators from Type Now types must be explicitly converted to uint32_t with Type::getID or to ValueType with Type::getVT. This fixes #2572 for switches that use Type::getVT. * getVT => getSingle
* [NFC] Enforce use of `Type::` on type names (#2434)Thomas Lively2020-01-076-397/+404
|
* [NFC] Clean up unnecessary `template`s in calls 🧹🧹🧹 (#2394)Thomas Lively2020-01-071-3/+3
|
* Use FeatureSet instead of FeatureSet::Feature(NFC) (#2562)Heejin Ahn2020-01-021-22/+20
| | | | | This uses `FeatureSet` in place of `FeatureSet::Feature` when possible, making it possible for functions take a set of multiple features as one argument.
* Add support for reference types proposal (#2451)Heejin Ahn2019-12-305-84/+219
| | | | | | | | | | | | This adds support for the reference type proposal. This includes support for all reference types (`anyref`, `funcref`(=`anyfunc`), and `nullref`) and four new instructions: `ref.null`, `ref.is_null`, `ref.func`, and new typed `select`. This also adds subtype relationship support between reference types. This does not include table instructions yet. This also does not include wasm2js support. Fixes #2444 and fixes #2447.
* Strip DWARF in finalize, to avoid keeping it around til later unnecessarily ↵Alon Zakai2019-12-201-0/+8
| | | | | | | | (#2544) Without this, the first wasm-opt invocation will remove it. But it can be very large, and we will soon start to automatically do updating on it when it exists, so avoid the work if we aren't actually building a final output with dwarf.
* Binary format code section offset tracking (#2515)Alon Zakai2019-12-193-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Optionally track the binary format code section offsets, that is, when loading a binary, remember where each IR node was read from. This is necessary for DWARF debug info, as these are the offsets DWARF refers to. (Note that eventually we may want to do something else, like first read the DWARF and only then add debug info annotations into the IR in a more LLVM-like manner, but this is more straightforward and should be enough to update debug lines and ranges). This tracking adds noticeable overhead - every single IR node adds an entry in a map - so avoid it unless actually necessary. Specifically, if the user passes in -g and there are actually DWARF sections in the binary, and we are not about to remove those sections, then we need it. Print binary format code section offsets in text, when printing with -g. This will help debug and test dwarf support. It looks like ;; code offset: 0x7 as an annotation right before each node. Also add support for -g in wasm-opt tests (unlike a pass, it has just one - as a prefix). Helps #2400
* Support stack overflow checks in standalone mode (#2525)Alon Zakai2019-12-121-0/+2
| | | | | | | | | In normal mode we call a JS import, but we can't import from JS in standalone mode. Instead, just trap in that case with an unreachable. (The error reporting is not as good in this case, but at least it catches all errors and halts, and the emitted wasm is valid for standalone mode.) Helps emscripten-core/emscripten#10019
* Make local.tee's type its local's type (#2511)Heejin Ahn2019-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to the current spec, `local.tee`'s return type should be the same as its local's type. (Discussions on whether we should change this rule is going on in WebAssembly/reference-types#55, but here I will assume this spec does not change. If this changes, we should change many parts of Binaryen transformation anyway...) But currently in Binaryen `local.tee`'s type is computed from its value's type. This didn't make any difference in the MVP, but after we have subtype relationship in #2451, this can become a problem. For example: ``` (func $test (result funcref) (local $0 anyref) (local.tee $0 (ref.func $test) ) ) ``` This shouldn't validate in the spec, but this will pass Binaryen validation with the current `local.tee` implementation. This makes `local.tee`'s type computed from the local's type, and makes `LocalSet::makeTee` get a type parameter, to which we should pass the its corresponding local's type. We don't embed the local type in the class `LocalSet` because it may increase memory size. This also fixes the type of `local.get` to be the local type where `local.get` and `local.set` pair is created from `local.tee`.
* Remove FunctionType (#2510)Thomas Lively2019-12-116-47/+39
| | | | | | | | | | | | | | | | | Function signatures were previously redundantly stored on Function objects as well as on FunctionType objects. These two signature representations had to always be kept in sync, which was error-prone and needlessly complex. This PR takes advantage of the new ability of Type to represent multiple value types by consolidating function signatures as a pair of Types (params and results) stored on the Function object. Since there are no longer module-global named function types, significant changes had to be made to the printing and emitting of function types, as well as their parsing and manipulation in various passes. The C and JS APIs and their tests also had to be updated to remove named function types.
* Use wat over wast for text format filenames (#2518)Sam Clegg2019-12-083-5/+5
|
* Add some tracing to wasm-emscripten-finalize (#2505)Sam Clegg2019-12-051-8/+13
| | | | | Also fix, but in splitting the names of the trace channels. Obviously I can't write string.split correctly in C first time around.
* Add string parameter to WASM_UNREACHABLE (#2499)Sam Clegg2019-12-055-50/+50
| | | | | This works more like llvm's unreachable handler in that is preserves information even in release builds.
* Fix metadce debug info after #2497 (#2501)Sam Clegg2019-12-041-0/+1
| | | This like was mistakenly removed as part of the BYN_TRACE conversion.
* Remove 'none' type as a branch target in ReFinalize (#2492)Alon Zakai2019-12-041-2/+2
| | | | | | | | | | | | | | | | | 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.
* Convert to using DEBUG macros (#2497)Sam Clegg2019-12-0410-52/+19
| | | | | | This means that debugging/tracing can now be enabled and controlled centrally without managing and passing state around the codebase.
* Add BYN_DEBUG/BYN_TRACE macros similar to LLVM's debug system (#2496)Sam Clegg2019-12-041-17/+8
| | | | | | | | | 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.
* Update spec test suite (#2484)Heejin Ahn2019-11-291-2/+2
| | | | | | | | | | | | | 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.
* Remove FunctionType from Event (#2466)Thomas Lively2019-11-251-9/+3
| | | | | | | | | 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.
* Multivalue type creation and inspection (#2459)Thomas Lively2019-11-224-21/+21
| | | | | | | | | | | | | 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.
* Warning improvements (#2438)Alon Zakai2019-11-152-4/+17
| | | | | | | | 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.
* Support --pass-arg in ToolOptions. (#2429)Alon Zakai2019-11-113-17/+18
| | | | | | This will allow us to pass pass args to wasm-emscripten-finalize, which runs legalize-js-interface internally, which recently added an optional argument.
* Improve type selection in fuzzer (#2424)Heejin Ahn2019-11-061-27/+27
| | | | | | | | | - 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
* Add i32x4.dot_i16x8_s (#2420)Thomas Lively2019-11-041-0/+1
| | | | | 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.
* Add SIMD integer min and max instructions (#2416)Thomas Lively2019-11-011-0/+12
| | | As proposed in https://github.com/WebAssembly/simd/pull/27.
* Fix autoreducing when not in the binaryen directory (#2390)Alon Zakai2019-10-171-1/+6
| | | | This uses argv[0] as the default way to find the location of the wasm binaries (wasm-reduce needs to call wasm-opt).
* Use early return in wasm-opt.cpp. NFC (#2387)Sam Clegg2019-10-151-22/+23
|
* Don't add __wasm_call_ctors to startup function list in wasm standalone mode ↵Sam Clegg2019-10-141-2/+6
| | | | | (#2384) In this mode crt1 takes care of calling it.
* Fix case of `windows.h` include (#2372)Mike J Innes2019-10-091-1/+1
| | | | The capitalisation causes issues on case-sensitive file systems, for example when cross-compiling binaryen for windows.
* v8x16.swizzle (#2368)Thomas Lively2019-10-031-1/+2
| | | | As specified at https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#swizzling-using-variable-indices.
* Add feature flags and validation to wasm-metadce (#2364)Thomas Lively2019-09-271-2/+12
| | | | | | Sometimes wasm-metadce is the last tool to run over a binary in Emscripten, and in that case it needs to know what features are enabled in order to emit a valid binary. For example it needs to know whether to emit a data count section.
* SIMD load and extend instructions (#2353)Thomas Lively2019-09-241-2/+16
| | | | | | Adds support for the new load and extend instructions. Also updates from C++11 to C++17 in order to use generic lambdas in the interpreter implementation.
* v128.andnot instruction (#2355)Thomas Lively2019-09-241-0/+1
| | | | | As specified at https://github.com/WebAssembly/simd/pull/102. Also fixes bugs in the JS API for other SIMD bitwise operators.
* vNxM.load_splat instructions (#2350)Thomas Lively2019-09-231-1/+26
| | | | | | | Introduces a new instruction class, `SIMDLoad`. Implements encoding, decoding, parsing, printing, and interpretation of the load and splat instructions, including in the C and JS APIs. `v128.load` remains in the `Load` instruction class for now because the interpreter code expects a `Load` to be able to load any memory value type.
* wasm-emscripten-finalize: Add more checking of __data_end global (#2352)Sam Clegg2019-09-231-0/+3
|
* Add a --standalone-wasm flag to wasm-emscripten-finalize (#2333)Alon Zakai2019-09-181-1/+17
| | | The flag indicates that we want to run the wasm by itself, without JS support. In that case we don't emit JS dynCalls etc., and we also emit a wasi _start if there is a main, i.e., we try to use the current conventions in the wasm-only space.
* SIMD narrowing and widening operations (#2341)Thomas Lively2019-09-141-2/+14
|
* QFMA/QFMS instructions (#2328)Thomas Lively2019-09-031-6/+13
| | | | | | | | | Renames the SIMDBitselect class to SIMDTernary and adds the new {f32x4,f64x2}.qfm{a,s} ternary instructions. Because the SIMDBitselect class is no more, this is a backwards-incompatible change to the C interface. The new instructions are not yet used in the fuzzer because they are not yet implemented in V8. The corresponding LLVM commit is https://reviews.llvm.org/rL370556.
* Allow all features on wasm2js and add atomic tests (#2311)Heejin Ahn2019-08-281-7/+7
| | | | | | This adds `-all` argument to wasm2js testing and fixes wasm2js to actually take that argument (currently it doesn't, when it takes a wast file). This also adds a wasm2js test for `atomic.fence` instruction that was added in #2307.
* Add atomic.fence instruction (#2307)Heejin Ahn2019-08-271-1/+5
| | | | | | | This adds `atomic.fence` instruction: https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#fence-operator This also fix bugs in `atomic.wait` and `atomic.notify` instructions in binaryen.js and adds tests for them.
* Do not hoist truncation of wasm2js divisions (#2305)Thomas Lively2019-08-261-2/+4
| | | | | | It is not valid to defer the truncation of divisions because accumulated non-integral results can produce different values when they are combined before truncation. This was causing a test failure in the Rust test suite.
* Add initial support for anyref as an opaque type (#2294)Jay Phelps2019-08-204-7/+34
| | | | | | | | | | | | | Another round of trying to push upstream things from my fork. This PR only adds support for anyref itself as an opaque type. It does NOT implement the full [reference types proposal](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md)--so no table.get/set/grow/etc or ref.null, ref.func, etc. Figured it was easier to review and merge as we go, especially if I did something fundamentally wrong. *** I did put it under the `--enable-reference-types` flag as I imagine that even though this PR doesn't complete the full feature set, it probably is the right home. Lmk if not. I'll also be adding a few github comments to places I want to point out/question.
* wasm-emscripten-finalize: Remove reliance on name section (#2285)Sam Clegg2019-08-061-1/+1
| | | | | | | | There were a couple of places where we were relying on internal names and therefore a name section. After this change wasm-emscripten-finalize works correctly on binaries without a name section at all and only relies on the names of imports and exports.
* Implement --check-stack-overflow flag for wasm-emscripten-finalize (#2278)Guanzhong Chen2019-08-021-0/+12
|
* Enable all features in wasm-shell assert failure tests (#2254)Heejin Ahn2019-07-251-0/+1
| | | | | | | If we don't enable features in assertion failure tests, new feature tests fail not because they are malformed but because they have unsupported features. It's hard to add tests because existing `assert_invalid` tests were already failing because they have unsupported features.
* Fuzz all feature flags, and fix another SignExt issue in the fuzzer (#2259)Alon Zakai2019-07-241-1/+1
|
* Put Extend* opcodes behind SignExt feature. fixes #2257 (#2258)Alon Zakai2019-07-241-1/+1
|
* Finalize tail call support (#2246)Thomas Lively2019-07-231-8/+15
| | | | Adds tail call support to fuzzer and makes small changes to handle return calls in multiple utilities and passes. Makes larger changes to DAE and inlining passes to properly handle tail calls.
* Simpify PassRunner.add() and automatically parallelize parallel functions ↵Alon Zakai2019-07-192-5/+2
| | | | | | | | | (#2242) Main change here is in pass.h, everything else is changes to work with the new API. The add("name") remains as before, while the weird variadic add(..) which constructed the pass now just gets a std::unique_ptr of a pass. This also makes the memory management internally fully automatic. And it makes it trivial to parallelize WalkerPass::run on parallel passes. As a benefit, this allows removing a lot of code since in many cases there is no need to create a new pass runner, and running a pass can be just a single line.