GC the Stacked Borrows allocation history
This commit is contained in:
parent
5ddf866c9c
commit
5f440dd069
7
src/tools/miri/bench-cargo-miri/invalidate/Cargo.lock
Normal file
7
src/tools/miri/bench-cargo-miri/invalidate/Cargo.lock
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "invalidate"
|
||||
version = "0.1.0"
|
8
src/tools/miri/bench-cargo-miri/invalidate/Cargo.toml
Normal file
8
src/tools/miri/bench-cargo-miri/invalidate/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "invalidate"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
4
src/tools/miri/bench-cargo-miri/invalidate/src/main.rs
Normal file
4
src/tools/miri/bench-cargo-miri/invalidate/src/main.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
// The end of the range is just chosen to make the benchmark run for a few seconds.
|
||||
for _ in 0..200_000 {}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
use smallvec::SmallVec;
|
||||
use std::fmt;
|
||||
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_middle::mir::interpret::{alloc_range, AllocId, AllocRange, InterpError};
|
||||
use rustc_span::{Span, SpanData};
|
||||
use rustc_target::abi::Size;
|
||||
@ -233,6 +234,12 @@ impl AllocHistory {
|
||||
protectors: SmallVec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn retain(&mut self, live_tags: &FxHashSet<BorTag>) {
|
||||
self.invalidations.retain(|event| live_tags.contains(&event.tag));
|
||||
self.creations.retain(|event| live_tags.contains(&event.retag.new_tag));
|
||||
self.protectors.retain(|event| live_tags.contains(&event.tag));
|
||||
}
|
||||
}
|
||||
|
||||
impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
|
||||
|
@ -456,6 +456,7 @@ impl Stacks {
|
||||
stack.retain(live_tags);
|
||||
}
|
||||
}
|
||||
self.history.retain(live_tags);
|
||||
self.modified_since_last_gc = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user