Skip to main content

Module bg_aot

Module bg_aot 

Source
Expand description

Background AOT-native compilation (HOTSWAP §Axis-3 / P18).

A very-hot function’s OPTIMIZED form is compiled to a cdylib and loaded on a WORKER thread — rustc is seconds, so it must never block the interpreter — then the loaded function is installed via Vm::install_aot_native at a drain point and runs at compiled-binary speed from then on. This is the AOT path to the coarse-tiered “optimize hot functions during the run” goal: it reuses the proven on-demand build (crate::compile::aot_build_function) off-thread, the same mpsc worker shape as the forge background compiler (§6), and the existing NativeSlot::Ready dispatch — no new VM seam. Because an AOT function is all-or-nothing per call (it bails to the lower tier on a signature mismatch rather than precise-deopting), it sidesteps the warm-bytecode run-loop change the forge coarse path would need.

Native-only: the browser uses pre-bundled wasm, and there is no rustc there.

Structs§

AotRequest
A request to background-compile function fi (named fn_name) from source, caching the artifact under cache_dir. All fields owned so the request crosses to the worker thread.
AotResult
The worker’s reply: the function index and the loaded AOT function (or None if the function was outside the scalar subset or the build/load failed — the interpreter then keeps it on VM+JIT).
BgAotCompiler
The interpreter-side handle to the background AOT compiler. submit is non-blocking; try_drain is polled at profiling points and drain_blocking is the determinism hook tests use. The worker detaches on drop.