Skip to content

Commit c29a9a8

Browse files
committed
---
yaml --- r: 147818 b: refs/heads/try2 c: 51ace54 h: refs/heads/master v: v3
1 parent 8a6d797 commit c29a9a8

File tree

12 files changed

+232
-66
lines changed

12 files changed

+232
-66
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 8f26d0b9b8725fa74dc36fcf4abf45dc1ca8c56a
8+
refs/heads/try2: 51ace54597984b221321d1cac0f80c50f9e00f71
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/driver/driver.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,4 @@ extern mod this = "rustdoc";
1919
#[cfg(rustc)]
2020
extern mod this = "rustc";
2121

22-
#[cfg(rustdoc_ng)]
23-
extern mod this = "rustdoc_ng";
24-
2522
fn main() { this::main() }

branches/try2/src/etc/emacs/rust-mode.el

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
;; We don't want to indent out to the open bracket if the
5555
;; open bracket ends the line
5656
(when (not (looking-at "[[:blank:]]*\\(?://.*\\)?$"))
57-
(when (looking-at "[[:space:]]") (forward-to-word 1))
57+
(when (looking-at "[[:space:]]")
58+
(forward-word 1)
59+
(backward-word 1))
5860
(current-column))))
5961

6062
(defun rust-mode-indent-line ()

branches/try2/src/libnative/io/net.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,14 @@ pub fn init() {
205205
}
206206

207207
unsafe {
208-
use std::unstable::mutex::{Mutex, MUTEX_INIT};
209-
static mut LOCK: Mutex = MUTEX_INIT;
210-
static mut INITIALIZED: bool = false;
211-
if INITIALIZED { return }
212-
LOCK.lock();
213-
if !INITIALIZED {
208+
use std::unstable::mutex::{Once, ONCE_INIT};
209+
static mut INIT: Once = ONCE_INIT;
210+
INIT.doit(|| {
214211
let mut data: WSADATA = intrinsics::init();
215212
let ret = WSAStartup(0x202, // version 2.2
216213
&mut data);
217214
assert_eq!(ret, 0);
218-
INITIALIZED = true;
219-
}
220-
LOCK.unlock();
215+
});
221216
}
222217
}
223218

branches/try2/src/librustc/back/link.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use std::run;
3434
use std::str;
3535
use std::io;
3636
use std::io::fs;
37+
use extra::hex::ToHex;
3738
use extra::tempfile::TempDir;
3839
use syntax::abi;
3940
use syntax::ast;
@@ -309,9 +310,8 @@ pub mod write {
309310
}
310311

311312
unsafe fn configure_llvm(sess: Session) {
312-
use std::unstable::mutex::{MUTEX_INIT, Mutex};
313-
static mut LOCK: Mutex = MUTEX_INIT;
314-
static mut CONFIGURED: bool = false;
313+
use std::unstable::mutex::{Once, ONCE_INIT};
314+
static mut INIT: Once = ONCE_INIT;
315315

316316
// Copy what clan does by turning on loop vectorization at O2 and
317317
// slp vectorization at O3
@@ -340,8 +340,7 @@ pub mod write {
340340
add(*arg);
341341
}
342342

343-
LOCK.lock();
344-
if !CONFIGURED {
343+
INIT.doit(|| {
345344
llvm::LLVMInitializePasses();
346345

347346
// Only initialize the platforms supported by Rust here, because
@@ -368,9 +367,7 @@ pub mod write {
368367

369368
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
370369
llvm_args.as_ptr());
371-
CONFIGURED = true;
372-
}
373-
LOCK.unlock();
370+
});
374371
}
375372

376373
unsafe fn populate_llvm_passes(fpm: lib::llvm::PassManagerRef,
@@ -494,8 +491,10 @@ pub fn build_link_meta(sess: Session,
494491
}
495492
}
496493

