diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-04-06 12:56:59 +0200 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-06-06 15:25:16 +0200 |
| commit | f9e6fbc4f751a5fd4befaf91ad4b1022efb99501 (patch) | |
| tree | ba97adcc611fcecb1375143e8c9833b23752d2bd /src/librustc_driver | |
| parent | 685faa2c3ee062aaf30ddf6d3daf4ef3b576979b (diff) | |
| download | rust-f9e6fbc4f751a5fd4befaf91ad4b1022efb99501.tar.gz rust-f9e6fbc4f751a5fd4befaf91ad4b1022efb99501.zip | |
Make queries block and handle query cycles
Diffstat (limited to 'src/librustc_driver')
| -rw-r--r-- | src/librustc_driver/driver.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 8dcbda917b2..c2a450a1122 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -49,7 +49,7 @@ use std::fs; use std::io::{self, Write}; use std::iter; use std::path::{Path, PathBuf}; -use rustc_data_structures::sync::{self, Lrc}; +use rustc_data_structures::sync::{self, Lrc, Lock}; use std::sync::mpsc; use syntax::{self, ast, attr, diagnostics, visit}; use syntax::ext::base::ExtCtxt; @@ -69,7 +69,9 @@ pub fn spawn_thread_pool<F: FnOnce(config::Options) -> R + sync::Send, R: sync:: opts: config::Options, f: F ) -> R { - f(opts) + ty::tls::GCX_PTR.set(&Lock::new(0), || { + f(opts) + }) } #[cfg(parallel_queries)] @@ -81,7 +83,10 @@ pub fn spawn_thread_pool<F: FnOnce(config::Options) -> R + sync::Send, R: sync:: use syntax_pos; use rayon::{ThreadPoolBuilder, ThreadPool}; + let gcx_ptr = &Lock::new(0); + let config = ThreadPoolBuilder::new().num_threads(Session::query_threads_from_opts(&opts)) + .deadlock_handler(ty::maps::handle_deadlock) .stack_size(16 * 1024 * 1024); let with_pool = move |pool: &ThreadPool| { @@ -98,7 +103,9 @@ pub fn spawn_thread_pool<F: FnOnce(config::Options) -> R + sync::Send, R: sync:: syntax::GLOBALS.set(syntax_globals, || { syntax_pos::GLOBALS.set(syntax_pos_globals, || { ty::tls::with_thread_locals(|| { - worker() + ty::tls::GCX_PTR.set(gcx_ptr, || { + worker() + }) }) }) }) |
