summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Make `i31ref` and `dataref` nullable (#4843)Thomas Lively2022-08-261-2/+2
| | | | | | | Match the latest version of the GC spec. This change does not depend on V8 changing its interpretation of the shorthands because we are still temporarily not emitting the binary shorthands, but all Binaryen users will have to update their interpretations along with this change if they use the text or binary shorthands.
* Add support for Tag names in the Names section (#4970)Alon Zakai2022-08-261-4/+57
|
* [NFC] Simplify binary reading logic for functions (#4969)Alon Zakai2022-08-261-18/+9
| | | | | | | We do a call to updateMaps() at the end of processNames anyhow, and so we may as well call addFunction immediately (and the names will get fixed up in that updateMaps later). The old code for some reason did that for function imports, but not normal functions. It also stored them separately in temporary storage for some unclear reason...
* Adding Multi-Memories Wasm Feature (#4968)Ashley Nelson2022-08-251-0/+4
| | | Adding multi-memories to the the list of wasm-features.
* Fix order of local names in Names section (#4964)Congcong Cai2022-08-251-17/+19
| | | | | | The wasm spec requires the order of local names in that section to be in increasing order: https://webassembly.github.io/spec/core/appendix/custom.html#binary-namemap
* Fix Memory64 binary parsing after #4811 (#4933)Alon Zakai2022-08-181-15/+21
| | | | Due to missing test coverage, we missed in #4811 that some memory operations needed to get make64() called on them.
* Restore the `extern` heap type (#4898)Thomas Lively2022-08-171-0/+12
| | | | | | | 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.
* Mutli-Memories Support in IR (#4811)Ashley Nelson2022-08-171-101/+172
| | | | | | | This PR removes the single memory restriction in IR, adding support for a single module to reference multiple memories. To support this change, a new memory name field was added to 13 memory instructions in order to identify the memory for the instruction. It is a goal of this PR to maintain backwards compatibility with existing text and binary wasm modules, so memory indexes remain optional for memory instructions. Similarly, the JS API makes assumptions about which memory is intended when only one memory is present in the module. Another goal of this PR is that existing tests behavior be unaffected. That said, tests must now explicitly define a memory before invoking memory instructions or exporting a memory, and memory names are now printed for each memory instruction in the text format. There remain quite a few places where a hardcoded reference to the first memory persist (memory flattening, for example, will return early if more than one memory is present in the module). Many of these call-sites, particularly within passes, will require us to rethink how the optimization works in a multi-memories world. Other call-sites may necessitate more invasive code restructuring to fully convert away from relying on a globally available, single memory pointer.
* Revert "[Wasm GC] GC-prefixed opcodes are int8, not LEBs (#4889)" (#4895)Alon Zakai2022-08-161-1/+1
| | | | | | | Reverts #4889 The spec is unclear on this, and that PR moved us to do what V8 does. But it sounds like we should clarify the spec to do things the other way, so this goes back to that.
* [Strings] Fix string.new_wtf16_array (#4894)Alon Zakai2022-08-101-0/+2
| | | Like the 8-bit array variants, it takes 3 parameters.
* [Strings] Linear memory string operations should emit a memory index (#4893)Alon Zakai2022-08-101-0/+12
| | | | | | | For now this index is always 0, but we must emit it. Also clean up the wat test a little - we don't have validation yet, but we should not validate without a memory in that file.
* [Wasm GC] GC-prefixed opcodes are int8, not LEBs (#4889)Alon Zakai2022-08-091-1/+1
| | | | | | This starts to matter with strings, it turns out. This change should make us runnable in v8. Spec: https://github.com/WebAssembly/gc/blob/main/proposals/gc/MVP.md#instructions-1
* [Strings] string.new.array methods have start:end arguments (#4888)Alon Zakai2022-08-091-1/+9
|
* Remove RTTs (#4848)Thomas Lively2022-08-051-117/+5
| | | | | | | RTTs were removed from the GC spec and if they are added back in in the future, they will be heap types rather than value types as in our implementation. Updating our implementation to have RTTs be heap types would have been more work than deleting them for questionable benefit since we don't know how long it will be before they are specced again.
* Remove support for parsing `let` (#4864)Thomas Lively2022-08-031-64/+2
| | | | | It has been removed from the typed function references proposal, so we no longer need to support it. Maintaining the test for `let` was difficult because Binaryen could not emit either text or binary that actually used it.
* Changing ref maps in wasm-binary to use a value of a vector of Name* (#4830)Ashley Nelson2022-07-261-37/+14
| | | | | | | | | | | * Changing ref maps in wasm-binary to use a value of a vector of Name* * clang-format * Update src/wasm/wasm-binary.cpp Co-authored-by: Thomas Lively <7121787+tlively@users.noreply.github.com> Co-authored-by: Thomas Lively <7121787+tlively@users.noreply.github.com>
* Update reference type shorthands in binary output (#4828)Thomas Lively2022-07-251-26/+31
| | | | | | | | | Add support for emitting the string type reference shorthands, which had previously been omitted accidentally due to the `default` case in that switch. Also avoid emitting shorthands for non-nullable reference types as a first step towards transitioning the shorthands to represent nullable types instead. Not emitting these shorthands at all will give V8 the flexibility it needs to change its interpretation of the shorthands without breaking any workflows using Binaryen.
* [Strings] GC variants for string.encode (#4817)Alon Zakai2022-07-211-1/+18
|
* Remove basic reference types (#4802)Thomas Lively2022-07-201-20/+35
| | | | | | | | | Basic reference types like `Type::funcref`, `Type::anyref`, etc. made it easy to accidentally forget to handle reference types with the same basic HeapTypes but the opposite nullability. In principle there is nothing special about the types with shorthands except in the binary and text formats. Removing these shorthands from the internal type representation by removing all basic reference types makes some code more complicated locally, but simplifies code globally and encourages properly handling both nullable and non-nullable reference types.
* [Strings] Add string.new GC variants (#4813)Alon Zakai2022-07-191-1/+20
|
* [Strings] stringview_wtf16.length (#4809)Alon Zakai2022-07-181-0/+2
| | | | This measures the length of a view, so it seems simplest to make it a sub-operation of the existing measure instruction.
* [Strings] stringview_*.slice (#4805)Alon Zakai2022-07-151-0/+34
| | | | | | | Unfortunately one slice is the same as python [start:end], using 2 params, and the other slice is one param, [CURR:CURR+num] (where CURR is implied by the current state in the iter). So we can't use a single class here. Perhaps a different name would be good, like slice vs substring (like JS does), but I picked names to match the current spec.
* [Strings] stringview access operations (#4798)Alon Zakai2022-07-131-0/+61
|
* [Strings] string.as (#4797)Alon Zakai2022-07-121-0/+19
|
* [Strings] string.is_usv_sequence (#4783)Alon Zakai2022-07-081-0/+2
| | | | | | | This implements it as a StringMeasure opcode. They do have the same number of operands, same trapping behavior, and same return type. They both get a string and do some inspection of it to return an i32. Perhaps the name could be StringInspect or something like that, rather than StringMeasure..? But I think for now this might be good enough, and the spec may change anyhow later.
* [Strings] string.eq (#4781)Alon Zakai2022-07-081-0/+13
|
* [Strings] string.concat (#4777)Alon Zakai2022-07-081-0/+14
|
* [Strings] string.encode (#4776)Alon Zakai2022-07-071-0/+30
|
* [Strings] string.measure (#4775)Alon Zakai2022-07-071-3/+31
|
* [Strings] Add string.const (#4768)Alon Zakai2022-07-061-0/+102
| | | | | This is more work than a typical instruction because it also adds a new section: all the (string.const "foo") strings are put in a new "strings" section in the binary, and the instructions refer to them by index.
* [Strings] Add feature flag for Strings proposal (#4766)Alon Zakai2022-06-301-0/+4
|
* [Strings] Add string.new* instructions (#4761)Alon Zakai2022-06-291-0/+31
| | | | | | This is the first instruction from the Strings proposal. This includes everything but interpreter support.
* [Strings] Add string proposal types (#4755)Alon Zakai2022-06-291-0/+36
| | | | | | | | This starts to implement the Wasm Strings proposal https://github.com/WebAssembly/stringref/blob/main/proposals/stringref/Overview.md This just adds the types.
* First class Data Segments (#4733)Ashley Nelson2022-06-211-31/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Updating wasm.h/cpp for DataSegments * Updating wasm-binary.h/cpp for DataSegments * Removed link from Memory to DataSegments and updated module-utils, Metrics and wasm-traversal * checking isPassive when copying data segments to know whether to construct the data segment with an offset or not * Removing memory member var from DataSegment class as there is only one memory rn. Updated wasm-validator.cpp * Updated wasm-interpreter * First look at updating Passes * Updated wasm-s-parser * Updated files in src/ir * Updating tools files * Last pass on src files before building * added visitDataSegment * Fixing build errors * Data segments need a name * fixing var name * ran clang-format * Ensuring a name on DataSegment * Ensuring more datasegments have names * Adding explicit name support * Fix fuzzing name * Outputting data name in wasm binary only if explicit * Checking temp dataSegments vector to validateBinary because it's the one with the segments before we processNames * Pass on when data segment names are explicitly set * Ran auto_update_tests.py and check.py, success all around * Removed an errant semi-colon and corrected a counter. Everything still passes * Linting * Fixing processing memory names after parsed from binary * Updating the test from the last fix * Correcting error comment * Impl kripken@ comments * Impl tlively@ comments * Updated tests that remove data print when == 0 * Ran clang format * Impl tlively@ comments * Ran clang-format
* Do not emit recursion groups without GC enabled (#4738)Thomas Lively2022-06-181-2/+7
| | | | | | | | We emit nominal types as a single large recursion group, but this produces invalid modules when --nominal or --hybrid was used without GC enabled. Fix the bug by always emitting types as though they were structural (i.e. without recursion groups) when GC is not enabled. Fixes #4723.
* Fix table exporting (#4736)Alon Zakai2022-06-171-1/+2
| | | | | | | This code was apparently not updated when we added multi-table support, and still had the old hardcoded index 0. Fixes #4711
* Update relaxed SIMD instructionsThomas Lively2022-06-071-8/+0
| | | | | Update the opcodes for all relaxed SIMD instructions and remove the unsigned dot product instructions that are no longer in the proposal.
* Fix binary parsing of the prototype nominal format (#4679)Thomas Lively2022-05-191-3/+0
| | | | | | We were checking that nominal modules only had a single element in their type sections, but that's not correct for the prototype nominal binary format we still want to support. The test for this missed catching the bug because it wasn't actually parsing in nominal mode.
* Add ref.cast_nop_static (#4656)Thomas Lively2022-05-111-2/+5
| | | | | | This unsafe experimental instruction is semantically equivalent to ref.cast_static, but V8 will unsafely turn it into a nop. This is meant to help us measure cast overhead more precisely than we can by globally turning all casts into nops.
* Parse the prototype nominal binary format (#4644)Thomas Lively2022-05-041-9/+40
| | | | | | In f124a11ca3 we removed support for the prototype nominal binary format entirely, but that means that we can no longer parse older binary modules that used that format. Fix this regression by restoring the ability to parse the prototype binary format.
* Remove externref (#4633)Thomas Lively2022-05-041-12/+0
| | | | | | 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.
* Update the type section binary format (#4625)Thomas Lively2022-05-021-64/+62
| | | | | | | | | | Print subtype declarations using the standards-track format with a vector of supertypes followed by a normal type declaration rather than our interim nominal format that used alternative versions of the func, struct, and array forms. Desugar the nominal format to additionally emit all the types into a single large recursion group. Currently V8 is performing this desugaring, but after this change and a future change that fixes the order of nominal types to ensure supertypes precede subtypes, it will no longer need to.
* Implement relaxed SIMD dot product instructions (#4586)Thomas Lively2022-04-111-0/+16
| | | As proposed in https://github.com/WebAssembly/relaxed-simd/issues/52.
* [SIMD] Make swizzle's opcode name consistent (NFC) (#4585)Heejin Ahn2022-04-091-2/+2
| | | | Other opcode ends with `Inxm` or `Fnxm` (where n and m are integers), while `i8x16.swizzle`'s opcode name doesn't have an `I` in there.
* Implement i16x8.relaxed_q15mulr_s (#4583)Thomas Lively2022-04-071-1/+5
| | | As proposed in https://github.com/WebAssembly/relaxed-simd/issues/40.
* [Wasm GC] Fix stacky non-nullable tuples (#4561)Alon Zakai2022-03-311-7/+8
| | | | | #4555 fixed validation for such tuples, but we also did not handle them in "stacky" code using pops etc., due to a logic bug in the binary reading code.
* Add support for extended-const proposal (#4529)Sam Clegg2022-03-191-0/+4
| | | See https://github.com/WebAssembly/extended-const
* Isorecursive binary format (#4494)Thomas Lively2022-02-031-16/+51
| | | | | | | | | | | Write and parse recursion groups in binary type sections. Unlike in the text format, where we ignore recursion groups when not using isorecursive types, do not allow parsing binary recursion group when using other type systems. Doing so would produce incorrect results because recursions groups only count as single entries in the type system vector so we dynamically grow the TypeBuilder when we encounter them. That would change the mapping of later indices to types, and would change the meaning of previous type definitions that use those later indices. This is not a problem in the isorecursive system because in that system type definitions are not allowed to use later indices.
* Make `TypeBuilder::build()` fallible (#4474)Thomas Lively2022-01-251-1/+5
| | | | | | | | | | | It is possible for type building to fail, for example if the declared nominal supertypes form a cycle or are structurally invalid. Previously we would report a fatal error and kill the program from inside `TypeBuilder::build()` in these situations, but this handles errors at the wrong layer of the code base and is inconvenient for testing the error cases. In preparation for testing the new error cases introduced by isorecursive typing, make type building fallible and add new tests for existing error cases. Also fix supertype cycle detection, which it turns out did not work correctly.
* Remove unused `isNominal` field on HeapTypeInfo (#4465)Thomas Lively2022-01-201-3/+1
| | | | | | | | This field was originally added with the goal of allowing types from multiple type systems to coexist by determining the type system on a per-type level rather than globally. This goal was never fully achieved and the `isNominal` field is not used outside of tests. Now that we are working on implementing the hybrid isorecursive system, it does not look like having types from multiple systems coexist will be useful in the near term, so clean up this tech debt.