Somewhere in the past we have observed a comparison instructions with arguments Arg1 Arg2. This function tries to guess a dictionary entry that will satisfy that comparison. It first tries to find one of the arguments (possibly swapped) in the input and if it succeeds it creates a DE with a position hint. Otherwise it creates a DE with one of the arguments w/o a position hint.
| 215 | // input and if it succeeds it creates a DE with a position hint. |
| 216 | // Otherwise it creates a DE with one of the arguments w/o a position hint. |
| 217 | DictionaryEntry MutationDispatcher::MakeDictionaryEntryFromCMP( |
| 218 | const void *Arg1, const void *Arg2, |
| 219 | const void *Arg1Mutation, const void *Arg2Mutation, |
| 220 | size_t ArgSize, const uint8_t *Data, |
| 221 | size_t Size) { |
| 222 | bool HandleFirst = Rand.RandBool(); |
| 223 | const void *ExistingBytes, *DesiredBytes; |
| 224 | Word W; |
| 225 | const uint8_t *End = Data + Size; |
| 226 | for (int Arg = 0; Arg < 2; Arg++) { |
| 227 | ExistingBytes = HandleFirst ? Arg1 : Arg2; |
| 228 | DesiredBytes = HandleFirst ? Arg2Mutation : Arg1Mutation; |
| 229 | HandleFirst = !HandleFirst; |
| 230 | W.Set(reinterpret_cast<const uint8_t*>(DesiredBytes), ArgSize); |
| 231 | const size_t kMaxNumPositions = 8; |
| 232 | size_t Positions[kMaxNumPositions]; |
| 233 | size_t NumPositions = 0; |
| 234 | for (const uint8_t *Cur = Data; |
| 235 | Cur < End && NumPositions < kMaxNumPositions; Cur++) { |
| 236 | Cur = |
| 237 | (const uint8_t *)SearchMemory(Cur, End - Cur, ExistingBytes, ArgSize); |
| 238 | if (!Cur) break; |
| 239 | Positions[NumPositions++] = Cur - Data; |
| 240 | } |
| 241 | if (!NumPositions) continue; |
| 242 | return DictionaryEntry(W, Positions[Rand(NumPositions)]); |
| 243 | } |
| 244 | DictionaryEntry DE(W); |
| 245 | return DE; |
| 246 | } |
| 247 | |
| 248 | |
| 249 | template <class T> |
nothing calls this directly
no test coverage detected