cranelift: Fuzz inline stack probes on x86 (#5185)

This commit is contained in:
Afonso Bordado
2022-11-03 15:12:31 +00:00
committed by GitHub
parent 2688b44915
commit 311b01875f
2 changed files with 28 additions and 1 deletions

View File

@@ -37,6 +37,8 @@ pub struct Config {
pub static_stack_slots_per_function: RangeInclusive<usize>,
/// Size in bytes
pub static_stack_slot_size: RangeInclusive<usize>,
/// Allowed stack probe sizes
pub stack_probe_size_log2: RangeInclusive<usize>,
/// Determines how often we generate a backwards branch
/// Backwards branches are prone to infinite loops, and thus cause timeouts.
@@ -80,6 +82,19 @@ impl Default for Config {
funcrefs_per_function: 0..=8,
static_stack_slots_per_function: 0..=8,
static_stack_slot_size: 0..=128,
// We need the mix of sizes that allows us to:
// * not generates any stack probes
// * generate unrolled stack probes
// * generate loop stack probes
//
// This depends on the total amount of stack space that we have for this function
// (controlled by `static_stack_slots_per_function` and `static_stack_slot_size`)
//
// 1<<6 = 64 and 1<<14 = 16384
//
// This range allows us to generate all 3 cases within the current allowed
// stack size range.
stack_probe_size_log2: 6..=14,
// 0.1% allows us to explore this, while not causing enough timeouts to significantly
// impact execs/s
backwards_branch_ratio: (1, 1000),

View File

@@ -238,7 +238,6 @@ where
builder.set("opt_level", &format!("{}", opt)[..])?;
// Boolean flags
// TODO: probestack is semantics preserving, but only works inline and on x64
// TODO: enable_pinned_reg does not work with our current trampolines. See: #4376
// TODO: is_pic has issues:
// x86: https://github.com/bytecodealliance/wasmtime/issues/5005
@@ -267,6 +266,19 @@ where
builder.set(flag_name, value.as_str())?;
}
// Optionally test inline stackprobes on x86
// TODO: inline stack probes are not available on AArch64
// TODO: Test outlined stack probes.
if cfg!(target_arch = "x86_64") && bool::arbitrary(self.u)? {
builder.enable("enable_probestack")?;
builder.set("probestack_strategy", "inline")?;
let size = self
.u
.int_in_range(self.config.stack_probe_size_log2.clone())?;
builder.set("probestack_size_log2", &format!("{}", size))?;
}
// Fixed settings
// We need llvm ABI extensions for i128 values on x86, so enable it regardless of