From e2f96cb92f4df52221f29b24ae3fd347da38c274 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Fri, 11 Dec 2020 10:21:55 +0100 Subject: [PATCH] inline allthethings --- afl/src/mutators/mutations.rs | 3 +++ afl/src/observers/mod.rs | 11 ++++++++++- afl/src/stages/mutational.rs | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/afl/src/mutators/mutations.rs b/afl/src/mutators/mutations.rs index 572bc908c1..05448a7029 100644 --- a/afl/src/mutators/mutations.rs +++ b/afl/src/mutators/mutations.rs @@ -69,6 +69,7 @@ const INTERESTING_32: [i32; 27] = [ 2147483647, ]; +#[inline] fn self_mem_move(data: &mut [u8], from: usize, to: usize, len: usize) { debug_assert!(from + len <= data.len()); debug_assert!(to + len <= data.len()); @@ -76,6 +77,7 @@ fn self_mem_move(data: &mut [u8], from: usize, to: usize, len: usize) { unsafe { core::ptr::copy(ptr.offset(from as isize), ptr.offset(to as isize), len) } } +#[inline] fn mem_move(dst: &mut [u8], src: &[u8], from: usize, to: usize, len: usize) { debug_assert!(from + len <= src.len()); debug_assert!(to + len <= dst.len()); @@ -90,6 +92,7 @@ fn mem_move(dst: &mut [u8], src: &[u8], from: usize, to: usize, len: usize) { } } +#[inline] fn mem_set(data: &mut [u8], from: usize, len: usize, val: u8) { debug_assert!(from + len <= data.len()); let ptr = data.as_mut_ptr(); diff --git a/afl/src/observers/mod.rs b/afl/src/observers/mod.rs index fdcd1c0020..0901350791 100644 --- a/afl/src/observers/mod.rs +++ b/afl/src/observers/mod.rs @@ -13,7 +13,6 @@ use crate::AflError; /// Observers observe different information about the target. /// They can then be used by various sorts of feedback. pub trait Observer: SerdeAny + 'static { - /// The testcase finished execution, calculate any changes. #[inline] fn flush(&mut self) -> Result<(), AflError> { @@ -82,10 +81,12 @@ impl Observer for StdMapObserver where T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned, { + #[inline] fn reset(&mut self) -> Result<(), AflError> { self.reset_map() } + #[inline] fn name(&self) -> &String { &self.name } @@ -95,9 +96,12 @@ impl SerdeAny for StdMapObserver where T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned, { + #[inline] fn as_any(&self) -> &dyn Any { self } + + #[inline] fn as_any_mut(&mut self) -> &mut dyn Any { self } @@ -107,22 +111,27 @@ impl MapObserver for StdMapObserver where T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned, { + #[inline] fn map(&self) -> &[T] { self.map.as_slice() } + #[inline] fn map_mut(&mut self) -> &mut [T] { self.map.as_mut_slice() } + #[inline] fn initial(&self) -> T { self.initial } + #[inline] fn initial_mut(&mut self) -> &mut T { &mut self.initial } + #[inline] fn set_initial(&mut self, initial: T) { self.initial = initial } diff --git a/afl/src/stages/mutational.rs b/afl/src/stages/mutational.rs index ee3e26e386..21ce655393 100644 --- a/afl/src/stages/mutational.rs +++ b/afl/src/stages/mutational.rs @@ -34,6 +34,7 @@ where /// Gets the number of iterations this mutator should run for. /// This call uses internal mutability, so it may change for each call + #[inline] fn iterations(&mut self, rand: &mut R) -> usize { 1 + rand.below(128) as usize } @@ -107,11 +108,13 @@ where R: Rand, { /// The mutator, added to this stage + #[inline] fn mutator(&self) -> &M { &self.mutator } /// The list of mutators, added to this stage (as mutable ref) + #[inline] fn mutator_mut(&mut self) -> &mut M { &mut self.mutator } @@ -126,6 +129,7 @@ where I: Input, R: Rand, { + #[inline] fn perform( &mut self, rand: &mut R,