Skip to content

Instantly share code, notes, and snippets.

@kripken
Last active April 9, 2024 13:25
Show Gist options
  • Save kripken/5cd3e18b6de41c559d590e44252eafff to your computer and use it in GitHub Desktop.
Save kripken/5cd3e18b6de41c559d590e44252eafff to your computer and use it in GitHub Desktop.
<script>
var module = WebAssembly.instantiateStreaming(fetch("linked_list.wasm"), {});
</script>
;; To compile this wat to wasm, you can use Binaryen:
;;
;; wasm-as -all linked_list.wat -o linked_list.wasm
;;
(module
(type $Node (struct (field $next (ref null $Node))))
(global $global (mut (ref null $Node)) (ref.null $Node))
(export "global" (global $global))
(start $main)
(func $main
(local $i i32)
(loop $loop
(global.set $global
(struct.new $Node
(global.get $global)
)
)
(local.set $i
(i32.add
(local.get $i)
(i32.const 1)
)
)
(br_if $loop
(i32.le_u
(local.get $i)
(i32.const 1000)
)
)
)
)
)
@marten-voorberg
Copy link

This does not actually run in Chrome 121 and produces the following error: Uncaught (in promise) CompileError: WebAssembly.instantiateStreaming(): unknown type form: 0 @+15

@kripken
Copy link
Author

kripken commented Jan 30, 2024

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