Skip to content

Commit 474b5fa

Browse files
---
yaml --- r: 277832 b: refs/heads/try c: bb8c8c5 h: refs/heads/master
1 parent 0a89c35 commit 474b5fa

File tree

6 files changed

+54
-46
lines changed

6 files changed

+54
-46
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 75bf6173e5f549a8345c092d4c2fe9ba896253e0
4+
refs/heads/try: bb8c8c58d3d6db6af12b69d047b30c0277ef7263
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_trans/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,7 @@ pub fn trans_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
18241824
closure_env: closure::ClosureEnv) {
18251825
ccx.stats().n_closures.set(ccx.stats().n_closures.get() + 1);
18261826

1827-
if collector::collecting_debug_information(ccx) {
1827+
if collector::collecting_debug_information(ccx.shared()) {
18281828
ccx.record_translation_item_as_generated(TransItem::Fn(instance));
18291829
}
18301830

@@ -2738,7 +2738,7 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
27382738
krate.visit_all_items(&mut TransModVisitor { ccx: &ccx });
27392739
}
27402740

2741-
collector::print_collection_results(&ccx);
2741+
collector::print_collection_results(ccx.shared());
27422742

27432743
symbol_names_test::report_symbol_names(&ccx);
27442744
}
@@ -2934,7 +2934,7 @@ fn collect_translation_items<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>) {
29342934
};
29352935

29362936
let (items, reference_map) = time(time_passes, "translation item collection", || {
2937-
collector::collect_crate_translation_items(&ccx, collection_mode)
2937+
collector::collect_crate_translation_items(ccx.shared(), collection_mode)
29382938
});
29392939

29402940
let strategy = if ccx.sess().opts.debugging_opts.incremental.is_some() {

branches/try/src/librustc_trans/collector.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ use syntax::{attr, errors};
210210
use syntax::parse::token;
211211

212212
use base::{custom_coerce_unsize_info, llvm_linkage_by_name};
213-
use context::CrateContext;
213+
use context::SharedCrateContext;
214214
use common::{fulfill_obligation, normalize_and_test_predicates, type_is_sized};
215215
use glue::{self, DropGlueKind};
216216
use llvm;
@@ -319,7 +319,7 @@ impl<'tcx> ReferenceMap<'tcx> {
319319
}
320320
}
321321

322-
pub fn collect_crate_translation_items<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
322+
pub fn collect_crate_translation_items<'a, 'tcx>(ccx: &SharedCrateContext<'a, 'tcx>,
323323
mode: TransItemCollectionMode)
324324
-> (FnvHashSet<TransItem<'tcx>>,
325325
ReferenceMap<'tcx>) {
@@ -347,7 +347,7 @@ pub fn collect_crate_translation_items<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
347347

348348
// Find all non-generic items by walking the HIR. These items serve as roots to
349349
// start monomorphizing from.
350-
fn collect_roots<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
350+
fn collect_roots<'a, 'tcx>(ccx: &SharedCrateContext<'a, 'tcx>,
351351
mode: TransItemCollectionMode)
352352
-> Vec<TransItem<'tcx>> {
353353
debug!("Collecting roots");
@@ -368,7 +368,7 @@ fn collect_roots<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
368368
}
369369

370370
// Collect all monomorphized translation items reachable from `starting_point`
371-
fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
371+
fn collect_items_rec<'a, 'tcx: 'a>(ccx: &SharedCrateContext<'a, 'tcx>,
372372
starting_point: TransItem<'tcx>,
373373
visited: &mut FnvHashSet<TransItem<'tcx>>,
374374
recursion_depths: &mut DefIdMap<usize>,
@@ -473,7 +473,7 @@ fn check_recursion_limit<'tcx>(tcx: &TyCtxt<'tcx>,
473473
}
474474

