Bug 260039 - [Wasm-GC] Module linking should take subtyping into account
Summary: [Wasm-GC] Module linking should take subtyping into account
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebAssembly (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 247394
  Show dependency treegraph
 
Reported: 2023-08-10 13:58 PDT by Asumu Takikawa
Modified: 2023-12-18 09:55 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Asumu Takikawa 2023-08-10 13:58:01 PDT
Right now, module linking checks for exact type index equality to make sure linked functions satisfy their types. The GC proposal extends this to work with subtypes, instead of exact match, but this isn't implemented yet.

For example, this test fragment is from the GC proposal repo test suite:

```
(module
  (type $t0 (sub (func (result (ref null func)))))
  (rec (type $t1 (sub $t0 (func (result (ref null $t1))))))
  (rec (type $t2 (sub $t1 (func (result (ref null $t2))))))

  (func (export "f0") (type $t0) (ref.null func))
  (func (export "f1") (type $t1) (ref.null $t1))
  (func (export "f2") (type $t2) (ref.null $t2))
)
(register "M")

(module
  (type $t0 (sub (func (result (ref null func)))))
  (rec (type $t1 (sub $t0 (func (result (ref null $t1))))))
  (rec (type $t2 (sub $t1 (func (result (ref null $t2))))))

  (func (import "M" "f0") (type $t0))
  (func (import "M" "f1") (type $t0))
  (func (import "M" "f1") (type $t1))
  (func (import "M" "f2") (type $t0))
  (func (import "M" "f2") (type $t1))
  (func (import "M" "f2") (type $t2))
)
```

The import "f1" takes a function that has type `$t1` (subtype of `$t0`) and tries to import it under type `$t0`. This currently fails, but is supposed to succeed.

It should be relatively easy to fix, by changing the index equality check to a `isSubtype` call.
Comment 1 Radar WebKit Bug Importer 2023-08-17 13:58:15 PDT
<rdar://problem/114045477>
Comment 2 Asumu Takikawa 2023-12-15 10:28:12 PST
Pull request: https://github.com/WebKit/WebKit/pull/21875
Comment 3 EWS 2023-12-18 09:55:06 PST
Committed 272226@main (3015bbe0e8ab): <https://commits.webkit.org/272226@main>

Reviewed commits have been landed. Closing PR #21875 and removing active labels.