Skip to content

Commit 9016750

Browse files
committed
Move the allocation interner out of InterpretInternerInner
1 parent aace842 commit 9016750

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/librustc/ty/context.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use middle::lang_items;
3232
use middle::resolve_lifetime::{self, ObjectLifetimeDefault};
3333
use middle::stability;
3434
use mir::{self, Mir, interpret};
35+
use mir::interpret::Allocation;
3536
use ty::subst::{Kind, Substs, Subst};
3637
use ty::ReprOptions;
3738
use ty::Instance;
@@ -914,6 +915,9 @@ pub struct GlobalCtxt<'tcx> {
914915

915916
stability_interner: Lock<FxHashSet<&'tcx attr::Stability>>,
916917

918+
/// Stores the value of constants (and deduplicates the actual memory)
919+
allocation_interner: Lock<FxHashSet<&'tcx Allocation>>,
920+
917921
pub interpret_interner: InterpretInterner<'tcx>,
918922

919923
layout_interner: Lock<FxHashSet<&'tcx LayoutDetails>>,
@@ -937,9 +941,6 @@ pub struct InterpretInterner<'tcx> {
937941

938942
#[derive(Debug, Default)]
939943
struct InterpretInternerInner<'tcx> {
940-
/// Stores the value of constants (and deduplicates the actual memory)
941-
allocs: FxHashSet<&'tcx interpret::Allocation>,
942-
943944
/// Allows obtaining function instance handles via a unique identifier
944945
functions: FxHashMap<interpret::AllocId, Instance<'tcx>>,
945946

@@ -1104,9 +1105,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11041105

11051106
pub fn intern_const_alloc(
11061107
self,
1107-
alloc: interpret::Allocation,
1108-
) -> &'gcx interpret::Allocation {
1109-
let allocs = &mut self.interpret_interner.inner.borrow_mut().allocs;
1108+
alloc: Allocation,
1109+
) -> &'gcx Allocation {
1110+
let allocs = &mut self.allocation_interner.borrow_mut();
11101111
if let Some(alloc) = allocs.get(&alloc) {
11111112
return alloc;
11121113
}
@@ -1277,6 +1278,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12771278
data_layout,
12781279
layout_interner: Lock::new(FxHashSet()),
12791280
stability_interner: Lock::new(FxHashSet()),
1281+
allocation_interner: Lock::new(FxHashSet()),
12801282
interpret_interner: Default::default(),
12811283
tx_to_llvm_workers: Lock::new(tx),
12821284
output_filenames: Arc::new(output_filenames.clone()),
@@ -2007,7 +2009,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
20072009
println!("Substs interner: #{}", self.interners.substs.borrow().len());
20082010
println!("Region interner: #{}", self.interners.region.borrow().len());
20092011
println!("Stability interner: #{}", self.stability_interner.borrow().len());
2010-
println!("Interpret interner: #{}", self.interpret_interner.inner.borrow().allocs.len());
2012+
println!("Allocation interner: #{}", self.allocation_interner.borrow().len());
20112013
println!("Layout interner: #{}", self.layout_interner.borrow().len());
20122014
}
20132015
}

0 commit comments

Comments
 (0)