1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Cross-layer hooks the JIT installs into the value layer.
//!
//! The JIT tier (`cljrs-jit`) needs to learn when a var is rebound so it can
//! mark the previous definition's compiled native code *stale* and reclaim it
//! at the next stop-the-world safepoint (Phase 10.2 — code unloading).
//!
//! `cljrs-value` sits far below `cljrs-jit` in the dependency graph, so the
//! coupling is inverted through a function-pointer hook: the JIT installs a
//! callback via [`set_var_rebind_hook`], and [`Var::bind`](crate::types::Var::bind)
//! invokes it (through [`notify_var_rebind`]) whenever it overwrites an existing
//! binding. When no JIT is active the hook is unset and the cost is a single
//! relaxed atomic load.
use OnceLock;
use crateValue;
/// Callback signature: `(old_value, new_value)`.
///
/// Called with the value being replaced and the value replacing it, so the
/// implementation can stale only the definitions that are genuinely going away
/// (an arity present in both `old` and `new` — e.g. rebinding a var to the same
/// function object — must not be staled).
type VarRebindHook = ;
static VAR_REBIND_HOOK: = new;
/// Install the var-rebind hook. Idempotent: only the first call wins.
///
/// Installed once by `cljrs_jit::init`.
/// Notify the JIT that a var holding `old` is being rebound to `new`.
///
/// No-op (one atomic load) when no hook is installed. Called from
/// `Var::bind` only when an existing value is being replaced.
pub