Skip to content

Commit

Permalink
More review feedback
Browse files Browse the repository at this point in the history
* Store the local crates in an Rc<[CrateNum]>
* Move all the allocation history into Stacks
* Clean up the implementation of get_logs_relevant_to a bit
  • Loading branch information
saethlin committed May 13, 2022
1 parent 972b3b3 commit 8ff0aac
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 187 deletions.
5 changes: 3 additions & 2 deletions src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::mem;
use std::num::NonZeroUsize;
use std::rc::Rc;
use std::time::Duration;

use log::trace;
Expand Down Expand Up @@ -797,7 +798,7 @@ pub fn isolation_abort_error(name: &str) -> InterpResult<'static> {

/// Retrieve the list of local crates that should have been passed by cargo-miri in
/// MIRI_LOCAL_CRATES and turn them into `CrateNum`s.
pub fn get_local_crates(tcx: &TyCtxt<'_>) -> Vec<CrateNum> {
pub fn get_local_crates(tcx: &TyCtxt<'_>) -> Rc<[CrateNum]> {
// Convert the local crate names from the passed-in config into CrateNums so that they can
// be looked up quickly during execution
let local_crate_names = std::env::var("MIRI_LOCAL_CRATES")
Expand All @@ -811,7 +812,7 @@ pub fn get_local_crates(tcx: &TyCtxt<'_>) -> Vec<CrateNum> {
local_crates.push(crate_num);
}
}
local_crates
Rc::from(local_crates.as_slice())
}

/// Formats an AllocRange like [0x1..0x3], for use in diagnostics.
Expand Down
5 changes: 3 additions & 2 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::cell::RefCell;
use std::collections::HashSet;
use std::fmt;
use std::num::NonZeroU64;
use std::rc::Rc;
use std::time::Instant;

use rand::rngs::StdRng;
Expand Down Expand Up @@ -273,7 +274,7 @@ pub struct Evaluator<'mir, 'tcx> {
pub(crate) backtrace_style: BacktraceStyle,

/// Crates which are considered local for the purposes of error reporting.
pub(crate) local_crates: Vec<CrateNum>,
pub(crate) local_crates: Rc<[CrateNum]>,

/// Mapping extern static names to their base pointer.
extern_statics: FxHashMap<Symbol, Pointer<Tag>>,
Expand Down Expand Up @@ -307,7 +308,6 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
config.tracked_pointer_tags.clone(),
config.tracked_call_ids.clone(),
config.tag_raw,
local_crates.clone(),
)))
} else {
None
Expand Down Expand Up @@ -575,6 +575,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
stacked_borrows,
kind,
&ecx.machine.threads,
ecx.machine.local_crates.clone(),
))
} else {
None
Expand Down
Loading

0 comments on commit 8ff0aac

Please sign in to comment.