497-
pub fn truncated_hash_result(symbol_hasher: &mut Sha256) -> ~str {
498-
symbol_hasher.result_str()
494+
fn truncated_hash_result(symbol_hasher: &mut Sha256) -> ~str {
495+
let output = symbol_hasher.result_bytes();
496+
// 64 bits should be enough to avoid collisions.
497+
output.slice_to(8).to_hex()
499498
}
500499

501500

@@ -883,8 +882,11 @@ fn link_rlib(sess: Session,
883882
match trans {
884883
Some(trans) => {
885884
// Instead of putting the metadata in an object file section, rlibs
886-
// contain the metadata in a separate file.
887-
let metadata = obj_filename.with_filename(METADATA_FILENAME);
885+
// contain the metadata in a separate file. We use a temp directory
886+
// here so concurrent builds in the same directory don't try to use
887+
// the same filename for metadata (stomping over one another)
888+
let tmpdir = TempDir::new("rustc").expect("needs a temp dir");
889+
let metadata = tmpdir.path().join(METADATA_FILENAME);
888890
fs::File::create(&metadata).write(trans.metadata);
889891
a.add_file(&metadata, false);
890892
fs::unlink(&metadata);

branches/try2/src/librustc/lib/llvm.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,15 +1459,16 @@ pub mod llvm {
14591459
BufferName: *c_char)
14601460
-> MemoryBufferRef;
14611461

1462+
pub fn LLVMIsMultithreaded() -> Bool;
1463+
pub fn LLVMStartMultithreaded() -> Bool;
1464+
14621465
/** Returns a string describing the last error caused by an LLVMRust*
14631466
call. */
14641467
pub fn LLVMRustGetLastError() -> *c_char;
14651468

14661469
/// Print the pass timings since static dtors aren't picking them up.
14671470
pub fn LLVMRustPrintPassTimings();
14681471

1469-
pub fn LLVMRustStartMultithreading() -> bool;
1470-
14711472
pub fn LLVMStructCreateNamed(C: ContextRef, Name: *c_char) -> TypeRef;
14721473

14731474
pub fn LLVMStructSetBody(StructTy: TypeRef,

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3189,8 +3189,21 @@ pub fn trans_crate(sess: session::Session,
31893189
analysis: &CrateAnalysis,
31903190
output: &Path) -> CrateTranslation {
31913191
// Before we touch LLVM, make sure that multithreading is enabled.
3192-
if unsafe { !llvm::LLVMRustStartMultithreading() } {
3193-
sess.bug("couldn't enable multi-threaded LLVM");
3192+
unsafe {
3193+
use std::unstable::mutex::{Once, ONCE_INIT};
3194+
static mut INIT: Once = ONCE_INIT;
3195+
static mut POISONED: bool = false;
3196+
INIT.doit(|| {
3197+
if llvm::LLVMStartMultithreaded() != 1 {
3198+
// use an extra bool to make sure that all future usage of LLVM
3199+
// cannot proceed despite the Once not running more than once.
3200+
POISONED = true;
3201+
}
3202+
});
3203+
3204+
if POISONED {
3205+
sess.bug("couldn't enable multi-threaded LLVM");
3206+
}
31943207
}
31953208

31963209
let mut symbol_hasher = Sha256::new();

branches/try2/src/librustdoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
242242
}
243243

244244
// Load all plugins/passes into a PluginManager
245-
let path = matches.opt_str("plugin-path").unwrap_or(~"/tmp/rustdoc_ng/plugins");
245+
let path = matches.opt_str("plugin-path").unwrap_or(~"/tmp/rustdoc/plugins");
246246
let mut pm = plugins::PluginManager::new(Path::new(path));
247247
for pass in passes.iter() {
248248
let plugin = match PASSES.iter().position(|&(p, _, _)| p == *pass) {

branches/try2/src/libstd/path/posix.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,4 +1404,45 @@ mod bench {
14041404
posix_home_path.ends_with_path(&Path::new("jome"));
14051405
});
14061406
}
1407+
1408+
#[bench]
1409+
fn is_ancestor_of_path_with_10_dirs(bh: &mut BenchHarness) {
1410+
let path = Path::new("/home/1/2/3/4/5/6/7/8/9");
1411+
let mut sub = path.clone();
1412+
sub.pop();
1413+
bh.iter(|| {
1414+
path.is_ancestor_of(&sub);
1415+
});
1416+
}
1417+
1418+
#[bench]
1419+
fn path_relative_from_forward(bh: &mut BenchHarness) {
1420+
let path = Path::new("/a/b/c");
1421+
let mut other = path.clone();
1422+
other.pop();
1423+
bh.iter(|| {
1424+
path.path_relative_from(&other);
1425+
});
1426+
}
1427+
1428+
#[bench]
1429+
fn path_relative_from_same_level(bh: &mut BenchHarness) {
1430+
let path = Path::new("/a/b/c");
1431+
let mut other = path.clone();
1432+
other.pop();
1433+
other.push("d");
1434+
bh.iter(|| {
1435+
path.path_relative_from(&other);
1436+
});
1437+
}
1438+
1439+
#[bench]
1440+
fn path_relative_from_backward(bh: &mut BenchHarness) {
1441+
let path = Path::new("/a/b");
1442+
let mut other = path.clone();
1443+
other.push("c");
1444+
bh.iter(|| {
1445+
path.path_relative_from(&other);
1446+
});
1447+
}
14071448
}

branches/try2/src/libstd/rt/local_ptr.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,30 +160,20 @@ pub mod native {
160160
use option::{Option, Some, None};
161161
use ptr;
162162
use tls = rt::thread_local_storage;
163-
use unstable::mutex::{Mutex, MUTEX_INIT};
164163

165-
static mut LOCK: Mutex = MUTEX_INIT;
166-
static mut INITIALIZED: bool = false;
167164
static mut RT_TLS_KEY: tls::Key = -1;
168165

169166
/// Initialize the TLS key. Other ops will fail if this isn't executed
170167
/// first.
171168
pub fn init() {
172169
unsafe {
173-
LOCK.lock();
174-
if !INITIALIZED {
175-
tls::create(&mut RT_TLS_KEY);
176-
INITIALIZED = true;
177-
}
178-
LOCK.unlock();
170+
tls::create(&mut RT_TLS_KEY);
179171
}
180172
}
181173

182174
pub unsafe fn cleanup() {
183-
rtassert!(INITIALIZED);
175+
rtassert!(RT_TLS_KEY != -1);
184176
tls::destroy(RT_TLS_KEY);
185-
LOCK.destroy();
186-
INITIALIZED = false;
187177
}
188178

189179
/// Give a pointer to thread-local storage.

0 commit comments

Comments
 (0)