Skip to content

Commit b18b776

Browse files
committed
Replace uses of Hash(Map|Set) with FxHash(Map|Set) in miri
1 parent bf8e4f2 commit b18b776

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/librustc_mir/interpret/memory.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian, BigEndian};
2-
use std::collections::{btree_map, BTreeMap, HashMap, HashSet, VecDeque};
2+
use std::collections::{btree_map, BTreeMap, VecDeque};
33
use std::{ptr, io};
44

55
use rustc::ty::Instance;
66
use rustc::ty::maps::TyCtxtAt;
77
use rustc::ty::layout::{self, Align, TargetDataLayout};
88
use syntax::ast::Mutability;
99

10+
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
1011
use rustc::mir::interpret::{MemoryPointer, AllocId, Allocation, AccessKind, UndefMask, Value, Pointer,
1112
EvalResult, PrimVal, EvalErrorKind};
1213

@@ -33,15 +34,15 @@ pub struct Memory<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> {
3334
pub data: M::MemoryData,
3435

3536
/// Helps guarantee that stack allocations aren't deallocated via `rust_deallocate`
36-
alloc_kind: HashMap<AllocId, MemoryKind<M::MemoryKinds>>,
37+
alloc_kind: FxHashMap<AllocId, MemoryKind<M::MemoryKinds>>,
3738

3839
/// Actual memory allocations (arbitrary bytes, may contain pointers into other allocations).
39-
alloc_map: HashMap<AllocId, Allocation>,
40+
alloc_map: FxHashMap<AllocId, Allocation>,
4041

4142
/// Actual memory allocations (arbitrary bytes, may contain pointers into other allocations).
4243
///
4344
/// Stores statics while they are being processed, before they are interned and thus frozen
44-
uninitialized_statics: HashMap<AllocId, Allocation>,
45+
uninitialized_statics: FxHashMap<AllocId, Allocation>,
4546

4647
/// The current stack frame. Used to check accesses against locks.
4748
pub cur_frame: usize,
@@ -53,9 +54,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
5354
pub fn new(tcx: TyCtxtAt<'a, 'tcx, 'tcx>, data: M::MemoryData) -> Self {
5455
Memory {
5556
data,
56-
alloc_kind: HashMap::new(),
57-
alloc_map: HashMap::new(),
58-
uninitialized_statics: HashMap::new(),
57+
alloc_kind: FxHashMap::default(),
58+
alloc_map: FxHashMap::default(),
59+
uninitialized_statics: FxHashMap::default(),
5960
tcx,
6061
cur_frame: usize::max_value(),
6162
}
@@ -338,7 +339,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
338339
allocs.sort();
339340
allocs.dedup();
340341
let mut allocs_to_print = VecDeque::from(allocs);
341-
let mut allocs_seen = HashSet::new();
342+
let mut allocs_seen = FxHashSet::default();
342343

343344
while let Some(id) = allocs_to_print.pop_front() {
344345
let mut msg = format!("Alloc {:<5} ", format!("{}:", id));

0 commit comments

Comments
 (0)