diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2021-05-02 14:04:25 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2021-05-02 14:06:07 -0400 |
| commit | 5065144d6db9b116ad67d37d081e0c13f7ee29d5 (patch) | |
| tree | 2746e8fa31b38e9feaab352708c38fcdfc5fa357 /compiler | |
| parent | 89ebad52a8b5a6d89d66a158d377cd7505ec4b48 (diff) | |
Use new thread-local const-init
Let's see if this gives us any speedup - some of the TLS state modified in this commit *is* pretty heavily accessed, so we can hope!
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_span/src/hygiene.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_span/src/lib.rs | 1 |
5 files changed, 8 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 45ea07a3db6..597a4fd0f52 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -50,6 +50,7 @@ #![feature(control_flow_enum)] #![feature(associated_type_defaults)] #![feature(iter_zip)] +#![feature(thread_local_const_init)] #![recursion_limit = "512"] #[macro_use] diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index b414618f7d5..10f7cc87c7c 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1705,7 +1705,7 @@ pub mod tls { #[cfg(not(parallel_compiler))] thread_local! { /// A thread local variable that stores a pointer to the current `ImplicitCtxt`. - static TLV: Cell<usize> = Cell::new(0); + static TLV: Cell<usize> = const { Cell::new(0) }; } /// Sets TLV to `value` during the call to `f`. diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 1989c91a879..174ec481ae9 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -55,10 +55,10 @@ macro_rules! define_scoped_cx { } thread_local! { - static FORCE_IMPL_FILENAME_LINE: Cell<bool> = Cell::new(false); - static SHOULD_PREFIX_WITH_CRATE: Cell<bool> = Cell::new(false); - static NO_TRIMMED_PATH: Cell<bool> = Cell::new(false); - static NO_QUERIES: Cell<bool> = Cell::new(false); + static FORCE_IMPL_FILENAME_LINE: Cell<bool> = const { Cell::new(false) }; + static SHOULD_PREFIX_WITH_CRATE: Cell<bool> = const { Cell::new(false) }; + static NO_TRIMMED_PATH: Cell<bool> = const { Cell::new(false) }; + static NO_QUERIES: Cell<bool> = const { Cell::new(false) }; } /// Avoids running any queries during any prints that occur diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index f75fe22767f..8b611626fca 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -1330,7 +1330,7 @@ fn update_disambiguator(expn_id: ExpnId) { // This cache is only used by `DummyHashStableContext`, // so we won't pollute the cache values of the normal `StableHashingContext` thread_local! { - static CACHE: ExpnIdCache = Default::default(); + static CACHE: ExpnIdCache = const { ExpnIdCache::new(Vec::new()) }; } &CACHE diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index d30236ec3ec..e0bc7544246 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -20,6 +20,7 @@ #![feature(negative_impls)] #![feature(nll)] #![feature(min_specialization)] +#![feature(thread_local_const_init)] #[macro_use] extern crate rustc_macros; |
