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: JITModuleThe 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: StackMapRegistryStack map registry populated during compilation.
Implementations§
Source§impl CodegenPipeline
impl CodegenPipeline
Sourcepub fn new(symbols: &[(&str, *const u8)]) -> Result<Self, PipelineError>
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).
Sourcepub fn make_func_signature(&self) -> Signature
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.
Sourcepub fn declare_function(&mut self, name: &str) -> Result<FuncId, PipelineError>
pub fn declare_function(&mut self, name: &str) -> Result<FuncId, PipelineError>
Declare a function in the JIT module.
Sourcepub fn define_function(
&mut self,
func_id: FuncId,
ctx: &mut Context,
) -> Result<(), PipelineError>
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.
Sourcepub fn finalize(&mut self) -> Result<(), PipelineError>
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.
Sourcepub fn get_function_ptr(&self, func_id: FuncId) -> *const u8
pub fn get_function_ptr(&self, func_id: FuncId) -> *const u8
Get the callable function pointer after finalization.
Sourcepub fn register_lambda(&mut self, func_id: FuncId, name: String)
pub fn register_lambda(&mut self, func_id: FuncId, name: String)
Register a lambda name for a function ID (call before finalize).
Sourcepub fn build_lambda_registry(&self) -> LambdaRegistry
pub fn build_lambda_registry(&self) -> LambdaRegistry
Build a LambdaRegistry from all registered lambdas.
Must be called after finalize() so code pointers are available.