Skip to content

Instantly share code, notes, and snippets.

@kripken
kripken / diff.diff
Created February 22, 2024 20:49
Binaryen wasm-opt.js pthreads build
diff --git a/CMakeLists.txt b/CMakeLists.txt
index def330b27..01ac747b9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -336,12 +336,12 @@ if(EMSCRIPTEN)
add_link_flag("-sALLOW_MEMORY_GROWTH")
add_link_flag("-sSTACK_SIZE=5MB")
- if(EMSCRIPTEN_ENABLE_WASM_EH)
- add_compile_flag("-fwasm-exceptions")
// Auto-generated C API
// Block
BINARYEN_API BinaryenExpressionRef BinaryenBlockGetListAt(BinaryenExpressionRef expr, BinaryenIndex index);
// If
BINARYEN_API BinaryenExpressionRef BinaryenIfGetIfTrue(BinaryenExpressionRef expr);
BINARYEN_API BinaryenExpressionRef BinaryenIfGetCondition(BinaryenExpressionRef expr);
// Loop
@kripken
kripken / a.c
Last active February 1, 2024 22:20
#include <emscripten.h>
extern void launch_missiles();
extern void foo_checkin();
extern void bar_checkin();
void (*mutable_global)() = &launch_missiles;
void benign() {}
--- 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"