Skip to content

Instantly share code, notes, and snippets.

@ManasJayanth
Last active August 14, 2019 16:59
Show Gist options
  • Save ManasJayanth/d05dbca34434f3c3e635b0254d4ba852 to your computer and use it in GitHub Desktop.
Save ManasJayanth/d05dbca34434f3c3e635b0254d4ba852 to your computer and use it in GitHub Desktop.

Table of Contents

  1. Ideal wasm output?
  2. Manual gc polyfilling
  3. How does the runtime interface with the garbage collector?
  4. Is CMM too low level for wasm.gc instructions?
  5. Aggregate allocators provided by wasm gc
    1. Arrays
    2. Structs (records, tuples)
    3. What about floats? Actually why do floats need to be allocs? Because unboxed?
  6. Closures
  7. Mutable records?
  8. Packed records
  9. Nullability?
  10. tagged ints

Ideal wasm output?

https://github.com/SanderSpies/ocaml-wasm-gc-experimenting

  1. Changes need?

Manual gc polyfilling

How does the runtime interface with the garbage collector?

  1. How does runtime track alloc made in the backend?

Is CMM too low level for wasm.gc instructions?

There's a nagging question in my head and it really worries me about Tuples and Records

type r = {foo: string; bar: int}

let process_rec r = print_endline r.foo

let () = process_rec {foo= "foo-bar-string"; bar= 6}

lambda IR

(seq
    (let
        (process_rec/1011 =
            (function r/1012
            (apply (field 30 (global Pervasives!)) (field 0 r/1012))))
            (setfield_imm 0 (global Foo!) process_rec/1011))
    (let (match/1016 = (apply (field 0 (global Foo!)) [0: "foo-bar-string" 6]))
        0a)
    0a)

(data int 768 global "camlFoo" "camlFoo":)
(data int 3068 "camlFoo__1": string "foo-bar-string" skip 1 byte 1)
(data int 2816 "camlFoo__2": addr "camlFoo__1" int 13) 

Aggregate allocators provided by wasm gc

Arrays

Structs (records, tuples)

What about floats? Actually why do floats need to be allocs? Because unboxed?

Closures

Mutable records?

Packed records

Nullability?

tagged ints

Ideal wasm output?

https://github.com/SanderSpies/ocaml-wasm-gc-experimenting

  1. Changes need?

Manual gc polyfilling

How does the runtime interface with the garbage collector?

  1. How does runtime track alloc made in the backend?

Is CMM too low level for wasm.gc instructions?

There’s a nagging question in my head and it really worries me about Tuples and Records

type r = {foo: string; bar: int}

let process_rec r = print_endline r.foo

let () = process_rec {foo= "foo-bar-string"; bar= 6}

lambda IR

(seq
    (let
        (process_rec/1011 =
            (function r/1012
            (apply (field 30 (global Pervasives!)) (field 0 r/1012))))
            (setfield_imm 0 (global Foo!) process_rec/1011))
    (let (match/1016 = (apply (field 0 (global Foo!)) [0: "foo-bar-string" 6]))
        0a)
    0a)
(data int 768 global "camlFoo" "camlFoo":)
(data int 3068 "camlFoo__1": string "foo-bar-string" skip 1 byte 1)
(data int 2816 "camlFoo__2": addr "camlFoo__1" int 13) 

Aggregate allocators provided by wasm gc

Arrays

Structs (records, tuples)

What about floats? Actually why do floats need to be allocs? Because unboxed?

Closures

Mutable records?

Packed records

Nullability?

tagged ints

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment