Update the mapping of blocks IDs to addresses if the mapping has changed.
(&self, vm: &mut Vm)
| 433 | |
| 434 | /// Update the mapping of blocks IDs to addresses if the mapping has changed. |
| 435 | fn update_mapping_cache(&self, vm: &mut Vm) { |
| 436 | let injector_mapping = match self.pack_bits { |
| 437 | true => { |
| 438 | &vm.get_injector_mut::<ExactBlockCoverageInjector>(self.injector).unwrap().mapping |
| 439 | } |
| 440 | false => { |
| 441 | &vm.get_injector_mut::<ExactBlockCountCoverageInjector>(self.injector) |
| 442 | .unwrap() |
| 443 | .mapping |
| 444 | } |
| 445 | }; |
| 446 | if self.mapping_cache.borrow().len() != injector_mapping.len() { |
| 447 | let mut mapping = self.mapping_cache.borrow_mut(); |
| 448 | mapping.clear(); |
| 449 | mapping.extend(injector_mapping.iter().map(|(addr, idx)| (*addr, *idx))); |
| 450 | mapping.sort_by_key(|(_, index)| *index); |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | /// Translate coverage bits to real blocks. |
| 455 | pub fn blocks_for(&self, vm: &mut Vm, bits: &[u32]) -> Vec<u64> { |
no test coverage detected