summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Support stack overflow checks in standalone mode (#2525)Alon Zakai2019-12-122-0/+343
| | | | | | | | | 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-125-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-11464-11814/+11911
| | | | | | | | | | | | | | | | | 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.
* Fix loop parent computation in DataFlow.Graph (#2522)Heejin Ahn2019-12-112-0/+43
| | | | | | This fixes the parent-child relationship computation in `DataFlow.Graph` when there is a loop. This wasn't discovered until now because this is used in Souperify and Souperify only runs after Flatten pass, which produces redundant blocks between inside and outside of a loop.
* Rename a couple of files that were missing in #2518 (#2521)Sam Clegg2019-12-104-0/+0
|
* Add a RoundTrip pass (#2516)Alon Zakai2019-12-092-0/+18
| | | | | | This pass writes and reads the module. This shows the effects of converting to and back from the binary format, and will be useful in testing dwarf debug support (where we'll need to see that writing and reading a module preserves debug info properly).
* Fix comparison of none and unreachable types (#2514)Heejin Ahn2019-12-094-542/+961
| | | | | | | | | | | | | | | | | | | Currently `none` and `unreachable` types are stored as the same empty `{}` in src/wasm/wasm-type.cpp. This makes `Type::operator<` incorrectly when given `none` and `unreachable`, because it expands both given types and lexicographically compare them, when both of the expanded vector will be empty. This was found by the fuzzer. This line in `Modder::visitExpression` tries to retrieve candidates of the same type. Because we can't really compare these two types, if you give `unreachable` as the key, candidates of `none` type can be returned. This generates incorrect code that ends up failing in validation in a very weird way. It was hard to generate a small testcase to trigger this part because it was found by generating fuzzed code from a random data file. But I guess this fix is pretty straightforward. Fixes #2512.
* Use wat over wast for text format filenames (#2518)Sam Clegg2019-12-0851-212/+15
|
* Don't include `$` with names unless outputting to wat format (#2506)Sam Clegg2019-12-0611-579/+579
| | | | | | | | | | | The `$` is not actually part of the name, its the marker that starts a name in the wat format. It can be confusing to see it show up when doing `cerr << name`, for example. This change has Print.cpp add the `$` which seem like the right place to do this. Plus it revealed a bunch of places where were not calling printName to escape all the names we were printing.
* Regenerate lld test inputs (#2502)Sam Clegg2019-12-0517-829/+182
|
* Update spec test suite (#2484)Heejin Ahn2019-11-29103-5603/+43125
| | | | | | | | | | | | | 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.
* Auto-update spec test outputs (#2481)Heejin Ahn2019-11-261-1/+0
| | | | | | | | This makes auto_update_tests.py update spec test outputs (ones that are printed with `spectest.print` import) and extracts spec tests blacklist into shared.py with comments for reasons why each of them fails. Also deletes if-label-scope.fail.wast.log because it does not seem to match with any of existing tests.
* Remove vanilla tests (#2482)Heejin Ahn2019-11-2616-239/+0
| | | These have not been used in years and seem outdated.
* Refactor and optimize binary writing type collection (#2478)Alon Zakai2019-11-262-0/+31
| | | | | | | | | | 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.
* Print only literal values when printing literals (#2469)Heejin Ahn2019-11-267-37/+33
| | | | | | | | | | | | | | | 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.
* Ensure example tests validate (#2470)Heejin Ahn2019-11-263-51/+58
| | | | | This makes sure example tests validate by adding missing `assert` on `BinaryenModuleValidate` calls and fixes existing errors in the example tests.
* Remove FunctionType from Event (#2466)Thomas Lively2019-11-2538-2832/+1236
| | | | | | | | | 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.
* Use package name in imports (NFC) (#2462)Heejin Ahn2019-11-229-71/+91
| | | | | Don't directly import names from shared.py and support.py, and use prefixes instead. Also this reorders imports based on PEP recommendation.
* Multivalue type creation and inspection (#2459)Thomas Lively2019-11-2211-1893/+2599
| | | | | | | | | | | | | 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.
* Add a pass to inline __original_main() into main() (#2461)Alon Zakai2019-11-212-0/+122
| | | | | | | | | | | | | | | | | | 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.
* Add a --strip-dwarf pass (#2454)Alon Zakai2019-11-192-0/+32
| | | | | | | | | | | | | 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.
* Add PostAssemblyScript pass (#2407)Daniel Wirtz2019-11-194-0/+699
| | | | | Adds the AssemblyScript-specific passes post-assemblyscript and post-assemblyscript-finalize, eliminating redundant ARC-style retain/release patterns conservatively emitted by the compiler.
* Optimize away invoke_ calls where possible (#2442)Alon Zakai2019-11-192-3/+157
| | | | | | | | | | | | 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.
* Warning improvements (#2438)Alon Zakai2019-11-152-1/+19
| | | | | | | | 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.
* uint32_t instead of int64_t as return type for GetMemorySegmentByteOffset ↵COFFEETALES2019-11-122-19/+18
| | | | | (#2432) `uint32_t` instead of `int64_t` as return type for `GetMemorySegmentByteOffset` and minor fixes on tests.
* When legalizing, optionally export the original function too with orig$X (#2427)Alon Zakai2019-11-112-0/+34
| | | | | 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
* Fix catch parsing (#2428)Heejin Ahn2019-11-114-20/+64
| | | | | | | - 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`
* Add Stack IR optimization support for EH (#2425)Heejin Ahn2019-11-072-0/+0
|
* Improve type selection in fuzzer (#2424)Heejin Ahn2019-11-062-1131/+1771
| | | | | | | | | - 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
* Don't attempt to de-duplicate asm consts (#2422)Sam Clegg2019-11-045-10/+10
| | | | | | | | | | | | 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.
* Add i32x4.dot_i16x8_s (#2420)Thomas Lively2019-11-0410-709/+800
| | | | | 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.
* OptimizeInstructions: Eq64 of 0 => Eqz64 (#2421)Alon Zakai2019-11-043-7/+40
| | | Fixes #2417
* Fix PostWalker traversal of push instruction (#2419)Heejin Ahn2019-11-042-0/+22
| | | PostWalker traversal should visit its value.
* Add SIMD integer min and max instructions (#2416)Thomas Lively2019-11-0110-829/+1949
| | | As proposed in https://github.com/WebAssembly/simd/pull/27.
* Add EH support for DCE pass (#2415)Heejin Ahn2019-11-012-0/+65
| | | | Like an `If`, `Try` construct is reachable when either its try body or catch body is reachable. This adds support for that.
* Don't remove events used in instructions (#2412)Heejin Ahn2019-11-012-8/+48
| | | | | Previously RemoveUnusedModuleElements pass only preserved exported events and did not preserve events used in `throw` and `br_on_exn` instructions. This fixes it.
* Use absolute memory addresses for emasm string indexes. (#2408)Sam Clegg2019-10-315-29/+40
| | | | | | | | | | 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
* Do not precompute SIMDLoad (#2409)Thomas Lively2019-10-302-1/+15
| | | This fixes a crash when programs containing load_splats are optimized.
* When renaming functions ensure the corresponding GOT.func entry is also ↵Sam Clegg2019-10-253-0/+373
| | | | | | renamed (#2382) Fixes https://github.com/WebAssembly/binaryen/issues/2180
* Add ModAsyncify* passes (#2404)Alon Zakai2019-10-238-0/+1329
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Convert usage of Pointer_stringify to UTF8ToString (#2403)Brad Morris2019-10-232-0/+4
| | | | 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.
* Fix incorrect assert in BinaryenHostGetOperand (#2393)Brad Morris2019-10-222-0/+12
|
* Ability to list each item on Exports/Data Segments/Functions (#2386)COFFEETALES2019-10-214-0/+150
| | | Adds functionality to the C API for getting the number of items in a module and fetching them out by index.
* Add BinaryenAddCustomSection API (#2381)Daniel Wirtz2019-10-112-0/+37
| | | | This adds a new BinaryenAddCustomSection API so a generator can add arbitrary custom sections to a module.
* Add offset parameter to BinaryenSetFunctionTable (#2380)Daniel Wirtz2019-10-115-11/+52
| | | | | | This PR adds an offset parameter to BinaryenSetFunctionTable so table elements can start at the value of an (imported constant) global. Previously, the offset was fixed to zero. As usual this is a breaking change to the C-API but backwards compatible when using the JS-API.
* Enable exnref instrumentation when EH is enabled (#2379)Heejin Ahn2019-10-111-1/+1
| | | | `exnref` is enabled by not reference type feature but exception handling feature. Sorry that I missed this in #2377.
* Don't instrument pops in InstrumentLocals (#2378)Heejin Ahn2019-10-102-13/+39
| | | | | `pop` is not a real instruction and automatically generated when reading binary and deleted when writing binary, so this does not work with instrumentation.
* Only add instrumentation to reftypes when the featureset supports it (#2377)Jacob Gravelle2019-10-101-2/+2
|
* Add support for reftypes in InstrumentLocals pass (#2375)Heejin Ahn2019-10-102-10/+84
| | | This adds support for anyref and exnref types in InstrumentLocals pass.
* Add push/pop support for anyref (#2376)Heejin Ahn2019-10-107-53/+148
| | | | This adds push/pop support for anyref. This also adds missing C API tests for push/pop.