pub struct FuncGen<'a, M: Machine> {Show 17 fields
module: &'a ModuleInfo,
config: &'a Singlepass,
vmoffsets: &'a VMOffsets,
memory_styles: &'a PrimaryMap<MemoryIndex, MemoryStyle>,
signature: FunctionType,
locals: Vec<Location<M::GPR, M::SIMD>>,
local_types: Vec<ValType>,
value_stack: Vec<(Location<M::GPR, M::SIMD>, CanonicalizeType)>,
control_stack: Vec<ControlFrame>,
stack_offset: MachineStackOffset,
save_area_offset: Option<MachineStackOffset>,
machine: M,
unreachable_depth: usize,
local_func_index: LocalFunctionIndex,
relocations: Vec<Relocation>,
special_labels: SpecialLabelSet,
calling_convention: CallingConvention,
}Expand description
The singlepass per-function code generator.
Fields§
§module: &'a ModuleInfoStatic module information.
config: &'a SinglepassModuleInfo compilation config.
vmoffsets: &'a VMOffsetsOffsets of vmctx fields.
memory_styles: &'a PrimaryMap<MemoryIndex, MemoryStyle>§signature: FunctionTypeFunction signature.
locals: Vec<Location<M::GPR, M::SIMD>>Memory locations of local variables.
local_types: Vec<ValType>Types of local variables, including arguments.
value_stack: Vec<(Location<M::GPR, M::SIMD>, CanonicalizeType)>Value stack.
control_stack: Vec<ControlFrame>A list of frames describing the current control stack.
stack_offset: MachineStackOffset§save_area_offset: Option<MachineStackOffset>§machine: MLow-level machine state.
unreachable_depth: usizeNesting level of unreachable code.
local_func_index: LocalFunctionIndexIndex of a function defined locally inside the WebAssembly module.
relocations: Vec<Relocation>Relocation information.
special_labels: SpecialLabelSetA set of special labels for trapping.
calling_convention: CallingConventionCalling convention to use.
Implementations§
Source§impl<'a, M: Machine> FuncGen<'a, M>
impl<'a, M: Machine> FuncGen<'a, M>
fn get_stack_offset(&self) -> usize
Sourcefn acquire_location(
&mut self,
ty: &WpType,
) -> Result<Location<M::GPR, M::SIMD>, CompileError>
fn acquire_location( &mut self, ty: &WpType, ) -> Result<Location<M::GPR, M::SIMD>, CompileError>
Acquires location from the machine state.
If the returned location is used for stack value, release_location needs to be called on it;
Otherwise, if the returned locations is used for a local, release_location does not need to be called on it.
Sourcefn release_locations(
&mut self,
locs: &[(Location<M::GPR, M::SIMD>, CanonicalizeType)],
) -> Result<(), CompileError>
fn release_locations( &mut self, locs: &[(Location<M::GPR, M::SIMD>, CanonicalizeType)], ) -> Result<(), CompileError>
Releases locations used for stack value.
Sourcefn release_locations_value(
&mut self,
stack_depth: usize,
) -> Result<(), CompileError>
fn release_locations_value( &mut self, stack_depth: usize, ) -> Result<(), CompileError>
Releases locations used for stack value.
fn release_locations_only_regs( &mut self, locs: &[(Location<M::GPR, M::SIMD>, CanonicalizeType)], ) -> Result<(), CompileError>
fn release_locations_only_stack( &mut self, locs: &[(Location<M::GPR, M::SIMD>, CanonicalizeType)], ) -> Result<(), CompileError>
fn release_locations_keep_state( &mut self, stack_depth: usize, ) -> Result<(), CompileError>
fn init_locals( &mut self, n: usize, sig: FunctionType, calling_convention: CallingConvention, ) -> Result<Vec<Location<M::GPR, M::SIMD>>, CompileError>
fn finalize_locals( &mut self, calling_convention: CallingConvention, ) -> Result<(), CompileError>
Sourcepub fn set_srcloc(&mut self, offset: u32)
pub fn set_srcloc(&mut self, offset: u32)
Set the source location of the Wasm to the given offset.
fn get_location_released( &mut self, loc: (Location<M::GPR, M::SIMD>, CanonicalizeType), ) -> Result<(Location<M::GPR, M::SIMD>, CanonicalizeType), CompileError>
fn pop_value_released( &mut self, ) -> Result<(Location<M::GPR, M::SIMD>, CanonicalizeType), CompileError>
Sourcefn i2o1_prepare(
&mut self,
ty: WpType,
canonicalize: CanonicalizeType,
) -> Result<I2O1<M::GPR, M::SIMD>, CompileError>
fn i2o1_prepare( &mut self, ty: WpType, canonicalize: CanonicalizeType, ) -> Result<I2O1<M::GPR, M::SIMD>, CompileError>
Prepare data for binary operator with 2 inputs and 1 output.
Sourcefn emit_call_native<I: Iterator<Item = Location<M::GPR, M::SIMD>>, J: Iterator<Item = WpType>, F: FnOnce(&mut Self) -> Result<(), CompileError>>(
&mut self,
cb: F,
params: I,
params_type: J,
call_type: NativeCallType,
) -> Result<(), CompileError>
fn emit_call_native<I: Iterator<Item = Location<M::GPR, M::SIMD>>, J: Iterator<Item = WpType>, F: FnOnce(&mut Self) -> Result<(), CompileError>>( &mut self, cb: F, params: I, params_type: J, call_type: NativeCallType, ) -> Result<(), CompileError>
Emits a Native ABI call sequence.
The caller MUST NOT hold any temporary registers allocated by acquire_temp_gpr when calling
this function.
Sourcefn _emit_call_native_label<I: Iterator<Item = Location<M::GPR, M::SIMD>>, J: Iterator<Item = WpType>>(
&mut self,
label: DynamicLabel,
params: I,
params_type: J,
) -> Result<(), CompileError>
fn _emit_call_native_label<I: Iterator<Item = Location<M::GPR, M::SIMD>>, J: Iterator<Item = WpType>>( &mut self, label: DynamicLabel, params: I, params_type: J, ) -> Result<(), CompileError>
Emits a Native ABI call sequence, specialized for labels as the call target.
Sourcefn op_memory<F: FnOnce(&mut Self, bool, bool, i32, DynamicLabel, DynamicLabel) -> Result<(), CompileError>>(
&mut self,
cb: F,
) -> Result<(), CompileError>
fn op_memory<F: FnOnce(&mut Self, bool, bool, i32, DynamicLabel, DynamicLabel) -> Result<(), CompileError>>( &mut self, cb: F, ) -> Result<(), CompileError>
Emits a memory operation.
fn emit_head(&mut self) -> Result<(), CompileError>
pub fn new( module: &'a ModuleInfo, config: &'a Singlepass, vmoffsets: &'a VMOffsets, memory_styles: &'a PrimaryMap<MemoryIndex, MemoryStyle>, _table_styles: &'a PrimaryMap<TableIndex, TableStyle>, local_func_index: LocalFunctionIndex, local_types_excluding_arguments: &[WpType], machine: M, calling_convention: CallingConvention, ) -> Result<FuncGen<'a, M>, CompileError>
pub fn has_control_frames(&self) -> bool
pub fn feed_operator(&mut self, op: Operator<'_>) -> Result<(), CompileError>
pub fn finalize( self, data: &FunctionBodyData<'_>, ) -> Result<(CompiledFunction, Option<UnwindFrame>), CompileError>
fn sort_call_movs(movs: &mut [(Location<M::GPR, M::SIMD>, M::GPR)])
Auto Trait Implementations§
impl<'a, M> Freeze for FuncGen<'a, M>where
M: Freeze,
impl<'a, M> !RefUnwindSafe for FuncGen<'a, M>
impl<'a, M> Send for FuncGen<'a, M>
impl<'a, M> Sync for FuncGen<'a, M>
impl<'a, M> Unpin for FuncGen<'a, M>
impl<'a, M> !UnwindSafe for FuncGen<'a, M>
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more