Auto merge of #115401 - Zoxc:freeze, r=oli-obk
Add `FreezeLock` type and use it to store `Definitions` This adds a `FreezeLock` type which allows mutation using a lock until the value is frozen where it can be accessed lock-free. It's used to store `Definitions` in `Untracked` instead of a `RwLock`. Unlike the current scheme of leaking read guards this doesn't deadlock if definitions is written to after no mutation are expected.
This commit is contained in:
commit
a0c28cd9dc
9 changed files with 148 additions and 32 deletions
|
@ -237,6 +237,10 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
|
|||
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
|
||||
});
|
||||
|
||||
// Freeze definitions as we don't add new ones at this point. This improves performance by
|
||||
// allowing lock-free access to them.
|
||||
tcx.untracked().definitions.freeze();
|
||||
|
||||
// FIXME: Remove this when we implement creating `DefId`s
|
||||
// for anon constants during their parents' typeck.
|
||||
// Typeck all body owners in parallel will produce queries
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue