Expand Miri's BorTag GC to a Provenance GC
This commit is contained in:
@@ -49,6 +49,14 @@ pub trait AllocMap<K: Hash + Eq, V> {
|
||||
where
|
||||
K: Borrow<Q>;
|
||||
|
||||
/// Callers should prefer [`AllocMap::contains_key`] when it is possible to call because it may
|
||||
/// be more efficient. This function exists for callers that only have a shared reference
|
||||
/// (which might make it slightly less efficient than `contains_key`, e.g. if
|
||||
/// the data is stored inside a `RefCell`).
|
||||
fn contains_key_ref<Q: ?Sized + Hash + Eq>(&self, k: &Q) -> bool
|
||||
where
|
||||
K: Borrow<Q>;
|
||||
|
||||
/// Inserts a new entry into the map.
|
||||
fn insert(&mut self, k: K, v: V) -> Option<V>;
|
||||
|
||||
|
||||
@@ -692,6 +692,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
Ok((&mut alloc.extra, machine))
|
||||
}
|
||||
|
||||
/// Check whether an allocation is live. This is faster than calling
|
||||
/// [`InterpCx::get_alloc_info`] if all you need to check is whether the kind is
|
||||
/// [`AllocKind::Dead`] because it doesn't have to look up the type and layout of statics.
|
||||
pub fn is_alloc_live(&self, id: AllocId) -> bool {
|
||||
self.tcx.try_get_global_alloc(id).is_some()
|
||||
|| self.memory.alloc_map.contains_key_ref(&id)
|
||||
|| self.memory.extra_fn_ptr_map.contains_key(&id)
|
||||
}
|
||||
|
||||
/// Obtain the size and alignment of an allocation, even if that allocation has
|
||||
/// been deallocated.
|
||||
pub fn get_alloc_info(&self, id: AllocId) -> (Size, Align, AllocKind) {
|
||||
|
||||
Reference in New Issue
Block a user