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
impl EvmCraneliftBackend
Sourcepub fn is_supported() -> Result<(), &'static str>
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.
Sourcepub fn new(aot: bool, opt_level: OptimizationLevel) -> Self
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
.
pub(crate) fn finish_module(&mut self) -> Result<Option<ObjectModule>>
Trait Implementations§
Source§impl Backend for EvmCraneliftBackend
impl Backend for EvmCraneliftBackend
type Builder<'a> = EvmCraneliftBuilder<'a>
type FuncId = FuncId
fn ir_extension(&self) -> &'static str
fn set_module_name(&mut self, name: &str)
fn set_is_dumping(&mut self, yes: bool)
fn set_debug_assertions(&mut self, yes: bool)
fn opt_level(&self) -> OptimizationLevel
fn set_opt_level(&mut self, level: OptimizationLevel)
fn is_aot(&self) -> bool
fn function_name_is_unique(&self, name: &str) -> bool
fn dump_ir(&mut self, path: &Path) -> Result<()>
fn dump_disasm(&mut self, path: &Path) -> Result<()>
fn build_function( &mut self, name: &str, ret: Option<Self::Type>, params: &[Self::Type], param_names: &[&str], linkage: Linkage, ) -> Result<(Self::Builder<'_>, FuncId)>
fn verify_module(&mut self) -> Result<()>
fn optimize_module(&mut self) -> Result<()>
fn write_object<W: Write>(&mut self, w: W) -> Result<()>
fn jit_function(&mut self, id: Self::FuncId) -> Result<usize>
unsafe fn free_function(&mut self, id: Self::FuncId) -> Result<()>
unsafe fn free_all_functions(&mut self) -> Result<()>
Source§impl BackendTypes for EvmCraneliftBackend
impl BackendTypes for EvmCraneliftBackend
Source§impl TypeMethods for EvmCraneliftBackend
impl TypeMethods for EvmCraneliftBackend
Auto Trait Implementations§
impl !Freeze for EvmCraneliftBackend
impl !RefUnwindSafe for EvmCraneliftBackend
impl Send for EvmCraneliftBackend
impl !Sync for EvmCraneliftBackend
impl Unpin for EvmCraneliftBackend
impl !UnwindSafe for EvmCraneliftBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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