Fix some reviewed items

This commit is contained in:
Lachlan Sneff
2019-01-29 12:49:51 -08:00
parent d73c7015fb
commit 767fdbd950
6 changed files with 31 additions and 7 deletions

View File

@ -13,14 +13,14 @@ pub struct Global {
impl Global {
pub fn new(value: Value) -> Self {
Self::_new(value, false)
Self::new_internal(value, false)
}
pub fn new_mutable(value: Value) -> Self {
Self::_new(value, true)
Self::new_internal(value, true)
}
fn _new(value: Value, mutable: bool) -> Self {
fn new_internal(value: Value, mutable: bool) -> Self {
let desc = GlobalDesc {
mutable,
ty: value.ty(),

View File

@ -7,6 +7,19 @@ use crate::{
pub const DYNAMIC_GUARD_SIZE: usize = 4096;
/// This is an internal-only api.
///
/// A Dynamic memory allocates only the minimum amount of memory
/// when first created. Over time, as it grows, it may reallocate to
/// a different location and size.
///
/// Dynamic memories are signifigantly faster to create than static
/// memories and use much less virtual memory, however, they require
/// the webassembly module to bounds-check memory accesses.
///
/// While, a dynamic memory could use a vector of some sort as its
/// backing memory, we use mmap (or the platform-equivalent) to allow
/// us to add a guard-page at the end to help elide some bounds-checks.
pub struct DynamicMemory {
memory: sys::Memory,
current: u32,

View File

@ -8,6 +8,17 @@ use crate::{
vm,
};
/// This is an internal-only api.
///
/// A static memory allocates 6GB of *virtual* memory when created
/// in order to allow the webassembly module to contain no bounds-checks.
///
/// Additionally, static memories stay at a single virtual address, so there is no need
/// to reload its address on each use.
///
/// Static memories take a relatively long time to create, so if memories are short-lived,
/// it's recommended that a dynamic memory is used. There is currently no user-facing api that
/// allows them to select the type of memory used however.
pub struct StaticMemory {
memory: sys::Memory,
current: u32,

View File

@ -27,7 +27,7 @@ struct GlobalSigRegistry {
pub struct SigRegistry;
impl SigRegistry {
pub fn lookup_sigindex<Sig>(&self, func_sig: Sig) -> SigIndex
pub fn lookup_sig_index<Sig>(&self, func_sig: Sig) -> SigIndex
where
Sig: Into<Arc<FuncSig>>,
{

View File

@ -106,7 +106,7 @@ impl AnyfuncTable {
if let Some(slot) = self.backing.get_mut(index as usize) {
let anyfunc = match element.inner {
AnyfuncInner::Host { ptr, signature } => {
let sig_index = SigRegistry.lookup_sigindex(signature);
let sig_index = SigRegistry.lookup_sig_index(signature);
let sig_id = vm::SigId(sig_index.index() as u32);
vm::Anyfunc {
@ -116,7 +116,7 @@ impl AnyfuncTable {
}
}
AnyfuncInner::Managed(ref func) => {
let sig_index = SigRegistry.lookup_sigindex(Arc::clone(&func.signature));
let sig_index = SigRegistry.lookup_sig_index(Arc::clone(&func.signature));
let sig_id = vm::SigId(sig_index.index() as u32);
vm::Anyfunc {