Skip to main content

CodegenPipeline

Struct CodegenPipeline 

Source
pub struct CodegenPipeline {
    pub module: JITModule,
    pub isa: Arc<dyn TargetIsa>,
    pub stack_maps: StackMapRegistry,
    /* private fields */
}
Expand description

Cranelift JIT compilation pipeline.

Single-compile strategy: module.define_function() compiles and links, then stack maps are extracted from ctx.compiled_code().

Fields§

§module: JITModule

The JIT module that manages executable memory.

This field is public as an escape hatch for advanced use cases and tests that need direct access to Cranelift’s JITModule. Most users should prefer the safe wrapper methods on CodegenPipeline (e.g., declare_function) instead of calling into module directly.

§isa: Arc<dyn TargetIsa>

Target ISA (needed for Context::compile).

§stack_maps: StackMapRegistry

Stack map registry populated during compilation.

Implementations§

Source§

impl CodegenPipeline

Source

pub fn new(symbols: &[(&str, *const u8)]) -> Result<Self, PipelineError>

Create a new CodegenPipeline with default x86-64 settings.

symbols is a list of (name, pointer) pairs for host functions that JIT code can call (e.g., gc_trigger).

Source

pub fn make_func_signature(&self) -> Signature

Create the standard function signature for compiled tidepool functions.

Uses the target ISA’s default C ABI calling convention, with vmctx: i64 as the first parameter and an i64 return value.

Source

pub fn declare_function(&mut self, name: &str) -> Result<FuncId, PipelineError>

Declare a function in the JIT module.

Source

pub fn define_function( &mut self, func_id: FuncId, ctx: &mut Context, ) -> Result<(), PipelineError>

Compile and define a function in the JIT module.

define_function internally calls ctx.compile(), then stack maps are extracted from ctx.compiled_code() — single compile per function.

After calling this for all functions, call finalize() to make them callable.

Source

pub fn finalize(&mut self) -> Result<(), PipelineError>

Finalize all defined functions, making them callable. Also registers stack maps now that we have function base pointers.

Source

pub fn get_function_ptr(&self, func_id: FuncId) -> *const u8

Get the callable function pointer after finalization.

Source

pub fn register_lambda(&mut self, func_id: FuncId, name: String)

Register a lambda name for a function ID (call before finalize).

Source

pub fn build_lambda_registry(&self) -> LambdaRegistry

Build a LambdaRegistry from all registered lambdas. Must be called after finalize() so code pointers are available.

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<Choices> CoproductSubsetter<CNil, HNil> for Choices

Source§

type Remainder = Choices

Source§

fn subset( self, ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

Source§

fn lift_into(self) -> U

Performs the indexed conversion.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Source> Sculptor<HNil, HNil> for Source

Source§

type Remainder = Source

Source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
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.