Skip to content
ry

Prior art from new language implementations

This page studies four recent language implementations, one new compiler, the production JITs of JavaScriptCore, LuaJIT and V8, and a set of narrower reference points (Julia, Ř, Truffle, YJIT, Deegen, HHVM, Project Leyden, Static Python, Sorbet, LXR, Riposte and pqR, plus CPython, PyPy, HotSpot and .NET in the table only) for ideas that ry’s R runtime can use, and decides which ones it takes. One constraint decides every verdict, and it comes from the runtime design: R’s C API must work unchanged. Any object a native package can reach is therefore a non-moving heap object with a reference count, reached through a raw SEXP pointer, rooted by PROTECT, possibly an ALTREP vector, and possibly written to by native code without regard for its reference count.

The order and status of the untyped-performance work these verdicts feed live in the runtime design’s roadmap; “step n” below refers to its steps.

Idea From Verdict Where it lands in ry
Precise reference counts, so the runtime “count is one” check succeeds more often Roc (Perceus) Adopt JIT-compiled code; copy-on-modify for vectors and the table type
Precise counts and borrowed parameters in the interpreter: decrement at last use and frame exit, and borrow a parameter the bytecode never assigns or passes to a modifying call Roc (Perceus, borrow inference) Adopt, planned (step 2) Tier 0, so x[i] <- v updates in place more often; reported as copies and peak memory
Borrowed arguments: a callee that only reads an argument leaves its count alone Roc, Bend Adopt, as a speculation The JIT, for callees it can see entirely
Escape analysis, inspired by Bend’s share inference Bend Adopt, scoped Temporaries in compiled code that native code never sees
Call-site specialization of known closures, inspired by lambda sets Roc Adopt, scoped lapply, vapply, Map, Reduce in compiled code
One IR feeding several backends Roc Adopt Bytecode feeds the interpreter and the Cranelift tier
A fast dev backend beside an optimizing one Roc Built, measured and removed A Sparkplug-style baseline tier ran more instructions than tier 0, because tier 0’s dispatch is only about 3% of the time (decisions/jit-ssa.md, “No baseline tier, and code images hold bytecode only”)
Static dispatch only Roc Reject S3, S4 and R6 are dynamic; ry speculates on the class instead
A top level that cannot perform effects Roc Adopt, planned for strict mode A strict library file’s top level holds only definitions and pure constants
Purity inference: effectful types use =>, effectful names end in ! Roc Reject Freedom from effects stays a runtime body fact the JIT reads, outside the type
Reference counting with no tracing collector, for immutable acyclic values Roc, Koka, Lean 4 Adopt for native typed values Typed ry’s own values; R values stay under the collector (typed-runtime.md, “Memory”)
Bounds-check elimination over difference constraints goose Adopt Subscript checks in compiled loops
Values built in their final destination goose Adopt Result preallocation in fused loops
No heap, data stacks only, no reference counts goose Reject Incompatible with SEXP identity and R_PreserveObject
Static multi-frame returns instead of an unwinder goose Reject R’s conditions and restarts are dynamic
Compile to one C file, call C through extern fn or spliced effects goose, Bend Reject ry hosts the existing C ABI; it does not emit C
Even-split parallel forks with no work stealing Bend Reject R code makes no balance promise
Automatic parallelism of effect-free work in untyped R Bend, pqR (helper threads) Adopt, scoped (step 4) lapply, vapply, Map over compiled effect-free closures that allocate nothing on the R heap, and element-wise ops on long vectors; reductions stay sequential
Automatic parallelism in typed ry, with atomic counts only for values marked as shared Bend, Lean 41 Adopt, planned List.map, List.walk, Dict and Set builders over functions the typed core proves effect-free
A stackless interpreter, so recursion never uses the C stack Bend Defer Tier 0 grows the native stack in segments; revisit with step 3’s tail-call handlers
Residency of data as a tracked fact Vx Adopt the idea, not the syntax Table columns: Arrow buffer or R vector, plus a lint
Content-hashed identifiers Vx Reject Bytecode and runtime summaries are install-time build output, so no cache needs a key
LLVM and MLIR as the JIT backend Vx Reject Compile latency; Cranelift is the choice
Macros Vx (macro_rules), Bend (templates) Reject ry has no macros, for checking speed; R’s own non-standard evaluation keeps working
Types as facts (free) or guesses (one check), with a second compiled copy that reads a guess in place Bun Adopt, keeping errors for non-conforming values Typed entry stubs (typed-runtime.md, “Facts and guesses”)
Whole-program value tracking Bun Adopt per namespace The typed core of a locked namespace or strict file; untyped code keeps profiles
Closed bindings per locked namespace: the bindings are closed though their values are not Bun Adopt (step 2) Direct calls to sibling namespace functions and imports, invalidated by unlockBinding and assignInNamespace
Freezing built-ins instead of deoptimizing Bun Adopt for ry’s standard library only R bindings get invalidation on unlockBinding, because mocking rebinds them
Ahead-of-time machine code from whole-program facts, no profiles, values tested once where they enter Bun (--aot) Adopt for strict typed code only Untyped package closures measured neutral and were removed (decisions/jit-ssa.md, “No baseline tier, and code images hold bytecode only”); typed closures are the open target
Machine code mapped read-only from the file and shared between processes Bun Adopt Typed code files in installed packages and executables
Mapped images shared across worker processes Bun Adopt, planned (step 5) callr, parallel and doParallel workers map the same package images; measured as resident memory per worker
A report of code compiled to a slow path, worst first, with fixes Bun Adopt, planned For strict typed code, beside its ahead-of-time compiler
Each program runs interpreted, compiled, and compiled with types erased; guesses forced to fail; facts checked Bun Adopt Typed differential tests and fuzzing
No compiler at run time, so every fallback is compiled at build time Bun Reject ry compiles a second copy at the first call that needs it
A standalone executable with its machine code mapped from the file Bun Adopt ry build --exe
Inline caches as the profile the optimizer reads JavaScriptCore, V8 Built, extend Tier 0 function lookups; tier 1 speculates on the cached cell
Shapes as cache keys, adapted to frames: remember slot k, check the symbol there JavaScriptCore, V8 Built Frame::find_hinted: a slot hint per tier 0 variable and function lookup site
Watchpoint sets per binding JavaScriptCore Adopt Watched binding cells list dependent bodies; replaces the epoch and stamp check at entry
Polymorphic inline caches JavaScriptCore, V8 Rejected for S3, adopted for S4 S3 finds methods through one row per method symbol, valid under its lookup stamp; S4 keeps a cache per generic
Value profiling of call targets and classes JavaScriptCore Adopt Beside tier 0’s value-kind feedback
OSR entry and exit JavaScriptCore, LuaJIT, V8 Built Loop headers; deoptimization to tier 0
Register-based interpreter with per-instruction tail-call dispatch and fast paths inside handlers JavaScriptCore (LLInt), LuaJIT 2 Adopt, planned (step 3); the assembly is rejected Tier 0 handlers ending in a become call through a handler table
Snapshots for side exits LuaJIT Built, as per-exit records Tier 1’s deoptimization exits
Allocation sinking LuaJIT Adopt, scoped Short vectors and lists a compiled loop builds and consumes
Specialization on constant arguments LuaJIT Adopt, scoped Literal arguments of base builtins (na.rm, drop)
NaN-boxing of values native code can see LuaJIT, JavaScriptCore Reject A SEXP must be a pointer; unboxing stays inside compiled code and record slots
Trace compilation LuaJIT Reject Promises and dispatch make traces fragile; Cranelift is a method JIT
Dense feedback slots, allocated lazily V8 Adopt (lazy half built) Feedback only for value-producing instructions
Fast mid tier on feedback V8 (Maglev) Adopt, scoped Tier 1, compiled off the main thread, with lower thresholds
Baseline compiler reusing the interpreter’s frame V8 (Sparkplug) Built, measured and removed Per instruction, a call to tier 0’s handler with immediate operands and native jumps. It ran 6.7% more instructions than tier 0 on testthat_full, against a ceiling of about 3.1% for all of tier 0’s dispatch
Accumulator bytecode V8 (Ignition) Reject Tier 0 keeps named registers
Sea-of-nodes optimizer, a fourth tier V8, JavaScriptCore Reject Tier 1 is the top tier
In-place instruction specialization (quickening), de-specialized on a miss CPython (PEP 659)2 Adopt the idea (step 3) Tier 0 instructions rewrite themselves to a specialized form and back; CPython is not the performance bar, JavaScriptCore is
Copy-and-patch JIT CPython (PEP 744)3 Reject The PEP calls it experimental and build-time only, with modest gains; a baseline that calls tier 0’s handlers is simpler for ry
Meta-tracing of an interpreter written in RPython PyPy4 Reject A tracing JIT (rejected under LuaJIT), and it needs the interpreter written in RPython
Per-signature method specialization driven by type inference Julia Adopt for numeric code (steps 2 and 4) Typed ry and ahead-of-time call facts select per-signature compiled copies
Environment elision, promise elision for strict effect-free arguments, contextual dispatch Ř Adopt (steps 2 and 4) Several compiled versions of a closure per call context, chosen at the call
Self-specializing AST nodes and partial evaluation Truffle, Graal Reject as an architecture The specialization idea arrives as quickening (step 3)
Counter-driven tier-up, call counting, background compilation, precompiled code replaced when hot HotSpot5, .NET6 Adopt the policy (step 4) Tier thresholds, off-thread compiles, and install-time images that hot code outgrows, as .NET’s ReadyToRun code is
Lazy basic block versioning: compile a block per combination of value kinds at its entry, only when reached YJIT7 Adopt, as the baseline’s second stage (step 4) Baseline blocks versioned on register kinds, once plain handler calls are measured
One description of each instruction generates the interpreter and the baseline JIT Deegen (LuaJIT Remake)8 Adopt the principle (steps 3 and 4); reject the generator Tier 0’s handlers are the semantics, and the baseline calls them
Profiles from a training run shipped with precompiled code, so the JIT starts warm HHVM Jump-Start9, Project Leyden10 Adopt, planned (step 5) Per-package images carry profiles from the package’s tests and examples, run at install time
Types added to a large dynamic codebase, then used for speed HHVM and Hack11, Static Python12, Sorbet13 Adopt as the strategy Typed ry: checked boundaries, per-file strict mode, compiled typed closures
Reference counting with Immix and occasional concurrent tracing for cycles LXR14 Adopt freeing from counts for lists and large vectors, checked against the roots; defer Immix lines and concurrent tracing (step 5) Native code holds objects without counting them, so a count of zero frees an object only once no root names it
Deferred, fused vector arithmetic Riposte15, pqR (task merging)16 Adopt, scoped (step 3) A lazy ALTREP vector for x * y + z on doubles, computed in one pass when read

