summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* [GC] ref.as_non_null (#3527)Alon Zakai2021-01-2813-0/+41
| | | | | | This is different than the other RefAs variants in that it is part of the typed functions proposal, and not GC. But it is part of GC prototype 3. Note: This is not useful to us yet as we don't support non-nullable types.
* [GC] Add br_on_func/data/i31 (#3525)Alon Zakai2021-01-2827-76/+339
| | | | | | | | This expands the existing BrOnCast into BrOn that can also handle the func/data/i31 variants. This is not as elegant as RefIs / RefAs in that BrOnCast has an extra rtt field, but I think it is still the best option. We already have optional fields on Break (the value and condition), so making rtt optional is not odd. And it allows us to share all the behavior of br_on_* which aside from the cast or the check itself, is identical - returning the value if the branch is not taken, etc.
* [GC] Update br_on_cast: the text format also no longer has a heap type (#3523)Alon Zakai2021-01-2713-41/+41
| | | | | | | As a result, we cannot handle a br_on_cast with an unreachable RTT. The binary format solves the problem by ignoring unreachable code, and this makes the text format do the same. A nice benefit of this is that we can remove the castType extra field.
* Remove test suite's assumption of minify_check roundtripping perfectly (#3524)Alon Zakai2021-01-271-13/+2
| | | | | | | | | | | | minify_check checks that we can print and read minified wast. The test also, however, assumed that we round-trip such things perfectly. That's never been true, and only by chance did this go unnoticed until now, in #3523 The specific issue happening there is that we create a block without a name. Then we write that as text, then read it. When we read it, we give all such blocks a name (and we rely on optimizations to remove it later when possible - this avoids optimizing in the parser). The extra name looks like a bug to minify_check.
* Memcpy data instead of bytewise copies (#3521)Philip Pfaffe2021-01-272-19/+23
| | | | | | wasm-finalize currently makes byte-wise copies of section data in the user and data sections. If the section is large, that's extraordinarily expensive. With a memcpy instead I see a speedup of 1.6 for a large wasm binary with DWARF data.
* Simplfy getExpressionName (#3522)Alon Zakai2021-01-2715-310/+166
| | | | | | | | | | This used to return a simple name like "if" for an If, but it is redundant with our proper printing logic. This PR turns it into a trivial helper that just prints out the name of the class, so it now prints "If" with a capital. That is useful for some logging, like in Metrics I think it is clearer than it was earlier (since we are actually counting the classes, and our old emitting of text-format-like names are just confusing, as we emitted "binary" there which is not valid). Also replace some usages of that method with proper printing.
* [GC] ref.as_* (#3520)Alon Zakai2021-01-2722-5/+257
| | | | | | | | These are similar to is, but instead of returning an i32 answer, they trap on an invalid value, and return it otherwise. These could in theory be in a single RefDoThing, with opcodes for both As and Is, but as the return values are different, that would be a little odd, and the name would be less clear.
* [GC] ref.is_func/data/i31 (#3519)Alon Zakai2021-01-2619-16/+182
|
* [GC] RefIsNull => RefIs. (#3516)Alon Zakai2021-01-2628-85/+137
| | | | | | | | This internal refactoring prepares us for ref.is_func/data/i31, by renaming the node and adding an "op" field. For now that field must always be "Null" which means it is a ref.is_null. This adjusts the C API to match the new IR shape. The high-level JS API is unchanged.
* Warn when running a pass not compatible with DWARF (#3506)Alon Zakai2021-01-2614-94/+149
| | | | | | | | | | | | Previously the addDefault* methods would avoid adding opt passes that we know are incompatible with DWARF. However, that didn't handle the case of passes that are added in other ways. For example, when running Asyncify, emcc will run --flatten before, and that pass is not compatible with DWARF. This PR lets us warn on that by annotating the passes themselves. Then we use those annotation to either not run a pass at all (matching the previous behavior) or to show a warning when necessary. Fixes emscripten-core/emscripten#13288 . That is, concretely after this PR running asyncify + DWARF will show a warning to the user.
* Revert cmake version requirement bump (#3515)Sam Clegg2021-01-251-1/+3
| | | | | | | | This was originally landed as part of #3484 but this broke the emsdk CI because we build binaryen on bionic there which is stuck on 3.10.2: https://packages.ubuntu.com/bionic/cmake We do use `add_link_options` but only when EMSCRIPTEN is defined which doesn't effect normal desktop builds.
* Consistent lowercase keyword/methods in CMakeLists.txt (#3514)Sam Clegg2021-01-251-20/+20
| | | Followup on original conversion done in #2495.
* Debug info handling for new EH try-catch (#3496)Alon Zakai2021-01-2510-45/+630
| | | | | | | | We now have multiple catches in each try, and a possible catch-all. This changes our "extra delimiter" storage to store either an "else" (unchanged from before) or an arbitrary list of things - we use that for catches.
* Reorder i31ref and dataref (#3509)Heejin Ahn2021-01-2324-100/+128
| | | | | | | | | | The binary spec (https://docs.google.com/document/d/1yAWU3dbs8kUa_wcnnirDxUu9nEBsNfq0Xo90OWx6yuo/edit#) lists `dataref` after `i31ref`, and `dataref` also comes after `i31ref` in its binary code in the value-increasing order. This reorders these two in wasm-type.h and other places, although in most of those places the order is irrelevant. This also adds C and JS API for `dataref`.
* Document how to install lit test requirements [ci skip] (#3510)Alon Zakai2021-01-221-0/+4
|
* Partially split up functions in optimize-instructions.wast (#3508)Thomas Lively2021-01-221-1609/+1722
| | | | | | | | | | FileCheck test cases are much more readable when their output assertions are close to the corresponding input lines. #3503 introduced a script for updating FileCheck assertions, but it only knows how to place input and output lines together at the function boundary, so smaller functions will produce more readable tests. optimize-instructions.wast has some very large functions that include many test cases, so this PR breaks up some of those functions into smaller functions to make the tests more readable. This PR only changes the first quarter of the file, leaving further improvements as future work.
* [GC] Update GC binary format for prototype v3 (#3507)Alon Zakai2021-01-222-16/+0
| | | | | Some fields were removed, see https://docs.google.com/document/d/1yAWU3dbs8kUa_wcnnirDxUu9nEBsNfq0Xo90OWx6yuo/edit#
* Remove exnref and br_on_exn (#3505)Heejin Ahn2021-01-2285-2577/+259
| | | This removes `exnref` type and `br_on_exn` instruction.
* Remove translate-to-fuzz_all-features.txt (#3504)Heejin Ahn2021-01-221-1143/+0
| | | This file has not been updated since #3401.
* Introduce a script for updating lit tests (#3503)Thomas Lively2021-01-2116-12655/+12820
| | | | And demonstrate its capabilities by porting all tests of the optimize-instructions pass to use lit and FileCheck.
* [GC] Add dataref type (#3500)Alon Zakai2021-01-2129-23/+154
| | | | | This is not 100% of everything, but is enough to get tests passing, which includes full binary and text format support, getting all switches to compile without error, and some additions to InstrumentLocals.
* Update interpreter for new EH spec (#3498)Heejin Ahn2021-01-218-149/+181
| | | | | | | | | | | | | This updates the interpreter for the EH instructions (modulo `delegate`) to match the new spec. Before we had an `exnref` type so threw a `Literal` of `exnref` type which contained `ExceptionPackage`. But now that we don't have `exnref` anymore, so we add the contents of `ExceptionPackage` to `WasmException`, which is used only for the `ExpressionRunner` class hierarchy. `exnref` and `ExceptionPackage` will be removed in a followup CL. This allows nonzero depths for `rethrow` for now for testing; we disallowed that for safety measure, but given that there are no passes that modifies that field, I think the risk is low.
* CFG traversal for the new EH spec (#3494)Heejin Ahn2021-01-214-129/+420
| | | | | | | | | | | | | | | | | | | | | | This updates CFG traversal to match the new spec. Previously there was only a single `catch` block that caught all exceptions, so all throwing instructions needed to have a link to its innermost catch BB. But now we can have multiple catches per try, requiring all throwing instrutions to have an edge to all of those innermost catch BBs. Furthermore, if there are only `catch`es and not a `catch_all` in a try, throwing instructions can further unwind to outer catches until they find a `catch_all`. `unwindCatchStack` and `unwindExprStack` are necessary to track and make correct links between throwing instructions and their unwind destination BBs. `processCatchStack` is used to remember the catch BBs currently being processed, so that after processing all of them, we can make a link from each of those catch's last block to the continuation block after the try-catch. RSE test cases are updated because they use the CFG traversal. The tests there mainly test that if all possible CFG edge to a `local.set` sets the same value to a local, the `local.set` is redundant and thus can be removed.
* Simplify set/gets of vectors in binaryen.js (#3495)Heejin Ahn2021-01-202-182/+58
| | | | | This uses existing `getAllNested` function in `ExpressionWrapper` functions. Also adds `setAllNested` which works in the other direction and uses it within `ExpressionWrapper` functions.
* Prototype additional f64x2 conversions (#3501)Thomas Lively2021-01-1916-23/+303
| | | | As proposed in https://github.com/WebAssembly/simd/pull/383, with opcodes coordinated with the WIP V8 prototype.
* Replace "master" with "main" in scripts and docs (#3502)Thomas Lively2021-01-195-14/+14
| | | | We have updated the default branch name from "master" to "main." This PR updates scripts, configurations, and docs to reflect this change.
* wasm-reduce: Fix setting of feature flags after loading (#3493)Alon Zakai2021-01-155-6/+52
| | | | | We mistakenly did not set the flags to all, which meant that if the features section was not present, we'd not have the proper features set, leading to errors on writing.
* wasm-reduce: default to -all, and make it customizable (#3492)Alon Zakai2021-01-151-11/+20
| | | | | | | | | This goes back to the downsides of #2813, but that seems unavoidable as without this, testcases without the features section but that use features did not work. This PR at least makes it easy to customize the flags send to the commands. See also #3393 (comment)
* [GC] Read and lower Let instructions (#3485)Alon Zakai2021-01-154-12/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For now we don't support non-nullability, and can therefore lower a let into simpler things. That is, (let $x = ... ;; ) => (block $x = ... ;; ) This lets us handle wasm binaries with let, so that we can optimize them (with the current downside of losing non-nullability). This is still not trivial to do, sadly, because the indexing of lets is somewhat odd in the binary. A let modifies the indexes of other things declared before it, which means that index "0" means different things at different times. And this is trickier for us because we add more locals as needed for tuples and stacky code. So this PR makes us track the absolute local indexes from which each let started to allocate its locals. The binary testcase was created from this wat using wasp: (module (type $vector (array (field (mut f64)))) (func $main (local $x i32) (local $y i32) (drop (local.get $x)) ;; 0 is the index appearing in the binary ;; first let (array.new_with_rtt $vector (f64.const 3.14159) (i32.const 1) (rtt.canon $vector) ) (let (local $v (ref $vector)) (drop (local.get $v)) ;; 0 (drop (local.get $x)) ;; 1 ;; another one, nested (array.new_with_rtt $vector (f64.const 1234) (i32.const 2) (rtt.canon $vector) ) (let (local $w (ref $vector)) (drop (local.get $v)) ;; 1 (drop (local.get $w)) ;; 0 (drop (local.get $x)) ;; 2 ) ) ;; another one, later (array.new_with_rtt $vector (f64.const 2.1828) (i32.const 3) (rtt.canon $vector) ) (let (local $v (ref $vector)) (drop (local.get $v)) ;; 0 (drop (local.get $x)) ;; 1 ) (drop (local.get $x)) ;; 0 ) )
* Reducer: Improve warning on scripts that ignore the input (#3490)Alon Zakai2021-01-152-9/+33
| | | | | | | | | | | | | The risk the warning checks for is giving the reducer a script that ignores the input. To do so it runs the command in the input, and runs it on a garbage file, and checks if the result is different. However, if the script does immediately fail on the input - because the input is a crash testcase or such - then this does not work, as the result on a garbage input may be the same error. To avoid that, also check what happens on a trivial valid wasm as input. Only show the warning if the result on the original input, on a garbage wasm, and on a trivial wasm, are all the same - in that case, likely the script really is ignoring the input.
* Basic EH instrucion support for the new spec (#3487)Heejin Ahn2021-01-1573-961/+1621
| | | | | | | | | | | | | | | | | | | | This updates `try`-`catch`-`catch_all` and `rethrow` instructions to match the new spec. `delegate` is not included. Now `Try` contains not a single `catchBody` expression but a vector of catch bodies and events. This updates most existing routines, optimizations, and tests modulo the interpreter and the CFG traversal. Because the interpreter has not been updated yet, the EH spec test is temporarily disabled in check.py. Also, because the CFG traversal for EH is not yet updated, several EH tests in `rse_all-features.wast`, which uses CFG traversal, are temporarily commented out. Also added a few more tests in existing EH test functions in test/passes. In the previous spec, `catch` was catching all exceptions so it was assumed that anything `try` body throws is caught by its `catch`, but now we can assume the same only if there is a `catch_all`. Newly added tests test cases when there is a `catch_all` and cases there are only `catch`es separately.
* Enable LTO on the Linux Clang build on CI (#3491)Derek Schuff2021-01-142-4/+4
| | | Also adjust the check for Clang to also match AppleClang
* Add support for building with thinLTO (#3484)Derek Schuff2021-01-141-2/+13
| | | | | Supports Clang, on win/mac/linux. Uses lld on Linux and Windows. I haven't tested yet on Mac, but in theory it should work.
* Avoid usedElements around code that modifys that value (#3488)Alon Zakai2021-01-141-6/+6
| | | | | | | | Followup to #3486, I wonder if it isn't a little more clear this way, which avoids the confusion of usedElements being changed while we are using it. In general I think it's best to only use usedElements in the most internal methods, and to call size() otherwise.
* [GC] RTT types are not defaultable (#3489)Alon Zakai2021-01-133-68/+28
| | | See WebAssembly/gc#175
* Fix an index error in ArenaVectorBase (#3486)Heejin Ahn2021-01-141-1/+1
| | | | | | | | Because `resize()` sets `usedElements` to its argument, we were accessing `data[usedElements]`, which can be outside of allocated memory depending the internal state, i.e., `allocatedElements`'s value. It is hard to come up with a test case for this because apparently the failure condition depends on the vector's internal state.
* [GC] Fix casts of non-GC data (#3483)Alon Zakai2021-01-123-2/+31
| | | | | The code previously assumed it could always call getGCData, but that assumes the input is an array or a struct. It could also be an anyref etc. that contains something other than GC data.
* Remove extra-unreachable.wast (#3480)Heejin Ahn2021-01-124-395/+0
| | | | | | | This test seems to be added in #2266 to test custom unreachable generation in `BinaryenIRWriter`, but given that the `fromBinary` files only contain a single `unreachable` for the whole function, I don't think this test serves a lot of purpose. Also the custom unreachable generation logic in #2266 was largely replaced in #3110.
* [GC] Add Type::IsDefaultable and use that to do more validation (#3456)Alon Zakai2021-01-113-6/+11
|
* [GC] More HeapType instead of Type (#3475)Alon Zakai2021-01-114-55/+108
| | | | | | | | To handle both nullable and non-nullable i31s and other heap types, we cannot just look at the isBasic case (which is just one of the two). This may fix this issue on the release builder: https://github.com/WebAssembly/binaryen/runs/1669944081?check_suite_focus=true but the issue does not reproduce locally, so I worry it is something else...
* [GC] Fix minor binary format issues of ordering and immediates (#3472)Alon Zakai2021-01-115-29/+32
| | | | | | | | | Noticed by comparing to V8 and Wasp. After this things are almost identical, but there is also at least https://bugs.chromium.org/p/v8/issues/detail?id=11300 Test updates are due to having an instruction with two operands of which one is unreachable. The new order puts the non-unreachable first, so it is not removed by round-tripping through the binary format like before (which removes all unreachable code).
* Fix #3481 (#3482)Cheng Shao2021-01-111-1/+1
|
* finalize: remove initializers from metadata output (#3479)Sam Clegg2021-01-1120-73/+3
| | | See https://github.com/emscripten-core/emscripten/pull/13208
* version_99 (#3478)Alon Zakai2021-01-092-1/+4
|
* Add more verbose logging of an assert that only happens on the release ↵Alon Zakai2021-01-081-1/+6
| | | | | builder for some inexplicable reason (#3477) See #3459
* [GC] Validate that struct.set is to a mutable field. (#3473)Alon Zakai2021-01-087-38/+41
| | | | This required a few test fixes, to ensure we don't have invalid wasts with writes to immutable fields.
* [GC] Fix the opcode of i31 (#3471)Alon Zakai2021-01-081-1/+1
|
* [GC] Fix parsing/printing of ref types using i31 (#3469)Alon Zakai2021-01-0713-74/+105
| | | | | | | | | | | | This lets us parse (ref null i31) and (ref i31) and not just i31ref. It also fixes the parsing of i31ref, making it nullable for now, which we need to do until we support non-nullability. Fix some internal handling of i31 where we had just i31ref (which meant we just handled the non-nullable type). After fixing a bug in printing (where we didn't print out (ref null i31) properly), I found some a simplification, to remove TypeName.
* Remove c-api-kitchen-sink.txt.txt (#3465)Heejin Ahn2021-01-071-2236/+0
| | | | This seems to be a file that used to contain results of tracing, but now that tracing is gone, this file is not updated or used from anywhere.
* Prototype prefetch instructions (#3467)Thomas Lively2021-01-0624-48/+243
| | | | As proposed in https://github.com/WebAssembly/simd/pull/352, using the opcodes used in the LLVM and V8 implementations.