Skip to main content

TierManager

Struct TierManager 

Source
pub struct TierManager { /* private fields */ }
Expand description

Manages tiered compilation state for all functions in a program.

Implementations§

Source§

impl TierManager

Source

pub fn new(function_count: usize, enabled: bool) -> Self

Create a new tier manager for a program with the given number of functions.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get_native_code(&self, function_id: u16) -> Option<*const u8>

Look up native code for a function, if available.

Source

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.

Source

pub fn get_tier(&self, function_id: u16) -> Tier

Get the current tier of a function.

Source

pub fn get_call_count(&self, function_id: u16) -> u32

Get the call count for a function.

Source

pub fn is_enabled(&self) -> bool

Whether tiered compilation is enabled.

Source

pub fn jit_compiled_count(&self) -> usize

Number of functions with native JIT code.

Source

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).

Source

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.

Source

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.

Source

pub fn osr_threshold(&self) -> u32

Get the current OSR threshold.

Source

pub fn set_osr_threshold(&mut self, threshold: u32)

Override the OSR threshold (useful for testing).

Source

pub fn get_loop_count(&self, func_id: u16, loop_ip: usize) -> u32

Get the loop iteration count for a specific loop.

Source

pub fn osr_compiled_count(&self) -> usize

Number of OSR-compiled loop entries.

Source

pub fn compilation_sender(&self) -> Option<&Sender<CompilationRequest>>

Access the compilation request sender (for OSR requests from the executor).

Source

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.

Source

pub fn is_osr_blacklisted(&self, func_id: u16, loop_ip: usize) -> bool

Check whether a loop is blacklisted (compilation previously failed).

Source

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).

Source

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.

Source

pub fn invalidate_all(&mut self, func_id: u16)

Bulk invalidation: invalidate function + all its OSR entries.

Source

pub fn stats(&self) -> TierStats

Summary statistics.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more