Remove some dead code (#3970)

This commit removes methods that are never used between crates or trait
impls like `Clone` which may have been used one day but are no longer used.
This commit is contained in:
Alex Crichton
2022-03-30 13:51:34 -05:00
committed by GitHub
parent d1d10dc8da
commit 453feb6f82
6 changed files with 11 additions and 46 deletions

View File

@@ -17,7 +17,7 @@ use thiserror::Error;
/// Information about a function, such as trap information, address map, /// Information about a function, such as trap information, address map,
/// and stack maps. /// and stack maps.
#[derive(Serialize, Deserialize, Clone, Default)] #[derive(Serialize, Deserialize, Default)]
#[allow(missing_docs)] #[allow(missing_docs)]
pub struct FunctionInfo { pub struct FunctionInfo {
pub start_srcloc: FilePos, pub start_srcloc: FilePos,
@@ -31,7 +31,7 @@ pub struct FunctionInfo {
/// Information about a compiled trampoline which the host can call to enter /// Information about a compiled trampoline which the host can call to enter
/// wasm. /// wasm.
#[derive(Serialize, Deserialize, Clone)] #[derive(Serialize, Deserialize)]
#[allow(missing_docs)] #[allow(missing_docs)]
pub struct Trampoline { pub struct Trampoline {
/// The signature this trampoline is for /// The signature this trampoline is for
@@ -45,7 +45,7 @@ pub struct Trampoline {
/// The offset within a function of a GC safepoint, and its associated stack /// The offset within a function of a GC safepoint, and its associated stack
/// map. /// map.
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] #[derive(Serialize, Deserialize, Debug)]
pub struct StackMapInformation { pub struct StackMapInformation {
/// The offset of the GC safepoint within the function's native code. It is /// The offset of the GC safepoint within the function's native code. It is
/// relative to the beginning of the function. /// relative to the beginning of the function.

View File

@@ -128,7 +128,7 @@ pub struct StaticMemoryInitializer {
} }
/// The type of WebAssembly linear memory initialization to use for a module. /// The type of WebAssembly linear memory initialization to use for a module.
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub enum MemoryInitialization { pub enum MemoryInitialization {
/// Memory initialization is segmented. /// Memory initialization is segmented.
/// ///
@@ -779,7 +779,7 @@ pub struct TableInitializer {
} }
/// Table initialization data for all tables in the module. /// Table initialization data for all tables in the module.
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub enum TableInitialization { pub enum TableInitialization {
/// "Segment" mode: table initializer segments, possibly with /// "Segment" mode: table initializer segments, possibly with
/// dynamic bases, possibly applying to an imported memory. /// dynamic bases, possibly applying to an imported memory.
@@ -850,7 +850,7 @@ impl ModuleType {
/// A translated WebAssembly module, excluding the function bodies and /// A translated WebAssembly module, excluding the function bodies and
/// memory initializers. /// memory initializers.
#[derive(Default, Debug, Clone, Serialize, Deserialize)] #[derive(Default, Debug, Serialize, Deserialize)]
pub struct Module { pub struct Module {
/// The name of this wasm module, often found in the wasm file. /// The name of this wasm module, often found in the wasm file.
pub name: Option<String>, pub name: Option<String>,
@@ -916,7 +916,7 @@ pub struct Module {
/// Initialization routines for creating an instance, encompassing imports, /// Initialization routines for creating an instance, encompassing imports,
/// modules, instances, aliases, etc. /// modules, instances, aliases, etc.
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub enum Initializer { pub enum Initializer {
/// An imported item is required to be provided. /// An imported item is required to be provided.
Import { Import {
@@ -936,12 +936,6 @@ impl Module {
Module::default() Module::default()
} }
/// Get the given passive element, if it exists.
pub fn get_passive_element(&self, index: ElemIndex) -> Option<&[FuncIndex]> {
let index = *self.passive_elements_map.get(&index)?;
Some(self.passive_elements[index].as_ref())
}
/// Convert a `DefinedFuncIndex` into a `FuncIndex`. /// Convert a `DefinedFuncIndex` into a `FuncIndex`.
#[inline] #[inline]
pub fn func_index(&self, defined_func: DefinedFuncIndex) -> FuncIndex { pub fn func_index(&self, defined_func: DefinedFuncIndex) -> FuncIndex {
@@ -1086,7 +1080,7 @@ impl Module {
/// ///
/// Note that this is shared amongst all modules coming out of a translation /// Note that this is shared amongst all modules coming out of a translation
/// in the case of nested modules and the module linking proposal. /// in the case of nested modules and the module linking proposal.
#[derive(Default, Debug, Clone, Serialize, Deserialize)] #[derive(Default, Debug, Serialize, Deserialize)]
#[allow(missing_docs)] #[allow(missing_docs)]
pub struct TypeTables { pub struct TypeTables {
pub(crate) wasm_signatures: PrimaryMap<SignatureIndex, WasmFuncType>, pub(crate) wasm_signatures: PrimaryMap<SignatureIndex, WasmFuncType>,
@@ -1109,7 +1103,7 @@ impl Index<SignatureIndex> for TypeTables {
} }
/// Type information about functions in a wasm module. /// Type information about functions in a wasm module.
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct FunctionType { pub struct FunctionType {
/// The type of this function, indexed into the module-wide type tables for /// The type of this function, indexed into the module-wide type tables for
/// a module compilation. /// a module compilation.

View File

@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
/// Note that this is currently primarily documented as cranelift's /// Note that this is currently primarily documented as cranelift's
/// `binemit::StackMap`, so for detailed documentation about this please read /// `binemit::StackMap`, so for detailed documentation about this please read
/// the docs over there. /// the docs over there.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct StackMap { pub struct StackMap {
bits: Box<[u32]>, bits: Box<[u32]>,
mapped_words: u32, mapped_words: u32,

View File

@@ -776,22 +776,6 @@ impl<P: PtrSize> VMOffsets<P> {
} }
} }
/// Target specific type for shared signature index.
#[derive(Debug, Copy, Clone)]
pub struct TargetSharedSignatureIndex(u32);
impl TargetSharedSignatureIndex {
/// Constructs `TargetSharedSignatureIndex`.
pub fn new(value: u32) -> Self {
Self(value)
}
/// Returns index value.
pub fn index(self) -> u32 {
self.0
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::vmoffsets::align; use crate::vmoffsets::align;

View File

@@ -518,11 +518,6 @@ impl CompiledModule {
&self.module &self.module
} }
/// Returns the `FunctionInfo` map for all defined functions.
pub fn functions(&self) -> &PrimaryMap<DefinedFuncIndex, FunctionInfo> {
&self.funcs
}
/// Looks up the `name` section name for the function index `idx`, if one /// Looks up the `name` section name for the function index `idx`, if one
/// was specified in the original wasm module. /// was specified in the original wasm module.
pub fn func_name(&self, idx: FuncIndex) -> Option<&str> { pub fn func_name(&self, idx: FuncIndex) -> Option<&str> {

View File

@@ -502,7 +502,7 @@ pub struct VMSharedSignatureIndex(u32);
mod test_vmshared_signature_index { mod test_vmshared_signature_index {
use super::VMSharedSignatureIndex; use super::VMSharedSignatureIndex;
use std::mem::size_of; use std::mem::size_of;
use wasmtime_environ::{Module, TargetSharedSignatureIndex, VMOffsets}; use wasmtime_environ::{Module, VMOffsets};
#[test] #[test]
fn check_vmshared_signature_index() { fn check_vmshared_signature_index() {
@@ -513,14 +513,6 @@ mod test_vmshared_signature_index {
usize::from(offsets.size_of_vmshared_signature_index()) usize::from(offsets.size_of_vmshared_signature_index())
); );
} }
#[test]
fn check_target_shared_signature_index() {
assert_eq!(
size_of::<VMSharedSignatureIndex>(),
size_of::<TargetSharedSignatureIndex>()
);
}
} }
impl VMSharedSignatureIndex { impl VMSharedSignatureIndex {