Skip to content

Commit 4387490

Browse files
committed
Add inline.
1 parent c989f89 commit 4387490

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

compiler/rustc_middle/src/dep_graph/dep_node.rs

+3
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ impl DepNodeExt for DepNode {
245245
/// Construct a DepNode from the given DepKind and DefPathHash. This
246246
/// method will assert that the given DepKind actually requires a
247247
/// single DefId/DefPathHash parameter.
248+
#[inline]
248249
fn from_def_path_hash(tcx: TyCtxt<'_>, def_path_hash: DefPathHash, kind: DepKind) -> DepNode {
249250
debug_assert!(tcx.query_fingerprint_style(kind) == FingerprintStyle::DefPathHash);
250251
DepNode { kind, hash: def_path_hash.0.into() }
@@ -260,6 +261,7 @@ impl DepNodeExt for DepNode {
260261
/// DepNode. Condition (2) might not be fulfilled if a DepNode
261262
/// refers to something from the previous compilation session that
262263
/// has been removed.
264+
#[inline]
263265
fn extract_def_id<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Option<DefId> {
264266
if tcx.query_fingerprint_style(self.kind) == FingerprintStyle::DefPathHash {
265267
Some(tcx.def_path_hash_to_def_id(DefPathHash(self.hash.into()), &mut || {
@@ -288,6 +290,7 @@ impl DepNodeExt for DepNode {
288290
}
289291

290292
/// Used in testing
293+
#[inline]
291294
fn has_label_string(label: &str) -> bool {
292295
dep_kind_from_label_string(label).is_ok()
293296
}

compiler/rustc_query_system/src/dep_graph/dep_node.rs

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ impl DepNode {
7777
/// Creates a new, parameterless DepNode. This method will assert
7878
/// that the DepNode corresponding to the given DepKind actually
7979
/// does not require any parameters.
80+
#[inline]
8081
pub fn new_no_params<Ctxt>(tcx: Ctxt, kind: DepKind) -> DepNode
8182
where
8283
Ctxt: super::DepContext,
@@ -121,6 +122,7 @@ fn default_kind_debug(kind: &DepKind, f: &mut std::fmt::Formatter<'_>) -> std::f
121122
}
122123

123124
impl fmt::Debug for DepNode {
125+
#[inline]
124126
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
125127
(*NODE_DEBUG)(self, f)
126128
}
@@ -210,6 +212,7 @@ pub struct WorkProductId {
210212
}
211213

212214
impl WorkProductId {
215+
#[inline]
213216
pub fn from_cgu_name(cgu_name: &str) -> WorkProductId {
214217
let mut hasher = StableHasher::new();
215218
cgu_name.len().hash(&mut hasher);

compiler/rustc_query_system/src/dep_graph/graph.rs

+17
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ impl DepGraph {
147147
}
148148
}
149149

150+
#[inline]
150151
pub fn new_disabled() -> DepGraph {
151152
DepGraph { data: None, virtual_dep_node_index: Lrc::new(AtomicU32::new(0)) }
152153
}
@@ -163,6 +164,7 @@ impl DepGraph {
163164
}
164165
}
165166

167+
#[inline]
166168
pub fn assert_ignored(&self) {
167169
if let Some(..) = self.data {
168170
crate::tls::read_deps(|task_deps| {
@@ -497,18 +499,21 @@ impl DepGraph {
497499
self.data.is_some() && self.dep_node_index_of_opt(dep_node).is_some()
498500
}
499501

502+
#[inline]
500503
pub fn prev_fingerprint_of(&self, dep_node: &DepNode) -> Option<Fingerprint> {
501504
self.data.as_ref().unwrap().previous.fingerprint_of(dep_node)
502505
}
503506

504507
/// Checks whether a previous work product exists for `v` and, if
505508
/// so, return the path that leads to it. Used to skip doing work.
509+
#[inline]
506510
pub fn previous_work_product(&self, v: &WorkProductId) -> Option<WorkProduct> {
507511
self.data.as_ref().and_then(|data| data.previous_work_products.get(v).cloned())
508512
}
509513

510514
/// Access the map of work-products created during the cached run. Only
511515
/// used during saving of the dep-graph.
516+
#[inline]
512517
pub fn previous_work_products(&self) -> &FxHashMap<WorkProductId, WorkProduct> {
513518
&self.data.as_ref().unwrap().previous_work_products
514519
}
@@ -535,10 +540,12 @@ impl DepGraph {
535540
dep_node_debug.borrow_mut().insert(dep_node, debug_str);
536541
}
537542

543+
#[inline]
538544
pub fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
539545
self.data.as_ref()?.dep_node_debug.borrow().get(&dep_node).cloned()
540546
}
541547

548+
#[inline]
542549
fn node_color(&self, dep_node: &DepNode) -> Option<DepNodeColor> {
543550
if let Some(ref data) = self.data {
544551
if let Some(prev_index) = data.previous.node_to_index_opt(dep_node) {
@@ -792,12 +799,14 @@ impl DepGraph {
792799

793800
// Returns true if the given node has been marked as red during the
794801
// current compilation session. Used in various assertions
802+
#[inline]
795803
pub fn is_red(&self, dep_node: &DepNode) -> bool {
796804
self.node_color(dep_node) == Some(DepNodeColor::Red)
797805
}
798806

799807
// Returns true if the given node has been marked as green during the
800808
// current compilation session. Used in various assertions
809+
#[inline]
801810
pub fn is_green(&self, dep_node: &DepNode) -> bool {
802811
self.node_color(dep_node).map_or(false, |c| c.is_green())
803812
}
@@ -838,6 +847,7 @@ impl DepGraph {
838847
}
839848
}
840849

850+
#[inline]
841851
pub fn encode(&self, profiler: &SelfProfilerRef) -> FileEncodeResult {
842852
if let Some(data) = &self.data {
843853
data.current.encoder.steal().finish(profiler)
@@ -846,6 +856,7 @@ impl DepGraph {
846856
}
847857
}
848858

859+
#[inline]
849860
pub(crate) fn next_virtual_depnode_index(&self) -> DepNodeIndex {
850861
let index = self.virtual_dep_node_index.fetch_add(1, Relaxed);
851862
DepNodeIndex::from_u32(index)
@@ -1012,6 +1023,7 @@ impl CurrentDepGraph {
10121023
}
10131024

10141025
#[cfg(debug_assertions)]
1026+
#[inline]
10151027
fn record_edge(&self, dep_node_index: DepNodeIndex, key: DepNode) {
10161028
if let Some(forbidden_edge) = &self.forbidden_edge {
10171029
forbidden_edge.index_to_node.lock().insert(dep_node_index, key);
@@ -1020,6 +1032,7 @@ impl CurrentDepGraph {
10201032

10211033
/// Writes the node to the current dep-graph and allocates a `DepNodeIndex` for it.
10221034
/// Assumes that this is a node that has no equivalent in the previous dep-graph.
1035+
#[inline]
10231036
fn intern_new_node(
10241037
&self,
10251038
profiler: &SelfProfilerRef,
@@ -1040,6 +1053,7 @@ impl CurrentDepGraph {
10401053
}
10411054
}
10421055

1056+
#[inline]
10431057
fn intern_node(
10441058
&self,
10451059
profiler: &SelfProfilerRef,
@@ -1142,6 +1156,7 @@ impl CurrentDepGraph {
11421156
}
11431157
}
11441158

1159+
#[inline]
11451160
fn promote_node_and_deps_to_current(
11461161
&self,
11471162
profiler: &SelfProfilerRef,
@@ -1237,6 +1252,7 @@ const COMPRESSED_RED: u32 = 1;
12371252
const COMPRESSED_FIRST_GREEN: u32 = 2;
12381253

12391254
impl DepNodeColorMap {
1255+
#[inline]
12401256
fn new(size: usize) -> DepNodeColorMap {
12411257
DepNodeColorMap { values: (0..size).map(|_| AtomicU32::new(COMPRESSED_NONE)).collect() }
12421258
}
@@ -1252,6 +1268,7 @@ impl DepNodeColorMap {
12521268
}
12531269
}
12541270

1271+
#[inline]
12551272
fn insert(&self, index: SerializedDepNodeIndex, color: DepNodeColor) {
12561273
self.values[index].store(
12571274
match color {

compiler/rustc_query_system/src/dep_graph/serialized.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub struct SerializedDepGraph {
5353
}
5454

5555
impl Default for SerializedDepGraph {
56+
#[inline]
5657
fn default() -> Self {
5758
SerializedDepGraph {
5859
nodes: Default::default(),
@@ -91,6 +92,7 @@ impl SerializedDepGraph {
9192
self.fingerprints[dep_node_index]
9293
}
9394

95+
#[inline]
9496
pub fn node_count(&self) -> usize {
9597
self.index.len()
9698
}
@@ -147,7 +149,7 @@ impl<'a> Decodable<opaque::Decoder<'a>> for SerializedDepGraph {
147149
}
148150
}
149151

150-
#[derive(Debug, Encodable, Decodable)]
152+
#[derive(Debug, Encodable)]
151153
pub struct NodeInfo {
152154
node: DepNode,
153155
fingerprint: Fingerprint,
@@ -169,6 +171,7 @@ struct EncoderState {
169171
}
170172

171173
impl EncoderState {
174+
#[inline]
172175
fn new(encoder: FileEncoder, record_stats: bool) -> Self {
173176
Self {
174177
encoder,
@@ -239,6 +242,7 @@ pub struct GraphEncoder {
239242
}
240243

241244
impl GraphEncoder {
245+
#[inline]
242246
pub fn new(
243247
encoder: FileEncoder,
244248
prev_node_count: usize,
@@ -312,6 +316,7 @@ impl GraphEncoder {
312316
}
313317
}
314318

319+
#[inline]
315320
pub(crate) fn send(
316321
&self,
317322
profiler: &SelfProfilerRef,
@@ -324,6 +329,7 @@ impl GraphEncoder {
324329
self.status.lock().encode_node(&node, &self.record_graph)
325330
}
326331

332+
#[inline]
327333
pub fn finish(self, profiler: &SelfProfilerRef) -> FileEncodeResult {
328334
let _prof_timer = profiler.generic_activity("incr_comp_encode_dep_graph");
329335
self.status.into_inner().finish(profiler)

compiler/rustc_query_system/src/query/job.rs

+12
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,25 @@ pub type QueryMap = FxHashMap<QueryJobId, QueryJobInfo>;
4141
pub struct QueryJobId(pub NonZeroU64);
4242

4343
impl QueryJobId {
44+
#[inline]
4445
fn query(self, map: &QueryMap) -> QueryStackFrame {
4546
map.get(&self).unwrap().query.clone()
4647
}
4748

4849
#[cfg(parallel_compiler)]
50+
#[inline]
4951
fn span(self, map: &QueryMap) -> Span {
5052
map.get(&self).unwrap().job.span
5153
}
5254

5355
#[cfg(parallel_compiler)]
56+
#[inline]
5457
fn parent(self, map: &QueryMap) -> Option<QueryJobId> {
5558
map.get(&self).unwrap().job.parent
5659
}
5760

5861
#[cfg(parallel_compiler)]
62+
#[inline]
5963
fn latch<'a>(self, map: &'a QueryMap) -> Option<&'a QueryLatch> {
6064
map.get(&self).unwrap().job.latch.as_ref()
6165
}
@@ -84,6 +88,7 @@ pub struct QueryJob {
8488

8589
impl QueryJob {
8690
/// Creates a new query job.
91+
#[inline]
8792
pub fn new(id: QueryJobId, span: Span, parent: Option<QueryJobId>) -> Self {
8893
QueryJob {
8994
id,
@@ -95,6 +100,7 @@ impl QueryJob {
95100
}
96101

97102
#[cfg(parallel_compiler)]
103+
#[inline]
98104
pub(super) fn latch(&mut self) -> QueryLatch {
99105
if self.latch.is_none() {
100106
self.latch = Some(QueryLatch::new());
@@ -106,6 +112,7 @@ impl QueryJob {
106112
///
107113
/// This does nothing for single threaded rustc,
108114
/// as there are no concurrent jobs which could be waiting on us
115+
#[inline]
109116
pub fn signal_complete(self) {
110117
#[cfg(parallel_compiler)]
111118
{
@@ -188,13 +195,15 @@ pub(super) struct QueryLatch {
188195

189196
#[cfg(parallel_compiler)]
190197
impl QueryLatch {
198+
#[inline]
191199
fn new() -> Self {
192200
QueryLatch {
193201
info: Lrc::new(Mutex::new(QueryLatchInfo { complete: false, waiters: Vec::new() })),
194202
}
195203
}
196204

197205
/// Awaits for the query job to complete.
206+
#[inline]
198207
pub(super) fn wait_on(&self, query: Option<QueryJobId>, span: Span) -> Result<(), CycleError> {
199208
let waiter =
200209
Lrc::new(QueryWaiter { query, span, cycle: Lock::new(None), condvar: Condvar::new() });
@@ -210,6 +219,7 @@ impl QueryLatch {
210219
}
211220

212221
/// Awaits the caller on this latch by blocking the current thread.
222+
#[inline]
213223
fn wait_on_inner(&self, waiter: &Lrc<QueryWaiter>) {
214224
let mut info = self.info.lock();
215225
if !info.complete {
@@ -232,6 +242,7 @@ impl QueryLatch {
232242
}
233243

234244
/// Sets the latch and resumes all waiters on it
245+
#[inline]
235246
fn set(&self) {
236247
let mut info = self.info.lock();
237248
debug_assert!(!info.complete);
@@ -244,6 +255,7 @@ impl QueryLatch {
244255

245256
/// Removes a single waiter from the list of waiters.
246257
/// This is used to break query cycles.
258+
#[inline]
247259
fn extract_waiter(&self, waiter: usize) -> Lrc<QueryWaiter> {
248260
let mut info = self.info.lock();
249261
debug_assert!(!info.complete);

0 commit comments

Comments
 (0)