F4: get (or lazily build ONCE) the shared all_defs Rust registry. Called by the * first worker that hits a NULL-filter rust file; later null-files reuse it. Fast * path is a lock-free atomic load; the build happens under rust_shared_mu into the * dedicated rust_shared_arena (never a shared pipeline arena from a worker thread). * Returns NULL if there are no defs (caller falls back to the per-f
| 3971 | * dedicated rust_shared_arena (never a shared pipeline arena from a worker thread). |
| 3972 | * Returns NULL if there are no defs (caller falls back to the per-file build). */ |
| 3973 | static CBMTypeRegistry *pp_rust_shared_registry(resolve_ctx_t *rc) { |
| 3974 | CBMTypeRegistry *p = atomic_load_explicit(&rc->rust_shared_reg, memory_order_acquire); |
| 3975 | if (p) |
| 3976 | return p; |
| 3977 | if (!rc->all_defs || rc->def_count <= 0) |
| 3978 | return NULL; |
| 3979 | cbm_mutex_lock(&rc->rust_shared_mu); |
| 3980 | p = atomic_load_explicit(&rc->rust_shared_reg, memory_order_relaxed); |
| 3981 | if (!p) { |
| 3982 | cbm_arena_init(&rc->rust_shared_arena); |
| 3983 | rc->rust_shared_arena_live = true; |
| 3984 | p = cbm_rust_build_cross_registry(&rc->rust_shared_arena, rc->all_defs, rc->def_count); |
| 3985 | if (p) { |
| 3986 | char sb[96]; |
| 3987 | snprintf(sb, sizeof(sb), "types=%d funcs=%d", p->type_count, p->func_count); |
| 3988 | cbm_log_info("cross_lsp.rust_registry", "scale", sb); |
| 3989 | } |
| 3990 | atomic_store_explicit(&rc->rust_shared_reg, p, memory_order_release); |
| 3991 | } |
| 3992 | cbm_mutex_unlock(&rc->rust_shared_mu); |
| 3993 | return p; |
| 3994 | } |
| 3995 | |
| 3996 | /* void*-typed adapter so the shared dispatch helper (pass_lsp_cross.c) can |
| 3997 | * borrow the lazily-built shared Rust registry without knowing resolve_ctx_t. */ |
no test coverage detected