Fuzzer: Use a WebAssembly.Tag from JS#7277
Conversation
| } else if (import->base == "throw") { | ||
| throwEmptyException(); | ||
| if (arguments[0].geti32() == 0) { | ||
| // Throw in a way similar to JS. | ||
| throwEmptyException(); | ||
| } else { | ||
| // Throw the argument in the imported JS tag. | ||
| auto payload = std::make_shared<ExnData>(fuzzTag, arguments); | ||
| throwException(WasmException{Literal(payload)}); | ||
| } |
There was a problem hiding this comment.
ifpart: Doesn'targuments[0].geti32() == 0mean we should throw 0 as an i32 (rather than an empty exception)?elsepart:fuzzTagis an i32, then what happens when the length of arguments is > 1?
Ah I understand what this means now I've seen TranslateToFuzzReader::makeImportThrowing, but I think this can be confusing... how about just passing an empty array when we want to throw an empty exception and add assert(arguments.size() == 1) in the else part?
There was a problem hiding this comment.
Hmm, we can't pass an empty array, since the signature is fixed by the wasm import. (Or do you mean a wasm Array? We wouldn't want to depend on GC here though, as this can be used when GC is disabled.)
We could have two i32s, one "throw JS?" and the other meaning "if not JS, this is the value to throw". I basically just combined those two into one, as it didn't seem to matter much, but if that's clearer I'm happy to do it.
There was a problem hiding this comment.
Not sure what "the signature is fixed by the wasm import" means..
What I meant was #7277 (comment)
There was a problem hiding this comment.
I see (after reading #7277 (comment)). How about adding a comment here too about what the rule is?
We now create a Tag in JS and import it in the wasm.
We can then use that tag from JS when we throw (only some of the
time, controlled by a new parameter to the throwing import).