Skip to content

Instantly share code, notes, and snippets.

View jandem's full-sized avatar

Jan de Mooij jandem

  • Mozilla
  • Netherlands
View GitHub Profile
@jandem
jandem / ion-osr-prototype.md
Created October 14, 2026 07:51
Ion OSR prototype

Ion OSR redesign prototype: separate OSR code per loop

Problem

Today an IonScript has at most one OSR entry, and it lives inside the script's normal compile. That causes two things:

  • Recompiles. When a different loop gets hot, we sit in Baseline for up to 6000 "OSR pc mismatch" checks, then invalidate and recompile the whole script.
  • Complexity and worse steady-state code. Entering the graph at an inner loop makes the CFG irreducible: a second graph root, fake loop predecessors, GVN OSR fixups, canOsr special cases, and no LICM or contiguity for the loops enclosing the OSR loop. Worse, when OSR fires first, that compile also becomes the function's entry code for every later call.

What the prototype does

  • No OSR entry in normal IonScripts. Every normal compile has a single root and none of the OSR special cases apply.
  • OSR code is its own IonScript per loop head. These are stored in a small side table on the JitScript, are only entered from Baseline at their loop head, and ar
@jandem
jandem / claude.md
Created October 8, 2026 07:47
polymorphic transpilation replacing Ion ICs

I don't think it's kooky. Given the data it may be the simplest option, because it needs no changes to Baseline. It's the E part of my earlier recommendation, pushed all the way, with recompiles taking the place of A's shared-IC call.

Why the data supports it

  • It covers almost every Ion IC execution. 95% of Ion IC executions are at sites whose Baseline chain has 2–4 stubs, never hit the fallback and has no failures. Another 3.4% are the same with 5 or more stubs.
  • Nearly every op can already be transpiled. Only 8 of 468 CacheIR ops are marked non-transpilable: GuardCompartment, the two GuardXray* guards, CallStringObjectConcatResult, WrapResult, CallPrintString, Breakpoint and PblReturn. Warp already transpiles each stub individually; what's missing is multi-stub dispatch.
  • Ion would rarely find a case Baseline didn't have. 90% of Ion IC attaches duplicate a stub already in the Baseline chain. Many sites also need fewer stubs in Ion than Baseline saw: 1,530 Ion IC sites ended
@jandem
jandem / test_madvise.cpp
Last active July 1, 2026 06:45
Stress test for MADV_FREE_REUSABLE / MADV_FREE_REUSE
#include <pthread.h>
#include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdatomic.h>
#include <errno.h>
#include <stdint.h>
#include <sched.h>
@jandem
jandem / test.cpp
Last active May 2, 2025 11:44
Test for fjcvtzs and denormals on Mac
// Instructions:
//
// Download as test.cpp, then compile and run it:
//
// $ clang++ -O3 test.cpp -o test && ./test
//
// Output on M1: zero flag: 1, result: 0 (Jan)
// Output on M4: zero flag: 0, result: 0 (Matt)
#include <cstdint>
@jandem
jandem / keybase.md
Created September 14, 2020 11:19
keybase.md

Keybase proof

I hereby claim:

  • I am jandem on github.
  • I am jandem (https://keybase.io/jandem) on keybase.
  • I have a public key ASCZT0cL6jJrELh7lYaExUWSKiZyayKj8zgWihjpAIGgYAo

To claim this, I am signing this object: