trans: remove item_symbols from metadata and CrateContext.

This commit is contained in:
Eduard Burtescu 2016-05-12 19:58:11 +03:00
parent b03bde9c2a
commit 04464db954
9 changed files with 6 additions and 97 deletions

View File

@ -34,8 +34,7 @@ use mir::mir_map::MirMap;
use session::Session;
use session::config::PanicStrategy;
use session::search_paths::PathKind;
use util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
use std::cell::RefCell;
use util::nodemap::{FnvHashMap, NodeSet, DefIdMap};
use std::rc::Rc;
use std::path::PathBuf;
use syntax::ast;
@ -169,7 +168,6 @@ pub trait CrateStore<'tcx> {
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
-> ty::GenericPredicates<'tcx>;
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>;
fn item_symbol(&self, def: DefId) -> String;
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>;
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>;
fn method_arg_names(&self, did: DefId) -> Vec<String>;
@ -275,7 +273,6 @@ pub trait CrateStore<'tcx> {
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>;
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
reexports: &def::ExportMap,
item_symbols: &RefCell<NodeMap<String>>,
link_meta: &LinkMeta,
reachable: &NodeSet,
mir_map: &MirMap<'tcx>,
@ -353,7 +350,6 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
-> ty::GenericPredicates<'tcx> { bug!("item_super_predicates") }
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
fn item_symbol(&self, def: DefId) -> String { bug!("item_symbol") }
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>
{ bug!("trait_def") }
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
@ -483,7 +479,6 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum> { None }
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
reexports: &def::ExportMap,
item_symbols: &RefCell<NodeMap<String>>,
link_meta: &LinkMeta,
reachable: &NodeSet,
mir_map: &MirMap<'tcx>,

View File

@ -33,7 +33,7 @@ pub const tag_items_data_item_family: usize = 0x24;
pub const tag_items_data_item_type: usize = 0x25;
pub const tag_items_data_item_symbol: usize = 0x26;
// GAP 0x26
pub const tag_items_data_item_variant: usize = 0x27;

View File

@ -25,7 +25,7 @@ use rustc::hir::map as hir_map;
use rustc::hir::map::DefKey;
use rustc::mir::repr::Mir;
use rustc::mir::mir_map::MirMap;
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
use rustc::util::nodemap::{FnvHashMap, NodeSet, DefIdMap};
use rustc::session::config::PanicStrategy;
use std::cell::RefCell;
@ -115,13 +115,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
decoder::get_item_attrs(&cdata, def_id.index)
}
fn item_symbol(&self, def: DefId) -> String
{
self.dep_graph.read(DepNode::MetaData(def));
let cdata = self.get_crate_data(def.krate);
decoder::get_symbol(&cdata, def.index)
}
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::TraitDef<'tcx>
{
self.dep_graph.read(DepNode::MetaData(def));
@ -569,7 +562,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
reexports: &def::ExportMap,
item_symbols: &RefCell<NodeMap<String>>,
link_meta: &LinkMeta,
reachable: &NodeSet,
mir_map: &MirMap<'tcx>,
@ -579,7 +571,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
diag: tcx.sess.diagnostic(),
tcx: tcx,
reexports: reexports,
item_symbols: item_symbols,
link_meta: link_meta,
cstore: self,
reachable: reachable,

View File

@ -213,10 +213,6 @@ fn item_sort(item: rbml::Doc) -> Option<char> {
})
}
fn item_symbol(item: rbml::Doc) -> String {
reader::get_doc(item, tag_items_data_item_symbol).as_str().to_string()
}
fn untranslated_def_id(d: rbml::Doc) -> DefId {
let id = reader::doc_as_u64(d);
let index = DefIndex::new((id & 0xFFFF_FFFF) as usize);
@ -640,10 +636,6 @@ pub fn get_impl_trait<'a, 'tcx>(cdata: Cmd,
}
}
pub fn get_symbol(cdata: Cmd, id: DefIndex) -> String {
return item_symbol(cdata.lookup_item(id));
}
/// Iterates over the language items in the given crate.
pub fn each_lang_item<F>(cdata: Cmd, mut f: F) -> bool where
F: FnMut(DefIndex, usize) -> bool,