475475
struct MirNeighborCollector<'a, 'tcx: 'a> {
476-
ccx: &'a CrateContext<'a, 'tcx>,
476+
ccx: &'a SharedCrateContext<'a, 'tcx>,
477477
mir: &'a mir::Mir<'tcx>,
478478
output: &'a mut Vec<TransItem<'tcx>>,
479479
param_substs: &'tcx Substs<'tcx>
@@ -593,7 +593,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
593593
// object shim or a closure that is handled differently),
594594
// we check if the callee is something that will actually
595595
// result in a translation item ...
596-
if can_result_in_trans_item(self.ccx, callee_def_id) {
596+
if can_result_in_trans_item(self.ccx.tcx(), callee_def_id) {
597597
// ... and create one if it does.
598598
let trans_item = create_fn_trans_item(self.ccx.tcx(),
599599
callee_def_id,
@@ -606,21 +606,21 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
606606

607607
self.super_operand(operand);
608608

609-
fn can_result_in_trans_item<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
610-
def_id: DefId)
611-
-> bool {
612-
if !match ccx.tcx().lookup_item_type(def_id).ty.sty {
609+
fn can_result_in_trans_item<'tcx>(tcx: &TyCtxt<'tcx>,
610+
def_id: DefId)
611+
-> bool {
612+
if !match tcx.lookup_item_type(def_id).ty.sty {
613613
ty::TyFnDef(def_id, _, _) => {
614614
// Some constructors also have type TyFnDef but they are
615615
// always instantiated inline and don't result in
616616
// translation item. Same for FFI functions.
617-
match ccx.tcx().map.get_if_local(def_id) {
617+
match tcx.map.get_if_local(def_id) {
618618
Some(hir_map::NodeVariant(_)) |
619619
Some(hir_map::NodeStructCtor(_)) |
620620
Some(hir_map::NodeForeignItem(_)) => false,
621621
Some(_) => true,
622622
None => {
623-
ccx.sess().cstore.variant_kind(def_id).is_none()
623+
tcx.sess.cstore.variant_kind(def_id).is_none()
624624
}
625625
}
626626
}
@@ -630,7 +630,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
630630
return false;
631631
}
632632

633-
can_have_local_instance(ccx.tcx(), def_id)
633+
can_have_local_instance(tcx, def_id)
634634
}
635635
}
636636
}
@@ -644,7 +644,7 @@ fn can_have_local_instance<'tcx>(tcx: &TyCtxt<'tcx>,
644644
def_id.is_local() || tcx.sess.cstore.is_item_mir_available(def_id)
645645
}
646646

647-
fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
647+
fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &SharedCrateContext<'a, 'tcx>,
648648
dg: DropGlueKind<'tcx>,
649649
output: &mut Vec<TransItem<'tcx>>) {
650650
let ty = match dg {
@@ -700,7 +700,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
700700
substs: self_type_substs,
701701
}.to_poly_trait_ref();
702702

703-
let substs = match fulfill_obligation(ccx.shared(), DUMMY_SP, trait_ref) {
703+
let substs = match fulfill_obligation(ccx, DUMMY_SP, trait_ref) {
704704
traits::VtableImpl(data) => data.substs,
705705
_ => bug!()
706706
};
@@ -779,7 +779,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
779779
}
780780
}
781781

782-
fn do_static_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
782+
fn do_static_dispatch<'a, 'tcx>(ccx: &SharedCrateContext<'a, 'tcx>,
783783
fn_def_id: DefId,
784784
fn_substs: &'tcx Substs<'tcx>,
785785
param_substs: &'tcx Substs<'tcx>)
@@ -822,7 +822,7 @@ fn do_static_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
822822

823823
// Given a trait-method and substitution information, find out the actual
824824
// implementation of the trait method.
825-
fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
825+
fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &SharedCrateContext<'a, 'tcx>,
826826
trait_method: &ty::Method,
827827
trait_id: DefId,
828828
callee_substs: &'tcx Substs<'tcx>,
@@ -843,7 +843,7 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
843843
callee_substs);
844844

845845
let trait_ref = ty::Binder(rcvr_substs.to_trait_ref(tcx, trait_id));
846-
let vtbl = fulfill_obligation(ccx.shared(), DUMMY_SP, trait_ref);
846+
let vtbl = fulfill_obligation(ccx, DUMMY_SP, trait_ref);
847847