What it is. Roc (roc-lang/roc) is a pure functional language whose compiler is being rewritten in Zig. It has no 0.1 release yet.17

What it does best for ry. Roc’s memory model is the closest match to R’s own value semantics. Lists and other builtins are reference counted, and a builtin that receives a value whose count is one updates it in place, while a shared value is shallowly cloned first.17 So List.set on a unique list costs nothing extra. The older Rust compiler does this with the Perceus “functional but in place” scheme (inc_dec.rs, borrow.rs, reset_reuse.rs), and its reuse still tests the count at runtime.18 The Zig compiler replaces Perceus with its own pass (src/lir/arc.zig), which runs after all specialization: it infers borrowed parameters, moves fields out of aggregates that die, and reuses dying allocations as the destination of a new value. In optimized builds it also infers uniqueness, so where it can prove a value is unique it removes the refcount == 1 check altogether.17 Roc’s alias analysis (Morphic) was built to decide in-place updates for list operations, but every optimization level calls its trivial solver, which answers “immutable”, because of a loop bug and little measured gain.17 So in practice uniqueness is either proven by the ARC pass or checked at runtime, which is R’s copy-on-modify contract (R decides by MAYBE_SHARED, which reads the count) with a compiler that keeps the counts tight.

When a function only reads an argument, passing it leaves its count unchanged, and the compiler works this out by itself.17 Higher-order functions compile by lambda set specialization, a form of defunctionalization: by code generation time a closure is a tagged union whose tag names the procedure and whose payload is the captured environment, so calls through it are direct (Roc also has boxed erased callables for the cases this does not cover).17 The Zig compiler monomorphizes by default, and it has an experimental --specialize=no mode, .boxy, that passes runtime type descriptors instead, which trades speed for compile time.17 Its inference is Hindley-Milner, and its only ad hoc polymorphism is static dispatch on nominal types; dynamic dispatch is unsupported by design.17

Roc has an interpreter, a dev backend that emits machine code directly for fast builds (also for wasm32), and LLVM for optimized builds, all fed from shared lower-level IRs.17 Its platforms supply the allocator: the host implements malloc and free for the Roc code it embeds, which lets a web server allocate each request into an arena and reset it afterwards.17 Roc has no stackless coroutines or continuation transform: its interpreter recurses on the native stack, tail calls compile through tail-recursion-modulo-cons and a trampoline, and asynchronous IO lives only in hosts (basic-cli blocks on a tokio runtime for each hosted call).17 Effectful functions are direct calls into the host through the C ABI.

What ry adopts.

  • Monomorphized natives with an unboxed calling convention. A closure typed #: (x: double) -> double compiles, at its first call, to a native function per argument type list. Its arguments and result travel as machine words, with no promises, no environment and no argument matching, and only the boundary to untyped code boxes them. Records, tuples and tags travel as pointers whose field types come from an allocation-site profile, and match compiles to a branch on the layout id. This is Roc’s specialization applied at runtime, where R loads code: the cache key is the closure and the argument types seen, not a whole-program instantiation (decisions/typed-stdlib.md, “Typed closures run as native functions over records, tags and match”).
  • Precise counts in compiled code. The interpreter keeps R’s count updates at every binding, which is what native code observes. The JIT tracks counts precisely inside a compiled function and drops increments and decrements that cancel. Three rules keep this correct for R. A binding in an elided environment still counts as a reference, so y <- x; x[1] <- 0 copies. Every elided count is materialized before a native call. Deoptimization rebuilds the exact counts. The effect on a loop like for (i in ...) x[i] <- v is that it copies at most once, on entry if x is shared, and the per-iteration sharing check moves out of the loop. (GNU R already updates an unshared local in place; the gain is the hoisted check and dispatch.)
  • Precise counts and borrowed parameters in tier 0, planned as step 2 of the roadmap. The interpreter can apply the same two ideas without a JIT. A parameter the bytecode never assigns and never passes to a call that may modify it is borrowed, so binding it needs no count increment. A local’s count is decremented at its last use and at frame exit rather than left to the collector, so the x[i] <- v that follows finds a count of one, and updates in place, more often. The measure is the number of copies and the peak memory of a run.
  • Call-site specialization of known closures. R code passes functions to lapply, vapply, Map and Reduce constantly. When the JIT sees vapply(xs, function(x) x * 2, double(1)) with a known closure, it compiles a loop that calls the closure directly. This is ordinary callback inlining with a deoptimization exit, inspired by lambda sets rather than a copy of them, because R semantics require the closure object to exist if anything reflects on it. It covers base R’s higher-order functions, which ry implements itself. purrr::map runs its loop in purrr’s own C code, so the JIT cannot specialize it.
  • One IR for every tier. ry’s bytecode feeds the tier 0 interpreter, and tier 1 compiles from the same bytecode through the mid-level SSA IR of crates/ssa, which the typed core shares, as Roc’s backends share their lower-level IR. A counterpart of Roc’s fast dev backend, a Sparkplug-style baseline tier, was measured and removed (see V8 below).

What ry rejects.

  • Static-only dispatch, because R’s S3 dispatch on class(x), S4 generics and R6 methods are dynamic by definition, and existing code depends on that. ry gets most of the benefit by speculating on the class seen at a call site, guarded by the class attribute.
  • Whole-program monomorphization, because R loads code at runtime. ry specializes per closure and argument type list at its first call instead.
  • Runtime type descriptors in place of specialization (.boxy), because ry’s tier 0 interpreter already plays that role and the native tier exists to remove it.
  • Purity inference. Roc infers which functions are effectful, lets only those call each other, and so guarantees that a top-level constant performs no effect and can be evaluated at compile time. It has no effect polymorphism, so a higher-order function exists twice, as Try.map_ok and Try.map_ok!.17 R cannot split lapply or Map that way, effect polymorphism would put an extra variable in the types R code calls most, and an inferred effect in a function’s type would let a body edit change every caller’s interface. ry takes the guarantee without the inference: strict mode is planned to limit a library file’s top level to definitions and constants that call only functions declared pure.
  • A host-provided allocator as a design principle. R already has the parts it needs: R_alloc is an arena by R’s own contract (freed when the foreign call returns), and allocVector3 with an R_allocator_t is R’s hook for custom vector allocation. ry implements both as specified.

What it is. Bend (HigherOrderCO/Bend) is Higher Order Company’s pure functional language with an affine dependent type system. Its current runtime is no longer the interaction-combinator evaluator of HVM: the runtime paper says it “keeps the goals and drops the mechanism”, replacing graph reduction with ownership.19 The compiler emits one C file that runs on one thread, on CPU threads, or on the GPU through Metal or CUDA, over one heap, with no garbage collector.19 Bend also checks proofs of user-declared laws (LAWS.bend), which is outside ry’s scope.20

