Skip to content

Commit

Permalink
Turn On WebAssembly Tail Calls
Browse files Browse the repository at this point in the history
With Safari 18.2 having shipped today, all browsers now support
WebAssembly Tail Calls. This allows the compiler to call a function at
the end of the current function by reusing the stack frame. This should
be a tiny bit faster and allow for recursion without stack overflows...
except that Rust doesn't have any way of guaranteeing this yet, so you
can't really rely on it.
  • Loading branch information
CryZe committed Dec 11, 2024
1 parent ee62d69 commit be82cd1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions buildCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let profile = "debug";
let cargoFlags = "";
// Keep .github/workflows/ci.yml in sync with these flags, so wasm-opt works.
let rustFlags =
"-C target-feature=+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext,+simd128,+extended-const,+multivalue,+reference-types";
"-C target-feature=+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext,+simd128,+extended-const,+multivalue,+reference-types,+tail-call";
let wasmBindgenFlags = "--encode-into always --target web --reference-types";
let target = "wasm32-unknown-unknown";
let targetFolder = target;
Expand All @@ -28,9 +28,6 @@ if (process.argv.some((v) => v === "--max-opt")) {
if (process.argv.some((v) => v === "--unstable")) {
// Relaxed SIMD is not supported by Firefox and Safari yet.
rustFlags += ",+relaxed-simd";

// Tail calls are not supported by Safari yet until 18.2 (early December).
rustFlags += ",+tail-call";
}

// Use the nightly toolchain, which enables some more optimizations.
Expand Down

0 comments on commit be82cd1

Please sign in to comment.