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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! v2.0 Track J sub-step J-A — `Send` wrapper newtype for
//! `cranelift_jit::JITModule`.
//!
//! ## Why this exists
//!
//! Track J's Option B (per-Vm JIT cache, Vm cross-thread sendable)
//! requires `JITModule` to be `Send`. As of cranelift_jit 0.124.3 the
//! type is **not** auto-`Send` because its
//! `memory: Box<dyn JITMemoryProvider>` field is a trait object with
//! no `+ Send` bound (see audit:
//! `.dev/rfcs/v2.0-track-j-prep.md` §Sub 3). The default concrete
//! provider — `SystemMemoryProvider` — IS `Send`
//! (`cranelift-jit-0.124.3/src/memory/system.rs:126 unsafe impl Send
//! for Memory`), and luna never plugs in a custom provider
//! (`grep memory_provider crates/luna-jit/src/` → 0 hits), so
//! wrapping `JITModule` in a newtype + `unsafe impl Send` is sound
//! for luna's actual usage pattern.
//!
//! This sub-step (J-A) only lands the wrapper + smoke test. The
//! field migration of `JIT_CACHE` / `JIT_CACHE_HANDLES` /
//! `TRACE_JIT_HANDLES` from `thread_local!` to `Vm.VmJitStorage` is
//! J-B's job; J-A keeps existing call sites unchanged.
//!
//! Precedent: `unsafe impl Send for TraceHandle` at
//! `trace.rs:2497`.
use JITModule;
use ;
/// `Send`-asserting newtype around [`cranelift_jit::JITModule`].
///
/// Wraps the module so it can live in a `Send` container (per-`Vm`
/// field under Track J Option B) without an inner trait-object Send
/// bound from upstream Cranelift.
///
/// **Not a stable embedder API.** The type is `pub` only so the J-A
/// integration test (`tests/j_a_send_jit_module_wrapper.rs`) can
/// import it via a `#[doc(hidden)]` re-export at the crate root —
/// embedders should treat it as internal to luna-jit. J-B field
/// migration / J-D rebind consume it; nothing else.
///
/// **Not `Sync`.** `JITModule` contains `RefCell<symbols>` (interior
/// mutability with non-atomic borrow tracking) so by-ref sharing
/// across threads is unsound; Track J Option B is move-only and
/// uses an `RwLock` at the outer Vm level to gate mutator access.
;
// SAFETY: J-A audit on cranelift_jit 0.124.3 confirmed (per
// `.dev/rfcs/v2.0-track-j-prep.md` §Sub 3-4) that `JITModule`'s sole
// `!Send` field is `memory: Box<dyn JITMemoryProvider>`
// (`backend.rs:175`, the trait object has no `+ Send` bound). The
// default concrete provider `SystemMemoryProvider` IS `Send`
// (`memory/system.rs:126 unsafe impl Send for Memory`). luna never
// calls `JITBuilder::memory_provider` (`grep memory_provider
// crates/luna-jit/src/` → 0 hits), so every `JITModule` luna
// constructs holds the default `SystemMemoryProvider`. Mirrors the
// established precedent `unsafe impl Send for TraceHandle` at
// `trace.rs:2497`.
//
// Caveat: future cranelift bumps must re-run the
// `.dev/rfcs/v2.0-track-j-prep.md` §Sub 3 field-by-field table; the
// static assertion in `tests/j_a_send_jit_module_wrapper.rs` is the
// canary.
unsafe