Browse Source
This commit is a small cleanup to drop the usage of the `FuncEnv` trait. In https://github.com/bytecodealliance/wasmtime/pull/6358, we agreed on making `winch-codegen` directly depend on `wasmtime-environ`. Introducing a direct relatioship between `winch-codegen` and `wasmtime-environ` means that the `FuncEnv` trait is no longer serving its original purpose, and we can drop the usage of the trait and use the types exposed from `winch-codegen` directly instead. Even though this change drops the `FuncEnv` trait, it still keeps a `FuncEnv` struct, which is used during code generation.pull/6447/head
Saúl Cabrera
1 year ago
committed by
GitHub
18 changed files with 86 additions and 145 deletions
@ -1,14 +0,0 @@ |
|||
[package] |
|||
authors = ["The Winch Project Developers"] |
|||
name = "winch-environ" |
|||
description = "Implementation of Winch's function compilation environment" |
|||
license = "Apache-2.0 WITH LLVM-exception" |
|||
repository = "https://github.com/bytecodealliance/wasmtime" |
|||
version = "0.8.0" |
|||
edition.workspace = true |
|||
|
|||
|
|||
[dependencies] |
|||
winch-codegen = { workspace = true } |
|||
wasmtime-environ = { workspace = true } |
|||
wasmparser = { workspace = true } |
@ -1,39 +0,0 @@ |
|||
//! This crate implements Winch's function compilation environment,
|
|||
//! which allows Winch's code generation to resolve module and runtime
|
|||
//! specific information. This crate mainly implements the
|
|||
//! `winch_codegen::FuncEnv` trait.
|
|||
|
|||
use wasmparser::types::Types; |
|||
use wasmtime_environ::{FuncIndex, Module}; |
|||
use winch_codegen::{self, Callee}; |
|||
|
|||
/// Function environment containing module and runtime specific
|
|||
/// information.
|
|||
pub struct FuncEnv<'a> { |
|||
/// The translated WebAssembly module.
|
|||
pub module: &'a Module, |
|||
/// Type information about a module, once it has been validated.
|
|||
pub types: &'a Types, |
|||
} |
|||
|
|||
impl<'a> winch_codegen::FuncEnv for FuncEnv<'a> { |
|||
fn callee_from_index(&self, index: u32) -> Callee { |
|||
let func = self |
|||
.types |
|||
.function_at(index) |
|||
.unwrap_or_else(|| panic!("function type at index: {}", index)); |
|||
|
|||
Callee { |
|||
ty: func.clone(), |
|||
import: self.module.is_imported_function(FuncIndex::from_u32(index)), |
|||
index, |
|||
} |
|||
} |
|||
} |
|||
|
|||
impl<'a> FuncEnv<'a> { |
|||
/// Create a new function environment.
|
|||
pub fn new(module: &'a Module, types: &'a Types) -> Self { |
|||
Self { module, types } |
|||
} |
|||
} |
Loading…
Reference in new issue