summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* [C/JS API] Add string reference types (#4810)dcode2022-07-274-0/+56
|
* [Strings] Add interpreter stubs for string instructions (#4835)Alon Zakai2022-07-261-1/+4
| | | | | | | | | The stubs let precompute skip over them without erroring. With this PR we can run the optimizer on strings code. We still can't run --fuzz-exec though, so we can't run the fuzzer. Also simplify the error strings in the earlier part of the file. All other code just has "unimp" so we might as well do the same and not mention full names there.
* Make `GlobalTypeRewriter` work for isorecursive types (#4829)Thomas Lively2022-07-262-0/+348
| | | | | | | | | | | | | | | | | | | There are two new potential problems that `GlobalTypeRewriter` can run into when working with isorecursive types instead of nominal types. First, the refined types may have replaced generic references with references to specific other types, potentially creating new recursions and making the existing recursion groups insufficient. Second, distinct types may be refined to structurally identical types and those distinct input types may map the same output type, potentially changing cast behavior. Both of these problems are solved by putting all the new types in a single large recursion group. We do not currently account for the fact that types may be used in the external interface of the module, but when we do, externalized types will be excluded from optimizations and will not be affected by the creation of this single large rec group. Fixes #4816.
* [C/JS API] Expose string reference feature (#4831)Max Graey2022-07-262-0/+2
|
* [OptimizeInstructions] Add folding for mixed left shift and mul with ↵Max Graey2022-07-261-0/+60
| | | | | | constants on RHS (#4808) (x * C1) << C2 -> x * (C1 << C2) (x << C1) * C2 -> x * (C2 << C1)
* [Wasm GC] i31get can trap (#4825)Alon Zakai2022-07-251-0/+21
|
* [wasm-split] Add --print-profile option (#4771)sps-gold2022-07-251-0/+6
| | | | | | | | | | | | | | | | | | | | | | | There are several reasons why a function may not be trained in deterministically. So to perform quick validation we need to inspect profile.data (another ways requires split to be performed). However as profile.data is a binary file and is not self sufficient, so we cannot currently use it to perform such validation. Therefore to allow quick check on whether a particular function has been trained in, we need to dump profile.data in a more readable format. This PR, allows us to output, the list of functions to be kept (in main wasm) and those split functions (to be moved to deferred.wasm) in a readable format, to console. Added a new option `--print-profile` - input path to orig.wasm (its the original wasm file that will be used later during split) - input path to profile.data that we need to output optionally pass `--unescape` to unescape the function names Usage: ``` binaryen\build>bin\wasm-split.exe test\profile_data\MY.orig.wasm --print-profile=test\profile_data\profile.data > test\profile_data\out.log ``` note: meaning of prefixes `+` => fn to be kept in main wasm `-` => fn to be split and moved to deferred wasm
* [Wasm GC] Properly represent nulls in i31 (#4819)Alon Zakai2022-07-252-1/+107
| | | | | The encoding here is simple: we store i31 values in the literal.i32 field. The top bit says if a value exists, which means literal.i32 == 0 is the same as null.
* [C API] Fix printf-related warnings when compiling C tests (NFC) (#4821)dcode2022-07-252-15/+15
|
* Grand Unified Flow Analysis (GUFA) (#4598)Alon Zakai2022-07-228-0/+7486
| | | | | | | | | | | | | This tracks the possible contents in the entire program all at once using a single IR. That is in contrast to say DeadArgumentElimination of LocalRefining etc., all of whom look at one particular aspect of the program (function params and returns in DAE, locals in LocalRefining). The cost is to build up an entire new IR, which takes a lot of new code (mostly in the already-landed PossibleContents). Another cost is this new IR is very big and requires a lot of time and memory to process. The benefit is that this can find opportunities that are only obvious when looking at the entire program, and also it can track information that is more specialized than the normal type system in the IR - in particular, this can track an ExactType, which is the case where we know the value is of a particular type exactly and not a subtype.
* [Test] Refactor C API kitchen sink test's Memory usage (#4815)Alon Zakai2022-07-212-19/+19
|
* [Strings] GC variants for string.encode (#4817)Alon Zakai2022-07-211-2/+55
|
* Remove basic reference types (#4802)Thomas Lively2022-07-2017-240/+205
| | | | | | | | | 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/+51
|
* [Strings] stringview_wtf16.length (#4809)Alon Zakai2022-07-181-0/+21
| | | | 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-2/+50
| | | | | | | 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.
* [Wasm GC] Check if ref.eq inputs can possibly be the same (#4780)Alon Zakai2022-07-141-4/+290
| | | | | For them to be the same we must have a value that can appear on both sides. If the heap types disallow that, then only null is possible, and if that is impossible as well then the result must be 0.
* [C-API] Add utility to go between types and heap types (#4792)dcode2022-07-141-0/+9
|
* [Wasm GC] GTO should not reorder trapping of removed sets (#4801)Alon Zakai2022-07-131-18/+124
| | | | | Minor fuzz bug. When we replace a struct.set with its children we also add a ref.as_non_null on the reference, but that must not occur before effects in the other child.
* [Strings] stringview access operations (#4798)Alon Zakai2022-07-131-2/+73
|
* [C-API] Unify logging in c-api-kitchen-sink test (#4800)dcode2022-07-132-34/+34
|
* [C-API] Add type system C-API (#4790)dcode2022-07-132-0/+19
|
* [Strings] string.as (#4797)Alon Zakai2022-07-121-0/+41
|
* [C-API] Add packed type constants for use with GC types (#4791)dcode2022-07-122-0/+10
|
* [Parser] Start to parse instructions (#4789)Thomas Lively2022-07-111-59/+50
| | | | | | | | | | | | | | | | | | | | | Update gen-s-parser.py to produce a second version of its parsing code that works with the new wat parser. The new version automatically replaces the `s` element argument in the existing parser with the `ctx` and `in` arguments used by the new parser, so adding new instructions will not require any additional work in gen-s-parser.py after this change. Also add stub `make***` functions to the new wat parser, with a few filled out, namely `makeNop`, `makeUnreachable`, `makeConst`, and `makeRefNull`. Update the `global` parser to parse global initializer instructions and update wat-kitchen-sink.wast to demonstrate that the instructions are parsed correctly. Adding new instruction classes will require adding a new `make***` function to wat-parser.cpp in additional to wasm-s-parser.{h,cpp} after this change, but adding a trivial failing implementation is good enough for the time being, so I don't expect this to appreciably increase our maintenance burden in the near term. The infrastructure for parsing folded instructions, instructions with operands, and control flow instructions will be implemented in future PRs.
* [Wasm GC] RefIs / RefEq / RefTest return a boolean (#4786)Alon Zakai2022-07-081-0/+66
| | | | | | | | | | | | This marks all reference operations that return 0/1 as doing so. This allows various bitwise operations to be optimized on them. This also marks StringEq as a boolean, though we can't test that fully yet as Strings support is wip (no interpreter or other stuff yet). As a driveby this moves emitsBoolean to its own file, and uses it in getMaxBits to avoid redundancy (the redundant code paths now have a WASM_UNREACHABLE).
* [Parser] Parse rec groups (#4785)Thomas Lively2022-07-081-7/+15
|
* Parse `rec` in update_lit_checks.py (#4784)Thomas Lively2022-07-085-74/+101
|
* [Strings] string.is_usv_sequence (#4783)Alon Zakai2022-07-081-0/+19
| | | | | | | 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-2/+23
|
* [Parser] Parse standard subtype declarations (#4778)Thomas Lively2022-07-081-16/+28
| | | | Parse type definitions with the format `(type $t (sub $super ...))`. Update the test to use hybrid types so that the subtypes are reflected in the test output.
* Port a recently-updated test to lit (#4779)Alon Zakai2022-07-085-453/+529
|
* [Strings] string.concat (#4777)Alon Zakai2022-07-081-0/+19
|
* [Strings] string.encode (#4776)Alon Zakai2022-07-071-2/+47
|
* Group reference types in binary format. (#4774)Alon Zakai2022-07-074-7/+159
| | | | | | | | | | | | Grouping all references together makes it easier for baseline compilers to zero out memory (as the zeroing out may be different for MVP types vs. references). This puts all references together, either at the start or the end. As a heuristic for that we see if the first local is a reference. As the optimizer will sort locals by frequency, this ensures that the most-frequent local stays in index 0. Fixes #4773. See more details there
* [Strings] string.measure (#4775)Alon Zakai2022-07-071-0/+41
|
* [Strings] Add string.const (#4768)Alon Zakai2022-07-061-3/+33
| | | | | 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-3014-3/+41
|
* [Strings] Print shorthand types where possible (#4763)Alon Zakai2022-06-291-1/+1
|
* [Strings] Add string.new* instructions (#4761)Alon Zakai2022-06-291-1/+48
| | | | | | 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/+25
| | | | | | | | This starts to implement the Wasm Strings proposal https://github.com/WebAssembly/stringref/blob/main/proposals/stringref/Overview.md This just adds the types.
* Disallow --nominal with GC (#4758)Thomas Lively2022-06-281-18/+3
| | | | | | | | | | | Nominal types don't make much sense without GC, and in particular trying to emit them with typed function references but not GC enabled can result in invalid binaries because nominal types do not respect the type ordering constraints required by the typed function references proposal. Making this change was mostly straightforward, but required fixing the fuzzer to use --nominal only when GC is enabled and required exiting early from nominal-only optimizations when GC was not enabled. Fixes #4756.
* [EH] Fix printing bug in nested blocks + delegate (#4753)Heejin Ahn2022-06-274-0/+52
| | | | | | | `controlFlowDepth` is a variable used to print `delegate`'s target. When printing nested blocks, we increase `controlFlowDepth` by the number of nested blocks at once. But we should decrement it as we finish each block, rather than decrease by the number of nested blocks at once, because we need correct `controlFlowDepth` within nested blocks.
* [JS API] Avoid trying to read the offset if segment is passive (#4750)Blaine Bublitz2022-06-242-3/+9
| | | This avoids hitting an assertion.
* [Wasm GC] OptimizeInstructions: Optimize ref.eq on equal inputs with a tee ↵Alon Zakai2022-06-241-0/+29
| | | | | | | | | | | (#4749) (ref.eq (local.tee $x (..)) (local.get $x) ) That will definitely return 1. Before this PR the side effects of tee stopped us from optimizing.
* [WasmGC] OptimizeInstructions: Improve RefIs cast ordering (#4752)Alon Zakai2022-06-241-2/+84
| | | | | | | | | | | | | | #4748 regressed us in some cases, because it removed casts first: (ref.is_func (ref.as_func (local.get $anyref))) If the cast is removed first, and the local has no useful type info, then we'd have removed the cast but could not remove the ref.is. But the ref.is could be optimized to 1, as it must be a func - the type info proves it thanks to the cast. To avoid this, remove casts after everything else.
* [Wasm2JS] Fix lowering of i64.extendN_s instructions (#4321)taylor.fish2022-06-243-4/+218
|
* [Wasm GC] [TNH] OptimizeInstructions: remove casts leading to comparisons ↵Alon Zakai2022-06-241-0/+164
| | | | | | (#4748) Comparing references does not depend on the cast, so if we are ignoring traps in traps-never-happen mode then we can remove them.
* [Parser] Parse struct and array types (#4745)Thomas Lively2022-06-221-0/+70
| | | | | | | | | Parse struct and array type definitions along with field names. Only the most basic definitions are parsed for now; subtype definitions (both nominal prototype and standard formats) and recursion groups are left to follow-on PRs. Since there is no official standard for the text format for GC type definitions, attempt to define a grammar that allows abbreviations that we already use widely, such as making `(field ... )` optional except for named fields.
* First class Data Segments (#4733)Ashley Nelson2022-06-2122-49/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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