[Strings] Work around ref.cast not working on string views, and add fuzzing#6549
[Strings] Work around ref.cast not working on string views, and add fuzzing#6549kripken merged 6 commits intoWebAssembly:mainfrom
Conversation
| heapType == HeapType::stringview_iter) { | ||
| // We cannot cast string views to/from anything, so the input must also | ||
| // be a view. | ||
| assert(curr->ref->type.getHeapType() == heapType); |
There was a problem hiding this comment.
I don't think this will handle casts to bottom correctly. If a string view is cast to (ref none), we should just emit (unreachable) because that cast cannot possibly succeed. If a string view is cast to (ref null none), I haven't thought of anything better than emitting (ref.is_null) (if (result nullref) (then (ref.null none)) (else (unreachable)).
There was a problem hiding this comment.
This isn't comprehensive atm, I guess, yeah, but it should handle all the things the fuzzer and the optimizer emit. I'm not sure if it's worth handling more things.
tlively
left a comment
There was a problem hiding this comment.
Fair enough, I guess this isn't the only problem we have in principle that we don't run into in practice. And hopefully we will be able to remove the view types soon either way.
As suggested in #6434 (comment) , lower
ref.castof string viewsto
ref.as_non_nullin binary writing. It is a simple hack that avoids theproblem of V8 not allowing them to be cast.
Add fuzzing support for the last three core string operations, after which
that problem becomes very frequent.
Also add yet another
makeTrappingRefUsethat was missing in thatfuzzer code.