summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* Validator: Check features for ref.null's type (#4677)Alon Zakai2022-05-182-0/+7
|
* [GC Fuzzing] Avoid non-nullable eqref without GC (#4675)Alon Zakai2022-05-181-2/+22
| | | | | | With only reference types but not GC, we cannot easily create a constant for eqref for example. Only GC adds i31.new etc. To avoid assertions in the fuzzer, avoid randomly picking (ref eq) etc., that is, keep it nullable so that we can emit a (ref.null eq) if we need a constant value of that type.
* wasm-reduce: Fix order in shrinkByReduction call (#4673)Alon Zakai2022-05-171-1/+4
| | | | | | The old code would short-circuit and not do anything after we managed any reduction in the loop here. That would end up doing entire iterations of the whole pipeline before removing another element segment, which could be slow.
* [NFC] Remove unneeded include (#4670)Alon Zakai2022-05-171-1/+0
|
* [NFC] Make InsertOrderedMap::insert's param const (#4669)Alon Zakai2022-05-171-1/+1
| | | | | Being a const reference allows writing insert({a, b}), which will be useful in a future PR, and there is no reason to actually update the reference.
* [NFC] Make PossibleConstantValues::dump() a const function (#4671)Alon Zakai2022-05-171-1/+1
|
* [Fuzzer] Reduce trap probability in function ref fallback code (#4653)Alon Zakai2022-05-161-10/+15
| | | | | | Also improve comments. As suggested in #4647
* Allow TypeBuilder::grow to take 0 as an argument (#4668)Thomas Lively2022-05-161-1/+1
| | | | | | | There's no reason not to allow growing by zero slots, but previously doing so would trigger an assertion. This caused a crash when roundtripping a trivial module. Fixes #4667.
* Ensure symmetric results in PossibleConstantValues (#4662)Alon Zakai2022-05-131-16/+23
| | | | | | | | | | | | | | | | | | | | | | | Previously we could return different results depending on the order we noted things: note(anyref.null); note(funcref.null); get() => anyref.null note(funcref.null); note(anyref.null); get() => funcref.null This is correct, as nulls are equal anyhow, and any could be used in the location we are optimizing. However, it can lead to nondeterminism if the caller's order of notes is nondeterministic. That is the case in DeadArgumentElimination, where we scan functions in parallel, then merge them without special ordering. To fix this, make the note operation symmetric. That seems simplest and least likely to be confusing. We can use the LUB to do that. To avoid duplicating the null logic, refactor note() to use combine().
* Followups to #3841 (#3842)Alon Zakai2022-05-131-6/+0
| | | | | If we don't think that preventing copies in assignment makes sense by itself (since we allow them on construction) then I think we can just remove the restriction and also the implicit copy constructor.
* Add SubTypes::getAllSubTypes variant which includes the type itself (#4649)Alon Zakai2022-05-133-17/+15
| | | | This also includes the type itself in the returned vector. This will be useful in a future PR.
* [NFC] Make Literal::makeNull take a HeapType (#4664)Alon Zakai2022-05-134-8/+7
| | | | | | | | Taking a Type is redundant as we only care about the heap type - the nullability must be Nullable. This avoids needing an assertion in the function, that is, it makes the API more type-safe.
* Make RefCast safe by default (#4663)Thomas Lively2022-05-121-1/+1
| | | | This prevents new `RefCast` expressions that don't explicitly have their safety set from getting an unitialized safety value.
* Costs: Increase cost of casts (#4661)Alon Zakai2022-05-122-13/+27
| | | | | Casts involve branches in the VM, so adding a cast in return for removing a branch (like If=>Select) is not beneficial. We don't want to ever do any more casts than we already are.
* Add ref.cast_nop_static (#4656)Thomas Lively2022-05-119-9/+44
| | | | | | 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.
* [NominalFuzzing] Fix SignaturePruning on types with a super (#4657)Alon Zakai2022-05-111-0/+9
| | | | | | | Do not prune parameters if there is a supertype that is a signature. Without this we crash on an assertion in TypeBuilder when we try to recreate the types (as we try to make a a subtype with fewer fields than the super).
* [Fuzzer] Fix another reference types vs gc types issue (#4647)Alon Zakai2022-05-061-36/+37
| | | | | | | | | | Diff without whitespace is smaller. We can't emit HeapType::data without GC. Fixing that by switching to func, another problem was uncovered: makeRefFuncConst had a TODO to handle the case where we need a function to refer to but have created none yet. In fact that TODO was done at the end of the function. Fix up the logic in between to actually get there.
* [NFC] Avoid scanning code in hasBranchTarget if the target is null (#4648)Alon Zakai2022-05-061-0/+4
| | | | | | | | A null target is not a valid name so nothing can branch to there. This just saves the wasted work. No existing code in the codebase benefits from this atm, but a later PR will. In particular this lets callers call this without checking if the name is non-null, which is more concise.
* Add CMake flag JS_OF_OCAML for js_of_ocaml (#4637)Blaine Bublitz2022-05-061-0/+6
|
* Revert "Reduce iterations required for DeadArgumentElimination convergence ↵arsnyder162022-05-051-16/+44
| | | | | (#4629)" (#4646) This reverts commit 4bcfba261cb8ee182261d26064453cab787d0df4.
* Fix fuzzer's choosing of reference types (#4642)Alon Zakai2022-05-051-7/+18
| | | | | | * Don't emit "i31" or "data" if GC is not enabled, as only the GC feature adds those. * Don't emit "any" without GC either. While it is allowed, fuzzer limitations prevent this atm (see details in comment - it's fixable).
* Parse the prototype nominal binary format (#4644)Thomas Lively2022-05-042-9/+44
| | | | | | 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.
* Reduce iterations required for DeadArgumentElimination convergence (#4629)arsnyder162022-05-041-44/+16
| | | | | | If we do not remove a param, we can try to remove the return value. We can do that on a per-function basis, and not only if we removed no params from anywhere. Also simplify tail call logic.
* Update StackCheck for memory64 (#4636)Sam Clegg2022-05-041-7/+11
|
* Remove externref (#4633)Thomas Lively2022-05-0421-158/+35
| | | | | | 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 nominal type ordering (#4631)Thomas Lively2022-05-031-14/+33
| | | | | | V8 requires that supertypes come before subtypes when it parses isorecursive (i.e. standards-track) type definitions. Since 2268f2a we are emitting nominal types using the standard isorecursive format, so respect the ordering requirement.
* Add missing include for windows (#4627)martinRenou2022-05-021-0/+2
| | | | | Without this Windows fails with: 'isdigit': is not a member of 'std'
* Handle call.without.effects in RemoveUnusedModuleElements (#4624)Alon Zakai2022-05-021-5/+39
| | | | | | | | | | | | | | | | | We assume a closed world atm in the GC space, but the call.without.effects intrinsic sort of breaks that: that intrinsic looks like an import, but we really need to care about what is sent to it even in a closed world: (call $call-without-effects (ref.func $target-keep) ) That reference cannot be ignored, as logically it is called just as if there were a call_ref there. This adds support for that, fixing the combination of #4621 and using call.without.effects. Also flip the vector of ref.func names to a set. I realized that in a very large program we might see the same name many times.
* Update the type section binary format (#4625)Thomas Lively2022-05-022-71/+67
| | | | | | | | | | 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.
* Lift the restriction in liveness-traversal.h that supported max 65535 locals ↵juj2022-04-284-59/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in a function. (#4567) * Lift the restriction in liveness-traversal.h that supported max 65535 locals in a function. * Lint * Fix typo * Fix static * Lint * Lint * Lint * Add needed canRun function * lint * Use either a sparse or a dense matrix for tracking liveness copies, depending on the locals count. * Lint * Fix lint * Lint * Implement sparse_square_matrix class and use that as a backing. * Lint * Lint * Lint #includes * Lint * Lint includes * Remove unnecessary code * Fix canonical accesses to copies matrix * Lint * Add missing variable update * Remove canRun() function * Address review * Update expected test results * Update test name * Add asserts to sparse_square_matrix set and get functions that they are not out of bound. * Lint includes * Update test expectation * Use .clear() + .resize() to reset totalCopies vector
* RemoveUnusedModuleElements: Track CallRef/RefFunc more precisely (#4621)Alon Zakai2022-04-281-3/+91
| | | | | | | | | | | | | | | | | | If we see (ref.func $foo) that does not mean that $foo is reachable - we must also see a (call_ref ..) of the proper type. Only after seeing both should we mark the function as reachable, which this PR does. This adds some complexity as we need to track intermediate state as we go, since we could see the RefFunc before the CallRef or vice versa. We also need to handle the case of a RefFunc without a CallRef properly: We cannot remove the function, as the RefFunc must refer to it, but at least we can empty out the body since we know it is never reached. This removes an old wasm-opt test which is now superseded by a new lit test. On J2Wasm output this removes 3% of all functions, which account for 2.5% of total code size.
* [NominalFuzzing] SignatureRefining can modify the IR while running a ↵Alon Zakai2022-04-283-7/+13
| | | | | | | | | parallel analysis (#4620) Normally ParallelFunctionAnalysis is just an analysis, and has no effects. However, in SignatureRefining we actually do have side effects, due to an internal limitation of the helper code it runs. This adds a template parameter to the class so users can note that they do modify the IR. The parameter is added in the middle as it is easier to add this param than to add the last one (the map).
* Fix some outdated comments (#4617)Alon Zakai2022-04-262-6/+2
| | | | * We implemented specialization of field types (the TypeRefining pass). * LUBFinder now handles nulls, so we need nothing extra for it in TypeRefining.
* wasm-reduce: Try to remove functions from a random place (#4612)Alon Zakai2022-04-251-7/+32
| | | | | | Previously we'd only try to remove functions from index 0, so we missed some opportunities. With this change we still go through all the functions if things go well, but we start from a deterministic random location in the vector.
* SmallSet: Mark iterator parent as const (#4613)Alon Zakai2022-04-251-2/+2
| | | | | | | | | | | | | | | | | | | We already assume the parent does not change, binaryen/src/support/small_set.h Lines 202 to 208 in 94d77ef // std::set allows changes while iterating. For us here, though, it would // be nontrivial to support that given we have two iterators that we // generalize over (switching "in the middle" would not be easy or fast), // so error on that. if (usingFixed != other.usingFixed) { Fatal() << "SmallSet does not support changes while iterating"; } This also marks the parent as const to reflect that. This fixed a weird C++ compilation error I had when working on something unrelated, but seems worth landing independently.
* OptimizeInstructions: Refinalize after a cast removal (#4611)Alon Zakai2022-04-251-0/+26
| | | | | | | | | Casts can replace a type with a subtype, which normally has no downsides, but in a corner case of struct types it can lead to us needing to refinalize higher up too, see details in the comment. We have avoided any Refinalize calls in OptimizeInstructions, but the case handled here requires it sadly. I considered moving it to another pass, but this is a peephole optimization so there isn't really a better place.
* [NominalFuzzing] SignatureRefining: Ignore exported functions (#4601)Alon Zakai2022-04-222-1/+60
| | | This hits the fuzzer when it tries to call reference exports with a null.
* [NominalFuzzing] Fix getHeapTypeCounts() on unreachable casts (#4609)Alon Zakai2022-04-221-53/+53
| | | | | | | | | | | The cast instruction may be unreachable but the intended type for the cast still needs to be collected. Otherwise we end up with problems both during optimizations that look at heap types and in printing (which will use the heap type in code but not declare it). Diff without whitespace is much smaller: this just moves code around so that we can use a template to avoid code duplication. The actual change is just to scan ->intendedType unconditionally, and not ignore it if the cast is unreachable.
* [NominalFuzzing] GTO: trap on null ref in removed struct.set (#4607)Alon Zakai2022-04-211-3/+5
| | | | | | | | | | | | | | When a field has no reads, we remove all its writes, but we did this: (struct.set $foo A B) => (drop A) (drop B) We also need to trap if A, the reference, is null, which this PR fixes, (struct.set $foo A B) => (drop (ref.as_non_null A)) (drop B)
* [NominalFuzzing] Add a validation error on ref.cast's etc. intended type (#4606)Alon Zakai2022-04-211-0/+7
|
* [NominalFuzzing] MergeSimilarFunctions: handle nominal types properly (#4602)Alon Zakai2022-04-211-2/+2
| | | | | | This fixes two bugs: First, we need to compare the nominal types of function constants when looking for constants to "merge", not just their structure. Second, when creating the new function we must use the proper type of those constants, and not just another type.
* [NominalFuzzing] Fix TranslateToFuzzReader::getSubType(Rtt) (#4604)Alon Zakai2022-04-211-0/+6
| | | | Randomly selecting a depth is ok for structural typing, but in nominal it must match the actual hierarchy of types.
* [NominalFuzzing] Don't compare nominal types in the fuzzer (#4603)Alon Zakai2022-04-211-3/+8
| | | | | The same module will have a different type after some transformations, even though that is not observable, like --roundtrip. Basically, we should not be comparing types between separate modules, which is what the fuzzer does.
* [NominalFuzzing] Fix replaceWithIdenticalType() on nondefaultable tuples (#4605)Alon Zakai2022-04-211-1/+1
|
* Rename asyncify-side-module to asyncify-relocatable (#4596)かめのこにょこにょこ2022-04-181-3/+3
| | | | | | | Related: emscripten-core/emscripten#15893 (comment) --pass-arg=asyncify-side-module option will be used not only from side modules, but also from main modules.
* Implement relaxed SIMD dot product instructions (#4586)Thomas Lively2022-04-1111-12/+118
| | | As proposed in https://github.com/WebAssembly/relaxed-simd/issues/52.
* [Inlining] Preserve return_calls when possible (#4589)Thomas Lively2022-04-111-0/+10
| | | | | | | | | We can preserve return_calls in inlined functions when the inlined call site is itself a return_call, since the call result types must transitively match in that case. This solves a problem where the previous inlining logic could introduce stack exhaustion by downgrading recursive return_calls to normal calls. Fixes #4587.
* [SIMD] Make swizzle's opcode name consistent (NFC) (#4585)Heejin Ahn2022-04-0912-21/+21
| | | | 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-079-7/+31
| | | As proposed in https://github.com/WebAssembly/relaxed-simd/issues/40.
* Avoid a code pattern of vec.resize() followed by std::fill() as suboptimal. ↵juj2022-04-054-9/+8
| | | | Instead do a clear()+resize() (#4580)