Struct CompiledFunctionsTable

Source
pub struct CompiledFunctionsTable { /* private fields */ }
Expand description

A table describing the set of functions compiled into an artifact, their locations within the text section, and etc…

Logically, this type is a map from a FuncKey to the associated function’s

  • location within the associated text section, and
  • optional source location.

How this map is actually implemented is with a series of lookup and binary search tables, split out in a data-oriented, struct-of-arrays style. We organize the data in this way is service of three goals:

  1. Provide fast look ups: We need to look up the metadata for a function by its key at runtime. During instantiation, for example, we need to create VMFuncRefs for escaping functions and this requires looking up the locations of those Wasm functions and their associated array-to-Wasm trampolines.

  2. Keep memory overheads low and code size small: This type is serialized into all of our ELF artifacts and deserialized into all Modules and Components at runtime.

  3. Be generic over any kind of function (whether defined Wasm function, trampoline, or etc…) that we compile: Adding a new kind of trampoline, for example, should not require updating this structure to add a new table of the function locations for just trampolines of that new kind. We should be able to store and query all kinds of functions uniformly.

Implementations§

Source§

impl CompiledFunctionsTable

Source

pub fn func_loc(&self, key: FuncKey) -> Option<&FunctionLoc>

Get the location of the function associated with the given key inside the text section, if any.

Source

pub fn src_loc(&self, key: FuncKey) -> Option<FilePos>

Get the initial source location of the function associated with the given key, if any.

Source

pub fn func_by_text_offset(&self, text_offset: u32) -> Option<FuncKey>

Given an offset into the text section, get the key for its associated function and its offset within that function.

Trait Implementations§

Source§

impl Debug for CompiledFunctionsTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CompiledFunctionsTable

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for CompiledFunctionsTable

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,