[HIW] The JavaScript FFI feature in GHC Wasm backend
The GHC wasm backend supports the JavaScript FFI feature for calling JavaScript from Haskell and vice verca, while managing JavaScript values as garbage collected Haskell values on the Haskell heap. It has been evaluated in experimental projects that port the miso frontend framework or runs Haskell in Cloudflare Workers, demonstrating the utility of JavaScript FFI in its current form.
The implementation poses a few interesting challenges:
- How to support asynchronous computation in JavaScript as Haskell green threads that can be concurrently executed?
- How to garbage collect JavaScript values with the Haskell garbage collector and vice versa, given we cross-compile the GHC RTS to wasm and the Haskell heap is distinct from the host heap?
- How to avoid paying for JavaScript when not using it, ensuring we can always generate self-contained wasm modules when not targeting the web?
This talk will dive into the rabbit holes and explain the solutions of the questions above. The most interesting part is how we implement a Haskell thread scheduler in Haskell userspace on top of the RTS scheduler, and the same technique might be useful for writing third party I/O managers for native platforms as well.
Sat 7 SepDisplayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
11:00 - 12:30 | |||
11:00 22mTalk | [HIW] Analysing the heap of uninstrumented Haskell programs using ghc-debug Haskell Zubin Duggal Well-Typed LLP | ||
11:22 22mTalk | [HIW] A zero-copy interface to compact regions powered by destinations Haskell Thomas BAGREL Tweag, LORIA/INRIA | ||
11:45 22mTalk | [HIW] Building Haskell with Buck2 Haskell Andreas Herrmann Tweag by Modus Create | ||
12:07 22mTalk | [HIW] The JavaScript FFI feature in GHC Wasm backend Haskell Cheng Shao Modus Create |