Struct polkavm_common::zygote::VmCtx

source ·
#[repr(C)]
pub struct VmCtx { pub heap_info: VmCtxHeapInfo, pub futex: CacheAligned<AtomicU32>, pub rpc_address: UnsafeCell<u64>, pub rpc_flags: UnsafeCell<u32>, pub rpc_sbrk: UnsafeCell<u32>, pub memory_config: UnsafeCell<SandboxMemoryConfig>, pub is_memory_dirty: AtomicBool, pub counters: CacheAligned<VmCtxCounters>, pub init: VmInit, pub message_length: UnsafeCell<u32>, pub message_buffer: UnsafeCell<[u8; 512]>, /* private fields */ }
Expand description

The virtual machine context.

This is mapped in shared memory and used by the sandbox to keep its state in, as well as by the host to communicate with the sandbox.

Fields§

§heap_info: VmCtxHeapInfo

The state of the program’s heap.

§futex: CacheAligned<AtomicU32>

The futex used to synchronize the sandbox with the host process.

§rpc_address: UnsafeCell<u64>

The address of the native code to call inside of the VM, if non-zero.

§rpc_flags: UnsafeCell<u32>

Flags specifying what exactly the sandbox should do.

§rpc_sbrk: UnsafeCell<u32>

The amount of memory to allocate.

§memory_config: UnsafeCell<SandboxMemoryConfig>

The memory configuration of the sandbox.

§is_memory_dirty: AtomicBool

Whether the memory of the sandbox is dirty.

§counters: CacheAligned<VmCtxCounters>

Performance counters. Only for debugging.

§init: VmInit

One-time args used during initialization.

§message_length: UnsafeCell<u32>

Length of the message in the message buffer.

§message_buffer: UnsafeCell<[u8; 512]>

A buffer used to marshal error messages.

Implementations§

source§

impl VmCtx

source

pub const fn zeroed() -> Self

Creates a zeroed VM context.

source

pub const fn new() -> Self

Creates a fresh VM context.

source

pub const fn gas(&self) -> &UnsafeCell<i64>

source

pub const fn heap_info(&self) -> &VmCtxHeapInfo

source

pub const fn hostcall(&self) -> &UnsafeCell<u32>

source

pub const fn regs(&self) -> &UnsafeCell<[u32; 13]>

source

pub const fn rip(&self) -> &UnsafeCell<u64>

source

pub const fn nth_instruction(&self) -> &UnsafeCell<u32>

Auto Trait Implementations§

§

impl !Freeze for VmCtx

§

impl !RefUnwindSafe for VmCtx

§

impl Send for VmCtx

§

impl !Sync for VmCtx

§

impl Unpin for VmCtx

§

impl UnwindSafe for VmCtx

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

§

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

§

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.