Skip to content

Commit 486a387

Browse files
committed
Split execute_job into execute_job_incr and execute_job_non_incr
1 parent ab9bb3e commit 486a387

File tree

1 file changed

+39
-30
lines changed

1 file changed

+39
-30
lines changed

compiler/rustc_query_system/src/query/plumbing.rs

+39-30
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,11 @@ where
379379

380380
match JobOwner::<'_, Q::Key, Qcx::DepKind>::try_start(&qcx, state, state_lock, span, key) {
381381
TryGetJob::NotYetStarted(job) => {
382-
let (result, dep_node_index) = execute_job(query, qcx, key.clone(), dep_node, job.id);
382+
let (result, dep_node_index) = match qcx.dep_context().dep_graph().data() {
383+
None => execute_job_non_incr(query, qcx, key, job.id),
384+
Some(data) => execute_job_incr(query, qcx, data, key, dep_node, job.id),
385+
};
386+
383387
let cache = query.query_cache(qcx);
384388
if query.feedable() {
385389
// We should not compute queries that also got a value via feeding.
@@ -413,48 +417,53 @@ where
413417
}
414418
}
415419

420+
// Fast path for when incr. comp. is off.
416421
#[inline(always)]
417-
fn execute_job<Q, Qcx>(
422+
fn execute_job_non_incr<Q, Qcx>(
418423
query: Q,
419424
qcx: Qcx,
420425
key: Q::Key,
421-
mut dep_node_opt: Option<DepNode<Qcx::DepKind>>,
422426
job_id: QueryJobId,
423427
) -> (Q::Value, DepNodeIndex)
424428
where
425429
Q: QueryConfig<Qcx>,
426430
Qcx: QueryContext,
427431
{
428-
let dep_graph = qcx.dep_context().dep_graph();
429-
let dep_graph_data = match dep_graph.data() {
430-
// Fast path for when incr. comp. is off.
431-
None => {
432-
// Fingerprint the key, just to assert that it doesn't
433-
// have anything we don't consider hashable
434-
if cfg!(debug_assertions) {
435-
let _ = key.to_fingerprint(*qcx.dep_context());
436-
}
432+
// Fingerprint the key, just to assert that it doesn't
433+
// have anything we don't consider hashable
434+
if cfg!(debug_assertions) {
435+
let _ = key.to_fingerprint(*qcx.dep_context());
436+
}
437437

438-
let prof_timer = qcx.dep_context().profiler().query_provider();
439-
let result =
440-
qcx.start_query(job_id, query.depth_limit(), None, || query.compute(qcx, key));
441-
let dep_node_index = dep_graph.next_virtual_depnode_index();
442-
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
443-
444-
// Similarly, fingerprint the result to assert that
445-
// it doesn't have anything not considered hashable.
446-
if cfg!(debug_assertions) && let Some(hash_result) = query.hash_result()
447-
{
448-
qcx.dep_context().with_stable_hashing_context(|mut hcx| {
449-
hash_result(&mut hcx, &result);
450-
});
451-
}
438+
let prof_timer = qcx.dep_context().profiler().query_provider();
439+
let result = qcx.start_query(job_id, query.depth_limit(), None, || query.compute(qcx, key));
440+
let dep_node_index = qcx.dep_context().dep_graph().next_virtual_depnode_index();
441+
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
452442

453-
return (result, dep_node_index);
454-
}
455-
Some(data) => data,
456-
};
443+
// Similarly, fingerprint the result to assert that
444+
// it doesn't have anything not considered hashable.
445+
if cfg!(debug_assertions) && let Some(hash_result) = query.hash_result() {
446+
qcx.dep_context().with_stable_hashing_context(|mut hcx| {
447+
hash_result(&mut hcx, &result);
448+
});
449+
}
457450

451+
(result, dep_node_index)
452+
}
453+
454+
#[inline(always)]
455+
fn execute_job_incr<Q, Qcx>(
456+
query: Q,
457+
qcx: Qcx,
458+
dep_graph_data: &DepGraphData<Qcx::DepKind>,
459+
key: Q::Key,
460+
mut dep_node_opt: Option<DepNode<Qcx::DepKind>>,
461+
job_id: QueryJobId,
462+
) -> (Q::Value, DepNodeIndex)
463+
where
464+
Q: QueryConfig<Qcx>,
465+
Qcx: QueryContext,
466+
{
458467
if !query.anon() && !query.eval_always() {
459468
// `to_dep_node` is expensive for some `DepKind`s.
460469
let dep_node =

0 commit comments

Comments
 (0)