Skip to content

Instantly share code, notes, and snippets.

@ManasJayanth
Last active August 14, 2019 16:59
Show Gist options
  • Select an option

  • Save ManasJayanth/d05dbca34434f3c3e635b0254d4ba852 to your computer and use it in GitHub Desktop.

Select an option

Save ManasJayanth/d05dbca34434f3c3e635b0254d4ba852 to your computer and use it in GitHub Desktop.

Revisions

  1. ManasJayanth revised this gist Aug 14, 2019. 1 changed file with 45 additions and 0 deletions.
    45 changes: 45 additions & 0 deletions wasm-gc.org
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    * 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

    #+BEGIN_SRC ocaml
    type r = {foo: string; bar: int}

    let process_rec r = print_endline r.foo

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

    lambda IR
    #+BEGIN_SRC lisp
    (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)

    #+END_SRC
    #+BEGIN_SRC lisp
    (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)
    #+END_SRC

    * 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
  2. ManasJayanth revised this gist Jul 13, 2019. 1 changed file with 48 additions and 58 deletions.
    106 changes: 48 additions & 58 deletions wasm-gc.md
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,22 @@

    # Table of Contents

    1. [Ideal wasm output?](#org9568e95)
    2. [Manual gc polyfilling](#orgd1cdfd0)
    3. [How does the runtime interface with the garbage collector?](#orga5f773f)
    4. [Is CMM too low level for wasm.gc instructions?](#org13aa17a)
    5. [Aggregate allocators provided by wasm gc](#orgf19e6a8)
    1. [Arrays](#orgac25e7b)
    2. [Structs (records, tuples)](#orgf0b3ce6)
    3. [What about floats? Actually why do floats need to be allocs? Because unboxed?](#org35e4a76)
    6. [Closures](#org5220c38)
    7. [Mutable records?](#org7e1971b)
    8. [Packed records](#orge8d2b38)
    9. [Nullability?](#org36a6a04)
    10. [tagged ints](#org46cf2f9)


    <a id="org9568e95"></a>
    1. [Ideal wasm output?](#org05b2fb7)
    2. [Manual gc polyfilling](#orgebe08a8)
    3. [How does the runtime interface with the garbage collector?](#org4d5b558)
    4. [Is CMM too low level for wasm.gc instructions?](#orgdc49bfc)
    5. [Aggregate allocators provided by wasm gc](#org388d7b8)
    1. [Arrays](#org296ec4a)
    2. [Structs (records, tuples)](#org13a01db)
    3. [What about floats? Actually why do floats need to be allocs? Because unboxed?](#orgedb74e1)
    6. [Closures](#org523cc69)
    7. [Mutable records?](#org5e78c77)
    8. [Packed records](#orgbc821ef)
    9. [Nullability?](#org115313f)
    10. [tagged ints](#orgd33b64a)


    <a id="org05b2fb7"></a>

    # Ideal wasm output?

    @@ -25,98 +25,88 @@
    1. Changes need?


    <a id="orgd1cdfd0"></a>
    <a id="orgebe08a8"></a>

    # Manual gc polyfilling


    <a id="orga5f773f"></a>
    <a id="org4d5b558"></a>

    # How does the runtime interface with the garbage collector?

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


    <a id="org13aa17a"></a>
    <a id="orgdc49bfc"></a>

    # 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

    \`\`\`ml
    type r = {
    foo: string;
    bar: int;
    }
    type r = {foo: string; bar: int}
    let process_rec r = print_endline r.foo
    let () = process_rec {foo= "foo-bar-string"; bar= 6}

    let process<sub>rec</sub> r =
    print<sub>endline</sub> r.foo
    lambda IR

    let () =
    process<sub>rec</sub> {foo = "foo-bar-string"; bar= 6 }
    \`\`\`
    (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)

    lambda IR
    \`\`\`lisp
    (seq
    (let
    (process<sub>rec</sub>/1011 =
    (function r/1012
    (apply (field 30 (global Pervasives!)) (field 0 r/1012))))
    (setfield<sub>imm</sub> 0 (global Foo!) process<sub>rec</sub>/1011))
    (let (match/1016 = (apply (field 0 (global Foo!)) [0: "foo-bar-string" 6]))
    0a)
    0a)
    \`\`\`

    \`\`\`lisp
    (data int 768 global "camlFoo" "camlFoo":)
    (data int 3068 "camlFoo\_<sub>1</sub>": string "foo-bar-string" skip 1 byte 1)
    (data int 2816 "camlFoo\_<sub>2</sub>": addr "camlFoo\_<sub>1</sub>" int 13)
    \`\`\`


    <a id="orgf19e6a8"></a>
    (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)


    <a id="org388d7b8"></a>

    # Aggregate allocators provided by wasm gc


    <a id="orgac25e7b"></a>
    <a id="org296ec4a"></a>

    ## Arrays


    <a id="orgf0b3ce6"></a>
    <a id="org13a01db"></a>

    ## Structs (records, tuples)


    <a id="org35e4a76"></a>
    <a id="orgedb74e1"></a>

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


    <a id="org5220c38"></a>
    <a id="org523cc69"></a>

    # Closures


    <a id="org7e1971b"></a>
    <a id="org5e78c77"></a>

    # Mutable records?


    <a id="orge8d2b38"></a>
    <a id="orgbc821ef"></a>

    # Packed records


    <a id="org36a6a04"></a>
    <a id="org115313f"></a>

    # Nullability?


    <a id="org46cf2f9"></a>
    <a id="orgd33b64a"></a>

    # tagged ints

  3. ManasJayanth revised this gist Jul 13, 2019. 1 changed file with 103 additions and 11 deletions.
    114 changes: 103 additions & 11 deletions wasm-gc.md
    Original file line number Diff line number Diff line change
    @@ -1,30 +1,122 @@

    # Table of Contents

    1. [Ideal wasm output?](#org9f6353a)
    2. [Manual gc polyfilling](#org01f8358)
    3. [How does the runtime interface with the garbage collector?](#orga8279b2)
    1. [How does runtime track alloc made in the backend?](#org8fef019)


    <a id="org9f6353a"></a>
    1. [Ideal wasm output?](#org9568e95)
    2. [Manual gc polyfilling](#orgd1cdfd0)
    3. [How does the runtime interface with the garbage collector?](#orga5f773f)
    4. [Is CMM too low level for wasm.gc instructions?](#org13aa17a)
    5. [Aggregate allocators provided by wasm gc](#orgf19e6a8)
    1. [Arrays](#orgac25e7b)
    2. [Structs (records, tuples)](#orgf0b3ce6)
    3. [What about floats? Actually why do floats need to be allocs? Because unboxed?](#org35e4a76)
    6. [Closures](#org5220c38)
    7. [Mutable records?](#org7e1971b)
    8. [Packed records](#orge8d2b38)
    9. [Nullability?](#org36a6a04)
    10. [tagged ints](#org46cf2f9)


    <a id="org9568e95"></a>

    # Ideal wasm output?

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

    1. Changes need?


    <a id="org01f8358"></a>
    <a id="orgd1cdfd0"></a>

    # Manual gc polyfilling


    <a id="orga8279b2"></a>
    <a id="orga5f773f"></a>

    # How does the runtime interface with the garbage collector?

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


    <a id="org13aa17a"></a>

    # 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

    \`\`\`ml
    type r = {
    foo: string;
    bar: int;
    }

    let process<sub>rec</sub> r =
    print<sub>endline</sub> r.foo

    let () =
    process<sub>rec</sub> {foo = "foo-bar-string"; bar= 6 }
    \`\`\`

    lambda IR
    \`\`\`lisp
    (seq
    (let
    (process<sub>rec</sub>/1011 =
    (function r/1012
    (apply (field 30 (global Pervasives!)) (field 0 r/1012))))
    (setfield<sub>imm</sub> 0 (global Foo!) process<sub>rec</sub>/1011))
    (let (match/1016 = (apply (field 0 (global Foo!)) [0: "foo-bar-string" 6]))
    0a)
    0a)
    \`\`\`

    \`\`\`lisp
    (data int 768 global "camlFoo" "camlFoo":)
    (data int 3068 "camlFoo\_<sub>1</sub>": string "foo-bar-string" skip 1 byte 1)
    (data int 2816 "camlFoo\_<sub>2</sub>": addr "camlFoo\_<sub>1</sub>" int 13)
    \`\`\`


    <a id="orgf19e6a8"></a>

    # Aggregate allocators provided by wasm gc


    <a id="orgac25e7b"></a>

    ## Arrays


    <a id="orgf0b3ce6"></a>

    ## Structs (records, tuples)


    <a id="org35e4a76"></a>

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


    <a id="org5220c38"></a>

    # Closures


    <a id="org7e1971b"></a>

    # Mutable records?


    <a id="orge8d2b38"></a>

    # Packed records


    <a id="org36a6a04"></a>

    # Nullability?


    <a id="org8fef019"></a>
    <a id="org46cf2f9"></a>

    ## How does runtime track alloc made in the backend?
    # tagged ints

  4. ManasJayanth created this gist Jul 6, 2019.
    30 changes: 30 additions & 0 deletions wasm-gc.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@

    # Table of Contents

    1. [Ideal wasm output?](#org9f6353a)
    2. [Manual gc polyfilling](#org01f8358)
    3. [How does the runtime interface with the garbage collector?](#orga8279b2)
    1. [How does runtime track alloc made in the backend?](#org8fef019)


    <a id="org9f6353a"></a>

    # Ideal wasm output?

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


    <a id="org01f8358"></a>

    # Manual gc polyfilling


    <a id="orga8279b2"></a>

    # How does the runtime interface with the garbage collector?


    <a id="org8fef019"></a>

    ## How does runtime track alloc made in the backend?