diff options
| author | Ben Kimock <kimockb@gmail.com> | 2023-11-19 16:17:48 -0500 |
|---|---|---|
| committer | Ben Kimock <kimockb@gmail.com> | 2023-11-22 22:40:55 -0500 |
| commit | f5dae8e73c3449d76311781ba86aa82034fb5296 (patch) | |
| tree | a0e4559c5acd6003617d49d91ddbacc790c0d3df /compiler/rustc_const_eval/src/interpret | |
| parent | 0ff861096449f47956521b40e5e4e88caa7fe27c (diff) | |
| download | rust-f5dae8e73c3449d76311781ba86aa82034fb5296.tar.gz rust-f5dae8e73c3449d76311781ba86aa82034fb5296.zip | |
Miri: GC the dead_alloc_map too
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/memory.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index d5b165a7415..1c1fd2a71ba 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -501,6 +501,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } } +impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { + /// This function is used by Miri's provenance GC to remove unreachable entries from the dead_alloc_map. + pub fn remove_unreachable_allocs(&mut self, reachable_allocs: &FxHashSet<AllocId>) { + // Unlike all the other GC helpers where we check if an `AllocId` is found in the interpreter or + // is live, here all the IDs in the map are for dead allocations so we don't + // need to check for liveness. + #[allow(rustc::potential_query_instability)] // Only used from Miri, not queries. + self.memory.dead_alloc_map.retain(|id, _| reachable_allocs.contains(id)); + } +} + /// Allocation accessors impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { /// Helper function to obtain a global (tcx) allocation. |
