Discard MTWT & interner tables from TLD after they stop being useful.
This commit is contained in:
parent
87e72c3812
commit
c04d4846f2
@ -305,6 +305,9 @@ pub fn phase_3_run_analysis_passes(sess: Session,
|
|||||||
time(time_passes, "resolution", (), |_|
|
time(time_passes, "resolution", (), |_|
|
||||||
middle::resolve::resolve_crate(&sess, lang_items, krate));
|
middle::resolve::resolve_crate(&sess, lang_items, krate));
|
||||||
|
|
||||||
|
// Discard MTWT tables that aren't required past resolution.
|
||||||
|
syntax::ext::mtwt::clear_tables();
|
||||||
|
|
||||||
let named_region_map = time(time_passes, "lifetime resolution", (),
|
let named_region_map = time(time_passes, "lifetime resolution", (),
|
||||||
|_| middle::resolve_lifetime::krate(&sess, krate));
|
|_| middle::resolve_lifetime::krate(&sess, krate));
|
||||||
|
|
||||||
@ -585,6 +588,10 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
|
|||||||
if stop_after_phase_3(&analysis.ty_cx.sess) { return; }
|
if stop_after_phase_3(&analysis.ty_cx.sess) { return; }
|
||||||
let (tcx, trans) = phase_4_translate_to_llvm(expanded_crate,
|
let (tcx, trans) = phase_4_translate_to_llvm(expanded_crate,
|
||||||
analysis, &outputs);
|
analysis, &outputs);
|
||||||
|
|
||||||
|
// Discard interned strings as they are no longer required.
|
||||||
|
token::get_ident_interner().clear();
|
||||||
|
|
||||||
(outputs, trans, tcx.sess)
|
(outputs, trans, tcx.sess)
|
||||||
};
|
};
|
||||||
phase_5_run_llvm_passes(&sess, &trans, &outputs);
|
phase_5_run_llvm_passes(&sess, &trans, &outputs);
|
||||||
|
@ -126,6 +126,15 @@ pub fn display_sctable(table: &SCTable) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clear the tables from TLD to reclaim memory.
|
||||||
|
pub fn clear_tables() {
|
||||||
|
with_sctable(|table| {
|
||||||
|
*table.table.borrow_mut().get() = Vec::new();
|
||||||
|
*table.mark_memo.borrow_mut().get() = HashMap::new();
|
||||||
|
*table.rename_memo.borrow_mut().get() = HashMap::new();
|
||||||
|
});
|
||||||
|
with_resolve_table_mut(|table| *table = HashMap::new());
|
||||||
|
}
|
||||||
|
|
||||||
// Add a value to the end of a vec, return its index
|
// Add a value to the end of a vec, return its index
|
||||||
fn idx_push<T>(vec: &mut Vec<T> , val: T) -> u32 {
|
fn idx_push<T>(vec: &mut Vec<T> , val: T) -> u32 {
|
||||||
|
@ -84,6 +84,11 @@ pub fn find_equiv<Q:Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> {
|
|||||||
None => None,
|
None => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear(&self) {
|
||||||
|
*self.map.borrow_mut().get() = HashMap::new();
|
||||||
|
*self.vect.borrow_mut().get() = Vec::new();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, Eq, Hash, Ord)]
|
#[deriving(Clone, Eq, Hash, Ord)]
|
||||||
@ -222,6 +227,11 @@ pub fn find_equiv<Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> {
|
|||||||
None => None,
|
None => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear(&self) {
|
||||||
|
*self.map.borrow_mut().get() = HashMap::new();
|
||||||
|
*self.vect.borrow_mut().get() = Vec::new();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user