Igalia / webengineshackfest

Web Engines Hackfest
http://www.webengineshackfest.org/
49 stars 6 forks source link

Wasm GC in JavaScriptCore #12

Closed mrego closed 1 year ago

mrego commented 1 year ago

Logistics

Description

Agenda

TBD

bashor commented 1 year ago

The general idea is to help non-experienced devs in JavaScriptCore (JSC), like me😊, to dive into the topic and try to fix the first wasm issue in JSC.

More experienced folks are also super welcome! You can start your hackathon earlier while others are exploring JSC internals. Or help others with their diving into JSC.

Agenda:

--

Preparation:

Since we are limited in time, ask participants to do a few things in advance:

--

List of (simple) issues to look at during the session (mostly around Wasm GC)

With comments from @catamorphism.

Bug 254760 - Enforce operand limit for array.new_canon_fixed

The next two are less simple, but might be pretty self-contained for people who already understand the basic idea of inline caching: Bug 244388 - Inline struct allocation Bug 245405 - Inline Wasm array operations & allocation

Bug 246981 - [Wasm-GC] Implement packed types in struct fields This is not too hard in principle - I already did it for arrays: https://github.com/WebKit/WebKit/commit/04de71ca40b4832b65e5c6861c399d91735c309c , and I think someone could look at the code for arrays and adapt it to structs pretty easily.

Bug 250107 - [Wasm-GC] Add support for final attribute How hard this one is probably depends on whether it only requires static checking or also requires changing the runtime type information that is used for dynamic checks. I haven't looked at this feature enough to know.

Bug 254694 - [Wasm-GC] Implement br_on_cast and br_on_cast_fail Naïvely, I can imagine this not being too hard, since you can look at how br is implemented and at how ref.cast is implemented and combine the two.

Bug 254695 - [Wasm-GC] Add nullexternref and nullfuncref types Probably not too hard either, since you can use nullref as a model.

--

_Also, you could recommend as pre-work that participants look at the test suite for the reference interpreter -- for example, the tests for br_on_cast are here: https://github.com/WebAssembly/gc/blob/main/test/core/gc/br_on_cast.wast_ and import those tests into the JSC GC test suite: https://github.com/WebKit/WebKit/tree/main/JSTests/wasm/gc

Of course, the tests will fail, but getting to the point where the test fails with the expected CompileError will be a way for people to validate that they have properly built WebKit. Then you'll already have the tests on a local branch, and can work during the hackfest on getting the tests to pass.

(There's also a way to automatically export spec tests into the JSC test suite -- see https://github.com/WebKit/WebKit/tree/main/JSTests/wasm/gc-spec-tests -- but for the purposes of this exercise it's probably easier to manually copy/paste code, following the structure of, for example, https://github.com/WebKit/WebKit/blob/main/JSTests/wasm/gc/casts.js .)

bashor commented 1 year ago

Special Thanks:

dbezhetskov commented 1 year ago

There is an overview of wasm gc: https://docs.google.com/presentation/d/1LvYMFXlRNPM9JpbGRSSRD7v0zhQwryK7qeIlx75rrP4/edit?usp=sharing

bashor commented 1 year ago

Please Join WebKit Slack workspace. Link to join.

Drop the message here https://webkit.slack.com/archives/CTV4FGWF4/p1686043667584729 so I add you to the private channel.

spectranaut commented 1 year ago

Notes (if necessary): https://notes.igalia.com/YbGF7z3eQ86Cf7Prz-kWnA#

bashor commented 1 year ago

Wasm GC proposal Less formal overview: https://github.com/WebAssembly/gc/blob/main/proposals/gc/Overview.md Formal description: https://github.com/WebAssembly/gc/blob/main/proposals/gc/MVP.md

bashor commented 1 year ago

Checkout

git clone -b main --single-branch --depth=1 https://github.com/WebKit/WebKit

Build

./Tools/Scripts/build-jsc --jsc-only --debug

If it fails, try: ./Tools/Scripts/build-jsc --debug

Run wasm GC tests

./Tools/Scripts/run-javascriptcore-tests --no-testapi --no-build --no-fail-fast --debug --jsc-only --filter wasm/gc/

bashor commented 1 year ago

WasmGC: Minimal JavaScript Interop:

Wasm objects in JS appear opaque Wasm structs and arrays will appear on the JavaScript side as frozen empty objects, i.e. having no properties, and it's not possible to add any. Attempting to write a property throws a TypeError. Formally: their [[Set]], [[DefineOwnProperty]], [[Delete]] internal slots throw exceptions (regardless of strict mode). [[HasProperty]] and [[IsExtensible]] return false. [[Get]] and [[GetOwnProperty]] return undefined. [[OwnPropertyKeys]] returns an empty list.

dbezhetskov commented 1 year ago

test scripts: WebKitBuild/Debug/bin/jsc-stress-results/.runner

mrego commented 1 year ago

No notes for this session.