What it does best for ry. Bend’s runtime is an argument that knowing ownership statically removes most runtime costs. Because the type system is affine, a value has one owner, and the match that consumes it frees it, so deallocation is compiled code.19 Two whole-program analyses decide the remaining memory traffic.

  • Share inference finds the constructor types that need reference counts at all. A type is “hot” when some binder of it is used more than once, when a hot type’s live field reaches it, or when it is boxed in an array; every other type is built and consumed with plain stores and loads.19
  • Borrow inference finds the arguments a callee only reads. Each argument starts borrowed and flips to owned on any escape, to a fixpoint, and a borrowed argument is lent raw, so “a fold over a reused tree costs no count traffic”.19

A term is one 64-bit word, and small values (a machine word, a constructor with one word-sized field) are packed into the word and never touch the heap.19 Parallelism is explicit: a parallel let that binds several calls means, in the paper’s words, “run these calls in parallel; they split the work into roughly equal parts”, and the scheduler trusts that promise, with no shared queue, no locks and no work stealing.19 On the authors’ benchmarks, the sequential build runs within 0.8 to 1.5 times the time of hand-written C, sixteen threads give 9 to 12 times one thread, and an integrated GPU up to 67 times.19 Foreign functionality enters through effects: an effect is a definition of type IO(R) whose body imports a .c (and a .js) file that registers a C implementation, which the compiler splices into the generated program.20

Bend’s runtime is also stackless: user code never grows the C stack. A call compiles to a tail call, a cut or a fork of a segment (with preserve_none and musttail in the generated C), a pending continuation is a heap node, and IO is written in continuation-passing style.19 Its predecessor HVM2 packs a term into 32-bit ports with 24-bit numbers, and balances work through per-thread redex bags that neighbouring threads steal from.20

What ry adopts.

  • Borrowed arguments, as a speculation. Bend can borrow soundly because it is affine and its analysis sees every escape. R’s escape facts are not sound in general: a callee can capture an argument through <<- or assign, by storing it in a list or attribute, through a closure over its frame, through parent.frame(), sys.frames(), eval or delayedAssign, through the promise itself (substitute, match.call), or in native code (R_PreserveObject, an external pointer’s protected slot). If a borrowed value were captured, a later in-place update by the caller would mutate the captured copy. So ry borrows only when the whole callee is compiled and visible, treats any call to unknown R code or to .Call or .External as an escape, and undoes the borrow on deoptimization by restoring the counts. The runtime design’s body facts (section 8 there) are where the “only reads” fact will live; the checker does not compute it today.
  • Escape analysis for temporaries, inspired by share inference. Share inference classifies types, which does not transfer to R. What does transfer is its premise that a value nobody else can see needs no count. A vector that a compiled loop creates and consumes, and that never reaches an environment, an attribute or a native call, needs no count, and often no heap object at all. The JIT’s scalar replacement and fusion are meant to handle that case.
  • Automatic parallelism of effect-free work in untyped R, scoped (step 4 of the roadmap). Bend’s README states the promise as “Split the work in two, and Bend spreads the calls over every core it can find, then joins them back”, provided the calls are balanced.20 R’s closest shapes are lapply, vapply and Map over a closure, and element-wise arithmetic on a long vector, where every element is independent. ry can split them over a thread pool when four conditions hold, and the conditions are what keep every result identical to GNU R’s. The closure is compiled and allocates nothing on the R heap, because the R heap and the interpreter stay single-threaded. Its body is free of effects, so it neither warns nor draws random numbers, and the .Random.seed stream advances exactly as in a sequential run. Each element’s result goes to its own slot of a preallocated result. And reductions (sum, Reduce, cumsum) stay sequential, because a parallel sum reassociates floating-point additions and would not be bit-identical to GNU R; element-wise arithmetic is bit-identical under any split, because each element’s operations are unchanged. A length threshold keeps short inputs on one thread. pqR’s helper threads (see “Riposte and pqR” below) are the R precedent.
  • Automatic parallelism in typed ry (planned). Typed ry’s own values are immutable and acyclic (typed-runtime.md, “Memory”), so List.map, List.walk and the Dict and Set builders over an effect-free function can be split across cores with no race on the values themselves. Two costs decide the design, and both have an answer.
    • Counts on shared values. Typed counts are plain integers, because R evaluation is single-threaded. Lean 4 tags every value single-threaded, multi-threaded or persistent, and only a multi-threaded value pays for atomic count updates; values start single-threaded, and before a task starts, markMT tags everything reachable from the task’s closure and argument as multi-threaded, while only one thread can still see it. The invariant that a multi-threaded value reaches only multi-threaded or persistent values means markMT visits each value at most once over a run. The paper reports that always-atomic counts cost noticeably even with one thread running, and that the tags significantly improve performance.1 ry adopts that scheme: one tag bit in the count word, a branch on it in dup and drop, and a marking pass over the input and the captures when a library function decides to split. Each worker allocates from its own pools, so allocation stays a pop from a free stack.
    • The effect-free fact. It does not exist yet. Purity in ry today is declared (@pure) and trusted without checking the body, and item_effect_free in crates/semantics/src/top_level.rs judges only what a top-level statement does at package load; the typed core (crates/typed) computes no effect facts. A trusted declaration is not enough for threads, because a wrong @pure on a function that reaches the R heap would become a data race. The typed core can compute the fact itself for strict and locked code, where it sees every callee: a body is effect-free when it calls only standard-library functions without effects and functions with the same fact, and any call across the R boundary, any I/O and any random draw makes it effectful. A failing element (an out-of-range index, say) does not stop the others; the split reports the failure with the lowest index, which is the one a sequential run reports, and with no effects the two runs cannot otherwise be told apart.

What ry defers.

  • A stackless runtime. BendRT compiles calls to tail calls and heap continuations, so user code never grows the C stack.19 ry’s tier 0 recurses on the native stack, but a closure call grows it in segments (stacker::maybe_grow in crates/interp/src/eval.rs), so an R recursion is stopped by the interpreter’s call-depth limit, not by the C stack. With options(expressions = 500000), a 20,000-deep recursion stops GNU R 4.3 with “C stack usage … is too close to the limit” and stops ry with “evaluation nested too deeply”. A stackless tier 0, where an R-to-R call pushes a frame and continues in the same dispatch loop, would also save the Rust frame setup of each call, so it is reconsidered with step 3’s tail-call handlers. It is deferred because lapply and native code that calls back into R re-enter the interpreter on the native stack anyway.

What ry rejects.

  • Ownership as the memory model. R values are freely aliased, and the C API exposes aliasing directly (R_PreserveObject, external pointer protection slots, environments). Affine typing cannot be retrofitted onto existing R code, so ry keeps a tracing collector plus reference counts and uses ownership only as an optimization inside compiled code.
  • Even-split forks without work stealing. The balance contract suits a language designed around it, but R’s parallel code (foreach, parallel, future) makes no such promise, and table operations need a work-stealing pool, which Polars already brings.
  • Effects spliced into generated C, because ry hosts existing compiled packages through the C ABI rather than emitting C.

What it is. This page studies aardappel/goose, a memory-safe systems language by Wouter van Oortmerssen.21 The name is ambiguous. The most prominent “goose” on GitHub is Block’s AI agent, which is not a language, and goose-lang/goose is a subset of Go with a semantics in Coq, built for verification rather than as an implementation to learn runtime techniques from.22 aardappel/goose is the one that matches the comparison.

What it does best for ry. goose has no heap at all. Every dynamic value lives inline on data stacks the compiler assigns statically, growth advances a pointer, and memory is freed when its scope ends. There is no allocator, garbage collector, reference counting or destructor, and the type rules make the model memory safe without lifetime annotations.21 Values are built in their final destination through any depth of calls, so items.push(parse(line)) writes the parsed record directly into the array.21

Its bounds-check elimination pass removes every check it can prove cannot fire. It uses a flow-sensitive domain of difference constraints, facts of the form l <= r + c over integer variables and array lengths, and answers a query as a shortest path over those facts. Every base, whether a variable or an array length, carries a generation, so a fact dies when the variable or array it describes changes.21 The pass is “required only to be sound”: a program’s meaning never depends on it.21 The README reports that over sixteen benchmarks goose runs 1.16 times as fast as hand-optimized C++ and 1.12 times as fast as the best safe Rust, while using less memory.21 It compiles to one C file and calls C through extern fn, with a bundled TinyCC backend that compiles and runs a program in-process.21

