Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GlobalCtxt implement Sync #45912

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1263c9e
Add sync module to rustc_data_structures
Zoxc Dec 3, 2017
9ee978b
Make arenas thread safe
Zoxc Dec 3, 2017
a31997f
Combine GlobalArenas and DroplessArena into AllArenas
Zoxc Dec 3, 2017
2f2048c
A SameThread type is introduced in src/librustc_trans/metadata.rs whi…
Zoxc Dec 3, 2017
81ca5f9
Make mk_attr_id thread safe
Zoxc Dec 3, 2017
51d8948
Make err_count thread safe
Zoxc Dec 3, 2017
d8eb707
Refactor code so the call to codemap.files() does not deadlock
Zoxc Dec 3, 2017
461548e
Convert IGNORED_ATTR_NAMES into a global variable and initialize it o…
Zoxc Dec 3, 2017
79ff212
Add a -Z query_threads compiler option
Zoxc Dec 3, 2017
11524d5
Assert that GlobalCtxt is Sync
Zoxc Dec 3, 2017
a5f71b8
Make PROFQ_CHAN a global
Zoxc Dec 3, 2017
be828a0
Make IndexVec implement Send and Sync
Zoxc Dec 3, 2017
b66aab1
Make TransitiveRelation thread safe. Avoid locking by using get_mut i…
Zoxc Dec 3, 2017
e12074f
Remove useless Rc
Zoxc Dec 3, 2017
5549ada
Use rustc_erase_owner! which produces a Send + Sync erased owner if c…
Zoxc Dec 3, 2017
1155689
Add Encodable and Decodable impls for Arc<[T]>
Zoxc Dec 3, 2017
35fbe11
Make USED_ATTRS and KNOWN_ATTRS into globals
Zoxc Dec 3, 2017
5c4dacd
Make REGISTERED_DIAGNOSTICS a global
Zoxc Dec 3, 2017
9251af3
FIXME note + thread safety
Zoxc Dec 3, 2017
868dda0
Make HYGIENE_DATA a global
Zoxc Dec 3, 2017
2d3112a
Make Span and Symbol implement Send and Sync
Zoxc Dec 3, 2017
6e573cb
Make InternedString Send
Zoxc Dec 3, 2017
3bb008d
Make syntax_pos interners globals
Zoxc Dec 3, 2017
e3a63ed
Mechanical translation which results in GlobalCtxt being Sync
Zoxc Dec 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make syntax_pos interners globals
  • Loading branch information
Zoxc committed Dec 8, 2017
commit 3bb008d6cf9993872fb315429c063391aef4145f
10 changes: 5 additions & 5 deletions src/libsyntax_pos/span_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use {BytePos, SpanData};
use hygiene::SyntaxContext;

use rustc_data_structures::fx::FxHashMap;
use std::cell::RefCell;
use rustc_data_structures::sync::Lock;

/// A compressed span.
/// Contains either fields of `SpanData` inline if they are small, or index into span interner.
Expand Down Expand Up @@ -135,11 +135,11 @@ impl SpanInterner {
}
}

// If an interner exists in TLS, return it. Otherwise, prepare a fresh one.
// If an interner exists, return it. Otherwise, prepare a fresh one.
#[inline]
fn with_span_interner<T, F: FnOnce(&mut SpanInterner) -> T>(f: F) -> T {
thread_local!(static INTERNER: RefCell<SpanInterner> = {
RefCell::new(SpanInterner::default())
rustc_global!(static INTERNER: Lock<SpanInterner> = {
Lock::new(SpanInterner::default())
});
INTERNER.with(|interner| f(&mut *interner.borrow_mut()))
rustc_access_global!(INTERNER, |interner| f(&mut *interner.lock()))
}
12 changes: 7 additions & 5 deletions src/libsyntax_pos/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

use hygiene::SyntaxContext;

use rustc_data_structures::sync::Lock;
use serialize::{Decodable, Decoder, Encodable, Encoder};
use std::cell::RefCell;
use std::collections::HashMap;
use std::fmt;

Expand Down Expand Up @@ -326,12 +326,14 @@ declare_keywords! {
(60, Union, "union")
}

// If an interner exists in TLS, return it. Otherwise, prepare a fresh one.

// If an interner exists, return it. Otherwise, prepare a fresh one.
#[inline]
fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
thread_local!(static INTERNER: RefCell<Interner> = {
RefCell::new(Interner::fresh())
rustc_global!(static INTERNER: Lock<Interner> = {
Lock::new(Interner::fresh())
});
INTERNER.with(|interner| f(&mut *interner.borrow_mut()))
rustc_access_global!(INTERNER, |interner| f(&mut *interner.lock()))
}

/// Represents a string stored in the thread-local interner. Because the
Expand Down