Skip to content

Commit 3bb008d

Browse files
committed
Make syntax_pos interners globals
1 parent 6e573cb commit 3bb008d

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/libsyntax_pos/span_encoding.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use {BytePos, SpanData};
1818
use hygiene::SyntaxContext;
1919

2020
use rustc_data_structures::fx::FxHashMap;
21-
use std::cell::RefCell;
21+
use rustc_data_structures::sync::Lock;
2222

2323
/// A compressed span.
2424
/// Contains either fields of `SpanData` inline if they are small, or index into span interner.
@@ -135,11 +135,11 @@ impl SpanInterner {
135135
}
136136
}
137137

138-
// If an interner exists in TLS, return it. Otherwise, prepare a fresh one.
138+
// If an interner exists, return it. Otherwise, prepare a fresh one.
139139
#[inline]
140140
fn with_span_interner<T, F: FnOnce(&mut SpanInterner) -> T>(f: F) -> T {
141-
thread_local!(static INTERNER: RefCell<SpanInterner> = {
142-
RefCell::new(SpanInterner::default())
141+
rustc_global!(static INTERNER: Lock<SpanInterner> = {
142+
Lock::new(SpanInterner::default())
143143
});
144-
INTERNER.with(|interner| f(&mut *interner.borrow_mut()))
144+
rustc_access_global!(INTERNER, |interner| f(&mut *interner.lock()))
145145
}

src/libsyntax_pos/symbol.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
1515
use hygiene::SyntaxContext;
1616

17+
use rustc_data_structures::sync::Lock;
1718
use serialize::{Decodable, Decoder, Encodable, Encoder};
18-
use std::cell::RefCell;
1919
use std::collections::HashMap;
2020
use std::fmt;
2121

@@ -326,12 +326,14 @@ declare_keywords! {
326326
(60, Union, "union")
327327
}
328328

329-
// If an interner exists in TLS, return it. Otherwise, prepare a fresh one.
329+
330+
// If an interner exists, return it. Otherwise, prepare a fresh one.
331+
#[inline]
330332
fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
331-
thread_local!(static INTERNER: RefCell<Interner> = {
332-
RefCell::new(Interner::fresh())
333+
rustc_global!(static INTERNER: Lock<Interner> = {
334+
Lock::new(Interner::fresh())
333335
});
334-
INTERNER.with(|interner| f(&mut *interner.borrow_mut()))
336+
rustc_access_global!(INTERNER, |interner| f(&mut *interner.lock()))
335337
}
336338

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

0 commit comments

Comments
 (0)