pulley_interpreter::decode

Struct SequencedVisitor

Source
pub struct SequencedVisitor<'a, F, V1, V2> { /* private fields */ }
Available on crate feature decode only.
Expand description

An OpVisitor combinator to sequence one visitor and then another.

Implementations§

Source§

impl<'a, F, V1, V2> SequencedVisitor<'a, F, V1, V2>

Source

pub fn new(join: F, v1: &'a mut V1, v2: &'a mut V2) -> Self

Create a new sequenced visitor.

The given join function is used to combine the results of each sub-visitor so that it can be returned from this combined visitor.

Trait Implementations§

Source§

impl<F, T, V1, V2> ExtendedOpVisitor for SequencedVisitor<'_, F, V1, V2>
where F: FnMut(V1::Return, V2::Return) -> T, V1: ExtendedOpVisitor, V2: ExtendedOpVisitor<BytecodeStream = V1::BytecodeStream>,

Source§

fn trap(&mut self) -> Self::Return

Raise a trap.

Source§

fn nop(&mut self) -> Self::Return

Do nothing.

Source§

fn call_indirect_host(&mut self, sig: u8) -> Self::Return

A special opcode to use an indirect function call to reenter the host from the interpreter.

This is used to implement host intrinsics such as memory.grow for example where that needs to reenter the host from the interpreter.

The sig immediate here is the Nth signature in the for_each_host_signature! macro below. The 0th “argument”, in register x0, is the function pointer that’s being called and all further arguments follow after that in registers.

Source§

impl<F, T, V1, V2> OpVisitor for SequencedVisitor<'_, F, V1, V2>
where F: FnMut(V1::Return, V2::Return) -> T, V1: OpVisitor, V2: OpVisitor<BytecodeStream = V1::BytecodeStream>,

Source§

fn ret(&mut self) -> Self::Return

Transfer control the address in the lr register.

Source§

fn call(&mut self, offset: PcRelOffset) -> Self::Return

Transfer control to the PC at the given offset and set the lr register to the PC just after this instruction.

Source§

fn call_indirect(&mut self, reg: XReg) -> Self::Return

Transfer control to the PC in reg and set lr to the PC just after this instruction.

Source§

fn jump(&mut self, offset: PcRelOffset) -> Self::Return

Unconditionally transfer control to the PC at the given offset.

Source§

fn br_if(&mut self, cond: XReg, offset: PcRelOffset) -> Self::Return

Conditionally transfer control to the given PC offset if cond contains a non-zero value.

Source§

fn br_if_not(&mut self, cond: XReg, offset: PcRelOffset) -> Self::Return

Conditionally transfer control to the given PC offset if cond contains a zero value.

Source§

fn br_if_xeq32(&mut self, a: XReg, b: XReg, offset: PcRelOffset) -> Self::Return

Branch if a == b.

Source§

fn br_if_xneq32( &mut self, a: XReg, b: XReg, offset: PcRelOffset, ) -> Self::Return

Branch if a != b.

Source§

fn br_if_xslt32( &mut self, a: XReg, b: XReg, offset: PcRelOffset, ) -> Self::Return

Branch if signed a < b.

Source§

fn br_if_xslteq32( &mut self, a: XReg, b: XReg, offset: PcRelOffset, ) -> Self::Return

Branch if signed a <= b.

Source§

fn br_if_xult32( &mut self, a: XReg, b: XReg, offset: PcRelOffset, ) -> Self::Return

Branch if unsigned a < b.

Source§

fn br_if_xulteq32( &mut self, a: XReg, b: XReg, offset: PcRelOffset, ) -> Self::Return

Branch if unsigned a <= b.

Source§

fn br_if_xeq64(&mut self, a: XReg, b: XReg, offset: PcRelOffset) -> Self::Return

Branch if a == b.

Source§

fn br_if_xneq64( &mut self, a: XReg, b: XReg, offset: PcRelOffset, ) -> Self::Return

Branch if a != b.

Source§

fn br_if_xslt64( &mut self, a: XReg, b: XReg, offset: PcRelOffset, ) -> Self::Return

Branch if signed a < b.

Source§

fn br_if_xslteq64( &mut self, a: XReg, b: XReg, offset: PcRelOffset, ) -> Self::Return

