wasmtime: enable stack probing for x86_64 targets. (#5350)
* wasmtime: enable stack probing for x86_64 targets. This commit unconditionally enables stack probing for x86_64 targets. On Windows, stack probing is always required because of the way Windows commits stack pages (via guard page access). Fixes #5340. * Remove SIMD types from test case.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
use anyhow::Result;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
|
||||
use wasmtime::*;
|
||||
|
||||
#[test]
|
||||
fn host_always_has_some_stack() -> anyhow::Result<()> {
|
||||
fn host_always_has_some_stack() -> Result<()> {
|
||||
static HITS: AtomicUsize = AtomicUsize::new(0);
|
||||
// assume hosts always have at least 128k of stack
|
||||
const HOST_STACK: usize = 128 * 1024;
|
||||
@@ -54,3 +55,35 @@ fn host_always_has_some_stack() -> anyhow::Result<()> {
|
||||
consume_some_stack(space.as_mut_ptr() as usize, stack.saturating_sub(1024))
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn big_stack_works_ok() -> Result<()> {
|
||||
const N: usize = 10000;
|
||||
|
||||
// Build a module with a function that uses a very large amount of stack space,
|
||||
// modeled here by calling an i64-returning-function many times followed by
|
||||
// adding them all into one i64.
|
||||
//
|
||||
// This should exercise the ability to consume multi-page stacks and
|
||||
// only touch a few internals of it at a time.
|
||||
let mut s = String::new();
|
||||
s.push_str("(module\n");
|
||||
s.push_str("(func (export \"\") (result i64)\n");
|
||||
s.push_str("i64.const 0\n");
|
||||
for _ in 0..N {
|
||||
s.push_str("call $get\n");
|
||||
}
|
||||
for _ in 0..N {
|
||||
s.push_str("i64.add\n");
|
||||
}
|
||||
s.push_str(")\n");
|
||||
s.push_str("(func $get (result i64) i64.const 0)\n");
|
||||
s.push_str(")\n");
|
||||
|
||||
let mut store = Store::<()>::default();
|
||||
let module = Module::new(store.engine(), &s)?;
|
||||
let instance = Instance::new(&mut store, &module, &[])?;
|
||||
let func = instance.get_typed_func::<(), i64>(&mut store, "")?;
|
||||
assert_eq!(func.call(&mut store, ())?, 0);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user