@@ -32,7 +32,7 @@ use syntax::source_map;
3232use syntax:: parse:: { self , ParseSess } ;
3333use syntax:: symbol:: Symbol ;
3434use syntax_pos:: { MultiSpan , Span } ;
35- use crate :: util:: profiling:: SelfProfiler ;
35+ use crate :: util:: profiling:: { SelfProfiler , SelfProfilerRef } ;
3636
3737use rustc_target:: spec:: { PanicStrategy , RelroLevel , Target , TargetTriple } ;
3838use rustc_data_structures:: flock;
@@ -129,7 +129,7 @@ pub struct Session {
129129 pub profile_channel : Lock < Option < mpsc:: Sender < ProfileQueriesMsg > > > ,
130130
131131 /// Used by `-Z self-profile`.
132- pub self_profiling : Option < Arc < SelfProfiler > > ,
132+ pub prof : SelfProfilerRef ,
133133
134134 /// Some measurements that are being gathered during compilation.
135135 pub perf_stats : PerfStats ,
@@ -835,24 +835,6 @@ impl Session {
835835 }
836836 }
837837
838- #[ inline( never) ]
839- #[ cold]
840- fn profiler_active < F : FnOnce ( & SelfProfiler ) -> ( ) > ( & self , f : F ) {
841- match & self . self_profiling {
842- None => bug ! ( "profiler_active() called but there was no profiler active" ) ,
843- Some ( profiler) => {
844- f ( & profiler) ;
845- }
846- }
847- }
848-
849- #[ inline( always) ]
850- pub fn profiler < F : FnOnce ( & SelfProfiler ) -> ( ) > ( & self , f : F ) {
851- if unlikely ! ( self . self_profiling. is_some( ) ) {
852- self . profiler_active ( f)
853- }
854- }
855-
856838 pub fn print_perf_stats ( & self ) {
857839 println ! (
858840 "Total time spent computing symbol hashes: {}" ,
@@ -896,16 +878,10 @@ impl Session {
896878 ret
897879 }
898880
899- /// Returns the number of query threads that should be used for this
900- /// compilation
901- pub fn threads_from_count ( query_threads : Option < usize > ) -> usize {
902- query_threads. unwrap_or ( :: num_cpus:: get ( ) )
903- }
904-
905881 /// Returns the number of query threads that should be used for this
906882 /// compilation
907883 pub fn threads ( & self ) -> usize {
908- Self :: threads_from_count ( self . opts . debugging_opts . threads )
884+ self . opts . debugging_opts . threads
909885 }
910886
911887 /// Returns the number of codegen units that should be used for this
@@ -1257,7 +1233,7 @@ fn build_session_(
12571233 imported_macro_spans : OneThread :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
12581234 incr_comp_session : OneThread :: new ( RefCell :: new ( IncrCompSession :: NotInitialized ) ) ,
12591235 cgu_reuse_tracker,
1260- self_profiling : self_profiler,
1236+ prof : SelfProfilerRef :: new ( self_profiler) ,
12611237 profile_channel : Lock :: new ( None ) ,
12621238 perf_stats : PerfStats {
12631239 symbol_hash_time : Lock :: new ( Duration :: from_secs ( 0 ) ) ,
0 commit comments