makepad/libs/relax/compiler/tests/live/inline_tier1/v0.rs
Admin b22a714840 makepad run: the Rust JIT (libs/relax) and makepad-remote
The JIT that runs makepad apps from source: lexer, front end, type checker,
lazy borrow checker (Gandalf; `--check-first` opts in), codegen, session and
warm/cold caches keyed by compiler stamp, provided crates bound late,
startup images, live patching. User-facing name is `makepad run` (binary
`makepad`, MAKEPAD_RUN_* env, ~/.makepad-run); libs/relax stays the internal
library name. `makepad check` reports rustc-style diagnostics with rustc
error codes and checks a whole workspace (`--workspace`). Runs on macOS,
Linux, Windows and Android. makepad-remote: one tool schema for apps and the
WM (app/1): grabs, captures, traces, frame profiles and tweaks.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 12:26:21 +02:00

35 lines
925 B
Rust

// 3.4: a patched leaf that O3 (and O1) inlined: every slot that inlined it is rebuilt at
// both tiers, and a O3 build in flight from the old source is dropped. MAKEPAD_RUN_O3_CALLS=1
// makes `drive` hot at once; each run sleeps so its O3 build installs before the next edit.
// v2 also edits the leaf reached through a devirtualised dyn call.
trait Op {
fn apply(&self, x: u64) -> u64;
}
struct Add3;
impl Op for Add3 {
fn apply(&self, x: u64) -> u64 {
x + 3
}
}
fn mix(x: u64, k: u64) -> u64 {
(x ^ k).wrapping_mul(0x9E37_79B9_7F4A_7C15)
}
fn drive(n: u64, op: &dyn Op) -> u64 {
let mut acc = 1;
for i in 0..n {
acc = op.apply(mix(acc, i)).rotate_left(7);
}
acc
}
#[test]
fn run() {
let op = Add3;
for _ in 0..20 {
drive(1000, &op);
}
println!("out {:016x}", drive(100_000, &op));
std::thread::sleep(std::time::Duration::from_millis(200));
}