View File

@ -34,7 +34,7 @@ use rustc::ty::util::IntTypeExt;
use rustc::hir::svh::Svh;
use rustc::mir::mir_map::MirMap;
use rustc::session::config::{self, PanicStrategy};
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet};
use rustc::util::nodemap::{FnvHashMap, NodeSet};
use rustc_serialize::Encodable;
use std::cell::RefCell;
@ -59,7 +59,6 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
pub diag: &'a Handler,
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
pub reexports: &'a def::ExportMap,
pub item_symbols: &'a RefCell<NodeMap<String>>,
pub link_meta: &'a LinkMeta,
pub cstore: &'a cstore::CStore,
pub type_abbrevs: tyencode::abbrev_map<'tcx>,
@ -213,20 +212,6 @@ fn encode_region(ecx: &EncodeContext,
rbml_w.end_tag();
}
fn encode_symbol(ecx: &EncodeContext,
rbml_w: &mut Encoder,
id: NodeId) {
match ecx.item_symbols.borrow().get(&id) {
Some(x) => {
debug!("encode_symbol(id={}, str={})", id, *x);
rbml_w.wr_tagged_str(tag_items_data_item_symbol, x);
}
None => {
bug!("encode_symbol: id not found {}", id);
}
}
}
fn encode_disr_val(_: &EncodeContext,
rbml_w: &mut Encoder,
disr_val: ty::Disr) {
@ -518,10 +503,6 @@ fn encode_info_for_struct_ctor<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
encode_name(rbml_w, name);
encode_parent_item(rbml_w, ecx.tcx.map.local_def_id(struct_id));
if ecx.item_symbols.borrow().contains_key(&ctor_id) {
encode_symbol(ecx, rbml_w, ctor_id);
}
let stab = ecx.tcx.lookup_stability(ecx.tcx.map.local_def_id(ctor_id));
let depr= ecx.tcx.lookup_deprecation(ecx.tcx.map.local_def_id(ctor_id));
encode_stability(rbml_w, stab);
@ -710,10 +691,6 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
}
encode_constness(rbml_w, sig.constness);
encode_defaultness(rbml_w, impl_item.defaultness);
if !any_types {
let m_id = ecx.local_id(m.def_id);
encode_symbol(ecx, rbml_w, m_id);
}
encode_method_argument_names(rbml_w, &sig.decl);
}
}
@ -894,7 +871,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
encode_family(rbml_w, 'c');
}
encode_bounds_and_type_for_item(rbml_w, ecx, index, item.id);
encode_symbol(ecx, rbml_w, item.id);
encode_name(rbml_w, item.name);
encode_visibility(rbml_w, vis);
encode_stability(rbml_w, stab);
@ -931,9 +907,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item));
encode_mir(ecx, rbml_w, item.id);
}
if tps_len == 0 {
encode_symbol(ecx, rbml_w, item.id);
}
encode_constness(rbml_w, constness);
encode_visibility(rbml_w, vis);
encode_stability(rbml_w, stab);
@ -1365,8 +1338,6 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
if abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic {
encode_inlined_item(ecx, rbml_w, InlinedItemRef::Foreign(nitem));
encode_mir(ecx, rbml_w, nitem.id);
} else {
encode_symbol(ecx, rbml_w, nitem.id);
}
encode_attributes(rbml_w, &nitem.attrs);
let stab = ecx.tcx.lookup_stability(ecx.tcx.map.local_def_id(nitem.id));
@ -1387,7 +1358,6 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
let depr = ecx.tcx.lookup_deprecation(ecx.tcx.map.local_def_id(nitem.id));
encode_stability(rbml_w, stab);
encode_deprecation(rbml_w, depr);
encode_symbol(ecx, rbml_w, nitem.id);
encode_name(rbml_w, nitem.name);
}
}

View File

@ -38,7 +38,6 @@ use llvm;
use rustc::cfg;
use rustc::hir::def_id::DefId;
use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem};
use middle::weak_lang_items;
use rustc::hir::pat_util::simple_name;
use rustc::ty::subst::{self, Substs};
use rustc::traits;
@ -2345,15 +2344,6 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
set_global_section(ccx, g, item);
update_linkage(ccx, g, Some(item.id), OriginalTranslation);
}
hir::ItemForeignMod(ref m) => {
if m.abi == Abi::RustIntrinsic || m.abi == Abi::PlatformIntrinsic {
return;
}
for fi in &m.items {
let lname = imported_name(fi.name, &fi.attrs).to_string();
ccx.item_symbols().borrow_mut().insert(fi.id, lname);
}
}
_ => {}
}
}
@ -2438,16 +2428,6 @@ pub fn create_entry_wrapper(ccx: &CrateContext, sp: Span, main_llfn: ValueRef) {
}
}
pub fn imported_name(name: ast::Name, attrs: &[ast::Attribute]) -> InternedString {
match attr::first_attr_value_str_by_name(attrs, "link_name") {
Some(ln) => ln.clone(),
None => match weak_lang_items::link_name(attrs) {
Some(name) => name,
None => name.as_str(),
}
}
}
fn contains_null(s: &str) -> bool {
s.bytes().any(|b| b == 0)
}
@ -2471,7 +2451,6 @@ pub fn write_metadata<'a, 'tcx>(cx: &SharedCrateContext<'a, 'tcx>,
let cstore = &cx.tcx().sess.cstore;
let metadata = cstore.encode_metadata(cx.tcx(),
cx.export_map(),
cx.item_symbols(),
cx.link_meta(),
reachable,
mir_map,

View File

@ -575,11 +575,6 @@ fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
llfn
};
// Always insert into item_symbols, in case this item is exported.
if let Some(id) = local_item {
ccx.item_symbols().borrow_mut().insert(id, sym);
}
ccx.instances().borrow_mut().insert(instance, llfn);
immediate_rvalue(llfn, fn_ptr_ty)

View File

@ -1033,13 +1033,10 @@ pub fn get_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, def_id: DefId)
// Create the global before evaluating the initializer;
// this is necessary to allow recursive statics.
let g = declare::define_global(ccx, &sym, llty).unwrap_or_else(|| {
declare::define_global(ccx, &sym, llty).unwrap_or_else(|| {
ccx.sess().span_fatal(span,
&format!("symbol `{}` is already defined", sym))
});
ccx.item_symbols().borrow_mut().insert(id, sym);
g
})
}
hir_map::NodeForeignItem(&hir::ForeignItem {

View File

@ -71,7 +71,6 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> {
export_map: ExportMap,
reachable: NodeSet,
item_symbols: RefCell<NodeMap<String>>,
link_meta: LinkMeta,
symbol_hasher: RefCell<Sha256>,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
@ -395,7 +394,6 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
metadata_llcx: metadata_llcx,
export_map: export_map,
reachable: reachable,
item_symbols: RefCell::new(NodeMap()),
link_meta: link_meta,
symbol_hasher: RefCell::new(symbol_hasher),
tcx: tcx,
@ -439,10 +437,6 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
&self.reachable
}
pub fn item_symbols<'a>(&'a self) -> &'a RefCell<NodeMap<String>> {
&self.item_symbols
}
pub fn trait_cache(&self) -> &RefCell<DepTrackingMap<TraitSelectionCache<'tcx>>> {
&self.trait_cache
}
@ -720,10 +714,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
&self.shared.reachable
}
pub fn item_symbols<'a>(&'a self) -> &'a RefCell<NodeMap<String>> {
&self.shared.item_symbols
}
pub fn link_meta<'a>(&'a self) -> &'a LinkMeta {
&self.shared.link_meta
}