Branch if signed a <= b.

Source§

fn br_if_xult64( &mut self, a: XReg, b: XReg, offset: PcRelOffset, ) -> Self::Return

Branch if unsigned a < b.

Source§

fn br_if_xulteq64( &mut self, a: XReg, b: XReg, offset: PcRelOffset, ) -> Self::Return

Branch if unsigned a <= b.

Source§

fn br_table32(&mut self, idx: XReg, amt: u32) -> Self::Return

Branch to the label indicated by idx.

After this instruction are amt instances of PcRelOffset and the idx selects which one will be branched to. The value of idx is clamped to amt - 1 (e.g. the last offset is the “default” one.

Source§

fn xmov(&mut self, dst: XReg, src: XReg) -> Self::Return

Move between x registers.

Source§

fn fmov(&mut self, dst: FReg, src: FReg) -> Self::Return

Move between f registers.

Source§

fn vmov(&mut self, dst: VReg, src: VReg) -> Self::Return

Move between v registers.

Source§

fn xconst8(&mut self, dst: XReg, imm: i8) -> Self::Return

Set dst = sign_extend(imm8).

Source§

fn xconst16(&mut self, dst: XReg, imm: i16) -> Self::Return

Set dst = sign_extend(imm16).

Source§

fn xconst32(&mut self, dst: XReg, imm: i32) -> Self::Return

Set dst = sign_extend(imm32).

Source§

fn xconst64(&mut self, dst: XReg, imm: i64) -> Self::Return

Set dst = imm64.

Source§

fn xadd32(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

32-bit wrapping addition: low32(dst) = low32(src1) + low32(src2).

The upper 32-bits of dst are unmodified.

Source§

fn xadd64(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

64-bit wrapping addition: dst = src1 + src2.

Source§

fn xeq64(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

64-bit equality.

Source§

fn xneq64(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

64-bit inequality.

Source§

fn xslt64(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

64-bit signed less-than.

Source§

fn xslteq64(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

64-bit signed less-than-equal.

Source§

fn xult64(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

64-bit unsigned less-than.

Source§

fn xulteq64(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

64-bit unsigned less-than-equal.

Source§

fn xeq32(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

32-bit equality.

Source§

fn xneq32(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

32-bit inequality.

Source§

fn xslt32(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

32-bit signed less-than.

Source§

fn xslteq32(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

32-bit signed less-than-equal.

Source§

fn xult32(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

32-bit unsigned less-than.

Source§

fn xulteq32(&mut self, operands: BinaryOperands<XReg>) -> Self::Return

32-bit unsigned less-than-equal.

Source§

fn load32_u(&mut self, dst: XReg, ptr: XReg) -> Self::Return

dst = zero_extend(load32(ptr))

Source§

fn load32_s(&mut self, dst: XReg, ptr: XReg) -> Self::Return

dst = sign_extend(load32(ptr))

Source§

fn load64(&mut self, dst: XReg, ptr: XReg) -> Self::Return

dst = load64(ptr)

Source§

fn load32_u_offset8(&mut self, dst: XReg, ptr: XReg, offset: i8) -> Self::Return

dst = zero_extend(load32(ptr + offset8))

Source§

fn load32_s_offset8(&mut self, dst: XReg, ptr: XReg, offset: i8) -> Self::Return

dst = sign_extend(load32(ptr + offset8))

Source§

fn load64_offset8(&mut self, dst: XReg, ptr: XReg, offset: i8) -> Self::Return

dst = load64(ptr + offset8)

Source§

fn load32_u_offset64( &mut self, dst: XReg, ptr: XReg, offset: i64, ) -> Self::Return

dst = zero_extend(load32(ptr + offset64))

Source§

fn load32_s_offset64( &mut self, dst: XReg, ptr: XReg, offset: i64, ) -> Self::Return

dst = sign_extend(load32(ptr + offset64))

Source§

fn load64_offset64(&mut self, dst: XReg, ptr: XReg, offset: i64) -> Self::Return

dst = load64(ptr + offset64)

Source§

fn store32(&mut self, ptr: XReg, src: XReg) -> Self::Return

*ptr = low32(src)

Source§

fn store64(&mut self, ptr: XReg, src: XReg) -> Self::Return

*ptr = src

Source§

fn store32_offset8(&mut self, ptr: XReg, offset: i8, src: XReg) -> Self::Return

*(ptr + sign_extend(offset8)) = low32(src)

Source§

fn store64_offset8(&mut self, ptr: XReg, offset: i8, src: XReg) -> Self::Return

*(ptr + sign_extend(offset8)) = src

Source§

fn store32_offset64( &mut self, ptr: XReg, offset: i64, src: XReg, ) -> Self::Return

*(ptr + sign_extend(offset64)) = low32(src)

Source§

fn store64_offset64( &mut self, ptr: XReg, offset: i64, src: XReg, ) -> Self::Return

*(ptr + sign_extend(offset64)) = src

Source§

fn push_frame(&mut self) -> Self::Return

push lr; push fp; fp = sp

Source§

fn pop_frame(&mut self) -> Self::Return

sp = fp; pop fp; pop lr

Source§

fn xpush32(&mut self, src: XReg) -> Self::Return

*sp = low32(src); sp = sp.checked_add(4)

Source§

fn xpush32_many(&mut self, srcs: RegSet<XReg>) -> Self::Return

for src in srcs { xpush32 src }

Source§

fn xpush64(&mut self, src: XReg) -> Self::Return

*sp = src; sp = sp.checked_add(8)

Source§

fn xpush64_many(&mut self, srcs: RegSet<XReg>) -> Self::Return

for src in srcs { xpush64 src }

Source§

fn xpop32(&mut self, dst: XReg) -> Self::Return

*dst = *sp; sp -= 4

Source§

fn xpop32_many(&mut self, dsts: RegSet<XReg>) -> Self::Return

for dst in dsts.rev() { xpop32 dst }

Source§

fn xpop64(&mut self, dst: XReg) -> Self::Return

*dst = *sp; sp -= 8

Source§

fn xpop64_many(&mut self, dsts: RegSet<XReg>) -> Self::Return

for dst in dsts.rev() { xpop64 dst }

Source§

fn bitcast_int_from_float_32(&mut self, dst: XReg, src: FReg) -> Self::Return

low32(dst) = bitcast low32(src) as i32

Source§

fn bitcast_int_from_float_64(&mut self, dst: XReg, src: FReg) -> Self::Return

dst = bitcast src as i64

Source§

fn bitcast_float_from_int_32(&mut self, dst: FReg, src: XReg) -> Self::Return

low32(dst) = bitcast low32(src) as f32

Source§

fn bitcast_float_from_int_64(&mut self, dst: FReg, src: XReg) -> Self::Return

dst = bitcast src as f64

Source§

fn stack_alloc32(&mut self, amt: u32) -> Self::Return

sp = sp.checked_sub(amt)

Source§

fn stack_free32(&mut self, amt: u32) -> Self::Return

sp = sp + amt

Source§

type BytecodeStream = <V1 as OpVisitor>::BytecodeStream

The type of this visitor’s bytecode stream.
Source§

type Return = T

The type of values returned by each visitor method.
Source§

fn bytecode(&mut self) -> &mut Self::BytecodeStream

Get this visitor’s underlying bytecode stream.
Source§

fn before_visit(&mut self)

A callback invoked before starting to decode an instruction. Read more
Source§

fn after_visit(&mut self)

A callback invoked after an instruction has been completely decoded. Read more

Auto Trait Implementations§

§

impl<'a, F, V1, V2> Freeze for SequencedVisitor<'a, F, V1, V2>
where F: Freeze,

§

impl<'a, F, V1, V2> RefUnwindSafe for SequencedVisitor<'a, F, V1, V2>

§

impl<'a, F, V1, V2> Send for SequencedVisitor<'a, F, V1, V2>
where F: Send, V1: Send, V2: Send,

§

impl<'a, F, V1, V2> Sync for SequencedVisitor<'a, F, V1, V2>
where F: Sync, V1: Sync, V2: Sync,

§

impl<'a, F, V1, V2> Unpin for SequencedVisitor<'a, F, V1, V2>
where F: Unpin,

§

impl<'a, F, V1, V2> !UnwindSafe for SequencedVisitor<'a, F, V1, V2>

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.