SlideShare a Scribd company logo
1 of 35
Download to read offline
A world to win
WebAssembly for the rest of us
17 Mar 2023 – BOB 2023
Andy Wingo
Igalia, S.L.
WebAssembly,
the story
WebAssembly is an exciting new
universal compute platform
WebAssembly,
the pitch
Predictable portable performance
Low-level
❧
Within 10% of native
❧
Reliable composition via isolation
Modules share nothing by default
❧
No nasal demons
❧
Memory sandboxing
❧
Compile your code to WebAssembly
for easier distribution and composition
WebAssembly,
the hype
It’s in all browsers! Serve your code to
anyone in the world!
It’s on the edge! Run code from your
web site close to your users!
Compose a library (eg: Expat) into
your program (eg: Firefox), without
risk!
It’s the new lightweight virtualization:
Wasm is what containers were to VMs!
Give me that Kubernetes cash!!!
WebAssembly,
the reality
WebAssembly is a weird backend for a
C compiler
Only some source languages are having
success on WebAssembly
What about Haskell, Ocaml, Scheme,
F#, and so on – what about us?
Are we just lazy? (Well...)
WebAssembly,
the reality
(2)
WebAssembly (1.0, 2.0) is not well-
suited to garbage-collected languages
Let’s look into why
GC and
WebAssembly
1.0
Where do garbage-collected values
live?
For WebAssembly 1.0, only possible
answer: linear memory
(module
(global $hp (mut i32) (i32.const 0))
(memory $mem 10)) ;; 640 kB
(func $alloc (param $size i32) (result i32)
(local $ret i32)
(loop $retry
(local.set $ret (global.get $hp))
(global.set $hp
(i32.add (local.get $size) (local.get $ret)))
(br_if 1
(i32.lt_u (i32.shr_u (global.get $hp) 16)
(memory.size))
(local.get $ret))
(call $gc)
(br $retry)))
GC and
WebAssembly
1.0 (2)
What hides behind (call $gc) ?
Ship a GC over linear memory
Stop-the-world, not parallel, not
concurrent
But... roots.
GC and
WebAssembly
1.0 (3)
Live objects are
the roots
❧
any object referenced by a live
object
❧
Roots are globals and locals in active
stack frames
No way to visit active stack
frames
GC and
WebAssembly
1.0 (3)
Workarounds
handle stack for precise roots
❧
spill all possibly-pointer values to
linear memory and collect
conservatively
❧
Handle book-keeping a drag for
compiled code
GC and
WebAssembly
1.0 (4)
Cycles with external objects (e.g.
JavaScript) uncollectable
A pointer to a GC-managed object is an
offset to linear memory, need
capability over linear memory to read/
write object from outside world
No way to give back memory to the OS
Gut check: gut says no
GC and
WebAssembly
1.0 (5)
There is already a high-performance
concurrent parallel compacting GC in
the browser
Halftime: C++ 1 – Altlangs 0
Change is
coming!
Support for built-in GC set to ship in
Q4 2023
With GC, the material conditions are
now in place
Let’s compile our languages to
WebAssembly
Scheme to
Wasm
Spritely + Igalia working on Scheme to
WebAssembly
Avoid truncating language to platform;
bring whole self
Value representation
❧
Varargs
❧
Tail calls
❧
Delimited continuations
❧
Numeric tower
❧
Scheme to
Wasm:
Values
;; any extern func
;; |
;; eq
;; / | 
;; i31 struct array
The unitype: (ref eq)
Immediate values in (ref i31)
fixnums with 30-bit range
❧
chars, bools, etc
❧
Explicit nullability: (ref null eq) vs
(ref eq)
Scheme to
Wasm:
Values (2)
Heap objects subtypes of struct;
concretely:
(struct $heap-object
(struct (field $tag-and-hash i32)))
(struct $pair
(sub $heap-object
(struct i32 (ref eq) (ref eq))))
GC proposal allows subtyping on
structs, functions, arrays
Structural type equivalance: explicit
tag useful
Scheme to
Wasm:
Values (3)
(func $cons (param (ref eq)
(ref eq))
(result (ref $pair))
(struct.new_canon $pair
;; Assume heap tag for pairs is 1.
(i32.const 1)
;; Car and cdr.
(local.get 0)
(local.get 1)))
(func $%car (param (ref $pair))
(result (ref eq))
(struct.get $pair 1 (local.get 0)))
(func $car (param (ref eq)) (result (ref eq))
(local (ref $pair))
(block $not-pair
(br_if $not-pair
(i32.eqz (ref.test $pair (local.get 0))))
(local.set 1 (ref.cast $pair) (local.get 0))
(br_if $not-pair
(i32.ne
(i32.const 1)
(i32.and
(i32.const 0xff)
(struct.get $heap-object 0 (local.get 1)))))
(return_call $%car (local.get 1)))
(call $type-error)
(unreachable))
Scheme to
Wasm
Value representation
❧
Varargs
❧
Tail calls
❧
Delimited continuations
❧
Numeric tower
❧
Scheme to
Wasm:
Varargs
(list 'hey) ;; => (hey)
(list 'hey 'bob) ;; => (hey bob)
Problem: Wasm functions strongly
typed
(func $list (param ???) (result (ref eq))
???)
Solution: Virtualize calling convention
;; "Registers" for args 0 to 3
(global $arg0 (mut (ref eq)) (i31.new (i32.const 0)))
(global $arg1 (mut (ref eq)) (i31.new (i32.const 0)))
(global $arg2 (mut (ref eq)) (i31.new (i32.const 0)))
(global $arg3 (mut (ref eq)) (i31.new (i32.const 0)))
;; "Memory" for the rest
(type $argv (array (ref eq)))
(global $argN (ref $argv)
(array.new_canon_default
$argv (i31.const 42) (i31.new (i32.const 0))))
Uniform function type: argument count as sole parameter
Callee moves args to locals, possibly clearing roots
Scheme to
Wasm
Value representation
❧
Varargs
❧
Tail calls
❧
Delimited continuations
❧
Numeric tower
❧
Scheme to
Wasm: Tail
calls
;; Call known function
(return_call $f arg ...)
;; Call function by value
(return_call_ref $type callee arg ...)
Scheme to
Wasm
Value representation
❧
Varargs
❧
Tail calls
❧
Delimited continuations
❧
Numeric tower
❧
Scheme to
Wasm:
Prompts (1)
Problem: Lightweight threads/fibers,
exceptions
Possible solutions
Eventually, built-in coroutines
❧
https://github.com/
WebAssembly/binaryen’s asyncify
(not yet ready for GC); see Julia
❧
Delimited continuations
❧
“Bring your whole self”
Scheme to
Wasm:
Prompts (2)
Prompts delimit continuations
(define k
(call-with-prompt 'foo
; body
(lambda ()
(+ 34 (abort-to-prompt 'foo)))
; handler
(lambda (continuation)
continuation)))
(k 10) ;; ⇒ 44
(- (k 10) 2) ;; ⇒ 42
k is the _ in (lambda () (+ 34 _))
Scheme to
Wasm:
Prompts (3)
Delimited continuations are stack
slices
Make stack explicit via minimal
continuation-passing-style conversion
Turn all calls into tail calls
❧
Allocate return continuations on
explicit stack
❧
Breaks functions into pieces at non-
tail calls
❧
Scheme to
Wasm:
Prompts (4)
Before a non-tail-call:
Push live-out vars on stacks (one
stack per top type)
❧
Push continuation as funcref
❧
Tail-call callee
❧
Return from call via pop and tail call:
(return_call_ref (call $pop-return)
(i32.const 0))
After return, continuation pops state
from stacks
Scheme to
Wasm:
Prompts (5)
abort-to-prompt:
Pop stack slice to reified
continuation object
❧
Tail-call new top of stack: prompt
handler
❧
Calling a reified continuation:
Push stack slice
❧
Tail-call new top of stack
❧
No need to wait for effect handlers
proposal; you can have it all now!
Scheme to
Wasm
Value representation
❧
Varargs
❧
Tail calls
❧
Delimited continuations
❧
Numeric tower
❧
Scheme to
Wasm:
Numbers
Numbers can be immediate: fixnums
Or on the heap: bignums, fractions,
flonums, complex
Supertype is still ref eq
Consider imports to implement
bignums
On web: BigInt
❧
On edge: Wasm support module
(mini-gmp?)
❧
Dynamic dispatch for polymorphic
ops, as usual
Scheme to
Wasm
Value representation
❧
Varargs
❧
Tail calls
❧
Delimited continuations
❧
Numeric tower
❧
Miscellenea Debugging: The wild west of DWARF;
prompts
Strings: stringref host strings spark
joy
JS interop: Export accessors; Wasm
objects opaque to JS. externref.
JIT: A whole ’nother talk! https://
wingolog.org/archives/2022/08/18/
just-in-time-code-generation-
within-webassembly
AOT: wasm2c
WebAssembly
for the rest
of us
With GC, WebAssembly is now ready
for us
Getting our languages on
WebAssembly now a S.M.O.P.
Let’s score some goals in the second
half!
(visit-links
"gitlab.com/spritely/guile-hoot-updates"
"wingolog.org"
"wingo@igalia.com"
"igalia.com"
"mastodon.social/@wingo")

More Related Content

Similar to WebAssembly for the rest of us: Bringing GC languages to WebAssembly

Groovy on Grails by Ziya Askerov
Groovy on Grails by Ziya AskerovGroovy on Grails by Ziya Askerov
Groovy on Grails by Ziya AskerovVuqar Suleymanov
 
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraAllen Wirfs-Brock
 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futureTakayuki Muranushi
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSkills Matter
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptJohn Stevenson
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the futureAnsviaLab
 
PIL - A Platform Independent Language
PIL - A Platform Independent LanguagePIL - A Platform Independent Language
PIL - A Platform Independent Languagezefhemel
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Eugene Yokota
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesEelco Visser
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScriptChengHui Weng
 
Building Distributed Systems in Scala
Building Distributed Systems in ScalaBuilding Distributed Systems in Scala
Building Distributed Systems in ScalaAlex Payne
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015Michiel Borkent
 
LLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, JapanLLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, Japanujihisa
 
Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009spierre
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)Ary Borenszweig
 

Similar to WebAssembly for the rest of us: Bringing GC languages to WebAssembly (20)

Grails
GrailsGrails
Grails
 
Grails
GrailsGrails
Grails
 
Groovy on Grails by Ziya Askerov
Groovy on Grails by Ziya AskerovGroovy on Grails by Ziya Askerov
Groovy on Grails by Ziya Askerov
 
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_future
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
 
Scala+data
Scala+dataScala+data
Scala+data
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the future
 
PIL - A Platform Independent Language
PIL - A Platform Independent LanguagePIL - A Platform Independent Language
PIL - A Platform Independent Language
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)
 
React native
React nativeReact native
React native
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScript
 
Building Distributed Systems in Scala
Building Distributed Systems in ScalaBuilding Distributed Systems in Scala
Building Distributed Systems in Scala
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
LLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, JapanLLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, Japan
 
Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 

More from Igalia

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Building End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPEBuilding End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPEIgalia
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Automated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded DevicesAutomated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded DevicesIgalia
 
Embedding WPE WebKit - from Bring-up to Maintenance
Embedding WPE WebKit - from Bring-up to MaintenanceEmbedding WPE WebKit - from Bring-up to Maintenance
Embedding WPE WebKit - from Bring-up to MaintenanceIgalia
 
Optimizing Scheduler for Linux Gaming.pdf
Optimizing Scheduler for Linux Gaming.pdfOptimizing Scheduler for Linux Gaming.pdf
Optimizing Scheduler for Linux Gaming.pdfIgalia
 
Running JS via WASM faster with JIT
Running JS via WASM      faster with JITRunning JS via WASM      faster with JIT
Running JS via WASM faster with JITIgalia
 
To crash or not to crash: if you do, at least recover fast!
To crash or not to crash: if you do, at least recover fast!To crash or not to crash: if you do, at least recover fast!
To crash or not to crash: if you do, at least recover fast!Igalia
 
Implementing a Vulkan Video Encoder From Mesa to GStreamer
Implementing a Vulkan Video Encoder From Mesa to GStreamerImplementing a Vulkan Video Encoder From Mesa to GStreamer
Implementing a Vulkan Video Encoder From Mesa to GStreamerIgalia
 
8 Years of Open Drivers, including the State of Vulkan in Mesa
8 Years of Open Drivers, including the State of Vulkan in Mesa8 Years of Open Drivers, including the State of Vulkan in Mesa
8 Years of Open Drivers, including the State of Vulkan in MesaIgalia
 
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por IgaliaIntroducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por IgaliaIgalia
 
2023 in Chimera Linux
2023 in Chimera                    Linux2023 in Chimera                    Linux
2023 in Chimera LinuxIgalia
 
Building a Linux distro with LLVM
Building a Linux distro        with LLVMBuilding a Linux distro        with LLVM
Building a Linux distro with LLVMIgalia
 
turnip: Update on Open Source Vulkan Driver for Adreno GPUs
turnip: Update on Open Source Vulkan Driver for Adreno GPUsturnip: Update on Open Source Vulkan Driver for Adreno GPUs
turnip: Update on Open Source Vulkan Driver for Adreno GPUsIgalia
 
Graphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devicesGraphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devicesIgalia
 
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOSDelegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOSIgalia
 
MessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the webMessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the webIgalia
 
Replacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shadersReplacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shadersIgalia
 
I'm not an AMD expert, but...
I'm not an AMD expert, but...I'm not an AMD expert, but...
I'm not an AMD expert, but...Igalia
 
Status of Vulkan on Raspberry
Status of Vulkan on RaspberryStatus of Vulkan on Raspberry
Status of Vulkan on RaspberryIgalia
 

More from Igalia (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Building End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPEBuilding End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPE
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Automated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded DevicesAutomated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded Devices
 
Embedding WPE WebKit - from Bring-up to Maintenance
Embedding WPE WebKit - from Bring-up to MaintenanceEmbedding WPE WebKit - from Bring-up to Maintenance
Embedding WPE WebKit - from Bring-up to Maintenance
 
Optimizing Scheduler for Linux Gaming.pdf
Optimizing Scheduler for Linux Gaming.pdfOptimizing Scheduler for Linux Gaming.pdf
Optimizing Scheduler for Linux Gaming.pdf
 
Running JS via WASM faster with JIT
Running JS via WASM      faster with JITRunning JS via WASM      faster with JIT
Running JS via WASM faster with JIT
 
To crash or not to crash: if you do, at least recover fast!
To crash or not to crash: if you do, at least recover fast!To crash or not to crash: if you do, at least recover fast!
To crash or not to crash: if you do, at least recover fast!
 
Implementing a Vulkan Video Encoder From Mesa to GStreamer
Implementing a Vulkan Video Encoder From Mesa to GStreamerImplementing a Vulkan Video Encoder From Mesa to GStreamer
Implementing a Vulkan Video Encoder From Mesa to GStreamer
 
8 Years of Open Drivers, including the State of Vulkan in Mesa
8 Years of Open Drivers, including the State of Vulkan in Mesa8 Years of Open Drivers, including the State of Vulkan in Mesa
8 Years of Open Drivers, including the State of Vulkan in Mesa
 
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por IgaliaIntroducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
 
2023 in Chimera Linux
2023 in Chimera                    Linux2023 in Chimera                    Linux
2023 in Chimera Linux
 
Building a Linux distro with LLVM
Building a Linux distro        with LLVMBuilding a Linux distro        with LLVM
Building a Linux distro with LLVM
 
turnip: Update on Open Source Vulkan Driver for Adreno GPUs
turnip: Update on Open Source Vulkan Driver for Adreno GPUsturnip: Update on Open Source Vulkan Driver for Adreno GPUs
turnip: Update on Open Source Vulkan Driver for Adreno GPUs
 
Graphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devicesGraphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devices
 
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOSDelegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
 
MessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the webMessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the web
 
Replacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shadersReplacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shaders
 
I'm not an AMD expert, but...
I'm not an AMD expert, but...I'm not an AMD expert, but...
I'm not an AMD expert, but...
 
Status of Vulkan on Raspberry
Status of Vulkan on RaspberryStatus of Vulkan on Raspberry
Status of Vulkan on Raspberry
 

Recently uploaded

Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
SEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistSEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistKHM Anwar
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 

Recently uploaded (20)

Call Girls In Noida 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Noida 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In Noida 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Noida 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
SEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistSEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization Specialist
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 

WebAssembly for the rest of us: Bringing GC languages to WebAssembly

  • 1. A world to win WebAssembly for the rest of us 17 Mar 2023 – BOB 2023 Andy Wingo Igalia, S.L.
  • 2. WebAssembly, the story WebAssembly is an exciting new universal compute platform
  • 3. WebAssembly, the pitch Predictable portable performance Low-level ❧ Within 10% of native ❧ Reliable composition via isolation Modules share nothing by default ❧ No nasal demons ❧ Memory sandboxing ❧ Compile your code to WebAssembly for easier distribution and composition
  • 4. WebAssembly, the hype It’s in all browsers! Serve your code to anyone in the world! It’s on the edge! Run code from your web site close to your users! Compose a library (eg: Expat) into your program (eg: Firefox), without risk! It’s the new lightweight virtualization: Wasm is what containers were to VMs! Give me that Kubernetes cash!!!
  • 5. WebAssembly, the reality WebAssembly is a weird backend for a C compiler Only some source languages are having success on WebAssembly What about Haskell, Ocaml, Scheme, F#, and so on – what about us? Are we just lazy? (Well...)
  • 6. WebAssembly, the reality (2) WebAssembly (1.0, 2.0) is not well- suited to garbage-collected languages Let’s look into why
  • 7. GC and WebAssembly 1.0 Where do garbage-collected values live? For WebAssembly 1.0, only possible answer: linear memory (module (global $hp (mut i32) (i32.const 0)) (memory $mem 10)) ;; 640 kB
  • 8. (func $alloc (param $size i32) (result i32) (local $ret i32) (loop $retry (local.set $ret (global.get $hp)) (global.set $hp (i32.add (local.get $size) (local.get $ret))) (br_if 1 (i32.lt_u (i32.shr_u (global.get $hp) 16) (memory.size)) (local.get $ret)) (call $gc) (br $retry)))
  • 9. GC and WebAssembly 1.0 (2) What hides behind (call $gc) ? Ship a GC over linear memory Stop-the-world, not parallel, not concurrent But... roots.
  • 10. GC and WebAssembly 1.0 (3) Live objects are the roots ❧ any object referenced by a live object ❧ Roots are globals and locals in active stack frames No way to visit active stack frames
  • 11. GC and WebAssembly 1.0 (3) Workarounds handle stack for precise roots ❧ spill all possibly-pointer values to linear memory and collect conservatively ❧ Handle book-keeping a drag for compiled code
  • 12. GC and WebAssembly 1.0 (4) Cycles with external objects (e.g. JavaScript) uncollectable A pointer to a GC-managed object is an offset to linear memory, need capability over linear memory to read/ write object from outside world No way to give back memory to the OS Gut check: gut says no
  • 13. GC and WebAssembly 1.0 (5) There is already a high-performance concurrent parallel compacting GC in the browser Halftime: C++ 1 – Altlangs 0
  • 14. Change is coming! Support for built-in GC set to ship in Q4 2023 With GC, the material conditions are now in place Let’s compile our languages to WebAssembly
  • 15. Scheme to Wasm Spritely + Igalia working on Scheme to WebAssembly Avoid truncating language to platform; bring whole self Value representation ❧ Varargs ❧ Tail calls ❧ Delimited continuations ❧ Numeric tower ❧
  • 16. Scheme to Wasm: Values ;; any extern func ;; | ;; eq ;; / | ;; i31 struct array The unitype: (ref eq) Immediate values in (ref i31) fixnums with 30-bit range ❧ chars, bools, etc ❧ Explicit nullability: (ref null eq) vs (ref eq)
  • 17. Scheme to Wasm: Values (2) Heap objects subtypes of struct; concretely: (struct $heap-object (struct (field $tag-and-hash i32))) (struct $pair (sub $heap-object (struct i32 (ref eq) (ref eq)))) GC proposal allows subtyping on structs, functions, arrays Structural type equivalance: explicit tag useful
  • 18. Scheme to Wasm: Values (3) (func $cons (param (ref eq) (ref eq)) (result (ref $pair)) (struct.new_canon $pair ;; Assume heap tag for pairs is 1. (i32.const 1) ;; Car and cdr. (local.get 0) (local.get 1))) (func $%car (param (ref $pair)) (result (ref eq)) (struct.get $pair 1 (local.get 0)))
  • 19. (func $car (param (ref eq)) (result (ref eq)) (local (ref $pair)) (block $not-pair (br_if $not-pair (i32.eqz (ref.test $pair (local.get 0)))) (local.set 1 (ref.cast $pair) (local.get 0)) (br_if $not-pair (i32.ne (i32.const 1) (i32.and (i32.const 0xff) (struct.get $heap-object 0 (local.get 1))))) (return_call $%car (local.get 1))) (call $type-error) (unreachable))
  • 20. Scheme to Wasm Value representation ❧ Varargs ❧ Tail calls ❧ Delimited continuations ❧ Numeric tower ❧
  • 21. Scheme to Wasm: Varargs (list 'hey) ;; => (hey) (list 'hey 'bob) ;; => (hey bob) Problem: Wasm functions strongly typed (func $list (param ???) (result (ref eq)) ???) Solution: Virtualize calling convention
  • 22. ;; "Registers" for args 0 to 3 (global $arg0 (mut (ref eq)) (i31.new (i32.const 0))) (global $arg1 (mut (ref eq)) (i31.new (i32.const 0))) (global $arg2 (mut (ref eq)) (i31.new (i32.const 0))) (global $arg3 (mut (ref eq)) (i31.new (i32.const 0))) ;; "Memory" for the rest (type $argv (array (ref eq))) (global $argN (ref $argv) (array.new_canon_default $argv (i31.const 42) (i31.new (i32.const 0)))) Uniform function type: argument count as sole parameter Callee moves args to locals, possibly clearing roots
  • 23. Scheme to Wasm Value representation ❧ Varargs ❧ Tail calls ❧ Delimited continuations ❧ Numeric tower ❧
  • 24. Scheme to Wasm: Tail calls ;; Call known function (return_call $f arg ...) ;; Call function by value (return_call_ref $type callee arg ...)
  • 25. Scheme to Wasm Value representation ❧ Varargs ❧ Tail calls ❧ Delimited continuations ❧ Numeric tower ❧
  • 26. Scheme to Wasm: Prompts (1) Problem: Lightweight threads/fibers, exceptions Possible solutions Eventually, built-in coroutines ❧ https://github.com/ WebAssembly/binaryen’s asyncify (not yet ready for GC); see Julia ❧ Delimited continuations ❧ “Bring your whole self”
  • 27. Scheme to Wasm: Prompts (2) Prompts delimit continuations (define k (call-with-prompt 'foo ; body (lambda () (+ 34 (abort-to-prompt 'foo))) ; handler (lambda (continuation) continuation))) (k 10) ;; ⇒ 44 (- (k 10) 2) ;; ⇒ 42 k is the _ in (lambda () (+ 34 _))
  • 28. Scheme to Wasm: Prompts (3) Delimited continuations are stack slices Make stack explicit via minimal continuation-passing-style conversion Turn all calls into tail calls ❧ Allocate return continuations on explicit stack ❧ Breaks functions into pieces at non- tail calls ❧
  • 29. Scheme to Wasm: Prompts (4) Before a non-tail-call: Push live-out vars on stacks (one stack per top type) ❧ Push continuation as funcref ❧ Tail-call callee ❧ Return from call via pop and tail call: (return_call_ref (call $pop-return) (i32.const 0)) After return, continuation pops state from stacks
  • 30. Scheme to Wasm: Prompts (5) abort-to-prompt: Pop stack slice to reified continuation object ❧ Tail-call new top of stack: prompt handler ❧ Calling a reified continuation: Push stack slice ❧ Tail-call new top of stack ❧ No need to wait for effect handlers proposal; you can have it all now!
  • 31. Scheme to Wasm Value representation ❧ Varargs ❧ Tail calls ❧ Delimited continuations ❧ Numeric tower ❧
  • 32. Scheme to Wasm: Numbers Numbers can be immediate: fixnums Or on the heap: bignums, fractions, flonums, complex Supertype is still ref eq Consider imports to implement bignums On web: BigInt ❧ On edge: Wasm support module (mini-gmp?) ❧ Dynamic dispatch for polymorphic ops, as usual
  • 33. Scheme to Wasm Value representation ❧ Varargs ❧ Tail calls ❧ Delimited continuations ❧ Numeric tower ❧
  • 34. Miscellenea Debugging: The wild west of DWARF; prompts Strings: stringref host strings spark joy JS interop: Export accessors; Wasm objects opaque to JS. externref. JIT: A whole ’nother talk! https:// wingolog.org/archives/2022/08/18/ just-in-time-code-generation- within-webassembly AOT: wasm2c
  • 35. WebAssembly for the rest of us With GC, WebAssembly is now ready for us Getting our languages on WebAssembly now a S.M.O.P. Let’s score some goals in the second half! (visit-links "gitlab.com/spritely/guile-hoot-updates" "wingolog.org" "wingo@igalia.com" "igalia.com" "mastodon.social/@wingo")