Bug 270374 - [Wasm-GC] Fix JS API casts for some top types
Summary: [Wasm-GC] Fix JS API casts for some top types
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: 2024-03-01 13:36 PST by Asumu Takikawa
Modified: 2024-03-22 16:54 PDT (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 2024-03-01 13:36:45 PST
There are a small number of cases in the JS API cast code that makes too-optimistic assumptions for top types (because the code was originally written to implement cast instructions, which benefit from static type-checking). Example diff for js-api.js: 

```
+  {
+    let m1 = instantiate(`
+      (module
+        (func (export "f"))
+      )
+    `);
+    assert.throws(
+      () => instantiate(`
+        (module
+          (global (import "m" "f") (ref any))
+        )
+      `, { m: { f: m1.exports.f } }),
+      WebAssembly.LinkError,
+      "Argument value did not match the reference type"
+    )
+  }
```

There's a simple fix for these cases.
Comment 1 Asumu Takikawa 2024-03-07 15:32:32 PST
Pull request: https://github.com/WebKit/WebKit/pull/25599
Comment 2 Radar WebKit Bug Importer 2024-03-08 13:37:12 PST
<rdar://problem/124294503>
Comment 3 EWS 2024-03-22 16:53:59 PDT
Committed 276580@main (a2bcc4921f7c): <https://commits.webkit.org/276580@main>

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