summaryrefslogtreecommitdiff
path: root/test/binaryen.js
Commit message (Collapse)AuthorAgeFilesLines
* [EH] Make tag's attribute encoding detail (#3947)Heejin Ahn2021-06-214-8/+8
| | | | | | | | | This removes `attribute` field from `Tag` class, making the reserved and unused field known only to binary encoder and decoder. This also removes the `attribute` parameter from `makeTag` and `addTag` methods in wasm-builder.h, C API, and Binaryen JS API. Suggested in https://github.com/WebAssembly/binaryen/pull/3946#pullrequestreview-687756523.
* Remove (attr 0) from tag text format (#3946)Heejin Ahn2021-06-193-11/+11
| | | | | | | | 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-189-81/+81
| | | | | | | | | | | 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
* [Wasm GC] Add experimental support for non-nullable locals (#3932)Alon Zakai2021-06-151-1/+1
| | | | | | | | | | | | | | This adds a new feature flag, GCNNLocals that enables support for non-nullable locals. No validation is applied to check that they are actually assigned before their use yet - this just allows experimentation to begin. This feature is not enabled by default even with -all. If we enabled it, then it would take effect in most of our tests and likely confuse current users as well. Instead, the flag must be opted in explicitly using --enable-gc-nn-locals. That is, this is an experimental feature flag, and as such must be explicitly enabled. (Once the spec stabilizes, we will remove the feature anyhow when we implement the final status of non-nullability. )
* Add SIMDLoadStoreLane get/setters to C/JS API (#3904)Daniel Wirtz2021-05-254-0/+75
|
* Remove Type ordering (#3793)Thomas Lively2021-05-182-4/+4
| | | | | | | | | As found in #3682, the current implementation of type ordering is not correct, and although the immediate issue would be easy to fix, I don't think the current intended comparison algorithm is correct in the first place. Rather than try to switch to using a correct algorithm (which I am not sure I know how to implement, although I have an idea) this PR removes Type ordering entirely. In places that used Type ordering with std::set or std::map because they require deterministic iteration order, this PR uses InsertOrdered{Set,Map} instead.
* Rename SIMD extending load instructions (#3798)Daniel Wirtz2021-04-121-1/+1
| | | | | | | | | Renames the SIMD instructions * LoadExtSVec8x8ToVecI16x8 -> Load8x8SVec128 * LoadExtUVec8x8ToVecI16x8 -> Load8x8UVec128 * LoadExtSVec16x4ToVecI32x4 -> Load16x4SVec128 * LoadExtUVec16x4ToVecI32x4 -> Load16x4UVec128 * LoadExtSVec32x2ToVecI64x2 -> Load32x2SVec128 * LoadExtUVec32x2ToVecI64x2 -> Load32x2UVec128
* Rename various SIMD load instructions (#3795)Daniel Wirtz2021-04-111-1/+1
| | | | | | | | | Renames the SIMD instructions * LoadSplatVec8x16 -> Load8SplatVec128 * LoadSplatVec16x8 -> Load16SplatVec128 * LoadSplatVec32x4 -> Load32SplatVec128 * LoadSplatVec64x2 -> Load64SplatVec128 * Load32Zero -> Load32ZeroVec128 * Load64Zero -> Load64ZeroVec128
* RefFunc: Validate that the type is non-nullable, and avoid possible bugs in ↵Alon Zakai2021-04-081-1/+3
| | | | | | | | the builder (#3790) The builder can receive a HeapType so that callers don't need to set non-nullability themselves. Not NFC as some of the callers were in fact still making it nullable.
* Add v128.load/storeN_lane SIMD instructions to C/JS API (#3784)Daniel Wirtz2021-04-082-0/+177
| | | | | | | | | | | Adds C/JS APIs for the SIMD instructions * Load8LaneVec128 (was LoadLaneVec8x16) * Load16LaneVec128 (was LoadLaneVec16x8) * Load32LaneVec128 (was LoadLaneVec32x4) * Load64LaneVec128 (was LoadLaneVec64x2) * Store8LaneVec128 (was StoreLaneVec8x16) * Store16LaneVec128 (was StoreLaneVec16x8) * Store32LaneVec128 (was StoreLaneVec32x4) * Store64LaneVec128 (was StoreLaneVec64x2)
* Add v128.load32/64_zero SIMD instructions to C/JS API (#3783)Daniel Wirtz2021-04-082-0/+22
| | | | | Adds C/JS APIs for the SIMD instructions * Load32Zero * Load64Zero
* Add new SIMD multiplication instructions to C/JS API (#3782)Daniel Wirtz2021-04-082-0/+169
| | | | | | | | | | | | | | | | Adds C/JS APIs for the SIMD instructions * Q15MulrSatSVecI16x8 * ExtMulLowSVecI16x8 * ExtMulHighSVecI16x8 * ExtMulLowUVecI16x8 * ExtMulHighUVecI16x8 * ExtMulLowSVecI32x4 * ExtMulHighSVecI32x4 * ExtMulLowUVecI32x4 * ExtMulHighUVecI32x4 * ExtMulLowSVecI64x2 * ExtMulHighSVecI64x2 * ExtMulLowUVecI64x2 * ExtMulHighUVecI64x2
* Add new SIMD conversion instructions to C/JS API (#3781)Daniel Wirtz2021-04-082-0/+66
| | | | | | | | | Adds C/JS APIs for the SIMD instructions * ConvertLowSVecI32x4ToVecF64x2 * ConvertLowUVecI32x4ToVecF64x2 * TruncSatZeroSVecF64x2ToVecI32x4 * TruncSatZeroUVecF64x2ToVecI32x4 * DemoteZeroVecF64x2ToVecF32x4 * PromoteLowVecF32x4ToVecF64x2
* Add iNxM.extadd_pairwise_* SIMD instructions to C/JS API (#3780)Daniel Wirtz2021-04-082-0/+44
| | | | | | | Adds C/JS APIs for the SIMD instructions * ExtAddPairwiseSVecI8x16ToI16x8 * ExtAddPairwiseUVecI8x16ToI16x8 * ExtAddPairwiseSVecI16x8ToI32x4 * ExtAddPairwiseUVecI16x8ToI32x4
* Add i64x2.extend_low/high_* SIMD instructions to C/JS API (#3778)Daniel Wirtz2021-04-072-0/+44
| | | | | | | Adds C/JS APIs for the SIMD instructions * ExtendLowSVecI32x4ToVecI64x2 * ExtendHighSVecI32x4ToVecI64x2 * ExtendLowUVecI32x4ToVecI64x2 * ExtendHighUVecI32x4ToVecI64x2
* Add various SIMD instructions to C/JS API (#3777)Daniel Wirtz2021-04-072-0/+122
| | | | | | | | | | | | | Adds C/JS APIs for the SIMD instructions * PopcntVecI8x16 * AbsVecI64x2 * AllTrueVecI64x2 * BitmaskVecI64x2 * EqVecI64x2 * NeVecI64x2 * LtSVecI64x2 * GtSVecI64x2 * LeSVecI64x2 * GeSVecI64x2
* Update SIMD names and opcodes (#3771)Thomas Lively2021-04-055-292/+142
| | | | Also removes experimental SIMD instructions that were not included in the final spec proposal.
* Reorder global definitions in Print pass (#3770)Abbas Mashayekh2021-04-022-8/+8
| | | | This is needed to make sure globals are printed before element segments, where `global.get` can appear both as offset and an expression.
* Remove passive keyword from data segment parser (#3757)Abbas Mashayekh2021-03-301-2/+2
| | | | | | | | 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
* Inlining: Always inline single-use functions (#3730)Alon Zakai2021-03-291-1/+1
| | | | | | | | | | | | | | | | This implements emscripten-core/emscripten#13744 Inlining functions with a single use allows us to remove the function afterward. That looks highly beneficial, shrinking every single benchmark in emscripten's benchmark suite, by an average of 2% on the macrobenchmarks and 3.5% on all of them. Speed also improves, although mostly on the microbenchmarks so that might be less realistic. There may be a slight downside to startup time due to emitting larger functions, but given the baseline compilers in VMs these days it seems worth it, as the delay would be just to get to the upper tier. On the benchmark suite the risk seems low. See more details in the PR above.
* [reference-types] Support passive elem segments (#3572)Abbas Mashayekh2021-03-054-29/+37
| | | | | | | | | | | Passive element segments do not belong to any table, so the link between Table and elem needs to be weaker; i.e. an elem may have a table in case of active segments, or simply be a collection of function references in case of passive/declarative segments. This PR takes Table::Segment out and turns it into a first class module element just like tables and functions. It also implements early support for parsing, printing, encoding and decoding passive/declarative elem segments.
* Add C and JS API bindings for ref.as_* (#3628)Daniel Wirtz2021-03-012-0/+53
|
* Add TypedFunctionReferences feature to C and JS API (#3603)Daniel Wirtz2021-02-262-0/+2
|
* Add RefIsGetOp/SetOp in C and JS API (#3605)Daniel Wirtz2021-02-261-0/+5
|
* Support Type names in the Names section (#3615)Alon Zakai2021-02-251-1/+1
|
* Properly use text format type names in printing (#3591)Alon Zakai2021-02-232-6/+6
| | | | | | | | | | | | | | | | | | | This adds a TypeNames entry to modules, which can store names for types. So far this PR uses that to store type names from text format. Future PRs will add support for field names and for the binary format. (Field names are added to wasm.h here to see if we agree on this direction.) Most of the work here is threading a module through the various functions in Print.cpp. This keeps the module optional, so that we can still print an expression independently of a module, which has always been the case, and which I think we should keep (but, if a module was mandatory perhaps this would be a little simpler, and could be refactored into a form that depends on that). 99% of this diff are test updates, since almost all our tests use the text format, and many of them specify a type name but we used to ignore it. This is a step towards a proper solution for #3589
* [EH] Make rethrow's target a try label (#3568)Heejin Ahn2021-02-184-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I was previously mistaken about `rethrow`'s argument rule and thought it only counted `catch`'s depth. But it turns out it follows the same rule `delegate`'s label: the immediate argument follows the same rule as when computing branch labels, but it only can target `try` labels (semantically it targets that `try`'s corresponding `catch`); otherwise it will be a validation failure. Unlike `delegate`, `rethrow`'s label denotes not where to rethrow, but which exception to rethrow. For example, ```wasm try $l0 catch ($l0) try $l1 catch ($l1) rethrow $l0 ;; rethrow the exception caught by 'catch ($l0)' end end ``` Refer to this comment for the more detailed informal semantics: https://github.com/WebAssembly/exception-handling/issues/146#issuecomment-777714491 --- This also reverts some of `delegateTarget` -> `exceptionTarget` changes done in #3562 in the validator. Label validation rules apply differently for `delegate` and `rethrow` for try-catch. For example, this is valid: ```wasm try $l0 try delegate $l0 catch ($l0) end ``` But this is NOT valid: ```wasm try $l0 catch ($l0) try delegate $l0 end ``` So `try`'s label should be used within try-catch range (not catch-end range) for `delegate`s. But for the `rethrow` the rule is different. For example, this is valid: ```wasm try $l0 catch ($l0) rethrow $l0 end ``` But this is NOT valid: ```wasm try $l0 rethrow $l0 catch ($l0) end ``` So the `try`'s label should be used within catch-end range instead.
* [EH] Update C and binaryen.js API for delegate (#3565)Heejin Ahn2021-02-135-8/+71
| | | | | | | | | | This updates C and binaryen.js API to match the new `Try` structure to support `delegate`, added in #3561. Now `try` can take a name (which can be null) like a block, and also has an additional `delegateTarget` field argument which should only be used for try-delegate and otherwise null. This also adds several more variant of `makeTry` methods in wasm-builder. Some are for making try-delegate and some are for try-catch(_all).
* [reference-types] remove single table restriction in IR (#3517)Abbas Mashayekh2021-02-095-10/+29
| | | Adds support for modules with multiple tables. Adds a field for the table name to `CallIndirect` and updates the C/JS APIs accordingly.
* Prototype i32x4.widen_i8x16_{s,u} (#3535)Thomas Lively2021-02-012-32/+32
| | | | | | | | As proposed in https://github.com/WebAssembly/simd/pull/395. Note that the other instructions in the proposal have not been implemented in LLVM or in V8, so there is no need to implement them in Binaryen right now either. This PR introduces a new expression class for the new instructions because they uniquely take an immediate argument identifying which portion of the input vector to widen.
* [GC] Add br_on_func/data/i31 (#3525)Alon Zakai2021-01-282-2/+2
| | | | | | | | 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] ref.is_func/data/i31 (#3519)Alon Zakai2021-01-261-0/+16
|
* [GC] RefIsNull => RefIs. (#3516)Alon Zakai2021-01-264-19/+19
| | | | | | | | 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.
* Reorder i31ref and dataref (#3509)Heejin Ahn2021-01-232-1/+13
| | | | | | | | | | 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`.
* Remove exnref and br_on_exn (#3505)Heejin Ahn2021-01-224-80/+22
| | | This removes `exnref` type and `br_on_exn` instruction.
* [GC] Add dataref type (#3500)Alon Zakai2021-01-211-2/+2
| | | | | 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.
* Simplify set/gets of vectors in binaryen.js (#3495)Heejin Ahn2021-01-201-8/+19
| | | | | This uses existing `getAllNested` function in `ExpressionWrapper` functions. Also adds `setAllNested` which works in the other direction and uses it within `ExpressionWrapper` functions.
* Basic EH instrucion support for the new spec (#3487)Heejin Ahn2021-01-157-91/+142
| | | | | | | | | | | | | | | | | | | | 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.
* Prototype prefetch instructions (#3467)Thomas Lively2021-01-062-45/+45
| | | | As proposed in https://github.com/WebAssembly/simd/pull/352, using the opcodes used in the LLVM and V8 implementations.
* Prototype SIMD extending pairwise add instructions (#3466)Thomas Lively2021-01-052-22/+0
| | | | | | As proposed in https://github.com/WebAssembly/simd/pull/380, using the opcodes used in LLVM and V8. Since these opcodes overlap with the opcodes of i64x2.all_true and i64x2.any_true, which have long since been removed from the SIMD proposal, this PR also removes those instructions.
* Improve C and JS API module inspection features (#3464)Daniel Wirtz2021-01-052-1/+12
| | | | | | * BinaryenGetFunction, BinaryenGetGlobal, BinaryenGetEvent now return NULL if an element does not exist * Adds BinaryenGetExport, BinaryenGetNumGlobals, BinaryenGetGlobalByIndex * Corrects BinaryenGetNumFunctions return type * Adds related descriptions of C API functions
* Refactor printing code so that printing Expressions always works (#3450)Alon Zakai2020-12-172-4/+4
| | | | | | | | This avoids needing to add include wasm-printing if a file doesn't already have it. To achieve that, add the std::ostream hooks in wasm.h, and also use them when possible, removing the need for the special WasmPrinter object. Also stop printing in "full" (print types on each line) in error messages by default. The user can still get that, as always, using BINARYEN_PRINT_FULL=1 in the env.
* [TypedFunctionReferences] Implement call_ref (#3396)Alon Zakai2020-11-242-12/+14
| | | | | | | | 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-233-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Rename atomic.notify and *.atomic.wait (#3353)Heejin Ahn2020-11-136-18/+18
| | | | | | | | | | | | | | - atomic.notify -> memory.atomic.notify - i32.atomic.wait -> memory.atomic.wait32 - i64.atomic.wait -> memory.atomic.wait64 See WebAssembly/threads#149. This renames instruction name printing but not the internal data structure names, such as `AtomicNotify`, which are not always the same as printed instruction names anyway. This also does not modify C API. But this fixes interface functions in binaryen.js because it seems binaryen.js's interface functions all follow the corresponding instruction names.
* [wasm2js] Use native JavaScript Math.trunc (#3329)Max Graey2020-11-101-0/+1
|
* wasm2js: Remove global dict arguments to asmFunc (#3325)Sam Clegg2020-11-051-26/+13
|
* Implement v128.{load,store}{8,16,32,64}_lane instructions (#3278)Thomas Lively2020-10-222-33/+33
| | | | | | | These instructions are proposed in https://github.com/WebAssembly/simd/pull/350. This PR implements them throughout Binaryen except in the C/JS APIs and in the fuzzer, where it leaves TODOs instead. Right now these instructions are just being implemented for prototyping so adding them to the APIs isn't critical and they aren't generally available to be fuzzed in Wasm engines.
* Add C and JS APIs for fast math (#3188)Max Graey2020-10-012-0/+4
| | | Adds `BinaryenGetFastMath` and `BinaryenSetFastMath` to the C API, respectively `binaryen.getFastMath` and `binaryen.setFastMath` to the JS API.
* GC: Add stubs for the remaining instructions (#3174)Daniel Wirtz2020-09-292-0/+24
| | | 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.