Struct EvmCraneliftBackend

Source
pub struct EvmCraneliftBackend {
    pub(crate) builder_context: FunctionBuilderContext,
    pub(crate) ctx: Context,
    pub(crate) module: ModuleWrapper,
    pub(crate) symbols: Symbols,
    pub(crate) opt_level: OptimizationLevel,
    pub(crate) comments: CommentWriter,
    pub(crate) functions: Vec<FuncId>,
}
Expand description

The Cranelift-based EVM bytecode compiler backend.

Fields§

§builder_context: FunctionBuilderContext

The function builder context, which is reused across multiple FunctionBuilder instances.

§ctx: Context

The main Cranelift context, which holds the state for codegen. Cranelift separates this from Module to allow for parallel compilation, with a context per thread, though this isn’t in the simple demo here.

§module: ModuleWrapper

The module, with the jit backend, which manages the JIT’d functions.

§symbols: Symbols§opt_level: OptimizationLevel§comments: CommentWriter§functions: Vec<FuncId>

Implementations§

Source§

impl EvmCraneliftBackend

Source

pub fn is_supported() -> Result<(), &'static str>

Returns Ok(()) if the current architecture is supported, or Err(()) if the host machine is not supported in the current configuration.

Source

pub fn new(aot: bool, opt_level: OptimizationLevel) -> Self

Creates a new instance of the JIT compiler.

§Panics

Panics if the current architecture is not supported. See is_supported.

Source

pub(crate) fn finish_module(&mut self) -> Result<Option<ObjectModule>>

Trait Implementations§

Source§

impl Backend for EvmCraneliftBackend

Source§

type Builder<'a> = EvmCraneliftBuilder<'a>

Source§

type FuncId = FuncId

Source§

fn ir_extension(&self) -> &'static str

Source§

fn set_module_name(&mut self, name: &str)

Source§

fn set_is_dumping(&mut self, yes: bool)

Source§

fn set_debug_assertions(&mut self, yes: bool)

Source§

fn opt_level(&self) -> OptimizationLevel

Source§

fn set_opt_level(&mut self, level: OptimizationLevel)

Source§

fn is_aot(&self) -> bool

Source§

fn function_name_is_unique(&self, name: &str) -> bool

Source§

fn dump_ir(&mut self, path: &Path) -> Result<()>

Source§

fn dump_disasm(&mut self, path: &Path) -> Result<()>

Source§

fn build_function( &mut self, name: &str, ret: Option<Self::Type>, params: &[Self::Type], param_names: &[&str], linkage: Linkage, ) -> Result<(Self::Builder<'_>, FuncId)>

Source§

fn verify_module(&mut self) -> Result<()>

Source§

fn optimize_module(&mut self) -> Result<()>

Source§

fn write_object<W: Write>(&mut self, w: W) -> Result<()>

Source§

fn jit_function(&mut self, id: Self::FuncId) -> Result<usize>

Source§

unsafe fn free_function(&mut self, id: Self::FuncId) -> Result<()>

Source§

unsafe fn free_all_functions(&mut self) -> Result<()>

Source§

impl BackendTypes for EvmCraneliftBackend

Source§

type Type = Type

Source§

type Value = Value

Source§

type StackSlot = StackSlot

Source§

type BasicBlock = Block

Source§

type Function = FuncRef

Source§

impl TypeMethods for EvmCraneliftBackend

Source§

fn type_ptr(&self) -> Self::Type

Source§

fn type_ptr_sized_int(&self) -> Self::Type

Source§

fn type_int(&self, bits: u32) -> Self::Type

Source§

fn type_array(&self, ty: Self::Type, size: u32) -> Self::Type

Source§

fn type_bit_width(&self, ty: Self::Type) -> u32

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

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 6480 bytes