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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! The seam between a runtime and its JIT compiler.
//!
//! The JIT is an optional system: a runtime runs its tiers without one (tree
//! walk → Tier-1 IR), and the compiler package that provides one
//! (`cljrs-compiler`) depends on this package, so the call can only go one
//! way. That is what this trait is for — and it is the *only* thing it is
//! for. Everything the JIT accumulates (invocation counters, argument-type
//! profiles, published function pointers, OSR entries) is runtime-owned state
//! in [`JitState`](crate::tiered::jit_state::JitState), not something a
//! process-global hook keeps on the side.
//!
//! A backend is installed per runtime, by `cljrs_compiler::jit::install`:
//!
//! ```rust,ignore
//! let runtime = Runtime::builder().execution_mode(ExecutionMode::Tiered).build()?;
//! cljrs_compiler::jit::install(&runtime);
//! ```
//!
//! Two runtimes in one process may install different backends, or one may
//! install none — dispatch reads the backend from the runtime it is
//! executing in, never from a global.
use Arc;
use Weak;
use IrFunction;
use Value;
use crateEnv;
use crateTiers;
/// A JIT compiler attached to one runtime.
///
/// Implementations are shared across mutator threads and the background
/// compile worker, hence `Send + Sync`. Individual methods may take `!Send`
/// arguments (`Value`, `Env`): those are only ever called on a mutator
/// thread.