Files
wasmtime/tests/all/main.rs
Chris Fallin 666c2554ea Merge pull request from GHSA-gwc9-348x-qwv2
* Run the GC smoketest with epoch support enabled as well.

* Handle safepoints in cold blocks properly.

Currently, the way that we find safepoint slots for a given instruction
relies on the instruction index order in the safepoint list matching the
order of instruction emission.

Previous to the introduction of cold-block support, this was trivially
satisfied by sorting the safepoint list: we emit instructions 0, 1, 2,
3, 4, ..., and so if we have safepoints at instructions 1 and 4, we will
encounter them in that order.

However, cold blocks are supported by swizzling the emission order at
the last moment (to avoid having to renumber instructions partway
through the compilation pipeline), so we actually emit instructions out
of index order when cold blocks are present.

Reference-type support in Wasm in particular uses cold blocks for
slowpaths, and has live refs and safepoints in these slowpaths, so we
can reliably "skip" a safepoint (not emit any metadata for it) in the
presence of reftype usage.

This PR fixes the emission code by building a map from instruction index
to safepoint index first, then doing lookups through this map, rather
than following along in-order as it emits instructions.
2022-03-31 14:26:01 -07:00

67 lines
1.6 KiB
Rust

mod async_functions;
mod call_hook;
mod cli_tests;
mod custom_signal_handler;
mod debug;
mod epoch_interruption;
mod externals;
mod fuel;
mod func;
mod funcref;
mod gc;
mod globals;
mod host_funcs;
mod iloop;
mod import_calling_export;
mod import_indexes;
mod instance;
mod invoke_func_via_table;
mod limits;
mod linker;
mod memory;
mod memory_creator;
mod module;
mod module_serialize;
mod name;
mod pooling_allocator;
mod relocs;
mod stack_overflow;
mod store;
mod table;
mod traps;
mod wast;
/// A helper to compile a module in a new store with reference types enabled.
pub(crate) fn ref_types_module(
use_epochs: bool,
source: &str,
) -> anyhow::Result<(wasmtime::Store<()>, wasmtime::Module)> {
use wasmtime::*;
let _ = env_logger::try_init();
let mut config = Config::new();
config.wasm_reference_types(true);
if use_epochs {
config.epoch_interruption(true);
}
let engine = Engine::new(&config)?;
let mut store = Store::new(&engine, ());
if use_epochs {
store.set_epoch_deadline(1);
}
let module = Module::new(&engine, source)?;
Ok((store, module))
}
/// A helper determining whether the pooling allocator tests should be skipped.
pub(crate) fn skip_pooling_allocator_tests() -> bool {
// There are a couple of issues when running the pooling allocator tests under QEMU:
// - high memory usage that may exceed the limits imposed by the environment (e.g. CI)
// - https://github.com/bytecodealliance/wasmtime/pull/2518#issuecomment-747280133
std::env::var("WASMTIME_TEST_NO_HOG_MEMORY").is_ok()
}