- fn relocations(&self, ptr: Pointer, size: usize)
- -> EvalResult<btree_map::Range<usize, AllocId>>
- {
- let start = ptr.offset.saturating_sub(self.pointer_size - 1);
- let end = start + size;
- Ok(try!(self.get(ptr.alloc_id)).relocations.range(Included(&start), Excluded(&end)))
- }
-
- fn clear_relocations(&mut self, ptr: Pointer, size: usize) -> EvalResult<()> {
- let keys: Vec<_> = try!(self.relocations(ptr, size)).map(|(&k, _)| k).collect();
- let alloc = try!(self.get_mut(ptr.alloc_id));
- for k in keys {
- alloc.relocations.remove(&k);
- }
- Ok(())
- }
-
- fn check_relocation_edges(&self, ptr: Pointer, size: usize) -> EvalResult<()> {
- let overlapping_start = try!(self.relocations(ptr, 0)).count();
- let overlapping_end = try!(self.relocations(ptr.offset(size as isize), 0)).count();
- if overlapping_start + overlapping_end != 0 {
- return Err(EvalError::ReadPointerAsBytes);
- }
- Ok(())
- }
-
- fn copy_relocations(&mut self, src: Pointer, dest: Pointer, size: usize) -> EvalResult<()> {
- let relocations: Vec<_> = try!(self.relocations(src, size))
- .map(|(&offset, &alloc_id)| {
- // Update relocation offsets for the new positions in the destination allocation.
- (offset + dest.offset - src.offset, alloc_id)
- })
- .collect();
- try!(self.get_mut(dest.alloc_id)).relocations.extend(relocations);
- Ok(())
- }