pub struct EvmLlvmBackend {Show 23 fields
pub(crate) cx: &'static Context,
pub(crate) _dh: DiagnosticHandlerGuard,
pub(crate) bcx: Builder<'static>,
pub(crate) module: Module<'static>,
pub(crate) machine: TargetMachine,
pub(crate) orc: Option<OrcJitState>,
pub(crate) _tscx: Option<ThreadSafeContext>,
pub(crate) _cx_handle: Option<Box<ManuallyDrop<Context>>>,
pub(crate) _aot_cx: Option<Box<Context>>,
pub(crate) di_state: Option<DiState>,
pub(crate) ty_void: VoidType<'static>,
pub(crate) ty_ptr: PointerType<'static>,
pub(crate) ty_i1: IntType<'static>,
pub(crate) ty_i8: IntType<'static>,
pub(crate) ty_i32: IntType<'static>,
pub(crate) ty_i64: IntType<'static>,
pub(crate) ty_i256: IntType<'static>,
pub(crate) ty_isize: IntType<'static>,
pub(crate) aot: bool,
pub(crate) backend_config: BackendConfig,
pub(crate) scratch: String,
pub(crate) function_counter: u32,
pub(crate) function_names: HashMap<u32, String, FxBuildHasher>,
}Expand description
The LLVM-based EVM bytecode compiler backend.
Fields§
§cx: &'static Context§_dh: DiagnosticHandlerGuard§bcx: Builder<'static>§module: Module<'static>§machine: TargetMachine§orc: Option<OrcJitState>ORC JIT state. None in AOT mode.
Dropped before _tscx so the JIT engine is disposed before the context.
_tscx: Option<ThreadSafeContext>ORC thread-safe context that owns the LLVM context (JIT mode only).
_cx_handle: Option<Box<ManuallyDrop<Context>>>Non-owning context handle for JIT mode. See create_orc_context.
_aot_cx: Option<Box<Context>>Owned context for AOT mode. None in JIT mode.
di_state: Option<DiState>LLVM debug info builder and compile unit, created lazily when debug_file is set.
ty_void: VoidType<'static>§ty_ptr: PointerType<'static>§ty_i1: IntType<'static>§ty_i8: IntType<'static>§ty_i32: IntType<'static>§ty_i64: IntType<'static>§ty_i256: IntType<'static>§ty_isize: IntType<'static>§aot: bool§backend_config: BackendConfig§scratch: String§function_counter: u32Separate from function_names to have always increasing IDs.
function_names: HashMap<u32, String, FxBuildHasher>Persistent mapping from function ID to symbol name.
Implementations§
Source§impl EvmLlvmBackend
impl EvmLlvmBackend
pub(crate) fn module(&self) -> &Module<'static>
pub(crate) fn ensure_orc(&mut self) -> Result<&mut OrcJitState>
pub(crate) fn fn_type( &self, ret: Option<BasicTypeEnum<'static>>, params: &[BasicTypeEnum<'static>], ) -> FunctionType<'static>
Sourcepub(crate) fn name<'a>(&self, name: &'a str) -> &'a str
pub(crate) fn name<'a>(&self, name: &'a str) -> &'a str
Returns the given name if IR output is being dumped, otherwise an empty string. LLVM skips internal name processing for empty names, avoiding overhead when names are not needed for readability.
pub(crate) fn id_to_name(&self, id: u32) -> &str
Sourcepub(crate) fn ensure_di_state(&mut self)
pub(crate) fn ensure_di_state(&mut self)
Lazily initializes the debug info builder and compile unit for the module.
Sourcepub(crate) fn commit_staged_module(&mut self) -> Result<()>
pub(crate) fn commit_staged_module(&mut self) -> Result<()>
Commits the current staging module to the ORC JIT if there are pending functions.
Sourcepub(crate) fn reset_jit(&mut self) -> Result<()>
pub(crate) fn reset_jit(&mut self) -> Result<()>
Clears all code from this compiler’s JITDylib, freeing JIT-compiled code. The LLVM context and global LLJIT are reused across resets.
Sourcepub fn take_last_resource_tracker(&mut self) -> Option<ResourceTracker>
pub fn take_last_resource_tracker(&mut self) -> Option<ResourceTracker>
Pops and returns the ResourceTracker for the last committed
JIT module.
Each call to jit_function commits a module
with its own tracker. The caller takes ownership and is responsible for calling
tracker.remove() to free the machine code when it is no longer needed.
The caller must also hold a JitDylibGuard to prevent the owning JITDylib from
being recycled before the tracker is removed.
Returns None in AOT mode or if no modules have been committed.
Sourcepub fn jit_dylib_guard(&self) -> Arc<JitDylibGuard>
pub fn jit_dylib_guard(&self) -> Arc<JitDylibGuard>
Returns a shared handle that keeps this backend’s JITDylib alive.
The JITDylib will not be cleared or recycled until all JitDylibGuard handles
(and the backend itself) are dropped. Callers holding JIT function pointers must
retain a guard to prevent the backing code from being freed.
Trait Implementations§
Source§impl Backend for EvmLlvmBackend
impl Backend for EvmLlvmBackend
type Builder<'a> = EvmLlvmBuilder<'a> where Self: 'a
type FuncId = u32
fn ir_extension(&self) -> &'static str
fn set_module_name(&mut self, name: &str)
Source§fn apply_config(&mut self, config: BackendConfig)
fn apply_config(&mut self, config: BackendConfig)
Source§fn finalize_debug_info(&mut self) -> Result<()>
fn finalize_debug_info(&mut self) -> Result<()>
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<'_>, Self::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>
Source§fn function_name(&self, id: Self::FuncId) -> Option<&str>
fn function_name(&self, id: Self::FuncId) -> Option<&str>
Source§fn function_sizes(&self) -> Vec<(String, usize)>
fn function_sizes(&self) -> Vec<(String, usize)>
(name, size) pairs.Source§fn clear_ir(&mut self) -> Result<()>
fn clear_ir(&mut self) -> Result<()>
unsafe fn free_function(&mut self, id: Self::FuncId) -> Result<()>
unsafe fn free_all_functions(&mut self) -> Result<()>
Source§impl BackendTypes for EvmLlvmBackend
impl BackendTypes for EvmLlvmBackend
Source§impl Debug for EvmLlvmBackend
impl Debug for EvmLlvmBackend
Source§impl TypeMethods for EvmLlvmBackend
impl TypeMethods for EvmLlvmBackend
impl Send for EvmLlvmBackend
Auto Trait Implementations§
impl !Freeze for EvmLlvmBackend
impl !RefUnwindSafe for EvmLlvmBackend
impl !Sync for EvmLlvmBackend
impl Unpin for EvmLlvmBackend
impl UnsafeUnpin for EvmLlvmBackend
impl UnwindSafe for EvmLlvmBackend
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
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: 512 bytes