Some minor cleanups/refactorings in components (#4582)

This is a collection of some minor renamings, refactorings, sharing of
code, etc. This was all discovered during my addition of string support
to adapter functions and I figured it'd be best to frontload this and
land it ahead of the full patch since it's getting complex.
This commit is contained in:
Alex Crichton
2022-08-03 11:21:55 -05:00
committed by GitHub
parent 0a6baeddf4
commit 9f82644cc3
5 changed files with 66 additions and 76 deletions

View File

@@ -10,7 +10,7 @@ use std::any::Any;
/// Description of where a trampoline is located in the text section of a
/// compiled image.
#[derive(Serialize, Deserialize)]
pub struct LoweringInfo {
pub struct FunctionInfo {
/// The byte offset from the start of the text section where this trampoline
/// starts.
pub start: u32,
@@ -22,11 +22,8 @@ pub struct LoweringInfo {
/// `ComponentCompiler::compile_always_trap`.
#[derive(Serialize, Deserialize)]
pub struct AlwaysTrapInfo {
/// The byte offset from the start of the text section where this trampoline
/// starts.
pub start: u32,
/// The byte length of this trampoline's function body.
pub length: u32,
/// Information about the extent of this generated function.
pub info: FunctionInfo,
/// The offset from `start` of where the trapping instruction is located.
pub trap_offset: u32,
}
@@ -79,7 +76,7 @@ pub trait ComponentCompiler: Send + Sync {
tramplines: Vec<(SignatureIndex, Box<dyn Any + Send>)>,
obj: &mut Object<'static>,
) -> Result<(
PrimaryMap<LoweredIndex, LoweringInfo>,
PrimaryMap<LoweredIndex, FunctionInfo>,
PrimaryMap<RuntimeAlwaysTrapIndex, AlwaysTrapInfo>,
Vec<Trampoline>,
)>;