RESOLVED FIXED 251874
[Wasm-GC] Update element segments to account for typed funcrefs and GC types
https://bugs.webkit.org/show_bug.cgi?id=251874
Summary [Wasm-GC] Update element segments to account for typed funcrefs and GC types
Tim Chevalier
Reported 2023-02-07 12:00:53 PST
The following test: ``` function testElem() { let m = instantiate(` (module (type $bvec (array i8)) (elem $e (ref $bvec) (array.new_canon $bvec (i32.const 7) (i32.const 3))))`); } ``` fails with: ``` Exception: CompileError: WebAssembly.Module doesn't parse at byte 30: opcode for exp in element section's should be either ref.func or ref.null 0th element's 0th index (evaluating 'new WebAssembly.Module(binary)') ``` This is because `SectionParser::parseElementSegmentVectorOfExpressions()` requires the members of the elements vector to be either a `RefFunc` or `RefNull`. The test should compile (this is taken from https://github.com/WebAssembly/gc/blob/main/test/core/gc/array.wast#L203 ) A related bug is https://bugs.webkit.org/show_bug.cgi?id=251041 , but that one covers tables rather than element segments.
Attachments
Tim Chevalier
Comment 1 2023-02-09 15:13:09 PST
externrefs also aren't allowed in element segments, and should be: ``` (module (elem $elem0 externref (ref.null extern))) ``` fails with: ``` Exception: CompileError: WebAssembly.Module doesn't parse at byte 17: reftype in element section should be funcref (evaluating 'new WebAssembly.Module(binary)') ``` but is accepted by the reference interpreter.
Radar WebKit Bug Importer
Comment 2 2023-02-14 12:01:32 PST
Tim Chevalier
Comment 3 2023-02-15 17:25:51 PST
This should also work: ``` (module (type $fty (func (result i32))) (func $f (result i32) (i32.const 2)) (elem $e (ref $fty) (ref.func $f))) ``` As it is, the element segment type is restricted to either `funcref` or `externref`.
Asumu Takikawa
Comment 4 2023-12-11 12:49:03 PST
EWS
Comment 5 2023-12-12 14:16:35 PST
Committed 271952@main (7e71e7282468): <https://commits.webkit.org/271952@main> Reviewed commits have been landed. Closing PR #21647 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.