pub struct TierManager { /* private fields */ }Expand description
Manages tiered compilation state for all functions in a program.
Implementations§
Source§impl TierManager
impl TierManager
Sourcepub fn new(function_count: usize, enabled: bool) -> Self
pub fn new(function_count: usize, enabled: bool) -> Self
Create a new tier manager for a program with the given number of functions.
Sourcepub fn set_channels(
&mut self,
compilation_tx: Sender<CompilationRequest>,
compilation_rx: Receiver<CompilationResult>,
)
pub fn set_channels( &mut self, compilation_tx: Sender<CompilationRequest>, compilation_rx: Receiver<CompilationResult>, )
Set up the background compilation channels.
The caller is responsible for spawning the background thread that reads
from request_rx and sends results to result_tx.
Sourcepub fn record_call(
&mut self,
function_id: u16,
feedback: Option<&FeedbackVector>,
) -> bool
pub fn record_call( &mut self, function_id: u16, feedback: Option<&FeedbackVector>, ) -> bool
Record a function call and check for tier promotion.
Returns true if the function should be compiled at a higher tier.
This is called in the Call opcode handler.
When promoting to OptimizingJit and a feedback vector is available, it is attached to the compilation request for speculative optimization.
Sourcepub fn request_compilation_with_feedback(
&self,
function_id: u16,
target_tier: Tier,
feedback: FeedbackVector,
)
pub fn request_compilation_with_feedback( &self, function_id: u16, target_tier: Tier, feedback: FeedbackVector, )
Send a compilation request with a feedback vector snapshot.
Used for Tier 2 (optimizing) promotion when the executor has collected enough type feedback to enable speculative optimization.
Sourcepub fn poll_completions(&mut self) -> Vec<CompilationResult>
pub fn poll_completions(&mut self) -> Vec<CompilationResult>
Poll for completed compilations (non-blocking).
Called at safe points: function entry, loop back-edges. Applies any completed compilations by updating the native code table. Also handles OSR compilation results by updating the osr_table.
Sourcepub fn get_native_code(&self, function_id: u16) -> Option<*const u8>
pub fn get_native_code(&self, function_id: u16) -> Option<*const u8>
Look up native code for a function, if available.
Sourcepub fn get_deopt_info(
&self,
function_id: u16,
deopt_id: usize,
) -> Option<&DeoptInfo>
pub fn get_deopt_info( &self, function_id: u16, deopt_id: usize, ) -> Option<&DeoptInfo>
Look up a DeoptInfo entry for a specific guard deopt point.
deopt_id is an index into the deopt_points vector stored when the
Tier 2 compilation result was installed. Returns None if no deopt
table exists for this function or the index is out of bounds.
Sourcepub fn get_call_count(&self, function_id: u16) -> u32
pub fn get_call_count(&self, function_id: u16) -> u32
Get the call count for a function.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether tiered compilation is enabled.
Sourcepub fn jit_compiled_count(&self) -> usize
pub fn jit_compiled_count(&self) -> usize
Number of functions with native JIT code.
Sourcepub fn record_loop_iteration(&mut self, func_id: u16, loop_ip: usize) -> bool
pub fn record_loop_iteration(&mut self, func_id: u16, loop_ip: usize) -> bool
Record a loop back-edge iteration and check if OSR compilation should be requested.
Returns true if this iteration crosses the OSR threshold and no
OSR code has been compiled for this loop yet (i.e., we should send
a compilation request).
Sourcepub fn register_osr_code(
&mut self,
func_id: u16,
loop_ip: usize,
code: *const u8,
)
pub fn register_osr_code( &mut self, func_id: u16, loop_ip: usize, code: *const u8, )
Register OSR-compiled native code for a specific loop.
Sourcepub fn get_osr_code(&self, func_id: u16, loop_ip: usize) -> Option<*const u8>
pub fn get_osr_code(&self, func_id: u16, loop_ip: usize) -> Option<*const u8>
Look up OSR-compiled native code for a specific loop.
Sourcepub fn osr_threshold(&self) -> u32
pub fn osr_threshold(&self) -> u32
Get the current OSR threshold.
Sourcepub fn set_osr_threshold(&mut self, threshold: u32)
pub fn set_osr_threshold(&mut self, threshold: u32)
Override the OSR threshold (useful for testing).
Sourcepub fn get_loop_count(&self, func_id: u16, loop_ip: usize) -> u32
pub fn get_loop_count(&self, func_id: u16, loop_ip: usize) -> u32
Get the loop iteration count for a specific loop.
Sourcepub fn osr_compiled_count(&self) -> usize
pub fn osr_compiled_count(&self) -> usize
Number of OSR-compiled loop entries.
Sourcepub fn compilation_sender(&self) -> Option<&Sender<CompilationRequest>>
pub fn compilation_sender(&self) -> Option<&Sender<CompilationRequest>>
Access the compilation request sender (for OSR requests from the executor).
Sourcepub fn set_backend(
&mut self,
backend: Box<dyn CompilationBackend>,
program: Arc<BytecodeProgram>,
)
pub fn set_backend( &mut self, backend: Box<dyn CompilationBackend>, program: Arc<BytecodeProgram>, )
Set a compilation backend. Spawns a worker thread that drives the backend, processing requests from the TierManager’s channel.
When the TierManager is dropped, compilation_tx is dropped, which
causes req_rx.recv() to return Err and the worker thread exits.
Sourcepub fn is_osr_blacklisted(&self, func_id: u16, loop_ip: usize) -> bool
pub fn is_osr_blacklisted(&self, func_id: u16, loop_ip: usize) -> bool
Check whether a loop is blacklisted (compilation previously failed).
Sourcepub fn invalidate_function(&mut self, func_id: u16)
pub fn invalidate_function(&mut self, func_id: u16)
Invalidate a compiled function (remove from native_code_table).
Called when the DeoptTracker determines a dependency changed (e.g., a global was reassigned that the JIT specialized on).
Sourcepub fn invalidate_osr(&mut self, func_id: u16)
pub fn invalidate_osr(&mut self, func_id: u16)
Invalidate all OSR entries for a function.
Removes compiled loop code and resets loop counters so the loops can be re-profiled and recompiled if still hot.
Sourcepub fn invalidate_all(&mut self, func_id: u16)
pub fn invalidate_all(&mut self, func_id: u16)
Bulk invalidation: invalidate function + all its OSR entries.
Trait Implementations§
impl Send for TierManager
Auto Trait Implementations§
impl Freeze for TierManager
impl RefUnwindSafe for TierManager
impl !Sync for TierManager
impl Unpin for TierManager
impl UnsafeUnpin for TierManager
impl UnwindSafe for TierManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more