Review feedback.

This commit is contained in:
Chris Fallin
2022-01-31 16:11:25 -08:00
parent 570dee63f3
commit 982df2f2e5
7 changed files with 332 additions and 310 deletions

View File

@@ -69,45 +69,13 @@ pub use module_id::{CompiledModuleId, CompiledModuleIdAllocator};
#[cfg(feature = "memfd-allocator")]
mod memfd;
#[cfg(feature = "memfd-allocator")]
pub use crate::memfd::{MemFdSlot, MemoryMemFd, ModuleMemFds};
pub use crate::memfd::MemoryMemFd;
/// When memfd support is not included, provide a shim type and
/// constructor instead so that higher-level code does not need
/// feature-conditional compilation.
#[cfg(not(feature = "memfd-allocator"))]
#[allow(dead_code)]
mod memfd {
use anyhow::Result;
use std::sync::Arc;
use wasmtime_environ::{DefinedMemoryIndex, Module};
/// A shim for the memfd image container when memfd support is not
/// included.
pub enum ModuleMemFds {}
/// A shim for an individual memory image.
#[allow(dead_code)]
pub enum MemoryMemFd {}
impl ModuleMemFds {
/// Construct a new set of memfd images. This variant is used
/// when memfd support is not included; it always returns no
/// images.
pub fn new(_: &Module, _: &[u8]) -> Result<Option<Arc<ModuleMemFds>>> {
Ok(None)
}
/// Get the memfd image for a particular memory.
pub(crate) fn get_memory_image(&self, _: DefinedMemoryIndex) -> Option<&Arc<MemoryMemFd>> {
// Should be unreachable because the `Self` type is
// uninhabitable.
match *self {}
}
}
}
pub use crate::memfd::ModuleMemFds;
mod memfd_disabled;
#[cfg(not(feature = "memfd-allocator"))]
pub use crate::memfd_disabled::{MemFdSlot, MemoryMemFd, ModuleMemFds};
/// Version number of this crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");