Skip to content

Commit 1a44439

Browse files
committed
Auto merge of #49991 - wesleywiser:remove_hir_inlining, r=michaelwoerister
Remove HIR inlining Fixes #49690 r? @michaelwoerister
2 parents 257d43d + 4a77d35 commit 1a44439

File tree

15 files changed

+117
-331
lines changed

15 files changed

+117
-331
lines changed

src/librustc/dep_graph/dep_node.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,6 @@ define_dep_nodes!( <'tcx>
556556
[input] DefSpan(DefId),
557557
[] LookupStability(DefId),
558558
[] LookupDeprecationEntry(DefId),
559-
[] ItemBodyNestedBodies(DefId),
560559
[] ConstIsRvaluePromotableToStatic(DefId),
561560
[] RvaluePromotableMap(DefId),
562561
[] ImplParent(DefId),
@@ -567,6 +566,7 @@ define_dep_nodes!( <'tcx>
567566
[] ItemAttrs(DefId),
568567
[] TransFnAttrs(DefId),
569568
[] FnArgNames(DefId),
569+
[] RenderedConst(DefId),
570570
[] DylibDepFormats(CrateNum),
571571
[] IsPanicRuntime(CrateNum),
572572
[] IsCompilerBuiltins(CrateNum),
@@ -615,7 +615,6 @@ define_dep_nodes!( <'tcx>
615615
[input] GetLangItems,
616616
[] DefinedLangItems(CrateNum),
617617
[] MissingLangItems(CrateNum),
618-
[] ExternConstBody(DefId),
619618
[] VisibleParentMap,
620619
[input] MissingExternCrateItem(CrateNum),
621620
[input] UsedCrateSource(CrateNum),

src/librustc/hir/map/mod.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ use syntax_pos::Span;
3030
use hir::*;
3131
use hir::print::Nested;
3232
use hir::svh::Svh;
33-
use util::nodemap::{DefIdMap, FxHashMap};
33+
use util::nodemap::FxHashMap;
3434

35-
use arena::SyncTypedArena;
3635
use std::io;
3736
use ty::TyCtxt;
3837

39-
use rustc_data_structures::sync::Lock;
40-
4138
pub mod blocks;
4239
mod collector;
4340
mod def_collector;
@@ -219,15 +216,13 @@ impl<'hir> MapEntry<'hir> {
219216
pub struct Forest {
220217
krate: Crate,
221218
pub dep_graph: DepGraph,
222-
inlined_bodies: SyncTypedArena<Body>
223219
}
224220

225221
impl Forest {
226222
pub fn new(krate: Crate, dep_graph: &DepGraph) -> Forest {
227223
Forest {
228224
krate,
229225
dep_graph: dep_graph.clone(),
230-
inlined_bodies: SyncTypedArena::new()
231226
}
232227
}
233228

@@ -264,9 +259,6 @@ pub struct Map<'hir> {
264259

265260
definitions: &'hir Definitions,
266261

267-
/// Bodies inlined from other crates are cached here.
268-
inlined_bodies: Lock<DefIdMap<&'hir Body>>,
269-
270262
/// The reverse mapping of `node_to_hir_id`.
271263
hir_to_node_id: FxHashMap<HirId, NodeId>,
272264
}
@@ -923,21 +915,6 @@ impl<'hir> Map<'hir> {
923915
}
924916
}
925917

926-
pub fn get_inlined_body_untracked(&self, def_id: DefId) -> Option<&'hir Body> {
927-
self.inlined_bodies.borrow().get(&def_id).cloned()
928-
}
929-
930-
pub fn intern_inlined_body(&self, def_id: DefId, body: Body) -> &'hir Body {
931-
let mut inlined_bodies = self.inlined_bodies.borrow_mut();
932-
if let Some(&b) = inlined_bodies.get(&def_id) {
933-
debug_assert_eq!(&body, b);
934-
return b;
935-
}
936-
let body = self.forest.inlined_bodies.alloc(body);
937-
inlined_bodies.insert(def_id, body);
938-
body
939-
}
940-
941918
/// Returns the name associated with the given NodeId's AST.
942919
pub fn name(&self, id: NodeId) -> Name {
943920
match self.get(id) {
@@ -1195,7 +1172,6 @@ pub fn map_crate<'hir>(sess: &::session::Session,
11951172
map,
11961173
hir_to_node_id,
11971174
definitions,
1198-
inlined_bodies: Lock::new(DefIdMap()),
11991175
};
12001176

12011177
hir_id_validator::check_crate(&map);

src/librustc/ich/impls_cstore.rs

-28
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
//! This module contains `HashStable` implementations for various data types
1212
//! from rustc::middle::cstore in no particular order.
1313
14-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult};
15-
1614
use middle;
1715

1816
impl_stable_hash_for!(enum middle::cstore::DepKind {
@@ -64,29 +62,3 @@ impl_stable_hash_for!(struct middle::cstore::CrateSource {
6462
rlib,
6563
rmeta
6664
});
67-
68-
impl<HCX> HashStable<HCX> for middle::cstore::ExternBodyNestedBodies {
69-
fn hash_stable<W: StableHasherResult>(&self,
70-
hcx: &mut HCX,
71-
hasher: &mut StableHasher<W>) {
72-
let middle::cstore::ExternBodyNestedBodies {
73-
nested_bodies: _,
74-
fingerprint,
75-
} = *self;
76-
77-
fingerprint.hash_stable(hcx, hasher);
78-
}
79-
}
80-
81-
impl<'a, HCX> HashStable<HCX> for middle::cstore::ExternConstBody<'a> {
82-
fn hash_stable<W: StableHasherResult>(&self,
83-
hcx: &mut HCX,
84-
hasher: &mut StableHasher<W>) {
85-
let middle::cstore::ExternConstBody {
86-
body: _,
87-
fingerprint,
88-
} = *self;
89-
90-
fingerprint.hash_stable(hcx, hasher);
91-
}
92-
}

src/librustc/middle/cstore.rs

-23
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,16 @@
2222
//! are *mostly* used as a part of that interface, but these should
2323
//! probably get a better home if someone can find one.
2424
25-
use hir;
2625
use hir::def;
2726
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
2827
use hir::map as hir_map;
2928
use hir::map::definitions::{Definitions, DefKey, DefPathTable};
3029
use hir::svh::Svh;
31-
use ich;
3230
use ty::{self, TyCtxt};
3331
use session::{Session, CrateDisambiguator};
3432
use session::search_paths::PathKind;
3533

3634
use std::any::Any;
37-
use std::collections::BTreeMap;
3835
use std::path::{Path, PathBuf};
3936
use syntax::ast;
4037
use syntax::ext::base::SyntaxExtension;
@@ -209,26 +206,6 @@ pub trait MetadataLoader {
209206
-> Result<MetadataRef, String>;
210207
}
211208

212-
#[derive(Clone)]
213-
pub struct ExternConstBody<'tcx> {
214-
pub body: &'tcx hir::Body,
215-
216-
// It would require a lot of infrastructure to enable stable-hashing Bodies
217-
// from other crates, so we hash on export and just store the fingerprint
218-
// with them.
219-
pub fingerprint: ich::Fingerprint,
220-
}
221-
222-
#[derive(Clone)]
223-
pub struct ExternBodyNestedBodies {
224-
pub nested_bodies: Lrc<BTreeMap<hir::BodyId, hir::Body>>,
225-
226-
// It would require a lot of infrastructure to enable stable-hashing Bodies
227-
// from other crates, so we hash on export and just store the fingerprint
228-
// with them.
229-
pub fingerprint: ich::Fingerprint,
230-
}
231-
232209
/// A store of Rust crates, through with their metadata
233210
/// can be accessed.
234211
///

src/librustc/ty/maps/config.rs

-6
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,6 @@ impl<'tcx> QueryDescription<'tcx> for queries::trait_of_item<'tcx> {
283283
}
284284
}
285285

