Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3391579

Browse files
committed
Add comment and move assertion.
1 parent f04d961 commit 3391579

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

‎compiler/rustc_metadata/src/rmeta/encoder.rs‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,11 @@ impl<D: Decoder> Decodable<D> for EncodedMetadata {
23502350

23512351
#[instrument(level = "trace", skip(tcx))]
23522352
pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path, ref_path: Option<&Path>) {
2353+
// Since encoding metadata is not in a query, and nothing is cached,
2354+
// there's no need to do dep-graph tracking for any of it.
2355+
tcx.dep_graph.assert_ignored();
2356+
2357+
// Generate the metadata stub manually, as that is a small file compared to full metadata.
23532358
if let Some(ref_path) = ref_path {
23542359
let _prof_timer = tcx.prof.verbose_generic_activity("generate_crate_metadata_stub");
23552360

@@ -2362,11 +2367,14 @@ pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path, ref_path: Option<&Path>) {
23622367
is_stub: true,
23632368
});
23642369
header.position.get()
2365-
});
2370+
})
23662371
}
23672372

2373+
let _prof_timer = tcx.prof.verbose_generic_activity("generate_crate_metadata");
2374+
23682375
let dep_node = tcx.metadata_dep_node();
23692376

2377+
// If the metadata dep-node is green, try to reuse the saved work product.
23702378
if tcx.dep_graph.is_fully_enabled()
23712379
&& let work_product_id = WorkProductId::from_cgu_name("metadata")
23722380
&& let Some(work_product) = tcx.dep_graph.previous_work_product(&work_product_id)
@@ -2383,19 +2391,15 @@ pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path, ref_path: Option<&Path>) {
23832391
return;
23842392
};
23852393

2386-
let _prof_timer = tcx.prof.verbose_generic_activity("generate_crate_metadata");
2387-
2388-
// Since encoding metadata is not in a query, and nothing is cached,
2389-
// there's no need to do dep-graph tracking for any of it.
2390-
tcx.dep_graph.assert_ignored();
2391-
23922394
if tcx.sess.threads() != 1 {
23932395
// Prefetch some queries used by metadata encoding.
23942396
// This is not necessary for correctness, but is only done for performance reasons.
23952397
// It can be removed if it turns out to cause trouble or be detrimental to performance.
23962398
join(|| prefetch_mir(tcx), || tcx.exported_symbols(LOCAL_CRATE));
23972399
}
23982400

2401+
// Perform metadata encoding inside a task, so the dep-graph can check if any encoded
2402+
// information changes, and maybe reuse the work product.
23992403
tcx.dep_graph.with_task(
24002404
dep_node,
24012405
tcx,
@@ -2416,7 +2420,7 @@ pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path, ref_path: Option<&Path>) {
24162420
);
24172421

24182422
root.position.get()
2419-
});
2423+
})
24202424
},
24212425
None,
24222426
);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /