Tidy up trap-handling code.
This commit is contained in:
@@ -19,6 +19,7 @@ wasmtime-runtime = { path = "../runtime" }
|
||||
region = "1.0.0"
|
||||
failure = { version = "0.1.3", default-features = false }
|
||||
failure_derive = { version = "0.1.3", default-features = false }
|
||||
target-lexicon = "0.2.0"
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
||||
@@ -12,9 +12,10 @@ use std::slice;
|
||||
use std::string::String;
|
||||
use std::vec::Vec;
|
||||
use std::{mem, ptr};
|
||||
use target_tunables::target_tunables;
|
||||
use trampoline_park::TrampolinePark;
|
||||
use wasmtime_environ::{
|
||||
compile_module, Compilation, CompileError, DataInitializer, Module, ModuleEnvironment, Tunables,
|
||||
compile_module, Compilation, CompileError, DataInitializer, Module, ModuleEnvironment,
|
||||
};
|
||||
use wasmtime_runtime::{
|
||||
wasmtime_call_trampoline, Export, Imports, Instance, InstantiationError, VMFunctionBody,
|
||||
@@ -42,9 +43,7 @@ impl InstancePlus {
|
||||
resolver: &mut Resolver,
|
||||
) -> Result<Self, ActionError> {
|
||||
let mut module = Module::new();
|
||||
|
||||
// TODO: Allow the tunables to be overridden.
|
||||
let tunables = Tunables::default();
|
||||
let tunables = target_tunables(isa.triple());
|
||||
|
||||
let (lazy_function_body_inputs, lazy_data_initializers) = {
|
||||
let environ = ModuleEnvironment::new(isa, &mut module, tunables);
|
||||
|
||||
@@ -37,12 +37,14 @@ extern crate alloc;
|
||||
extern crate failure;
|
||||
#[macro_use]
|
||||
extern crate failure_derive;
|
||||
extern crate target_lexicon;
|
||||
|
||||
mod action;
|
||||
mod instance_plus;
|
||||
mod jit_code;
|
||||
mod link;
|
||||
mod resolver;
|
||||
mod target_tunables;
|
||||
mod trampoline_park;
|
||||
|
||||
pub use action::{ActionError, ActionOutcome, RuntimeValue};
|
||||
@@ -50,6 +52,7 @@ pub use instance_plus::InstancePlus;
|
||||
pub use jit_code::JITCode;
|
||||
pub use link::link_module;
|
||||
pub use resolver::{NullResolver, Resolver};
|
||||
pub use target_tunables::target_tunables;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod std {
|
||||
|
||||
@@ -320,7 +320,10 @@ fn relocate(
|
||||
FloorF64 => wasmtime_f64_floor as usize,
|
||||
TruncF64 => wasmtime_f64_trunc as usize,
|
||||
NearestF64 => wasmtime_f64_nearest as usize,
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
Probestack => __rust_probestack as usize,
|
||||
#[cfg(all(target_os = "windows", target_pointer_width = "64"))]
|
||||
Probestack => __chkstk as usize,
|
||||
other => panic!("unexpected libcall: {}", other),
|
||||
}
|
||||
}
|
||||
@@ -357,5 +360,8 @@ fn relocate(
|
||||
/// A declaration for the stack probe function in Rust's standard library, for
|
||||
/// catching callstack overflow.
|
||||
extern "C" {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pub fn __rust_probestack();
|
||||
#[cfg(all(target_os = "windows", target_pointer_width = "64"))]
|
||||
pub fn __chkstk();
|
||||
}
|
||||
|
||||
22
lib/execute/src/target_tunables.rs
Normal file
22
lib/execute/src/target_tunables.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use std::cmp::min;
|
||||
use target_lexicon::{OperatingSystem, Triple};
|
||||
use wasmtime_environ::Tunables;
|
||||
|
||||
/// Return a `Tunables` instance tuned for the given target platform.
|
||||
pub fn target_tunables(triple: &Triple) -> Tunables {
|
||||
let mut result = Tunables::default();
|
||||
|
||||
match triple.operating_system {
|
||||
OperatingSystem::Windows => {
|
||||
// For now, use a smaller footprint on Windows so that we don't
|
||||
// don't outstrip the paging file.
|
||||
// TODO: Make this configurable.
|
||||
result.static_memory_bound = min(result.static_memory_bound, 0x100);
|
||||
result.static_memory_offset_guard_size =
|
||||
min(result.static_memory_offset_guard_size, 0x10000);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
Reference in New Issue
Block a user