286-
impl<'tcx> QueryDescription<'tcx> for queries::item_body_nested_bodies<'tcx> {
287-
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
288-
format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
289-
}
290-
}
291-
292286
impl<'tcx> QueryDescription<'tcx> for queries::const_is_rvalue_promotable_to_static<'tcx> {
293287
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
294288
format!("const checking if rvalue is promotable to static `{}`",

src/librustc/ty/maps/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ use hir::svh::Svh;
1717
use infer::canonical::{self, Canonical};
1818
use lint;
1919
use middle::borrowck::BorrowCheckResult;
20-
use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary,
21-
ExternBodyNestedBodies, ForeignModule};
22-
use middle::cstore::{NativeLibraryKind, DepKind, CrateSource, ExternConstBody};
20+
use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
21+
use middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
2322
use middle::privacy::AccessLevels;
2423
use middle::reachable::ReachableSet;
2524
use middle::region;
@@ -254,9 +253,11 @@ define_maps! { <'tcx>
254253
[] fn item_attrs: ItemAttrs(DefId) -> Lrc<[ast::Attribute]>,
255254
[] fn trans_fn_attrs: trans_fn_attrs(DefId) -> TransFnAttrs,
256255
[] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
256+
/// Gets the rendered value of the specified constant or associated constant.
257+
/// Used by rustdoc.
258+
[] fn rendered_const: RenderedConst(DefId) -> String,
257259
[] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
258260
[] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
259-
[] fn item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> ExternBodyNestedBodies,
260261
[] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
261262
[] fn rvalue_promotable_map: RvaluePromotableMap(DefId) -> Lrc<ItemLocalSet>,
262263
[] fn is_mir_available: IsMirAvailable(DefId) -> bool,
@@ -376,7 +377,6 @@ define_maps! { <'tcx>
376377
[] fn get_lang_items: get_lang_items_node(CrateNum) -> Lrc<LanguageItems>,
377378
[] fn defined_lang_items: DefinedLangItems(CrateNum) -> Lrc<Vec<(DefId, usize)>>,
378379
[] fn missing_lang_items: MissingLangItems(CrateNum) -> Lrc<Vec<LangItem>>,
379-
[] fn extern_const_body: ExternConstBody(DefId) -> ExternConstBody<'tcx>,
380380
[] fn visible_parent_map: visible_parent_map_node(CrateNum)
381381
-> Lrc<DefIdMap<DefId>>,
382382
[] fn missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,

src/librustc/ty/maps/plumbing.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
10481048
DepKind::LookupDeprecationEntry => {
10491049
force!(lookup_deprecation_entry, def_id!());
10501050
}
1051-
DepKind::ItemBodyNestedBodies => { force!(item_body_nested_bodies, def_id!()); }
10521051
DepKind::ConstIsRvaluePromotableToStatic => {
10531052
force!(const_is_rvalue_promotable_to_static, def_id!());
10541053
}
@@ -1063,6 +1062,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
10631062
DepKind::ItemAttrs => { force!(item_attrs, def_id!()); }
10641063
DepKind::TransFnAttrs => { force!(trans_fn_attrs, def_id!()); }
10651064
DepKind::FnArgNames => { force!(fn_arg_names, def_id!()); }
1065+
DepKind::RenderedConst => { force!(rendered_const, def_id!()); }
10661066
DepKind::DylibDepFormats => { force!(dylib_dependency_formats, krate!()); }
10671067
DepKind::IsPanicRuntime => { force!(is_panic_runtime, krate!()); }
10681068
DepKind::IsCompilerBuiltins => { force!(is_compiler_builtins, krate!()); }
@@ -1119,7 +1119,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
11191119
DepKind::GetLangItems => { force!(get_lang_items, LOCAL_CRATE); }
11201120
DepKind::DefinedLangItems => { force!(defined_lang_items, krate!()); }
11211121
DepKind::MissingLangItems => { force!(missing_lang_items, krate!()); }
1122-
DepKind::ExternConstBody => { force!(extern_const_body, def_id!()); }
11231122
DepKind::VisibleParentMap => { force!(visible_parent_map, LOCAL_CRATE); }
11241123
DepKind::MissingExternCrateItem => {
11251124
force!(missing_extern_crate_item, krate!());

src/librustc_metadata/astencode.rs

-96
This file was deleted.

src/librustc_metadata/cstore_impl.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
142142
mir_const_qualif => {
143143
(cdata.mir_const_qualif(def_id.index), Lrc::new(IdxSetBuf::new_empty(0)))
144144
}
145-
typeck_tables_of => { cdata.item_body_tables(def_id.index, tcx) }
146145
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
147146
inherent_impls => { Lrc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
148147
is_const_fn => { cdata.is_const_fn(def_id.index) }
@@ -161,9 +160,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
161160
// This is only used by rustdoc anyway, which shouldn't have
162161
// incremental recompilation ever enabled.
163162
fn_arg_names => { cdata.get_fn_arg_names(def_id.index) }
163+
rendered_const => { cdata.get_rendered_const(def_id.index) }
164164
impl_parent => { cdata.get_parent_impl(def_id.index) }
165165
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
166-
item_body_nested_bodies => { cdata.item_body_nested_bodies(tcx, def_id.index) }
167166
const_is_rvalue_promotable_to_static => {
168167
cdata.const_is_rvalue_promotable_to_static(def_id.index)
169168
}
@@ -243,11 +242,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
243242
defined_lang_items => { Lrc::new(cdata.get_lang_items()) }
244243
missing_lang_items => { Lrc::new(cdata.get_missing_lang_items()) }
245244

246-
extern_const_body => {
247-
debug!("item_body({:?}): inlining item", def_id);
248-
cdata.extern_const_body(tcx, def_id.index)
249-
}
250-
251245
missing_extern_crate_item => {
252246
let r = match *cdata.extern_crate.borrow() {
253247
Some(extern_crate) if !extern_crate.direct => true,

0 commit comments

Comments
 (0)