@@ -48,23 +48,22 @@ macro_rules! provide {
4848 $tcx: TyCtxt <$lt>,
4949 def_id_arg: T ,
5050 ) -> <ty:: queries:: $name<$lt> as QueryConfig <$lt>>:: Value {
51+ let _prof_timer =
52+ $tcx. prof. generic_activity( "metadata_decode_entry" ) ;
53+
5154 #[ allow( unused_variables) ]
5255 let ( $def_id, $other) = def_id_arg. into_args( ) ;
5356 assert!( !$def_id. is_local( ) ) ;
5457
55- let def_path_hash = $tcx. def_path_hash( DefId {
56- krate: $def_id. krate,
57- index: CRATE_DEF_INDEX
58- } ) ;
59- let dep_node = def_path_hash
60- . to_dep_node( rustc:: dep_graph:: DepKind :: CrateMetadata ) ;
61- // The DepNodeIndex of the DepNode::CrateMetadata should be
62- // cached somewhere, so that we can use read_index().
63- $tcx. dep_graph. read( dep_node) ;
64-
6558 let $cdata = $tcx. crate_data_as_rc_any( $def_id. krate) ;
6659 let $cdata = $cdata. downcast_ref:: <cstore:: CrateMetadata >( )
6760 . expect( "CrateStore created data is not a CrateMetadata" ) ;
61+
62+ if $tcx. dep_graph. is_fully_enabled( ) {
63+ let crate_dep_node_index = $cdata. get_crate_dep_node_index( $tcx) ;
64+ $tcx. dep_graph. read_index( crate_dep_node_index) ;
65+ }
66+
6867 $compute
6968 } ) *
7069
@@ -449,6 +448,8 @@ impl cstore::CStore {
449448 }
450449
451450 pub fn load_macro_untracked ( & self , id : DefId , sess : & Session ) -> LoadedMacro {
451+ let _prof_timer = sess. prof . generic_activity ( "metadata_load_macro" ) ;
452+
452453 let data = self . get_crate_data ( id. krate ) ;
453454 if data. is_proc_macro_crate ( ) {
454455 return LoadedMacro :: ProcMacro ( data. load_proc_macro ( id. index , sess) ) ;
@@ -526,20 +527,10 @@ impl CrateStore for cstore::CStore {
526527 /// parent `DefId` as well as some idea of what kind of data the
527528 /// `DefId` refers to.
528529 fn def_key ( & self , def : DefId ) -> DefKey {
529- // Note: loading the def-key (or def-path) for a def-id is not
530- // a *read* of its metadata. This is because the def-id is
531- // really just an interned shorthand for a def-path, which is the
532- // canonical name for an item.
533- //
534- // self.dep_graph.read(DepNode::MetaData(def));
535530 self . get_crate_data ( def. krate ) . def_key ( def. index )
536531 }
537532
538533 fn def_path ( & self , def : DefId ) -> DefPath {
539- // See `Note` above in `def_key()` for why this read is
540- // commented out:
541- //
542- // self.dep_graph.read(DepNode::MetaData(def));
543534 self . get_crate_data ( def. krate ) . def_path ( def. index )
544535 }
545536
0 commit comments