pub struct FuncGen<'a, M: Machine> {Show 19 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<M>>,
stack_offset: usize,
save_area_offset: Option<usize>,
machine: M,
unreachable_depth: usize,
local_func_index: LocalFunctionIndex,
relocations: Vec<Relocation>,
special_labels: SpecialLabelSet,
calling_convention: CallingConvention,
function_name: String,
assembly_comments: HashMap<usize, AssemblyComment>,
}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<M>>A list of frames describing the current control stack.
stack_offset: usizeStack offset tracking in bytes.
save_area_offset: Option<usize>§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.
function_name: StringName of the function.
assembly_comments: HashMap<usize, AssemblyComment>Assembly comments.
Implementations§
Source§impl<'a, M: Machine> FuncGen<'a, M>
impl<'a, M: Machine> FuncGen<'a, M>
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 acquire_location_on_stack(
&mut self,
) -> Result<Location<M::GPR, M::SIMD>, CompileError>
fn acquire_location_on_stack( &mut self, ) -> Result<Location<M::GPR, M::SIMD>, CompileError>
Acquire location that will live on the stack.
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.
fn release_reg_locations( &mut self, locs: &[(Location<M::GPR, M::SIMD>, CanonicalizeType)], ) -> Result<(), CompileError>
fn release_stack_locations( &mut self, locs: &[(Location<M::GPR, M::SIMD>, CanonicalizeType)], ) -> Result<(), CompileError>
fn release_stack_locations_keep_stack_offset( &mut self, stack_depth: usize, ) -> Result<(), CompileError>
fn check_location_on_stack( &self, loc: &Location<M::GPR, M::SIMD>, expected_stack_offset: usize, ) -> Result<(), CompileError>
Sourcefn allocate_return_slots_and_swap(
&mut self,
stack_slots: usize,
return_slots: usize,
) -> Result<(), CompileError>
fn allocate_return_slots_and_swap( &mut self, stack_slots: usize, return_slots: usize, ) -> Result<(), CompileError>
Allocate return slots for block operands (Block, If, Loop) and swap them with the corresponding input parameters on the value stack.
This method reserves memory slots that can accommodate both integer and
floating-point types, then swaps these slots with the last stack_slots
values on the stack to position them correctly for the block’s return values.
that are already present at the value stack.
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>, CanonicalizeType)>, J: Iterator<Item = WpType>, K: Iterator<Item = WpType>, F: FnOnce(&mut Self) -> Result<(), CompileError>>(
&mut self,
cb: F,
params: I,
params_type: J,
return_types: K,
call_type: NativeCallType,
) -> Result<(), CompileError>
fn emit_call_native<I: Iterator<Item = (Location<M::GPR, M::SIMD>, CanonicalizeType)>, J: Iterator<Item = WpType>, K: Iterator<Item = WpType>, F: FnOnce(&mut Self) -> Result<(), CompileError>>( &mut self, cb: F, params: I, params_type: J, return_types: K, 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 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
Sourcefn emit_return_values(
&mut self,
value_stack_depth_after: usize,
return_values: usize,
) -> Result<(), CompileError>
fn emit_return_values( &mut self, value_stack_depth_after: usize, return_values: usize, ) -> Result<(), CompileError>
Moves the top return_values items from the value stack into the
preallocated return slots starting at value_stack_depth_after.
Used when completing Block/If/Loop constructs or returning from the function. Applies NaN canonicalization when enabled and supported.
Sourcefn emit_loop_params_store(
&mut self,
value_stack_depth_after: usize,
param_count: usize,
) -> Result<(), CompileError>
fn emit_loop_params_store( &mut self, value_stack_depth_after: usize, param_count: usize, ) -> Result<(), CompileError>
Similar to emit_return_values, except it stores the return_values items into the slots
preallocated for parameters of a loop.
fn return_types_for_block( &self, block_type: WpTypeOrFuncType, ) -> SmallVec<[WpType; 1]>
fn param_types_for_block( &self, block_type: WpTypeOrFuncType, ) -> SmallVec<[WpType; 8]>
pub fn feed_operator(&mut self, op: Operator<'_>) -> Result<(), CompileError>
fn add_assembly_comment(&mut self, comment: AssemblyComment)
pub fn finalize( self, data: &FunctionBodyData<'_>, arch: Architecture, ) -> 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