Skip to content

Instantly share code, notes, and snippets.

--- a.out.js 2024-01-31 09:42:57.311326787 -0800
+++ b.out.js 2024-01-31 09:43:14.131501278 -0800
@@ -1,40 +1,38 @@
var Module = typeof Module != "undefined" ? Module : {};
var moduleOverrides = Object.assign({}, Module);
var arguments_ = [];
var thisProgram = "./this.program";
diff --git a/test/lit/passes/once-reduction.wast b/test/lit/passes/once-reduction.wast
index dd15da5da..7feae8857 100644
--- a/test/lit/passes/once-reduction.wast
+++ b/test/lit/passes/once-reduction.wast
@@ -1349,311 +1349,311 @@
)
;; Corner case: Exported mutable global. We cannot optimize it, since the
;; outside may read and write it.
(module
@kripken
kripken / bench.cpp
Last active January 15, 2025 22:18
Parallel Benchmarks
// Compile with e.g.
//
// ./emcc a.cpp -pthread -sPROXY_TO_PTHREAD -O3 -s INITIAL_MEMORY=1GB
//
#include <atomic>
#include <stdio.h>
#include <stdlib.h>
#include <emscripten.h>
#include <emscripten/threading.h>
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index dec9249c3..b56348b31 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -42,70 +42,76 @@ int unhex(char c) {
}
if (c >= 'A' && c <= 'F') {
return c - 'A' + 10;
}
throw wasm::ParseException("invalid hexadecimal");
<script>
var module = WebAssembly.instantiateStreaming(fetch("linked_list.wasm"), {});
</script>
var Module = typeof Module != "undefined" ? Module : {};
(function() {
return this;
}())["Module"] = function() {
var moduleOverrides = Object.assign({}, Module);
var arguments_ = [];
var thisProgram = "./this.program";
var quit_ = (status, toThrow) => {
throw toThrow;
[package]
name = "fannkuch"
version = "0.1.0"
edition = "2021"
[profile.release]
lto = "yes"
panic = "abort"
opt-level = "s"

Trying to avoid quadratic work in 1b

(context: WebAssembly/function-references#44)

An idea I've had is to annotate validated branches. The key thing is that the set of validated branch targets is monotonic - just like the set of set locals. That is, once we see that a branch to $b validates, any subsequent branch must also validate, since we can only add more locals that are set. So as an optimization, the validator could track those until the end of the current block. That basically means to handle the set of valid branch targets in a 1a-like manner, and could be a nice speedup on stuff like this:

  (br_if $b ..) ;; Linear time here.
  (br_if $b ..) ;; But constant time here
  (br_if $b ..) ;; and here!

Example of Wasm GC non-nullable variations on the "defer" option

Imagine this source code:

func foo() {
  var ref: A = ..some non-null result..;
  bar(ref, ref);
}
@kripken
kripken / NonNullableLocals.markdown
Last active July 26, 2022 07:53
Options for Non-Nullable Locals in Wasm GC

Options for Non-Nullable Locals in Wasm GC

This document attempts to summarize the current state of discussions around non-nullable locals in Wasm GC, as of late June 2022. To do so I re-read in their entirety the main thread on this topic as well as adjacent ones, and this document is an attempt to compare the main options being discussed and their tradeoffs, with links to the relevant parts of those discussions. This is far from a perfect document, in particular because I do not completely grasp some of the more subtle points being debated. But hopefully this document is helpful as a summary of where we are at a high level. Please let me know if I missed or misunderstood anything!

Background (that might be mostly useful for people not already involved in the discussions): Why do we want non-nullabile locals in wasm at all? In theo