/// Only the first byte of a pointer is inserted into the map; i.e.,
/// every entry in this map applies to `pointer_size` consecutive bytes starting
/// at the given offset.
- pub relocations: Relocations<Tag>,
+ relocations: Relocations<Tag>,
/// Denotes which part of this allocation is initialized.
undef_mask: UndefMask,
/// The size of the allocation. Currently, must always equal `bytes.len()`.
pub fn undef_mask(&self) -> &UndefMask {
&self.undef_mask
}
+
+ /// Returns the relocation list.
+ pub fn relocations(&self) -> &Relocations<Tag> {
+ &self.relocations
+ }
}
impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx Allocation {}
/// Relocations
impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
/// Returns all relocations overlapping with the given ptr-offset pair.
- pub fn relocations(
+ pub fn get_relocations(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
ptr: Pointer<Tag>,
size: Size,
) -> InterpResult<'tcx> {
- if self.relocations(cx, ptr, size).is_empty() {
+ if self.get_relocations(cx, ptr, size).is_empty() {
Ok(())
} else {
throw_unsup!(ReadPointerAsBytes)
// Find the start and end of the given range and its outermost relocations.
let (first, last) = {
// Find all relocations overlapping the given range.
- let relocations = self.relocations(cx, ptr, size);
+ let relocations = self.get_relocations(cx, ptr, size);
if relocations.is_empty() {
return Ok(());
}
alloc.mutability = mutability;
// link the alloc id to the actual allocation
let alloc = tcx.intern_const_alloc(alloc);
- self.leftover_relocations.extend(alloc.relocations.iter().map(|&(_, ((), reloc))| reloc));
+ self.leftover_relocations.extend(alloc.relocations().iter().map(|&(_, ((), reloc))| reloc));
tcx.alloc_map.lock().set_alloc_id_memory(ptr.alloc_id, alloc);
Ok(None)
}
// So we hand-roll the interning logic here again
let alloc = tcx.intern_const_alloc(alloc);
tcx.alloc_map.lock().set_alloc_id_memory(alloc_id, alloc);
- for &(_, ((), reloc)) in alloc.relocations.iter() {
+ for &(_, ((), reloc)) in alloc.relocations().iter() {
if leftover_relocations.insert(reloc) {
todo.push(reloc);
}
for i in 0..alloc.size.bytes() {
let i = Size::from_bytes(i);
- if let Some(&(_, target_id)) = alloc.relocations.get(&i) {
+ if let Some(&(_, target_id)) = alloc.relocations().get(&i) {
if allocs_seen.insert(target_id) {
allocs_to_print.push_back(target_id);
}
// (`get_bytes_with_undef_and_ptr` below checks that there are no
// relocations overlapping the edges; those would not be handled correctly).
let relocations = {
- let relocations = self.get(src.alloc_id)?.relocations(self, src, size);
+ let relocations = self.get(src.alloc_id)?.get_relocations(self, src, size);
if relocations.is_empty() {
// nothing to copy, ignore even the `length` loop
Vec::new()
}
Some(GlobalAlloc::Memory(alloc)) => {
trace!("collecting {:?} with {:#?}", alloc_id, alloc);
- for &((), inner) in alloc.relocations.values() {
+ for &((), inner) in alloc.relocations().values() {
collect_miri(tcx, inner, output);
}
},
collect_miri(tcx, ptr.alloc_id, output),
ConstValue::Slice { data: alloc, start: _, end: _ } |
ConstValue::ByRef { alloc, .. } => {
- for &((), id) in alloc.relocations.values() {
+ for &((), id) in alloc.relocations().values() {
collect_miri(tcx, id, output);
}
}
} else {
bug!("Matching on non-ByRef static")
};
- if alloc.relocations.len() != 0 {
+ if alloc.relocations().len() != 0 {
let msg = "statics with a custom `#[link_section]` must be a \
simple list of bytes on the wasm target with no \
extra levels of indirection such as references";