Trait InliningCompiler

Source
pub trait InliningCompiler: Sync + Send {
    // Required methods
    fn calls(
        &self,
        func: &CompiledFunctionBody,
        calls: &mut IndexSet<FuncIndex>,
    ) -> Result<()>;
    fn size(&self, func: &CompiledFunctionBody) -> u32;
    fn inline<'a>(
        &self,
        func: &mut CompiledFunctionBody,
        get_callee: &'a mut dyn FnMut(FuncIndex) -> Option<&'a CompiledFunctionBody>,
    ) -> Result<()>;
    fn finish_compiling(
        &self,
        func: &mut CompiledFunctionBody,
        input: Option<FunctionBody<'_>>,
        symbol: &str,
    ) -> Result<()>;
}
Expand description

An inlining compiler.

Required Methods§

Source

fn calls( &self, func: &CompiledFunctionBody, calls: &mut IndexSet<FuncIndex>, ) -> Result<()>

Enumerate the function calls that the given func makes.

Source

fn size(&self, func: &CompiledFunctionBody) -> u32

Get the abstract size of the given function, for the purposes of inlining heuristics.

Source

fn inline<'a>( &self, func: &mut CompiledFunctionBody, get_callee: &'a mut dyn FnMut(FuncIndex) -> Option<&'a CompiledFunctionBody>, ) -> Result<()>

Process this function for inlining.

Implementations should call get_callee for each of their direct function call sites and if get_callee returns Some(_), they should inline the given function body into that call site.

Source

fn finish_compiling( &self, func: &mut CompiledFunctionBody, input: Option<FunctionBody<'_>>, symbol: &str, ) -> Result<()>

Finish compiling the given function.

This method must be called before passing the CompiledFunctionBody’s contents to Compiler::append_code, even if no inlining was performed.

Implementors§