Skip to main content

NativeFrame

Struct NativeFrame 

Source
pub struct NativeFrame<'a> { /* private fields */ }
Expand description

A validated safe view of a ShadowFrame and its register (handle) array. Constructed only inside the bamts_* wrappers, which reject a null, misaligned, or malformed frame before dispatching.

Implementations§

Source§

impl<'a> NativeFrame<'a>

Source

pub fn new( frame: &'a mut ShadowFrame, handles: &'a mut [Value], ) -> Option<NativeFrame<'a>>

Builds a safe view from an already-borrowed frame and register slice. Returns None unless the frame’s handle_len and handles metadata describe exactly handles. This lets runtime-owned execution paths use the same checked view without raw pointers or unsafe code.

Source

pub unsafe fn from_raw(frame: *mut ShadowFrame) -> Option<NativeFrame<'a>>

Validates a raw frame pointer into a safe view.

§Safety

frame, when non-null, must point to a live, unaliased ShadowFrame whose handles field addresses exactly handle_len initialized Values (or is unused when handle_len == 0). Generated native code upholds this: it owns the frame for the synchronous duration of the helper call, and the register array is a distinct allocation from the 32-byte header. Returns None for a null or misaligned pointer.

Source

pub fn handle_len(&self) -> u32

The number of live registers (ShadowFrame::handle_len).

Source

pub fn module_id(&self) -> u32

The dense module id of the executing function.

Source

pub fn pc(&self) -> u32

The current bytecode program counter / resume token.

Source

pub fn set_resume(&mut self, token: u32)

Stores a resume token into the frame (yield path).

Source

pub fn registers(&self) -> &[Value]

The register array.

Source

pub fn registers_mut(&mut self) -> &mut [Value]

The register array, mutably.

Source

pub fn register(&self, index: u32) -> Value

Register index. Panics if out of range; the wrapper turns the panic into a CompletionTag::FatalTrap. Use NativeFrame::try_register to branch instead.

Source

pub fn set_register(&mut self, index: u32, value: Value)

Sets register index. Panics if out of range (see NativeFrame::register).

Source

pub fn try_register(&self, index: u32) -> Option<Value>

Register index, or None when out of range.

Source

pub fn try_set_register(&mut self, index: u32, value: Value) -> bool

Sets register index, returning false when out of range.

Source

pub fn previous(&self) -> *mut ShadowFrame

The caller’s frame, or null at the base of the stack.

Auto Trait Implementations§

§

impl<'a> !Send for NativeFrame<'a>

§

impl<'a> !Sync for NativeFrame<'a>

§

impl<'a> !UnwindSafe for NativeFrame<'a>

§

impl<'a> Freeze for NativeFrame<'a>

§

impl<'a> RefUnwindSafe for NativeFrame<'a>

§

impl<'a> Unpin for NativeFrame<'a>

§

impl<'a> UnsafeUnpin for NativeFrame<'a>

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.