848848
// Now that we know which impl is being used, we can dispatch to
849849
// the actual function:
@@ -911,7 +911,7 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
911911
///
912912
/// Finally, there is also the case of custom unsizing coercions, e.g. for
913913
/// smart pointers such as `Rc` and `Arc`.
914-
fn find_vtable_types_for_unsizing<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
914+
fn find_vtable_types_for_unsizing<'a, 'tcx>(ccx: &SharedCrateContext<'a, 'tcx>,
915915
source_ty: ty::Ty<'tcx>,
916916
target_ty: ty::Ty<'tcx>)
917917
-> (ty::Ty<'tcx>, ty::Ty<'tcx>) {
@@ -936,7 +936,7 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
936936
&ty::TyStruct(target_adt_def, target_substs)) => {
937937
assert_eq!(source_adt_def, target_adt_def);
938938

939-
let kind = custom_coerce_unsize_info(ccx.shared(), source_ty, target_ty);
939+
let kind = custom_coerce_unsize_info(ccx, source_ty, target_ty);
940940

941941
let coerce_index = match kind {
942942
CustomCoerceUnsized::Struct(i) => i
@@ -986,7 +986,7 @@ fn create_fn_trans_item<'tcx>(tcx: &TyCtxt<'tcx>,
986986

987987
/// Creates a `TransItem` for each method that is referenced by the vtable for
988988
/// the given trait/impl pair.
989-
fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
989+
fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &SharedCrateContext<'a, 'tcx>,
990990
trait_ty: ty::Ty<'tcx>,
991991
impl_ty: ty::Ty<'tcx>,
992992
output: &mut Vec<TransItem<'tcx>>) {
@@ -998,7 +998,7 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
998998

999999
// Walk all methods of the trait, including those of its supertraits
10001000
for trait_ref in traits::supertraits(ccx.tcx(), poly_trait_ref) {
1001-
let vtable = fulfill_obligation(ccx.shared(), DUMMY_SP, trait_ref);
1001+
let vtable = fulfill_obligation(ccx, DUMMY_SP, trait_ref);
10021002
match vtable {
10031003
traits::VtableImpl(
10041004
traits::VtableImplData {
@@ -1035,7 +1035,7 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
10351035
//=-----------------------------------------------------------------------------
10361036

10371037
struct RootCollector<'b, 'a: 'b, 'tcx: 'a + 'b> {
1038-
ccx: &'b CrateContext<'a, 'tcx>,
1038+
ccx: &'b SharedCrateContext<'a, 'tcx>,
10391039
mode: TransItemCollectionMode,
10401040
output: &'b mut Vec<TransItem<'tcx>>,
10411041
enclosing_item: Option<&'tcx hir::Item>,
@@ -1546,12 +1546,12 @@ pub enum TransItemState {
15461546
NotPredictedButGenerated,
15471547
}
15481548

1549-
pub fn collecting_debug_information(ccx: &CrateContext) -> bool {
1549+
pub fn collecting_debug_information(ccx: &SharedCrateContext) -> bool {
15501550
return cfg!(debug_assertions) &&
15511551
ccx.sess().opts.debugging_opts.print_trans_items.is_some();
15521552
}
15531553

1554-
pub fn print_collection_results<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>) {
1554+
pub fn print_collection_results<'a, 'tcx>(ccx: &SharedCrateContext<'a, 'tcx>) {
15551555
use std::hash::{Hash, SipHasher, Hasher};
15561556

15571557
if !collecting_debug_information(ccx) {

branches/try/src/librustc_trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ pub fn trans_static(ccx: &CrateContext,
11331133
attrs: &[ast::Attribute])
11341134
-> Result<ValueRef, ConstEvalErr> {
11351135

1136-
if collector::collecting_debug_information(ccx) {
1136+
if collector::collecting_debug_information(ccx.shared()) {
11371137
ccx.record_translation_item_as_generated(TransItem::Static(id));
11381138
}
11391139

branches/try/src/librustc_trans/context.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,28 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
469469
pub fn use_dll_storage_attrs(&self) -> bool {
470470
self.use_dll_storage_attrs
471471
}
472+
473+
pub fn get_mir(&self, def_id: DefId) -> Option<CachedMir<'b, 'tcx>> {
474+
if def_id.is_local() {
475+
let node_id = self.tcx.map.as_local_node_id(def_id).unwrap();
476+
self.mir_map.map.get(&node_id).map(CachedMir::Ref)
477+
} else {
478+
if let Some(mir) = self.mir_cache.borrow().get(&def_id).cloned() {
479+
return Some(CachedMir::Owned(mir));
480+
}
481+
482+
let mir = self.sess().cstore.maybe_get_item_mir(self.tcx, def_id);
483+
let cached = mir.map(Rc::new);
484+
if let Some(ref mir) = cached {
485+
self.mir_cache.borrow_mut().insert(def_id, mir.clone());
486+
}
487+
cached.map(CachedMir::Owned)
488+
}
489+
}
490+
491+
pub fn translation_items(&self) -> &RefCell<FnvHashMap<TransItem<'tcx>, TransItemState>> {
492+
&self.translation_items
493+
}
472494
}
473495

474496
impl<'tcx> LocalCrateContext<'tcx> {
@@ -843,21 +865,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
843865
}
844866

845867
pub fn get_mir(&self, def_id: DefId) -> Option<CachedMir<'b, 'tcx>> {
846-
if def_id.is_local() {
847-
let node_id = self.tcx().map.as_local_node_id(def_id).unwrap();
848-
self.shared.mir_map.map.get(&node_id).map(CachedMir::Ref)
849-
} else {
850-
if let Some(mir) = self.shared.mir_cache.borrow().get(&def_id).cloned() {
851-
return Some(CachedMir::Owned(mir));
852-
}
853-
854-
let mir = self.sess().cstore.maybe_get_item_mir(self.tcx(), def_id);
855-
let cached = mir.map(Rc::new);
856-
if let Some(ref mir) = cached {
857-
self.shared.mir_cache.borrow_mut().insert(def_id, mir.clone());
858-
}
859-
cached.map(CachedMir::Owned)
860-
}
868+
self.shared.get_mir(def_id)
861869
}
862870

863871
pub fn translation_items(&self) -> &RefCell<FnvHashMap<TransItem<'tcx>, TransItemState>> {

branches/try/src/librustc_trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
489489

490490
fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueKind<'tcx>)
491491
-> Block<'blk, 'tcx> {
492-
if collector::collecting_debug_information(bcx.ccx()) {
492+
if collector::collecting_debug_information(bcx.ccx().shared()) {
493493
bcx.ccx()
494494
.record_translation_item_as_generated(TransItem::DropGlue(g));
495495
}

0 commit comments

Comments
 (0)