aboutsummaryrefslogtreecommitdiff
path: root/test/long_mode/reuse_test.rs
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2021-07-01 23:54:06 -0700
committeriximeow <me@iximeow.net>2021-07-01 23:54:06 -0700
commita781322552d9fb52b7b5e51641f49f12678f682f (patch)
treeb7ea7042d707dca8ffc322ddac4ebd5b8c475027 /test/long_mode/reuse_test.rs
parent889ce5c55af062d12cdd109bac22cc05565f68a6 (diff)
reallocate OperandCode, convert disparate registers to array
also remove redundant assignments of operand_count and some OperandSpec, bulk-assign all registers and operands on entry to `read_instr`. this all, taken together, shaves off about 7 cycles per decode.
Diffstat (limited to 'test/long_mode/reuse_test.rs')
-rw-r--r--test/long_mode/reuse_test.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/long_mode/reuse_test.rs b/test/long_mode/reuse_test.rs
index 117f3fa..60a91e1 100644
--- a/test/long_mode/reuse_test.rs
+++ b/test/long_mode/reuse_test.rs
@@ -1989,17 +1989,21 @@ const INSTRUCTIONS: [&'static [u8]; 1982] = [
#[test]
fn test_against_leftover_data() {
use super::rand::{thread_rng, Rng};
+ use yaxpeax_arch::U8Reader;
let mut rng = thread_rng();
let decoder = InstDecoder::default();
for _ in 0..100000 {
let first_vec = INSTRUCTIONS[rng.gen_range(0..INSTRUCTIONS.len())];
- let first_decode = decoder.decode(first_vec.to_vec().iter().cloned()).unwrap();
+ let mut first_reader = U8Reader::new(first_vec);
+ let first_decode = decoder.decode(&mut first_reader).unwrap();
let second_vec = INSTRUCTIONS[rng.gen_range(0..INSTRUCTIONS.len())];
- let mut reused_decode = decoder.decode(second_vec.to_vec().iter().cloned()).unwrap();
- decoder.decode_into(&mut reused_decode, first_vec.to_vec().iter().cloned()).unwrap();
+ let mut second_reader = U8Reader::new(second_vec);
+ let mut reused_decode = decoder.decode(&mut second_reader).unwrap();
+ let mut first_reader = U8Reader::new(first_vec);
+ decoder.decode_into(&mut reused_decode, &mut first_reader).unwrap();
assert_eq!(first_decode, reused_decode);
}