What ry adopts.

  • Bounds-check elimination over difference constraints. R’s subscripts are checked (an out-of-range read with [ returns NA, and an out-of-range write extends the vector), so a compiled for (i in seq_along(x)) y[i] <- x[i] * 2 carries checks on every iteration unless they are proven redundant. goose’s domain fits: for evaluates seq_along(x) once, so i ranges over 1..length(x), and after preallocation length(y) >= length(x), which removes both checks. The facts need goose’s generations, because rebinding x or y in the body kills them. Only positive in-range subscripts are bounds facts. Zero, negative and NA subscripts, [[ (which errors out of range), and a classed vector with its own [<- method all stay behind guards. Like goose’s, the pass need only be sound.
  • Construction in place. When the JIT fuses z <- x * y + 1, it allocates z once, at its final size, and the fused loop writes into it. When a function’s result is assigned straight into a list element or a column, the JIT can pass the destination down.

What ry rejects.

  • The heapless memory model, because R needs stable object identity and native code needs pointers that outlive scopes (R_PreserveObject).
  • Static multi-frame returns, because R’s condition system is dynamic.
  • Shared-nothing threads as the language model, because R code already shares through environments, and ry keeps R-level evaluation single-threaded.
  • In-process C compilation as the build path. It is attractive for compiling package code quickly during development, but it does not replace building packages with the platform’s real compiler, which the C++-heavy part of the benchmark dependency set requires.

What it is. Vx (vx-lang/Vx) is a research systems language, written in Rust and compiling through MLIR and LLVM, that puts hardware topology and memory placement into the type system. Its README describes it as an early research compiler at version 0.0.3.23

What it does best for ry. A Vx tensor’s type carries its element type, its dimensions and its residency, for example Tensor<f32, [4, 4], Memory::GPU_HBM>, and the compiler rejects host code that reads device memory, transfers with no declared hardware path, and working sets that exceed a device’s declared capacity.23 Machines are described declaratively (memory capacities, bandwidths, links), so a program can be checked against a target it is not running on.23 Its frontend identifies every symbol and instantiation by a 256-bit content hash and type-checks modules in parallel without locks, with output that is byte-identical across thread counts.23 An identifier packs a module hash, a symbol hash, a generic hash and flags; an instantiation gets an arena index, and content digests are used only inside evaluation, never merged into the identity.23 Its “JIT” compiles the module with llc to an object file, links it with clang and runs the executable; lli appears only in its roadmap.23

What ry adopts.

  • Residency as a tracked fact. ry’s table columns live either in an Arrow buffer owned by Polars or in an R vector. Integer and double columns without nulls can be read in place, while logical, character and dictionary columns, and any column native code wants to write, must become R vectors first (section 7 of the runtime design). Vx makes every transfer explicit in source and checks it at compile time; ry keeps the transfer implicit, because R users should not have to write it, and borrows the checking side instead: a lint when typed code forces a column to materialize inside a loop.

What ry rejects.

  • Content hashes as identities, in memory or on disk. Salsa’s interned ids already give every item and type a stable identity within a session, and bytecode and runtime summaries leave a session only as install-time build output stamped with the ry build (r-runtime.md, “Where bytecode comes from”), so no on-disk cache needs a key derived from content.
  • MLIR and LLVM as the JIT backend, for the compile-latency reasons in the runtime design.
  • Placement types as a language feature, because no benchmark code base targets accelerators.

What it is. bun compile (shorthand for bun build --compile --aot) compiles TypeScript and JavaScript to machine code at build time and writes one executable with no JIT, no bytecode and no profiling data in it. Bun documents it as experimental.24 It type-checks the whole program, tracks values through it, optimizes each function and generates code with the backend of JavaScriptCore’s fastest JIT.24

What it does best for ry. It solves the problem ry’s typed runtime has: typed code that must run fast without trusting values that arrive from untyped code.

  • Facts and guesses. A type describing a value the program creates is a fact: objects get fixed layouts and a property read is one load with no check. A type describing a value from outside (JSON.parse, any, as, a .d.ts-only package) is a guess and costs one layout check where the value arrives. A failed check sends the call to a second copy of the function that treats only that parameter as plain JavaScript. A mismatch never throws or converts, so types change speed and never behavior.24
  • Whole-program value tracking. For each variable, parameter and property it works out which objects can reach it, and for each call which functions it can reach. Untyped JavaScript gets fixed layouts the same way, and code the compiler cannot resolve looks properties up at run time.24
  • Freezing instead of deoptimizing. An executable cannot discard compiled code, so replacing or deleting a member of a built-in object such as Array.prototype throws a TypeError, which makes the compiler’s assumption true. Adding members, or patching console, process or fetch, works.24
  • Shared code. The machine code and its tables are read-only and mapped straight from the file, so processes and workers share them.24
  • Explaining slow paths. --explain lists code that compiled to a slow path, worst first, with a fix for each, and --explain=json prints one object per line.24
  • The test matrix. Each test runs under bun run, compiled, and compiled with every annotation erased, and all three must match in output and exit status. Programs are also compiled with every guess forced to fail, and a mode checks every fact the executable relies on at run time.24
  • No profiles and no deoptimization. Hotness is estimated from loops and the call graph, a failed check takes a slow path instead of discarding code, and eval, new Function and node:vm run in JavaScriptCore’s interpreter on the same objects.25

What it measured. The pull request that added it reports these numbers:25

Program Under Bun’s JIT Compiled ahead of time
TypeScript 6 compiler on a 370,839-line project 14.00 s, 29.2 s CPU, 2,581 MB peak 4.25 s, 5.3 s CPU, 963 MB peak
A CLI, time to its first prompt 318 ms, 5,530M instructions 141 ms, 1,117M instructions
Web servers, requests in the first second 1x 1.03x to 1.93x
The same servers once warm 1x Hono, Bun.serve and node:http within 3%; Express, Elysia, Fastify and Koa 7% to 23% slower
1,814 untyped idioms, instructions per iteration 1x median 0.94x in a small program and 1.44x in a large one, where 1,229 idioms are slower

So ahead-of-time code wins start-up, short runs and memory by a wide margin, and loses to the JIT on long-running untyped code, where run-time feedback knows more than whole-program analysis can prove.

What ry adopts. All six, fitted to R (typed-runtime.md holds the design), and two more that apply Bun’s closed-world reasoning to untyped packages:

  • Facts and guesses, but with ry’s contract: an annotation means the value has the type, so a value that does not conform is refused with a type-mismatch error. A conforming R value takes the second copy, which reads it in place, because typed ry’s own values are native values outside the R heap and an R value never has their layout.
  • Value tracking per namespace. The typed core of a locked namespace or a strict file has no eval and its bindings are locked, so it is closed apart from the functions that escape to R (exports, registered S3 methods and closures it hands out). The values of untyped R code are never closed, because eval, get and assign reach any binding, so it keeps allocation profiles.
  • Closed bindings per locked namespace, step 2 of the roadmap. A locked namespace’s set of bindings is closed even though their values are not: no binding can be added or rebound without unlockBinding or assignInNamespace. So a call from a package function to a sibling function of its namespace, or to an import, resolves to its target directly, and those two primitives invalidate the code that assumed the binding.
  • Freezing for ry’s standard library. No existing R code rebinds List.map, so its namespaces cannot be unlocked, and a call the checker resolves to it is direct. R’s own locked bindings are not frozen, because testthat’s local_mocked_bindings and assignInNamespace rebind them on purpose. Instead, the binding-unlock primitive discards the compiled code whose direct calls assumed the binding.
  • Mapped, shared code for the typed code that ry install writes into each installed package, which matters for CI machines that run several test processes and are bound by memory, and for ry build --exe, which writes a standalone executable as bun compile does. Worker processes started by callr, parallel and doParallel load the same packages, so mapping each package’s image read-only lets them share it (planned as step 5, measured as resident memory per worker).
  • Ahead-of-time machine code for strict typed code. Inside typed code a type is a fact, so the code needs no guesses and tests an R value once at the typed boundary. For untyped package closures the idea was built and measured: scalar numeric functions compiled at install covered 5 to 11% of closures and left the testthat workload unchanged, and baseline code for every body could save at most about 3% of its instructions, so code images hold bytecode only (decisions/jit-ssa.md, “No baseline tier, and code images hold bytecode only”).
  • The test matrix for typed differential tests and the typed fuzzer.

What ry rejects.

  • Compiling every fallback at build time, because ry has a compiler at run time and compiles a second copy at the first call that needs it.
  • Types that never change behavior, because ry’s annotations are checked at the boundary and report mismatches.

Beside ry’s start image, install-time code and typed core

Section titled “Beside ry’s start image, install-time code and typed core”

The pipeline. The type checker behind bun check checks each file, a lowering turns its syntax tree and types into an SSA IR, and JavaScriptCore runs a flow analysis over the whole program, optimizes the IR and generates machine code through B3. Bun’s own node: and bun: modules compile from their TypeScript sources with the program, which is why the executable needs no JIT.25 Each property access compiles to one of three forms, and the build prints the split (for example “1,204 free, 61 tested, 38 by name”): free is one load or store, tested is a shape test before the load, and by name is a run-time lookup through a cache.25 A later pull request rewrote Bun’s side of the compiler, which is experimental and also runs tests with bun test --aot.26 In Bun’s own numbers, the wins are start-up and short runs (the TypeScript 6 compiler from 14.00 s to 4.25 s, a CLI’s first prompt from 318 ms to 141 ms) and the losses are long-running untyped code: idioms in a large program at 1.44 times a warm JIT’s instructions, and Koa 22.9% slower once warm.

What ry has today. Three pieces each cover part of what Bun’s compiler does:

Piece What it holds When a type check fails
Start image (crates/heap/src/image.rs, architecture) Base R’s heap after start-up, mapped in place, with the closures bound in base R’s namespaces stored as bytecode the writer compiles (a lazy-load binding start-up never forced, or a body the compiler rejects or finds too small to compile, keeps its source). No machine code: a session compiles hot base closures to native code at run time Not applicable
Install-time code (R/<package>.<build>.ryc, CLI reference) Machine code for a package’s numeric functions, for the argument types annotations or constant defaults declare, otherwise for double, integer and logical scalars and vectors The call runs in the interpreter
Typed core (crates/typed) Strict typed closures on native values, lowered and compiled at their first call The call reruns in the interpreter

The start image skips running start-up code and compiling base R to bytecode, but not compiling it to machine code, and untyped code outside an installed package’s numeric functions reaches the JIT at run time. The typed core has Bun’s split between facts and predictions: inside typed code a type is a fact, and an R value is checked and converted once where it enters. ry’s boundary is stricter, because an R list never becomes a record without as.record() (decisions/typed-stdlib.md). Both compiled paths fall back to the interpreter where Bun runs a compiled slow second version of the function.

Ideas for ry, not decisions (the adopted ones are listed above):

  • Extend the install-time compiler to typed ry, first by compiling strict typed closures and the typed standard library at install or build time instead of at their first call, then by building a whole typed script ahead of time. Strict typed code has no eval and a closed set of values, which is what Bun’s flow analysis needs, and untyped R stays on the JIT.
  • A slow second version instead of the interpreter. A compiled copy that takes the failing argument as a plain R value would keep the call native without discarding code.
  • A free, tested and by-name split in a slow-path report for typed code, with a program-wide count.

Production JITs: JavaScriptCore, LuaJIT and V8

Section titled “Production JITs: JavaScriptCore, LuaJIT and V8”

The four languages above know their types or ownership statically. ry’s untyped tiers face a different problem, the one production JavaScript and Lua engines solve: running dynamically typed code fast while anything may be redefined at any time. The performance bar in the mandate is Bun, which is JavaScriptCore, and ry’s tier 0 decides the speed of most real R code. Its per-call cost is where it trails GNU R’s bytecode interpreter: ggplot2, lattice and PerformanceAnalytics render 1.2 to 1.9 times slower than on GNU R, which the knowledge base attributes to interpreter call cost. On the call-heavy application workloads (tools/bench/applications, current numbers in benchmarks.mdx), a ry run --profile-summary measurement split the untyped time into tier-0 instructions (23 to 44%), closure call setup (12 to 24%), builtins (about 25%) and S3 method lookup (up to 17%), with tier 1 under 3% on all but one workload, because most hot closures run too few times to reach it. This part studies the three engines for ideas that cut that cost.

R adds two constraints to the SEXP one at the top of this page. Environments are first-class and mutable from anywhere (assign, eval, sys.function, parent.frame, and native code through Rf_defineVar), so no frame layout is ever final. Arguments are lazy promises, so whether and when an argument’s expression runs depends on the callee.

What it is. JavaScriptCore runs code in four tiers. The LLInt is an interpreter written in offlineasm, a portable assembly language that compiles to each target’s assembler. The Baseline JIT emits a fixed template per bytecode. The DFG is a speculative optimizing compiler, and the FTL is a slower, stronger backend for the hottest code, built on the B3 compiler since B3 replaced LLVM there.272829 Code moves up the tiers by counters, enters optimized code at loop headers (OSR entry), and leaves it at a failed speculation (OSR exit) for the Baseline tier.27

What it does best for ry. Speculation is fed by three mechanisms. A structure (a hidden class) names the layout of an object’s properties, so a property read caches “structure S, offset k” and becomes a compare and a load. An inline cache that sees several structures becomes a polymorphic cache with one case each, and past a limit it goes megamorphic. Every value-producing bytecode keeps a value profile, and the inline caches double as profiles, so the DFG reads the structures a site saw from its cache. Watchpoints cover facts that rarely change, such as “this global holds this function”: compiled code depends on a watchpoint set instead of checking, and when the fact changes the set fires and throws away the dependent code.27 Bun adds fast startup (a transpiler cache, and bytecode caching with bun build --bytecode) and implements its hot builtins in Zig and C++.30

What ry adopts.

  • Inline caches as the profile. ry already does this for functions: tier 0’s lookup cache holds the binding cell it found, keyed on the enclosure and the symbol’s lookup stamp (cached_cell in crates/interp/src/bytecode.rs), and tier 1 speculates on that cell.
  • Shapes, adapted to frames. An environment is R’s dictionary object, as an object is JavaScript’s, but ry’s lookup cache skips function frames entirely, because their bindings come and go without moving any stamp. A structure id cannot work for a frame either, because assign from anywhere would have to update it. ry’s frame layout allows a cheaper key: bindings stay in insertion order, and removal leaves a slot holding no real symbol instead of shifting, so a binding keeps its slot until the frame compacts. Each tier 0 GetVar, SetVar and function lookup site keeps a u32 slot hint (the HINTS vector of the code object), and Frame::find_hinted in crates/heap/src/env.rs tests the frame’s bit filter first, then compares the symbol in the hinted slot, and only on a mismatch searches the frame (the inline pairs, or a hash index past 32 bindings) and stores the slot it found as the new hint. Calls of one closure bind their formals and locals in the same order, so a hint from an earlier call answers in later frames with one compare. The hint needs no invalidation, because the check reads the frame itself, and a frame that binds a symbol twice (duplicate formals) ignores hints, so a stale hint never matches the wrong binding. Built. Before slot hints, the frame search (Heap::frame_cell) took 2.9% of the samples by self time on the validation application workload with the JIT off.
  • Watchpoint sets per binding. Today a compiled body checks its function speculations on every entry: one global binding epoch, and when that moved, the lookup stamp of each speculated symbol (valid in crates/jit/src/runtime.rs). The epoch moves on every top-level binding, which a package load or a test suite does constantly, so the per-symbol path runs often. A watched binding cell can instead list the compiled bodies that depend on it (the cell’s third field holds nothing for an ordinary binding), and assigning or removing it invalidates them, so entry checks one flag. One R-specific check stays: a function frame can gain a binding that shadows the speculated one (assign into parent.frame()), and that path, which the rooted check covers today, is not a watched cell. Section 5 of the runtime design plans watch sets; this is their concrete shape. Adopt. How often valid() reaches the per-symbol loop on a real test suite is not yet measured.
  • Polymorphic inline caches for S3 dispatch. Built and then replaced. Per-site entries keyed on the class vector hit for only 15 to 40% of resolutions on the measured workloads, because most dispatch sites run a few times and $ dispatch has no site. What a site cached is a fact about a method name, not about the site, so S3 dispatch keeps it once per name: the method symbol carries the index of a row that holds the binding found from the top environment on, valid under the symbol’s lookup stamp (MethodRows in crates/interp/src/dispatch.rs; decisions/interp.md, “S3 methods are found through one row per method symbol”). The JIT can guard an inlined method on that stamp, as it does for global function lookups. Rejected in the per-site form.
  • Value profiling, extended. Tier 0 records a bit set of eleven value kinds per instruction (feedback in bytecode.rs). JavaScriptCore also profiles call targets and structures; ry’s equivalents are the closure a call site called and the class a dispatch site saw, which the inlining and S3 items above need. Adopt.
  • OSR entry and exit are built: tier 1 enters at loop headers and deoptimizes to tier 0.
  • Bun’s two non-JIT reasons, builtins in a systems language and cached bytecode, are already section 5 of the runtime design.

What ry adopts from the interpreters. The LLInt is in offlineasm so that it controls register assignment and dispatch, and shares its frame layout with the JIT tiers; LuaJIT 2’s interpreter does the same in DynASM. ry takes the technique and rejects the assembly. Tier 0 is one dispatch loop (interpret in crates/interp/src/bytecode.rs): each instruction word carries its opcode and its operand count, and every instruction jumps back through one match, so all instructions share one indirect branch, whose target the predictor must guess from one history. Its register window is already shared with tier 1. The Rust path to LLInt-like dispatch is one handler function per instruction, each ending in a tail call through a handler table (become, Rust’s explicit tail calls, nightly only).31 That keeps the machine state in argument registers across instructions as hand-written assembly does, and splits the shared branch into one per handler, which the predictor can learn. Each handler also gets the fast path for the common operand kinds inline, as LLInt handlers do. ry builds on nightly Rust (rust-toolchain.toml), so become is available. Adopt, planned as step 3 of the roadmap, together with quickening (CPython, in the table). An earlier profile of a scalar loop with the JIT off (s <- s + i * 2 and a comparison, 2e7 iterations) put the shared dispatch jump at about 28% of samples and the allocation of result scalars at about 8%. It predates the single dispatch loop, so the dispatch share needs remeasuring.

What ry rejects.

  • An interpreter in assembly, because a Rust handler with a guaranteed tail call gets the same dispatch shape and stays portable and checkable.
  • Four tiers. Each tier adds a compiler to maintain and a set of transitions to test. ry has two and plans a third, the baseline described under V8 below.

What it is. LuaJIT is Mike Pall’s Lua implementation. Its interpreter is hand-written assembly, generated with DynASM (vm_x64.dasc), which pins the bytecode base, the program counter and the dispatch table to fixed machine registers and ends every handler by decoding and jumping to the next one. A value is one 64-bit word: a double is itself, and every other type is encoded in the unused NaN space, with pointers in the low bits (lj_obj.h). A table has an array part for dense integer keys and a hash part for the rest (lj_tab.c).32

What it does best for ry. The JIT is a trace compiler: it records the path a hot loop actually takes, through calls, as a linear SSA trace, specializing on the constants it sees, including the identity of each called function. Every guard carries a snapshot, a compact map from interpreter slots to the trace’s values at that point, which is all a side exit needs to rebuild the interpreter’s state (lj_snap.c). A hot side exit gets a side trace of its own. Allocation sinking moves an allocation the trace does not let escape onto the side exits that need it, so the hot path never allocates (lj_opt_sink.c).32

What ry adopts.

  • Snapshots are built in spirit: each tier 1 guard has an exit record listing the registers and slots tier 0 will read and their machine representations, and a cold block that stores them before one shared exit (emit_deopts in crates/jit/src/codegen.rs). Recompiling with updated feedback, up to four times per body, plays the role of side traces in a method JIT.
  • Allocation sinking, extended from scalars to small vectors and lists. Compiled code already boxes an unboxed scalar only on exit. The same rule for a short vector or a list a loop builds and consumes is the escape analysis already adopted from Bend above, and LuaJIT’s pass is the concrete design for it. Adopt, scoped.
  • Specialization on constants. A call such as sum(x, na.rm = TRUE) or x[i, , drop = FALSE] passes a literal that selects the builtin’s path. Tier 1 can pick that path at compile time, as LuaJIT specializes a trace on a constant key. Adopt, scoped to literal arguments of base builtins.
  • Array and hash parts. ry’s frames have the same split by size: inline pairs, with a hash index past 32 bindings. Built.

What ry rejects.

  • NaN-boxing for any value native code can see. A SEXP is a pointer to a header, and native code dereferences it, so a register, a binding, a list element or an argument that can reach the C API must hold a real pointer. Inside ry the idea is already used where native code cannot look: compiled code keeps scalars unboxed in machine registers, and a ry record stores an integer or a logical slot under a quiet-NaN prefix (Slot in crates/heap/src/object.rs). Tagging tier 0’s registers too would remove the allocation of scalar results, but every builtin call would box its operands. The knowledge base’s plan, reusing a register’s scalar in place when it is unshared, removes most of those allocations with one representation, so it comes first.
  • A trace JIT. Cranelift is a method compiler, and ry already has OSR and deoptimization around it. R’s control flow also suits traces badly: a hot loop calls closures whose arguments are promises, so a trace through a call has to record which promises the callee forces and in what order, and S3 dispatch, tryCatch and on.exit multiply the paths. Riposte, the one tracing JIT for R, was a research prototype for vector code that ran no packages (section 3 of the runtime design).
  • An assembly interpreter. ry adopts its dispatch technique in Rust, as described under JavaScriptCore.

What it is. Ignition, V8’s interpreter, runs a register-machine bytecode with an implicit accumulator: most instructions read or write the accumulator, which shortens their operands.33 Sparkplug, the baseline compiler, walks the bytecode once and emits, for each instruction, a fixed sequence that mostly calls a builtin, with no IR and no register allocation. It keeps Ignition’s frame layout, so switching between the two at any instruction needs no frame translation, and the post reports a gain of 5 to 15 percent on real-world benchmarks.34 Maglev is a mid-tier SSA compiler that specializes on feedback; the post puts its compile speed at about ten times slower than Sparkplug and ten times faster than TurboFan.35 TurboFan is the top tier, whose sea-of-nodes IR V8 has since replaced with a control-flow graph (Turboshaft).36 Objects have hidden classes (maps), as JavaScriptCore’s have structures.37 Each function’s feedback lives in a feedback vector, a side array with one slot per inline-cache site, assigned when the bytecode is generated and allocated only once the function has run a few times.38

What ry adopts.

  • Dense, lazily allocated feedback. ry’s lazy half is built: tier 0 records feedback only once a body is warm (warm in bytecode.rs). Its storage is one integer per code word, operands included, so most of the array is never written. Assigning feedback slots at compile time, only to the instructions that produce values, gives a dense side array with no unused entries, which is the data-oriented layout the mandate asks for. Adopt. The share of code words that carry feedback over a package’s bytecode is not yet measured.
  • A fast mid tier. Tier 1 already has Maglev’s shape: it builds a typed plan straight from the bytecode and its feedback, with no R-level IR. Its thresholds (3000 entries, 10,000 back edges) are high because Cranelift compiles slowly for code that runs only a few thousand times. Maglev’s lesson is that compile speed decides how early a tier can pay off. ry can build the plan on the main thread, which reads the heap, and run Cranelift on another thread, which does not, and then lower the thresholds. Adopt, scoped. On the validation workload, tier 1 compiles 73 bodies in about 15 ms of the run’s 3 s, about 0.2 ms per body including planning, so compile time is not what keeps code in tier 0 there: the thresholds are. The split between planning and Cranelift is not yet measured.
  • A Sparkplug-style baseline tier. ry built one: per instruction, a call to that instruction’s tier 0 handler with its operands as immediates and its branches as native jumps, sharing tier 0’s register window. It removes only decoding and dispatch, which are about 3.1% of testthat_full, and it ran 6.7% more instructions than tier 0 there, so it was removed (decisions/jit-ssa.md, “No baseline tier, and code images hold bytecode only”). The time is in the op bodies (allocations, guards and frame searches), which the other roadmap steps attack. Rejected after measurement.

What ry rejects.

  • The accumulator. It shortens bytecode for an interpreter that cannot allocate registers. ry’s tier 0 names every register, tier 1 maps each one to a Cranelift variable, and rewriting the bytecode would gain encoding size, not speed.
  • A sea-of-nodes top tier. V8 left it for a control-flow graph, citing compile time and maintenance cost.36

These engines answer narrower questions than the three above: how a compiler for a dynamic language uses inferred types, what an optimizing R compiler removes, what form a baseline tier takes, how a JIT can start warm, how other dynamic languages added types, how a counted heap can reclaim memory, and how R’s vector code can avoid temporaries. CPython, PyPy, HotSpot and .NET have one row each in the table and no section here.

What it is. Julia compiles a method separately for each concrete signature of argument types it is called with. At the first call with a new signature, type inference runs over the method body with those argument types, and the inferred types let the compiler unbox numbers, devirtualize calls and inline, so numeric code compiles much as a statically typed language’s would.39

What ry adopts. Per-signature specialization for numeric code, in steps 2 and 4 of the roadmap. Typed ry already supplies argument types, and the ahead-of-time call facts give untyped calls the types the checker can prove, so a closure gets a compiled copy per argument type signature, chosen at the call. ry does not adopt Julia’s model of inferring every call: an untyped call whose types are unknown keeps tier 0 and feedback.

What it is. Ř is a research VM for R from Jan Vitek’s group, built on a patched GNU R (section 3 of the runtime design). Its optimizing tier compiles to PIR, an SSA IR that models R’s environments and promises explicitly, so the compiler can remove an environment nothing reflects on and a promise whose argument it can evaluate eagerly.40 Contextual dispatch keeps several compiled versions of a closure, each for a call context: which arguments are already evaluated, which are missing, and their types. The call site picks the most specific version that fits its context.41

What ry adopts. All three ideas, in steps 2 and 4 of the roadmap: environment elision, promise elision for arguments that are strict and free of effects, and contextual dispatch, with the call context computed at the call site. Ř’s papers are also the evidence behind the runtime design’s finding that R’s cost is mostly semantic (environments, promises, argument matching) rather than instruction dispatch.

What ry rejects. Ř’s base, a fork of GNU R, for the reason in section 3 of the runtime design: forks cannot follow upstream R.

What it is. Truffle runs a language as an AST interpreter whose nodes rewrite themselves into specialized versions for the types they see, and Graal compiles a hot AST by partial evaluation of the interpreter with the tree as a constant.42 FastR, the Truffle R, ran R code fast but emulated the C API, so packages’ native code was slow and incomplete (section 3 of the runtime design).

What ry rejects. Truffle as an architecture. It requires GraalVM, and FastR shows where it fails for R: the package ecosystem’s native code. The self-specialization idea is the same as quickening, which ry adopts in step 3.

What it is. YJIT is CRuby’s JIT, built at Shopify on basic block versioning by Maxime Chevalier-Boisvert, who introduced the technique with Marc Feeley for JavaScript.43 Lazy basic block versioning compiles a basic block only when execution first reaches it, and compiles a separate version of the block for each combination of value types known at its entry, so a type test whose answer that version already knows disappears without any program analysis. The ECOOP 2015 paper reports that it removes 71% of type tests on average, gives speedups of up to 50%, and does as well as or better than a classical flow-based type analysis on all its benchmarks.7 Shopify reports YJIT about 20% faster than the CRuby interpreter on railsbench.43

What ry adopts. Nothing yet. Block versioning was planned as the second stage of a baseline tier, which was measured and removed: a call-threaded baseline ran more instructions than tier 0 (decisions/jit-ssa.md, “No baseline tier, and code images hold bytecode only”). The idea that survives is the one versioning shares with tier 1’s speculation, a check at a block’s entry instead of one in every instruction, and tier 1 already specializes on tier 0’s value-kind feedback.

What it is. Deegen (Xu and Kjolstad) generates a dynamic language’s VM from one description: the semantics of each bytecode are written as a C++ function, compiled to LLVM IR with unmodified Clang, and turned into both an interpreter and a baseline JIT. The interpreter has one native function per bytecode with tail-call dispatch, pinned VM state, monomorphic inline caches and quickening when a cache is updated; the baseline JIT copies and patches stencils that Deegen builds from the same IR at build time.8 LuaJIT Remake, a Lua 5.1 VM built with it, reports its interpreter about 31% faster than LuaJIT’s hand-written assembly interpreter on average over 44 benchmarks, and its baseline JIT about 360% faster than PUC Lua.8

What ry adopts. The single source of truth (steps 3 and 4). Tier 0’s handlers, written once in Rust, are the semantics of each instruction: step 3 turns them into tail-calling functions, and the step 4 baseline calls them, so no instruction is implemented twice. Deegen’s interpreter result is also the evidence for step 3’s bet, that compiler-generated handlers with tail calls and inline caches can beat an interpreter written in assembly.

What ry rejects. The generator. Deegen needs LLVM IR analysis at build time, and its baseline is copy-and-patch, which ry rejects (CPython row in the table). A Rust handler called from baseline code gives the same single source with no IR tooling.

What it is. HHVM Jump-Start (Ottoni and Liu, CGO 2021) shares the JIT’s profile data across Facebook’s web servers, so a restarted server does not profile from scratch; on the Facebook website it cut the capacity lost during warm-up by 54.9% and raised steady-state performance by 5.4%.9 Java’s Project Leyden does the same through an ahead-of-time cache. JEP 483 (JDK 24) caches loaded and linked classes, and JEP 515 (JDK 25) adds the method profiles collected in a training run, so the JIT compiles hot methods at start-up instead of waiting for profiles, while production runs keep profiling. The JEP’s example program runs in 73 ms with profiles in the cache instead of 90 ms without.10

What ry adopts. Training-run profiles in the per-package image (step 5). ry install is planned to write each package’s bytecode and call targets into a mapped image (Bun’s compiler, above). It can also run the package’s tests and examples once and store tier 0’s feedback and call counts in that image, so a session that loads the package starts with warm profiles and compiles hot closures at their first calls. That targets the measured gap that tier 1 runs under 3% of the time, because most hot closures never reach its thresholds. As in Leyden, the shipped profile is only a start: guards stay, and live feedback replaces it. A training run executes package code, so it is bounded in time, and a package whose run fails is installed without profiles.

What they are. Each added types to a large dynamic codebase and then used them for speed. Hack “reconciles the fast development cycle of a dynamically typed language with the discipline provided by static typing” and runs on HHVM, whose JIT the PLDI 2018 paper describes as profile-guided and region-based.1144 Static Python, Instagram’s gradually typed Python, mixes concrete types, which are fully sound and cheap at run time, with transient types, which are shallowly checked and easier to adopt; moving parts of Instagram’s web server to it raised the maximum requests per second by 3.7%.12 Sorbet checks Ruby statically, and sorbet-runtime checks each sig when the method runs. Its experimental compiler turns files marked # compiled: true into native extensions through LLVM, using the types Sorbet inferred.13

What ry adopts. They are prior art for ry’s whole strategy, and they agree on its parts. Types arrive file by file (Sorbet’s sigils and compiled marker, ry’s strict mode). Values from untyped code are checked at the boundary (Sorbet’s runtime sigs, Static Python’s transient checks, ry’s facts and guesses). And the speed comes from compiling typed code, not from trusting annotations in untyped code. Two lessons carry over. Static Python’s measured gain is a few percent of server throughput, so types are ry’s second lever and the untyped tiers must close the gap to GNU R on their own. And the HHVM JIT paper’s abstract names profiling, not Hack’s types, as its basis, which matches ry’s plan for untyped code: profiles, with types as early profiles.

What it is. LXR (Zhao, Blackburn and McKinley, PLDI 2022) is a collector for Java that reclaims most memory by reference counting in short stop-the-world pauses, over an Immix heap of blocks and lines, so most memory is freed without copying. Occasional concurrent tracing finds cyclic garbage, mature objects are copied only judiciously, and one write barrier serves the counts, the concurrent trace and the remembered sets. On 17 workloads in a moderate heap it beats OpenJDK’s default G1 by 4% in throughput, and Shenandoah by 43%.14

How ry’s heap compares. ry’s heap also combines counts and tracing, but with the roles reversed. Every R object carries a 16-bit saturating count (refcount in crates/heap/src/object.rs), maintained by the stores R’s C API makes, and the count only answers R’s sharing question (MAYBE_SHARED) for copy-on-modify. The same count frees lists, large atomic vectors and returned frames early: an object whose count falls to zero is listed, and at an allocation every listed object that no root names is freed (reconcile). Everything else, and every cycle, is reclaimed by a non-moving, generational tracing collector with sticky mark bits and a write barrier, over size-segregated pages (crates/heap/src/heap.rs). Typed ry’s own values are freed by exact counts and never traced (typed-runtime.md, “Memory”).

What ry defers. Concurrent tracing and Immix’s line-level reuse (step 5). Both pay off when collector pauses or fragmentation are measured problems, and neither is measured yet.

What ry rejects. Freeing an R object at the store that takes its count to zero. Native code holds objects in C locals and on the PROTECT stack without counting them, so a count of zero does not mean the object is dead. The free waits for the next allocation, which is the first point where C code may no longer hold an unprotected object, and for a pass over the roots.

What they are. Riposte (Talbot, DeVito and Hanrahan, PACT 2012) is a research VM for R whose vector trace recorder and JIT fuse vector operations, so sum(x * y + z) runs without temporaries (section 3 of the runtime design).15 pqR, Radford Neal’s fork of R 2.15, has a deferred evaluation framework behind two features. Task merging turns an expression such as exp(v + 1) into one task that computes exp(v[i] + 1) for each element in a single loop, and helper threads compute tasks in parallel with the interpreter, with a pending value returned until a reader needs it.16

What ry adopts. Deferred, fused arithmetic at tier 0, through ALTREP (step 3). A builtin +, -, * or / on long double vectors can return an ALTREP vector that holds its operands and the operation instead of the result. A further element-wise operation on such a vector extends the expression, and the first read of the data (DATAPTR from native code, a subscript, a builtin that cannot fuse) computes the whole expression into one buffer in one pass. An ALTREP vector is a legal R vector to every consumer, native code included, so fusion reaches untyped code without the JIT. The scope keeps it exact:

  • Only double arithmetic fuses, because it never warns, so no warning can arrive late. Length checks and the recycling warning happen eagerly, when the operation is called.
  • The fused loop performs each element’s operations in the original order, with no fused multiply-add, so results are bit-identical to GNU R’s.
  • The deferred vector holds its operands with counts, so a later x[i] <- v copies x instead of changing a deferred result.
  • Attributes are computed eagerly, and short vectors are computed at once, because a deferred node costs more than their arithmetic.

What ry rejects. pqR’s approach as a fork of GNU R, for the reason in the runtime design.

This page is an Open Knowledge Format v0.2 concept document.45 The frontmatter carries the type, the provenance (sources) and the trust (generated, verified) fields that format defines, and each claim about a project cites its source with a footnote keyed to a sources entry. The docs site does not render frontmatter, so each footnote also carries the source’s link.

  1. Ullrich and de Moura: Counting Immutable Beans, Reference Counting Optimized for Purely Functional Programming (IFL 2019), section 7.2, https://arxiv.org/abs/1908.05647 ↩ ↩2

  2. PEP 659: Specializing Adaptive Interpreter, https://peps.python.org/pep-0659/ ↩

  3. PEP 744: JIT Compilation, https://peps.python.org/pep-0744/ ↩

  4. Bolz, Cuni, Fijałkowski and Rigo: Tracing the meta-level, PyPy’s tracing JIT compiler (ICOOOLPS 2009), and the PyPy documentation, https://doc.pypy.org/en/latest/ ↩

  5. Java SE 21 HotSpot VM guide: performance enhancements, tiered compilation, https://docs.oracle.com/en/java/javase/21/vm/java-hotspot-virtual-machine-performance-enhancements.html ↩

  6. .NET runtime design document: tiered compilation, and the compilation configuration reference, https://github.com/dotnet/runtime/blob/main/docs/design/features/tiered-compilation.md, https://learn.microsoft.com/en-us/dotnet/core/runtime-config/compilation ↩

  7. Chevalier-Boisvert and Feeley: Simple and Effective Type Check Removal through Lazy Basic Block Versioning (ECOOP 2015), https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ECOOP.2015.101, https://arxiv.org/abs/1411.0352 ↩ ↩2

  8. Xu and Kjolstad: Deegen, a JIT-Capable VM Generator for Dynamic Languages (2024), https://arxiv.org/abs/2411.11469 ↩ ↩2 ↩3

  9. Ottoni and Liu: HHVM Jump-Start, Boosting Both Warmup and Steady-State Performance at Scale (CGO 2021), https://research.facebook.com/publications/hhvm-jump-start-boosting-both-warmup-and-steady-state-performance-at-scale/ ↩ ↩2

  10. JEP 515: Ahead-of-Time Method Profiling, and the Project Leyden page, https://openjdk.org/jeps/515, https://openjdk.org/projects/leyden/ ↩ ↩2

  11. The Hack language home page, https://hacklang.org/ ↩ ↩2

  12. Lu, Greenman, Meyer, Viehland, Panse and Krishnamurthi: Gradual Soundness, Lessons from Static Python (Programming 2023), https://arxiv.org/abs/2206.13831 ↩ ↩2

  13. Sorbet documentation overview, and Open-sourcing the Sorbet Compiler, https://sorbet.org/docs/overview, https://sorbet.org/blog/2021/07/30/open-sourcing-sorbet-compiler ↩ ↩2

  14. Zhao, Blackburn and McKinley: Low-Latency, High-Throughput Garbage Collection (PLDI 2022), https://doi.org/10.1145/3519939.3523440 ↩ ↩2

  15. Talbot, DeVito and Hanrahan: Riposte, a Trace-Driven Compiler and Parallel VM for Vector Code in R (PACT 2012), and its repository, https://github.com/jtalbot/riposte ↩ ↩2

  16. pqR NEWS: deferred evaluation, task merging and helper threads, https://github.com/radfordneal/pqR/blob/Release-2016-10-24/NEWS ↩ ↩2

  17. Roc repository: docs/langref, design.md, design/lambda-set-specialization.md, https://github.com/roc-lang/roc ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12

  18. Reinking, Xie, de Moura and Leijen: Perceus, Garbage Free Reference Counting with Reuse, https://www.microsoft.com/en-us/research/wp-content/uploads/2020/11/perceus-tr-v4.pdf ↩

  19. Taelin et al.: BendRT, a Parallel Runtime for CPUs and GPUs, https://github.com/HigherOrderCO/Bend/blob/main/paper/BendRT.pdf ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10

  20. Bend repository: README.md, guide/EFFECTS.md, https://github.com/HigherOrderCO/Bend ↩ ↩2 ↩3 ↩4

  21. goose repository: README.md, docs/implementation.md, docs/reference.md, https://github.com/aardappel/goose ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7

  22. goose-lang/goose: a Go subset with a semantics in Coq, https://github.com/goose-lang/goose ↩

  23. Vx repository: README.md, ROADMAP.md, docs/language_rules_for_a_parallel_compiler.md, www/book/src/quick-reference.md, https://github.com/vx-lang/Vx ↩ ↩2 ↩3 ↩4 ↩5 ↩6

  24. Bun documentation: the ahead-of-time compiler, and its internals page, https://bun.sh/docs/compiler/aot, https://bun.sh/docs/compiler/internals ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8

  25. Bun pull request 45631, “Compile TypeScript to machine code ahead of time: bun build --compile --aot”, https://github.com/oven-sh/bun/pull/45631 ↩ ↩2 ↩3 ↩4

  26. Bun pull request 48120, “AOT: the next base”, https://github.com/oven-sh/bun/pull/48120 ↩

  27. Pizlo: Speculation in JavaScriptCore (WebKit blog, 2020), https://webkit.org/blog/10308/speculation-in-javascriptcore/ ↩ ↩2 ↩3

  28. Pizlo: Introducing the B3 JIT Compiler (WebKit blog, 2016), https://webkit.org/blog/5852/introducing-the-b3-jit-compiler/ ↩

  29. Pizlo: Introducing the WebKit FTL JIT (WebKit blog, 2014), https://webkit.org/blog/3362/introducing-the-webkit-ftl-jit/ ↩

  30. Bun documentation: the bundler and bytecode caching, https://bun.sh/docs/bundler ↩

  31. Rust RFC 3407: explicit tail calls, https://github.com/rust-lang/rfcs/pull/3407 ↩

  32. LuaJIT repository: src/vm_x64.dasc, src/lj_obj.h, src/lj_tab.c, src/lj_snap.c, src/lj_opt_sink.c, https://github.com/LuaJIT/LuaJIT ↩ ↩2

  33. V8 blog: Firing up the Ignition interpreter (2016), https://v8.dev/blog/ignition-interpreter ↩

  34. V8 blog: Sparkplug, a non-optimizing JavaScript compiler (2021), https://v8.dev/blog/sparkplug ↩

  35. V8 blog: Maglev, V8’s fastest optimizing JIT (2023), https://v8.dev/blog/maglev ↩

  36. V8 blog: Land ahoy, leaving the Sea of Nodes (2025), https://v8.dev/blog/leaving-the-sea-of-nodes ↩ ↩2

  37. V8 documentation: Maps (hidden classes) in V8, https://v8.dev/docs/hidden-classes ↩

  38. V8 blog: A lighter V8 (2019), https://v8.dev/blog/v8-lite ↩

  39. Bezanson et al.: Julia, dynamism and performance reconciled by design (OOPSLA 2018), and the Julia developer documentation, https://docs.julialang.org/en/v1/devdocs/compiler/ ↩

  40. Flückiger et al.: R Melts Brains, an IR for First-Class Environments and Lazy Effectful Arguments (DLS 2019), https://doi.org/10.1145/3359619.3359744 ↩

  41. Flückiger et al.: Contextual Dispatch for Function Specialization (OOPSLA 2020), https://doi.org/10.1145/3428288 ↩

  42. Würthinger et al.: One VM to Rule Them All (Onward! 2013), https://doi.org/10.1145/2509578.2509581 ↩

  43. Shopify Engineering: YJIT, building a new JIT compiler for CRuby (2021), https://shopify.engineering/yjit-just-in-time-compiler-cruby ↩ ↩2

  44. Ottoni: HHVM JIT, a Profile-Guided, Region-Based Compiler for PHP and Hack (PLDI 2018), https://research.facebook.com/publications/hhvm-jit-a-profile-guided-region-based-compiler-for-php-and-hack/ ↩

  45. Open Knowledge Format v0.2, https://github.com/GoogleCloudPlatform/open-knowledge-format/blob/main/SPEC.md ↩