Skip to content

Commit a6458ce

Browse files
committed
Add inline.
1 parent 24a7c7f commit a6458ce

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

compiler/rustc_query_system/src/dep_graph/dep_kind.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static_assert_size!(DepNode, 24);
6262

6363
impl DepNode {
6464
/// Used in testing
65+
#[inline]
6566
pub fn has_label_string(label: &str) -> bool {
6667
dep_kind_from_label_string(label).is_ok()
6768
}

compiler/rustc_query_system/src/dep_graph/dep_node.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ impl DepNode {
6161
/// Creates a new, parameterless DepNode. This method will assert
6262
/// that the DepNode corresponding to the given DepKind actually
6363
/// does not require any parameters.
64+
#[inline]
6465
pub fn new_no_params<Ctxt>(tcx: Ctxt, kind: DepKind) -> DepNode
6566
where
6667
Ctxt: super::DepContext,
@@ -92,6 +93,7 @@ impl DepNode {
9293
}
9394

9495
impl fmt::Debug for DepNode {
96+
#[inline]
9597
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9698
(*NODE_DEBUG)(self, f)
9799
}
@@ -170,6 +172,7 @@ pub struct WorkProductId {
170172
}
171173

172174
impl WorkProductId {
175+
#[inline]
173176
pub fn from_cgu_name(cgu_name: &str) -> WorkProductId {
174177
let mut hasher = StableHasher::new();
175178
cgu_name.len().hash(&mut hasher);

compiler/rustc_query_system/src/dep_graph/graph.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ impl DepGraph {
140140
}
141141
}
142142

143+
#[inline]
143144
pub fn new_disabled() -> DepGraph {
144145
DepGraph { data: None, virtual_dep_node_index: Lrc::new(AtomicU32::new(0)) }
145146
}
@@ -156,6 +157,7 @@ impl DepGraph {
156157
}
157158
}
158159

160+
#[inline]
159161
pub fn assert_ignored(&self) {
160162
if let Some(..) = self.data {
161163
crate::tls::read_deps(|task_deps| {
@@ -422,18 +424,21 @@ impl DepGraph {
422424
self.data.is_some() && self.dep_node_index_of_opt(dep_node).is_some()
423425
}
424426

427+
#[inline]
425428
pub fn prev_fingerprint_of(&self, dep_node: &DepNode) -> Option<Fingerprint> {
426429
self.data.as_ref().unwrap().previous.fingerprint_of(dep_node)
427430
}
428431

429432
/// Checks whether a previous work product exists for `v` and, if
430433
/// so, return the path that leads to it. Used to skip doing work.
434+
#[inline]
431435
pub fn previous_work_product(&self, v: &WorkProductId) -> Option<WorkProduct> {
432436
self.data.as_ref().and_then(|data| data.previous_work_products.get(v).cloned())
433437
}
434438

435439
/// Access the map of work-products created during the cached run. Only
436440
/// used during saving of the dep-graph.
441+
#[inline]
437442
pub fn previous_work_products(&self) -> &FxHashMap<WorkProductId, WorkProduct> {
438443
&self.data.as_ref().unwrap().previous_work_products
439444
}
@@ -452,10 +457,12 @@ impl DepGraph {
452457
dep_node_debug.borrow_mut().insert(dep_node, debug_str);
453458
}
454459

460+
#[inline]
455461
pub fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
456462
self.data.as_ref()?.dep_node_debug.borrow().get(&dep_node).cloned()
457463
}
458464

465+
#[inline]
459466
fn node_color(&self, dep_node: &DepNode) -> Option<DepNodeColor> {
460467
if let Some(ref data) = self.data {
461468
if let Some(prev_index) = data.previous.node_to_index_opt(dep_node) {
@@ -709,12 +716,14 @@ impl DepGraph {
709716

710717
// Returns true if the given node has been marked as red during the
711718
// current compilation session. Used in various assertions
719+
#[inline]
712720
pub fn is_red(&self, dep_node: &DepNode) -> bool {
713721
self.node_color(dep_node) == Some(DepNodeColor::Red)
714722
}
715723

716724
// Returns true if the given node has been marked as green during the
717725
// current compilation session. Used in various assertions
726+
#[inline]
718727
pub fn is_green(&self, dep_node: &DepNode) -> bool {
719728
self.node_color(dep_node).map_or(false, |c| c.is_green())
720729
}
@@ -755,6 +764,7 @@ impl DepGraph {
755764
}
756765
}
757766

767+
#[inline]
758768
pub fn encode(&self, profiler: &SelfProfilerRef) -> FileEncodeResult {
759769
if let Some(data) = &self.data {
760770
data.current.encoder.steal().finish(profiler)
@@ -763,6 +773,7 @@ impl DepGraph {
763773
}
764774
}
765775

776+
#[inline]
766777
pub(crate) fn next_virtual_depnode_index(&self) -> DepNodeIndex {
767778
let index = self.virtual_dep_node_index.fetch_add(1, Relaxed);
768779
DepNodeIndex::from_u32(index)
@@ -929,6 +940,7 @@ impl CurrentDepGraph {
929940
}
930941

931942
#[cfg(debug_assertions)]
943+
#[inline]
932944
fn record_edge(&self, dep_node_index: DepNodeIndex, key: DepNode) {
933945
if let Some(forbidden_edge) = &self.forbidden_edge {
934946
forbidden_edge.index_to_node.lock().insert(dep_node_index, key);
@@ -937,6 +949,7 @@ impl CurrentDepGraph {
937949

938950
/// Writes the node to the current dep-graph and allocates a `DepNodeIndex` for it.
939951
/// Assumes that this is a node that has no equivalent in the previous dep-graph.
952+
#[inline]
940953
fn intern_new_node(
941954
&self,
942955
profiler: &SelfProfilerRef,
@@ -957,6 +970,7 @@ impl CurrentDepGraph {
957970
}
958971
}
959972

973+
#[inline]
960974
fn intern_node(
961975
&self,
962976
profiler: &SelfProfilerRef,
@@ -1059,6 +1073,7 @@ impl CurrentDepGraph {
10591073
}
10601074
}
10611075

1076+
#[inline]
10621077
fn promote_node_and_deps_to_current(
10631078
&self,
10641079
profiler: &SelfProfilerRef,
@@ -1129,6 +1144,7 @@ const COMPRESSED_RED: u32 = 1;
11291144
const COMPRESSED_FIRST_GREEN: u32 = 2;
11301145

11311146
impl DepNodeColorMap {
1147+
#[inline]
11321148
fn new(size: usize) -> DepNodeColorMap {
11331149
DepNodeColorMap { values: (0..size).map(|_| AtomicU32::new(COMPRESSED_NONE)).collect() }
11341150
}
@@ -1144,6 +1160,7 @@ impl DepNodeColorMap {
11441160
}
11451161
}
11461162

1163+
#[inline]
11471164
fn insert(&self, index: SerializedDepNodeIndex, color: DepNodeColor) {
11481165
self.values[index].store(
11491166
match color {

compiler/rustc_query_system/src/dep_graph/serialized.rs

Lines changed: 7 additions & 1 deletion
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
}
@@ -153,7 +155,7 @@ impl<'a> Decodable<opaque::Decoder<'a>> for SerializedDepGraph {
153155
}
154156
}
155157

156-
#[derive(Debug, Encodable, Decodable)]
158+
#[derive(Debug, Encodable)]
157159
pub struct NodeInfo {
158160
node: DepNode,
159161
fingerprint: Fingerprint,
@@ -175,6 +177,7 @@ struct EncoderState {
175177
}
176178

177179
impl EncoderState {
180+
#[inline]
178181
fn new(encoder: FileEncoder, record_stats: bool) -> Self {
179182
Self {
180183
encoder,
@@ -247,6 +250,7 @@ pub struct GraphEncoder {
247250
}
248251

249252
impl GraphEncoder {
253+
#[inline]
250254
pub fn new(
251255
encoder: FileEncoder,
252256
prev_node_count: usize,
@@ -320,6 +324,7 @@ impl GraphEncoder {
320324
}
321325
}
322326

327+
#[inline]
323328
pub(crate) fn send(
324329
&self,
325330
profiler: &SelfProfilerRef,
@@ -332,6 +337,7 @@ impl GraphEncoder {
332337
self.status.lock().encode_node(&node, &self.record_graph)
333338
}
334339

340+
#[inline]
335341
pub fn finish(self, profiler: &SelfProfilerRef) -> FileEncodeResult {
336342
let _prof_timer = profiler.generic_activity("incr_comp_encode_dep_graph");
337343
self.status.into_inner().finish(profiler)

compiler/rustc_query_system/src/query/job.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,30 @@ pub struct QueryJobId {
5353
}
5454

5555
impl QueryJobId {
56+
#[inline]
5657
pub fn new(job: QueryShardJobId, shard: usize, kind: DepKind) -> Self {
5758
QueryJobId { job, shard: u16::try_from(shard).unwrap(), kind }
5859
}
5960

61+
#[inline]
6062
fn query(self, map: &QueryMap) -> QueryStackFrame {
6163
map.get(&self).unwrap().query.clone()
6264
}
6365

6466
#[cfg(parallel_compiler)]
67+
#[inline]
6568
fn span(self, map: &QueryMap) -> Span {
6669
map.get(&self).unwrap().job.span
6770
}
6871

6972
#[cfg(parallel_compiler)]
73+
#[inline]
7074
fn parent(self, map: &QueryMap) -> Option<QueryJobId> {
7175
map.get(&self).unwrap().job.parent
7276
}
7377

7478
#[cfg(parallel_compiler)]
79+
#[inline]
7580
fn latch<'a>(self, map: &'a QueryMap) -> Option<&'a QueryLatch> {
7681
map.get(&self).unwrap().job.latch.as_ref()
7782
}
@@ -100,6 +105,7 @@ pub struct QueryJob {
100105

101106
impl QueryJob {
102107
/// Creates a new query job.
108+
#[inline]
103109
pub fn new(id: QueryShardJobId, span: Span, parent: Option<QueryJobId>) -> Self {
104110
QueryJob {
105111
id,
@@ -111,6 +117,7 @@ impl QueryJob {
111117
}
112118

113119
#[cfg(parallel_compiler)]
120+
#[inline]
114121
pub(super) fn latch(&mut self) -> QueryLatch {
115122
if self.latch.is_none() {
116123
self.latch = Some(QueryLatch::new());
@@ -122,6 +129,7 @@ impl QueryJob {
122129
///
123130
/// This does nothing for single threaded rustc,
124131
/// as there are no concurrent jobs which could be waiting on us
132+
#[inline]
125133
pub fn signal_complete(self) {
126134
#[cfg(parallel_compiler)]
127135
{
@@ -204,6 +212,7 @@ pub(super) struct QueryLatch {
204212

205213
#[cfg(parallel_compiler)]
206214
impl QueryLatch {
215+
#[inline]
207216
fn new() -> Self {
208217
QueryLatch {
209218
info: Lrc::new(Mutex::new(QueryLatchInfo { complete: false, waiters: Vec::new() })),
@@ -214,6 +223,7 @@ impl QueryLatch {
214223
#[cfg(parallel_compiler)]
215224
impl QueryLatch {
216225
/// Awaits for the query job to complete.
226+
#[inline]
217227
pub(super) fn wait_on(&self, query: Option<QueryJobId>, span: Span) -> Result<(), CycleError> {
218228
let waiter =
219229
Lrc::new(QueryWaiter { query, span, cycle: Lock::new(None), condvar: Condvar::new() });
@@ -229,6 +239,7 @@ impl QueryLatch {
229239
}
230240

231241
/// Awaits the caller on this latch by blocking the current thread.
242+
#[inline]
232243
fn wait_on_inner(&self, waiter: &Lrc<QueryWaiter>) {
233244
let mut info = self.info.lock();
234245
if !info.complete {
@@ -251,6 +262,7 @@ impl QueryLatch {
251262
}
252263

253264
/// Sets the latch and resumes all waiters on it
265+
#[inline]
254266
fn set(&self) {
255267
let mut info = self.info.lock();
256268
debug_assert!(!info.complete);
@@ -263,6 +275,7 @@ impl QueryLatch {
263275

264276
/// Removes a single waiter from the list of waiters.
265277
/// This is used to break query cycles.
278+
#[inline]
266279
fn extract_waiter(&self, waiter: usize) -> Lrc<QueryWaiter> {
267280
let mut info = self.info.lock();
268281
debug_assert!(!info.complete);

0 commit comments

Comments
 (0)