Skip to content

Commit ad7b865

Browse files
committed
wip
1 parent d5ff0e6 commit ad7b865

File tree

26 files changed

+334
-180
lines changed

26 files changed

+334
-180
lines changed

src/Cargo.lock

+67
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/libproc_macro/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ mod diagnostic;
5050
pub use diagnostic::{Diagnostic, Level};
5151

5252
use std::{ascii, fmt, iter};
53-
use std::rc::Rc;
53+
use std::sync::Arc;
5454
use std::str::FromStr;
5555

5656
use syntax::ast;
@@ -274,7 +274,7 @@ pub struct LineColumn {
274274
#[unstable(feature = "proc_macro", issue = "38356")]
275275
#[derive(Clone)]
276276
pub struct SourceFile {
277-
filemap: Rc<FileMap>,
277+
filemap: Arc<FileMap>,
278278
}
279279

280280
impl SourceFile {
@@ -324,7 +324,7 @@ impl fmt::Debug for SourceFile {
324324
#[unstable(feature = "proc_macro", issue = "38356")]
325325
impl PartialEq for SourceFile {
326326
fn eq(&self, other: &Self) -> bool {
327-
Rc::ptr_eq(&self.filemap, &other.filemap)
327+
Arc::ptr_eq(&self.filemap, &other.filemap)
328328
}
329329
}
330330

src/librustc/ich/caching_codemap_view.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::rc::Rc;
11+
use std::sync::Arc;
1212
use syntax::codemap::CodeMap;
1313
use syntax_pos::{BytePos, FileMap};
1414

@@ -18,7 +18,7 @@ struct CacheEntry {
1818
line_number: usize,
1919
line_start: BytePos,
2020
line_end: BytePos,
21-
file: Rc<FileMap>,
21+
file: Arc<FileMap>,
2222
file_index: usize,
2323
}
2424

@@ -51,7 +51,7 @@ impl<'cm> CachingCodemapView<'cm> {
5151

5252
pub fn byte_pos_to_line_and_col(&mut self,
5353
pos: BytePos)
54-
-> Option<(Rc<FileMap>, usize, BytePos)> {
54+
-> Option<(Arc<FileMap>, usize, BytePos)> {
5555
self.time_stamp += 1;
5656

5757
// Check if the position is in one of the cached lines
@@ -78,11 +78,9 @@ impl<'cm> CachingCodemapView<'cm> {
7878
// If the entry doesn't point to the correct file, fix it up
7979
if pos < cache_entry.file.start_pos || pos >= cache_entry.file.end_pos {
8080
let file_valid;
81-
let files = self.codemap.files();
82-
83-
if files.len() > 0 {
81+
if self.codemap.files().len() > 0 {
8482
let file_index = self.codemap.lookup_filemap_idx(pos);
85-
let file = files[file_index].clone();
83+
let file = self.codemap.files()[file_index].clone();
8684

8785
if pos >= file.start_pos && pos < file.end_pos {
8886
cache_entry.file = file;

src/librustc/session/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
10101010
"prints the llvm optimization passes being run"),
10111011
ast_json: bool = (false, parse_bool, [UNTRACKED],
10121012
"print the AST as JSON and halt"),
1013+
query_threads: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
1014+
"execute queries on a thread pool with N threads"),
10131015
ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
10141016
"print the pre-expansion AST as JSON and halt"),
10151017
ls: bool = (false, parse_bool, [UNTRACKED],
@@ -1584,6 +1586,10 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
15841586
}
15851587
}
15861588

1589+
if debugging_opts.query_threads == Some(0) {
1590+
early_error(error_format, "Value for codegen units must be a positive nonzero integer");
1591+
}
1592+
15871593
if codegen_units == Some(0) {
15881594
early_error(error_format, "Value for codegen units must be a positive nonzero integer");
15891595
}

src/librustc/session/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,12 @@ impl Session {
657657
ret
658658
}
659659

660+
/// Returns the number of query threads that should be used for this
661+
/// compilation
662+
pub fn query_threads(&self) -> usize {
663+
self.opts.debugging_opts.query_threads.unwrap_or(1)
664+
}
665+
660666
/// Returns the number of codegen units that should be used for this
661667
/// compilation
662668
pub fn codegen_units(&self) -> usize {

0 commit comments

Comments
 (0)