makepad/libs/relax/compiler/tests/live/palette_tier1/v2.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

22 lines
889 B
Rust

// A palette body edit must invalidate every caller that absorbed it, including O3.
struct Cell { light: f32 }
struct Palette { red: f32, green: f32, blue: f32, generation: u32 }
fn palette() -> Palette {
Palette { red: 0.125, green: 0.25, blue: 0.5, generation: 1 }
}
pub fn version() -> u32 { palette().generation }
pub fn color(c: &Cell) -> [f32; 4] {
let p = palette();
[p.red * c.light, p.green * c.light, p.blue * c.light, 1.0]
}
#[test]
fn run() {
let color = std::hint::black_box(color as fn(&Cell) -> [f32; 4]);
let version = std::hint::black_box(version as fn() -> u32);
let cell = Cell { light: 2.0 };
println!("out immediate {} {:?}", version(), color(&cell));
for _ in 0..10000 { std::hint::black_box(color(&cell)); }
std::thread::sleep(std::time::Duration::from_millis(1000));
println!("out warm {} {:?}", version(), color(&cell));
}