summaryrefslogtreecommitdiff
path: root/test/unit/test_features.py
Commit message (Collapse)AuthorAgeFilesLines
* [FP16] Add a feature flag for FP16. (#6864)Brendan Dahl2024-08-221-0/+1
| | | Ensure the "fp16" feature is enabled for FP16 instructions.
* [threads] Add a "shared-everything" feature (#6658)Thomas Lively2024-06-141-0/+1
| | | | | Add the feature and flags to enable and disable it. Require the new feature to be enabled for shared heap types to validate. To make the test work, update the validator to actually check features for global types.
* Get more tests working with the new text parser (#6284)Thomas Lively2024-02-071-1/+1
| | | | | | | | The new parser enforces the rule that imports must come before declarations (except for type declarations). The old parser does not enforce this rule, so many of our tests did not follow it. Fix them to follow that rule and fix other invalid syntax. Also add missing finalization of Load expressions in wasm-builder.h that was causing a test to fail under the new parser and guard against an error case in wasm-ir-builder.cpp that used to cause a segfault.
* Add a `tuple.drop` text pseudoinstruction (#6170)Thomas Lively2023-12-121-1/+1
| | | | | | | | | | | | | | | | | We previously overloaded `drop` to mean both normal drops of single values and also drops of tuple values. That works fine in the legacy text parser since it can infer parent-child relationships directly from the s-expression structure of the input, so it knows that a drop should drop an entire tuple if the tuple-producing instruction is a child of the drop. The new text parser, however, is much more like the binary parser in that it uses instruction types to create parent-child instructions. The new parser always assumes that `drop` is meant to drop just a single value because that's what it does in WebAssembly. Since we want to continue to let `Drop` IR expressions consume tuples, and since we will need a way to write tests for that IR pattern that work with the new parser, introduce a new pseudoinstruction, `tuple.drop`, to represent drops of tuples. This pseudoinstruction only exists in the text format and it parses to normal `Drop` expressions. `tuple.drop` takes the arity of its operand as an immediate, which will let the new parser parse it correctly in the future.
* Update `tuple.make` text format to include arity (#6169)Thomas Lively2023-12-121-2/+2
| | | | | | | | | | Previously, the number of tuple elements was inferred from the number of s-expression children of the `tuple.make` expression, but that scheme would not work in the new wat parser, where s-expressions are optional and cannot be semantically meaningful. Update the text format to take the number of tuple elements (i.e. the tuple arity) as an immediate. This new format will be able to be implemented in the new parser as follow-on work.
* Typed Continuations: Add cont type (#5998)Frank Emrich2023-10-241-0/+12
| | | | | | | | | This PR is part of a series that adds basic support for the [typed continuations proposal](https://github.com/wasmfx/specfx). This PR adds continuation types, of the form `(cont $foo)` for some function type `$foo`. The only notable changes affecting existing code are the following: - This is the first `HeapType` which has another `HeapType` (rather than, say, a `Type`) as its immediate child. This required fixes to certain traversals that have a flag for being at the toplevel of a type. - Some shared logic for parsing `HeapType`s has been factored out.
* [typed-cont] Allow result types on tags (#5997)Frank Emrich2023-10-051-0/+16
| | | | | | | | | | | This PR is part of a series that adds basic support for the typed continuations proposal. This PR relaxes the restriction that tags must not have results , only params. Tags with results must not be used for exception handling and are only allowed if the typed continuations feature is enabled. As a minor point, this PR also changes the printing of tags without params: To make the presentation consistent, (param) is omitted when printing a tag.
* [typed-cont] Add feature flag (#5996)Frank Emrich2023-10-051-0/+1
| | | | | | | This PR is part of a series that adds basic support for the [typed continuations proposal](https://github.com/wasmfx/specfx). This particular PR simply extends `FeatureSet` with a corresponding entry for this proposal.
* Rename multimemory flag (#5890)Ashley Nelson2023-08-211-1/+1
| | | Renaming the multimemory flag in Binaryen to match its naming in LLVM.
* [NFC] Mention relevant flags in validator errors (#5203)Alon Zakai2022-11-011-12/+9
| | | | | | | | | | E.g. Atomic operation (atomics are disabled) => Atomic operations require threads [--enable-threads]
* Remove typed-function-references feature (#5030)Thomas Lively2022-09-091-1/+0
| | | | | | | | | | | | | | | | In practice typed function references will not ship before GC and is not independently useful, so it's not necessary to have a separate feature for it. Roll the functionality previously enabled by --enable-typed-function-references into --enable-gc instead. This also avoids a problem with the ongoing implementation of the new GC bottom heap types. That change will make all ref.null instructions in Binaryen IR refer to one of the bottom heap types. But since those bottom types are introduced in GC, it's not valid to emit them in binaries unless unless GC is enabled. The fix if only reference types is enabled is to emit (ref.null func) instead of (ref.null nofunc), but that doesn't always work if typed function references are enabled because a function type more specific than func may be required. Getting rid of typed function references as a separate feature makes this a nonissue.
* Adding Multi-Memories Wasm Feature (#4968)Ashley Nelson2022-08-251-0/+1
| | | Adding multi-memories to the the list of wasm-features.
* Restore the `extern` heap type (#4898)Thomas Lively2022-08-171-1/+1
| | | | | | | The GC proposal has split `any` and `extern` back into two separate types, so reintroduce `HeapType::ext` to represent `extern`. Before it was originally removed in #4633, externref was a subtype of anyref, but now it is not. Now that we have separate heaptype type hierarchies, make `HeapType::getLeastUpperBound` fallible as well.
* [Strings] Add feature flag for Strings proposal (#4766)Alon Zakai2022-06-301-0/+1
|
* Remove externref (#4633)Thomas Lively2022-05-041-5/+5
| | | | | | Remove `Type::externref` and `HeapType::ext` and replace them with uses of anyref and any, respectively, now that we have unified these types in the GC proposal. For backwards compatibility, continue to parse `extern` and `externref` and maintain their relevant C API functions.
* Add support for extended-const proposal (#4529)Sam Clegg2022-03-191-0/+1
| | | See https://github.com/WebAssembly/extended-const
* Add feature flag for relaxed-simd (#4183)Ng Zhi An2021-09-231-0/+1
|
* Apply features from the commandline first (#3960)Alon Zakai2021-07-021-17/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | As suggested in https://github.com/WebAssembly/binaryen/pull/3955#issuecomment-871016647 This applies commandline features first. If the features section is present, and disallows some of them, then we warn. Otherwise, the features can combine (for example, a wasm may enable feature X because it has to use it, and a user can simply add the flag for feature Y if they want the optimizer to try to use it; both flags will then be enabled). This is important because in some cases we need to know the features before parsing the wasm, in the case that the wasm does not use the features section. In particular, non-nullable GC locals have an effect during parsing. (Typed function references also does, but we found a way to apply its effect all the time, that is, always use the refined type, and that happened to not break the case where the feature is disabled - but such a workaround is not possible with non-nullable locals.) To make this less error-prone, add a FeatureSet input as a parameter to WasmBinaryBuilder. That is, when building a module, we must give it the features to use while doing so. This will unblock #3955 . That PR will also add a test for the actual usage of a feature during loading (the test can only be added there, after that PR unbreaks things).
* Remove (attr 0) from tag text format (#3946)Heejin Ahn2021-06-191-2/+2
| | | | | | | | This attribute is always 0 and reserved for future use. In Binayren's unofficial text format we were writing this field as `(attr 0)`, but we have recently come to the conclusion that this is not necessary. Relevant discussion: https://github.com/WebAssembly/exception-handling/pull/160#discussion_r653254680
* [EH] Replace event with tag (#3937)Heejin Ahn2021-06-181-6/+6
| | | | | | | | | | | We recently decided to change 'event' to 'tag', and to 'event section' to 'tag section', out of the rationale that the section contains a generalized tag that references a type, which may be used for something other than exceptions, and the name 'event' can be confusing in the web context. See - https://github.com/WebAssembly/exception-handling/issues/159#issuecomment-857910130 - https://github.com/WebAssembly/exception-handling/pull/161
* Remove passive keyword from data segment parser (#3757)Abbas Mashayekh2021-03-301-1/+1
| | | | | | | | The passive keyword has been removed from spec's text format, and now any data segment that doesn't have an offset is considered as passive. This PR remove that from both parser and the Print pass, plus all tests that used that syntax. Fixes #2339
* [EH] Remove dependency of reference types from EH (#3575)Heejin Ahn2021-02-191-6/+3
| | | | | | | | The new spec does not have `exnref` so EH does not have dependency of the reference types proposal anymore. exception_handling_target_feature.wasm's contents are the same except previously its target features section contained both reference-types and exception-handling but now it only has exception-handling.
* Allow specifying additional features past the features section (#3564)Alon Zakai2021-02-121-1/+8
| | | | | That is, if a wasm says "simd", it is ok to let the user specify simd as well as more features, and the the optimizer can perhaps do something with them.
* Remove exnref and br_on_exn (#3505)Heejin Ahn2021-01-221-10/+0
| | | This removes `exnref` type and `br_on_exn` instruction.
* [TypedFunctionReferences] Implement call_ref (#3396)Alon Zakai2020-11-241-2/+2
| | | | | | | | Includes minimal support in various passes. Also includes actual optimization work in Directize, which was easy to add. Almost has fuzzer support, but the actual makeCallRef is just a stub so far. Includes s-parser support for parsing typed function references types.
* [TypedFunctionReferences] Add Typed Function References feature and use the ↵Alon Zakai2020-11-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | types (#3388) This adds the new feature and starts to use the new types where relevant. We use them even without the feature being enabled, as we don't know the features during wasm loading - but the hope is that given the type is a subtype, it should all work out. In practice, if you print out the internal type you may see a typed function reference-specific type for a ref.func for example, instead of a generic funcref, but it should not affect anything else. This PR does not support non-nullable types, that is, everything is nullable for now. As suggested by @tlively this is simpler for now and leaves nullability for later work (which will apparently require let or something else, and many passes may need to be changed). To allow this PR to work, we need to provide a type on creating a RefFunc. The wasm-builder.h internal API is updated for this, as are the C and JS APIs, which are breaking changes. cc @dcodeIO We must also write and read function types properly. This PR improves collectSignatures to find all the types, and also to sort them by the dependencies between them (as we can't emit X in the binary if it depends on Y, and Y has not been emitted - we need to give Y's index). This sorting ends up changing a few test outputs. InstrumentLocals support for printing function types that are not funcref is disabled for now, until we figure out how to make that work and/or decide if it's important enough to work on. The fuzzer has various fixes to emit valid types for things (mostly whitespace there). Also two drive-by fixes to call makeTrivial where it should be (when we fail to create a specific node, we can't just try to make another node, in theory it could infinitely recurse). Binary writing changes here to replace calls to a standalone function to write out a type with one that is called on the binary writer object itself, which maintains a mapping of type indexes (getFunctionSignatureByIndex).
* GC: Integrate eqref and i31ref types (#3141)Daniel Wirtz2020-09-191-1/+21
| | | 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.
* Initial implementation of "Memory64" proposal (#3130)Wouter van Oortmerssen2020-09-181-1/+2
| | | Also includes a lot of new spec tests that eventually need to go into the spec repo
* Add GC feature flag (#3135)Daniel Wirtz2020-09-171-9/+9
| | | Adds the `--enable-gc` feature flag, so far enabling the `anyref` type incl. subtyping, and removes the temporary `--enable-anyref` feature flag that it replaces.
* Add anyref feature and type (#3109)Daniel Wirtz2020-09-101-5/+39
| | | Adds `anyref` type, which is enabled by a new feature `--enable-anyref`. This type is primarily used for testing that passes correctly handle subtype relationships so that the codebase will continue to be prepared for future subtyping. Since `--enable-anyref` is meaningless without also using `--enable-reference-types`, this PR also makes it a validation error to pass only the former (and similarly makes it a validation error to enable exception handling without enabling reference types).
* Skip tests that fail on windows and enable all the rest (#3035)Alon Zakai2020-08-111-1/+1
| | | | | | | | | | | | | | This lets us run most tests at least on that platform. Add a new function for skipping those tests, skip_if_on_windows, so that it's easy to find which tests are disabled on windows for later fixing efforts. This fixes a few minor issues for windows, like comparisons should ignore \r in some cases. Rename all passes tests that use --dwarfdump to contain "dwarf" in their name, which makes it easy to skip those (and is clearer anyhow).
* Rename anyref to externref to match proposal change (#2900)Jay Phelps2020-06-101-6/+6
| | | | | | | anyref future semantics were changed to only represent opaque host values, and thus renamed to externref. [Chromium](https://bugs.chromium.org/p/v8/issues/detail?id=7748#c360) was just updated to today (not yet released). I couldn't find a Mozilla bugzilla ticket mentioning externref so I don't immediately know if they've updated yet. https://github.com/WebAssembly/reference-types/pull/87
* Initial multivalue support (#2675)Thomas Lively2020-03-051-11/+65
| | | | | | | | | Implements parsing and emitting of tuple creation and extraction and tuple-typed control flow for both the text and binary formats. TODO: - Extend Precompute/interpreter to handle tuple values - C and JS API support/testing - Figure out how to lower in stack IR - Fuzzing
* Add multivalue feature (#2668)Thomas Lively2020-02-271-5/+6
|
* Concise error output (#2652)Alon Zakai2020-02-181-1/+1
| | | | | | | | | | | Don't print the entire module on an error. Instead, just print the validation errors. However, if the user passed --print, then do print it, as otherwise nothing would get printed - the error would be before the pass to print happens. And in general a user passing in a request to print would expect a printed module anyhow. fixes #2634
* Add support for reference types proposal (#2451)Heejin Ahn2019-12-301-10/+15
| | | | | | | | | | | | 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.
* Use package name in imports (NFC) (#2462)Heejin Ahn2019-11-221-17/+26
| | | | | Don't directly import names from shared.py and support.py, and use prefixes instead. Also this reorders imports based on PEP recommendation.
* Add initial support for anyref as an opaque type (#2294)Jay Phelps2019-08-201-2/+30
| | | | | | | | | | | | | 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.
* Switch python indentation from 2-space to 4-space (#2299)Sam Clegg2019-08-161-252/+251
| | | | | | | | pep8 specifies 4 space indentation. The use of 2 spaces is, I believe a historical anomaly where certain large organizations such as google chose 2 over 4 and have yet to make the switch. Since there isn't too much code in binaryen today it seems reasonable to make the switch.
* Add basic exception handling support (#2282)Heejin Ahn2019-08-131-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds basic support for exception handling instructions, according to the spec: https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md This PR includes support for: - Binary reading/writing - Wast reading/writing - Stack IR - Validation - binaryen.js + C API - Few IR routines: branch-utils, type-updating, etc - Few passes: just enough to make `wasm-opt -O` pass - Tests This PR does not include support for many optimization passes, fuzzer, or interpreter. They will be follow-up PRs. Try-catch construct is modeled in Binaryen IR in a similar manner to that of if-else: each of try body and catch body will contain a block, which can be omitted if there is only a single instruction. This block will not be emitted in wast or binary, as in if-else. As in if-else, `class Try` contains two expressions each for try body and catch body, and `catch` is not modeled as an instruction. `exnref` value pushed by `catch` is get by `pop` instruction. `br_on_exn` is special: it returns different types of values when taken and not taken. We make `exnref`, the type `br_on_exn` pushes if not taken, as `br_on_exn`'s type.
* Python3-ify check.py and auto_update_tests.py (#2270)Alon Zakai2019-07-311-1/+1
| | | | | I fixed flatten.bin.txt which seems to have just had some corrupted data, and I removed some fancy unicode from the spec comments tests, which I'm not sure it's important enough to figure out how to fix. Fixes #1691
* Finalize tail call support (#2246)Thomas Lively2019-07-231-0/+14
| | | | 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.
* Initial tail call implementation (#2197)Thomas Lively2019-07-031-2/+23
| | | | | | | | | | | Including parsing, printing, assembling, disassembling. TODO: - interpreting - effects - finalization and typing - fuzzing - JS/C API
* Clean up loose ends in feature handling (#2203)Thomas Lively2019-07-031-0/+24
| | | | | Fix and test mutable globals support, replace string literals with constants, and add a pass to emit the target features section.
* Add exception handling feature (#2083)Heejin Ahn2019-05-031-0/+3
| | | This only adds the feature and its flag and not the instructions yet.
* Change default feature set to MVP (#1993)Thomas Lively2019-04-161-40/+30
| | | | | In the absence of the target features section or command line flags. When there are command line flags, it is an error if they do not exactly match the target features section, except if --detect-features has been provided. Also adds a --print-features pass to print the command line flags for all enabled options and uses it to make the feature tests more rigorous.
* DataCount section (#2006)Thomas Lively2019-04-151-22/+11
| | | | | | | | * DataCount section Read the DataCount section and verify that it agrees with the data section. Also emit the DataCount section when bulk-memory is enabled and there are a nonzero number of segments. Factor out some shared unit test code.
* Move features from passOptions to Module (#2001)Thomas Lively2019-04-121-0/+14
| | | | | This allows us to emit a (potentially modified) target features section and conditionally emit other sections such as the DataCount section based on the presence of features.
* Passive segments (#1976)Thomas Lively2019-04-051-2/+27
| | | | | Adds support for the bulk memory proposal's passive segments. Uses a new (data passive ...) s-expression syntax to mark sections as passive.
* Use target features section in wasm-opt (#1967)Thomas Lively2019-04-031-23/+88
| | | | | | | If the user does not supply features explicitly on the command line, read and use the features in the target features section for validation and passes. If the user does supply features explicitly, error if they are not a superset of the features marked as used in the target features section and the user does not explicitly handle this.