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§
Sourcefn calls(
&self,
func: &CompiledFunctionBody,
calls: &mut IndexSet<FuncIndex>,
) -> Result<()>
fn calls( &self, func: &CompiledFunctionBody, calls: &mut IndexSet<FuncIndex>, ) -> Result<()>
Enumerate the function calls that the given func
makes.
Sourcefn size(&self, func: &CompiledFunctionBody) -> u32
fn size(&self, func: &CompiledFunctionBody) -> u32
Get the abstract size of the given function, for the purposes of inlining heuristics.
Sourcefn inline<'a>(
&self,
func: &mut CompiledFunctionBody,
get_callee: &'a mut dyn FnMut(FuncIndex) -> Option<&'a CompiledFunctionBody>,
) -> Result<()>
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.
Sourcefn finish_compiling(
&self,
func: &mut CompiledFunctionBody,
input: Option<FunctionBody<'_>>,
symbol: &str,
) -> Result<()>
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.