test(compiler): opt-in checks of every 32-bit word at five PCs that the direct integer path goes past no decoder of the lift or of the block parse that would take the word, where upstream PR #247's own tests sample a million words and its full check was never committed
every_direct_word_skips_every_decoder_before_the_integer_one and every_direct_word_skips_the_block_decoders run on all host threads in release, at PCs 0, 0x1000, a user and a kernel address and the highest word, where branch and literal targets overflow. They are the proof to rerun when a decoder is added before the integer one or to the parse.
This commit is contained in:
1 parent
84a3106593
commit
0e458bf4e7
4 files changed
+93
-1
No files matched your search
@@ -832,4 +832,4 @@ fn lift_integer(pc: GuestAddress, word: u32) -> Result<Operation, UnsupportedRea
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
pub(crate) mod tests;
|
||||
@@ -73,6 +73,58 @@ fn direct_classes_skip_no_decoder() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The PCs the checks of every word run at: the lowest, a page's, a user
|
||||
/// one, a kernel one and the highest, where branch and literal targets
|
||||
/// overflow.
|
||||
pub(crate) const EVERY_WORD_PCS: [u64; 5] = [
|
||||
0,
|
||||
0x1000,
|
||||
0x1_0000_4000,
|
||||
0xffff_fe00_0bbc_0000,
|
||||
u64::MAX - 3,
|
||||
];
|
||||
|
||||
/// The first word at each of [`EVERY_WORD_PCS`] that `wrong` holds for, of
|
||||
/// every 32-bit word, on all of the host's threads.
|
||||
pub(crate) fn first_wrong_word(
|
||||
wrong: impl Fn(GuestAddress, u32) -> bool + Sync,
|
||||
) -> Option<(u64, u32)> {
|
||||
let threads = std::thread::available_parallelism().map_or(4, |n| n.get());
|
||||
let chunk = (1u64 << 32).div_ceil(threads as u64);
|
||||
let wrong = &wrong;
|
||||
EVERY_WORD_PCS.into_iter().find_map(|pc| {
|
||||
std::thread::scope(|scope| {
|
||||
let workers: alloc::vec::Vec<_> = (0..threads as u64)
|
||||
.map(|thread| {
|
||||
scope.spawn(move || {
|
||||
let end = ((thread + 1) * chunk).min(1 << 32);
|
||||
(thread * chunk..end)
|
||||
.map(|word| word as u32)
|
||||
.find(|&word| wrong(GuestAddress(pc), word))
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
workers
|
||||
.into_iter()
|
||||
.filter_map(|worker| worker.join().unwrap())
|
||||
.min()
|
||||
.map(|word| (pc, word))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// [`direct_classes_skip_no_decoder`] for every word at each of
|
||||
/// [`EVERY_WORD_PCS`]: no decoder before [`lift_integer`] takes a word
|
||||
/// [`skips_decoders`] sends there. Opt-in, in release: `cargo test -p
|
||||
/// stela-compiler --release --lib every_direct_word -- --ignored`.
|
||||
#[test]
|
||||
#[ignore = "manual: opt-in"]
|
||||
fn every_direct_word_skips_every_decoder_before_the_integer_one() {
|
||||
let wrong =
|
||||
first_wrong_word(|pc, word| skips_decoders(pc, word) && taken_before_integer(pc, word));
|
||||
assert_eq!(wrong, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn synchronization_admits_only_context_independent_effects() {
|
||||
const YIELD_WORD: u32 = 0xd503_203f;
|
||||
|
||||
@@ -2380,3 +2380,27 @@ fn direct_words_skip_the_block_decoders() {
|
||||
}
|
||||
assert!(direct > 100_000, "{direct}");
|
||||
}
|
||||
|
||||
/// [`direct_words_skip_the_block_decoders`] for every word at each of
|
||||
/// [`crate::aarch64::tests::EVERY_WORD_PCS`]: none of the parse's own
|
||||
/// decoders takes a word `aarch64::skips_decoders` sends past them. Opt-in,
|
||||
/// in release: `cargo test -p stela-compiler --release --lib every_direct_word
|
||||
/// -- --ignored`.
|
||||
#[test]
|
||||
#[ignore = "manual: opt-in"]
|
||||
fn every_direct_word_skips_the_block_decoders() {
|
||||
let wrong = crate::aarch64::tests::first_wrong_word(|pc, word| {
|
||||
crate::aarch64::skips_decoders(pc, word) && {
|
||||
let synchronization = crate::aarch64::system::synchronization::decode(word);
|
||||
synchronization.is_some()
|
||||
|| decode_pointer_authentication(pc, word) != Ok(None)
|
||||
|| system::decode_system_mode_with_sync(pc, word, synchronization) != Ok(None)
|
||||
|| decode_system_instruction(pc, word) != Ok(None)
|
||||
|| decode_clock_instruction(pc, word) != Ok(None)
|
||||
|| decode_thread_register_instruction(pc, word) != Ok(None)
|
||||
|| crate::amx::decode(pc, word) != Ok(None)
|
||||
|| decode_terminator(pc, word) != Ok(None)
|
||||
}
|
||||
});
|
||||
assert_eq!(wrong, None);
|
||||
}
|
||||
@@ -5277,6 +5277,22 @@
|
||||
"inputs": [],
|
||||
"reason": "host timing of the run loop's fixed cost per native run, on one PE and on parallel hubs of one, two and four PEs; run in release on request"
|
||||
},
|
||||
{
|
||||
"package": "stela-compiler",
|
||||
"test": "every_direct_word_skips_every_decoder_before_the_integer_one",
|
||||
"source": "crates/stela-compiler/src/aarch64/tests.rs",
|
||||
"kind": "manual",
|
||||
"inputs": [],
|
||||
"reason": "every 32-bit word at five PCs against the lift's decoders that the direct integer path goes past; run in release on request"
|
||||
},
|
||||
{
|
||||
"package": "stela-compiler",
|
||||
"test": "every_direct_word_skips_the_block_decoders",
|
||||
"source": "crates/stela-compiler/src/block/tests.rs",
|
||||
"kind": "manual",
|
||||
"inputs": [],
|
||||
"reason": "every 32-bit word at five PCs against the block parse's own decoders that the direct integer path goes past; run in release on request"
|
||||
},
|
||||
{
|
||||
"package": "stela-engine",
|
||||
"test": "reinstall_cost",
|
||||
|
||||
Reference in new issue
Block a user