Rewrite linear memory handling in terms of simple mmap/VirtualAlloc.

The memmap crate doesn't make it straightforward to have part of the
region be writeable and part readonly. Since this is a fairly boutique
use case, and we don't need all that much code, just use the low-level
APIs directly.

Also, introduce a concept of "tunables" for adjusting the parameters of
the runtime.
This commit is contained in:
Dan Gohman
2018-11-29 10:11:11 -08:00
parent 1b98efd979
commit f44fe25f9c
13 changed files with 359 additions and 111 deletions

View File

@@ -56,7 +56,7 @@ use std::path::PathBuf;
use std::process;
use std::str::FromStr;
use target_lexicon::Triple;
use wasmtime_environ::{compile_module, Module, ModuleEnvironment};
use wasmtime_environ::{compile_module, Module, ModuleEnvironment, Tunables};
use wasmtime_obj::emit_module;
const USAGE: &str = "
@@ -136,7 +136,9 @@ fn handle_module(path: PathBuf, target: &Option<String>, output: &str) -> Result
let mut obj = Artifact::new(isa.triple().clone(), String::from(output));
let mut module = Module::new();
let environ = ModuleEnvironment::new(&*isa, &mut module);
// TODO: Expose the tunables as command-line flags.
let tunables = Tunables::default();
let environ = ModuleEnvironment::new(&*isa, &mut module, tunables);
let translation = environ.translate(&data).map_err(|e| e.to_string())?;
// FIXME: We need to initialize memory in a way that supports alternate