winch: Introduce winch-environ (#6017)
This commit introduces the `winch-environ` crate. This crate's responsibility is to provide a shared implementatation of the `winch_codegen::FuncEnv` trait, which is Winch's function compilation environment, used to resolve module and runtime specific information needed by the code generation, such as resolving all the details about a callee in a WebAssembly module, or resolving specific information from the `VMContext`. As of this change, the implementation only includes the necessary pieces to resolve a function callee in a WebAssembly module. The idea is to evolve the `winch_codegen::FuncEnv` trait as we evolve Winch's code generation.
This commit is contained in:
19
winch/codegen/src/codegen/env.rs
Normal file
19
winch/codegen/src/codegen/env.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use wasmparser::FuncType;
|
||||
|
||||
/// Function environment used the by the code generation to
|
||||
/// resolve module and runtime-specific information.
|
||||
pub trait FuncEnv {
|
||||
/// Get the callee information from a given function index.
|
||||
fn callee_from_index(&self, index: u32) -> Callee;
|
||||
}
|
||||
|
||||
/// Metadata about a function callee. Use by the code generation
|
||||
/// to emit function calls.
|
||||
pub struct Callee {
|
||||
/// The function type.
|
||||
pub ty: FuncType,
|
||||
/// A flag to determine if the callee is imported.
|
||||
pub import: bool,
|
||||
/// The callee index in the WebAssembly function index space.
|
||||
pub index: u32,
|
||||
}
|
||||
@@ -7,6 +7,8 @@ use wasmparser::{BinaryReader, FuncValidator, ValType, ValidatorResources, Visit
|
||||
|
||||
mod context;
|
||||
pub(crate) use context::*;
|
||||
mod env;
|
||||
pub use env::*;
|
||||
|
||||
/// The code generation abstraction.
|
||||
pub(crate) struct CodeGen<'a, M>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
mod abi;
|
||||
mod codegen;
|
||||
pub use codegen::{Callee, FuncEnv};
|
||||
mod frame;
|
||||
pub mod isa;
|
||||
pub use isa::*;
|
||||
|
||||
Reference in New Issue
Block a user