Skip to content

Commit 51d2d8a

Browse files
committed
---
yaml --- r: 172925 b: refs/heads/batch c: 56f3554 h: refs/heads/master i: 172923: 09bc8ee v: v3
1 parent 794eb70 commit 51d2d8a

File tree

18 files changed

+118
-273
lines changed

18 files changed

+118
-273
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/issue-18208-method-dispatch-2: 9e1eae4fb9b6527315b4441cf8a0f5ca911d1671
3030
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
32-
refs/heads/batch: 4fd1e6235dd241939475f79c8f58a455f5996690
32+
refs/heads/batch: 56f3554f52e50712fe0830720d8f7e4a4fdaa0cf
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 44a287e6eb22ec3c2a687fc156813577464017f7
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

branches/batch/src/librustc/metadata/csearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn get_item_attrs<F>(cstore: &cstore::CStore,
209209
F: FnOnce(Vec<ast::Attribute>),
210210
{
211211
let cdata = cstore.get_crate_data(def_id.krate);
212-
decoder::get_item_attrs(&*cdata, def_id.node, f)
212+
f(decoder::get_item_attrs(&*cdata, def_id.node));
213213
}
214214

215215
pub fn get_struct_fields(cstore: &cstore::CStore,

branches/batch/src/librustc/metadata/decoder.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,18 +1025,16 @@ pub fn get_tuple_struct_definition_if_ctor(cdata: Cmd,
10251025
ret
10261026
}
10271027

1028-
pub fn get_item_attrs<F>(cdata: Cmd,
1029-
orig_node_id: ast::NodeId,
1030-
f: F) where
1031-
F: FnOnce(Vec<ast::Attribute>),
1032-
{
1028+
pub fn get_item_attrs(cdata: Cmd,
1029+
orig_node_id: ast::NodeId)
1030+
-> Vec<ast::Attribute> {
10331031
// The attributes for a tuple struct are attached to the definition, not the ctor;
10341032
// we assume that someone passing in a tuple struct ctor is actually wanting to
10351033
// look at the definition
10361034
let node_id = get_tuple_struct_definition_if_ctor(cdata, orig_node_id);
10371035
let node_id = node_id.map(|x| x.node).unwrap_or(orig_node_id);
10381036
let item = lookup_item(node_id, cdata.data());
1039-
f(get_attributes(item));
1037+
get_attributes(item)
10401038
}
10411039

10421040
pub fn get_struct_field_attrs(cdata: Cmd) -> HashMap<ast::NodeId, Vec<ast::Attribute>> {

branches/batch/src/librustc/metadata/filesearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a> FileSearch<'a> {
5454

5555
debug!("filesearch: searching lib path");
5656
let tlib_path = make_target_lib_path(self.sysroot,
57-
self.triple);
57+
self.triple);
5858
if !visited_dirs.contains(tlib_path.as_vec()) {
5959
match f(&tlib_path) {
6060
FileMatches => found = true,

branches/batch/src/librustc/session/search_paths.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use std::slice;
1212

13-
#[derive(Clone, Show)]
13+
#[derive(Clone)]
1414
pub struct SearchPaths {
1515
paths: Vec<(PathKind, Path)>,
1616
}
@@ -20,7 +20,7 @@ pub struct Iter<'a> {
2020
iter: slice::Iter<'a, (PathKind, Path)>,
2121
}
2222

23-
#[derive(Eq, PartialEq, Clone, Copy, Show)]
23+
#[derive(Eq, PartialEq, Clone, Copy)]
2424
pub enum PathKind {
2525
Native,
2626
Crate,

branches/batch/src/librustc_driver/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn run_compiler(args: &[String]) {
186186
list_metadata(&sess, &(*ifile), &mut stdout).unwrap();
187187
}
188188
Input::Str(_) => {
189-
early_error("cannot list metadata for stdin");
189+
early_error("can not list metadata for stdin");
190190
}
191191
}
192192
return;

branches/batch/src/librustc_trans/trans/base.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,9 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
702702
let mut cx = cx;
703703

704704
for (i, &arg) in variant.args.iter().enumerate() {
705-
let arg = monomorphize::apply_param_substs(tcx, substs, &arg);
706-
cx = f(cx, adt::trans_field_ptr(cx, repr, av, variant.disr_val, i), arg);
705+
cx = (*f)(cx,
706+
adt::trans_field_ptr(cx, repr, av, variant.disr_val, i),
707+
arg.subst(tcx, substs));
707708
}
708709
return cx;
709710
}

branches/batch/src/librustc_trans/trans/debuginfo.rs

Lines changed: 22 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -323,28 +323,26 @@ impl<'tcx> TypeMap<'tcx> {
323323
fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
324324
type_: Ty<'tcx>) -> UniqueTypeId {
325325

326-
// basic type -> {:name of the type:}
327-
// tuple -> {tuple_(:param-uid:)*}
328-
// struct -> {struct_:svh: / :node-id:_<(:param-uid:),*> }
329-
// enum -> {enum_:svh: / :node-id:_<(:param-uid:),*> }
330-
// enum variant -> {variant_:variant-name:_:enum-uid:}
331-
// reference (&) -> {& :pointee-uid:}
332-
// mut reference (&mut) -> {&mut :pointee-uid:}
333-
// ptr (*) -> {* :pointee-uid:}
334-
// mut ptr (*mut) -> {*mut :pointee-uid:}
335-
// unique ptr (~) -> {~ :pointee-uid:}
336-
// @-ptr (@) -> {@ :pointee-uid:}
337-
// sized vec ([T; x]) -> {[:size:] :element-uid:}
338-
// unsized vec ([T]) -> {[] :element-uid:}
339-
// trait (T) -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
340-
// closure -> {<unsafe_> <once_> :store-sigil:
341-
// |(:param-uid:),* <,_...>| -> \
342-
// :return-type-uid: : (:bounds:)*}
343-
// function -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \
344-
// :return-type-uid:}
345-
// unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>}
346-
// gc box -> {GC_BOX<:pointee-uid:>}
347-
// projection (<T as U>::V) -> {<:ty-uid: as :trait-uid:> :: :name-uid: }
326+
// basic type -> {:name of the type:}
327+
// tuple -> {tuple_(:param-uid:)*}
328+
// struct -> {struct_:svh: / :node-id:_<(:param-uid:),*> }
329+
// enum -> {enum_:svh: / :node-id:_<(:param-uid:),*> }
330+
// enum variant -> {variant_:variant-name:_:enum-uid:}
331+
// reference (&) -> {& :pointee-uid:}
332+
// mut reference (&mut) -> {&mut :pointee-uid:}
333+
// ptr (*) -> {* :pointee-uid:}
334+
// mut ptr (*mut) -> {*mut :pointee-uid:}
335+
// unique ptr (~) -> {~ :pointee-uid:}
336+
// @-ptr (@) -> {@ :pointee-uid:}
337+
// sized vec ([T; x]) -> {[:size:] :element-uid:}
338+
// unsized vec ([T]) -> {[] :element-uid:}
339+
// trait (T) -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
340+
// closure -> {<unsafe_> <once_> :store-sigil: |(:param-uid:),* <,_...>| -> \
341+
// :return-type-uid: : (:bounds:)*}
342+
// function -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \
343+
// :return-type-uid:}
344+
// unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>}
345+
// gc box -> {GC_BOX<:pointee-uid:>}
348346

349347
match self.type_to_unique_id.get(&type_).cloned() {
350348
Some(unique_type_id) => return unique_type_id,
@@ -437,25 +435,6 @@ impl<'tcx> TypeMap<'tcx> {
437435
principal.substs,
438436
&mut unique_type_id);
439437
},
440-
ty::ty_projection(ref projection) => {
441-
unique_type_id.push_str("<");
442-
443-
let self_ty = projection.trait_ref.self_ty();
444-
let self_type_id = self.get_unique_type_id_of_type(cx, self_ty);
445-
let self_type_id = self.get_unique_type_id_as_string(self_type_id);
446-
unique_type_id.push_str(&self_type_id[]);
447-
448-
unique_type_id.push_str(" as ");
449-
450-
from_def_id_and_substs(self,
451-
cx,
452-
projection.trait_ref.def_id,
453-
projection.trait_ref.substs,
454-
&mut unique_type_id);
455-
456-
unique_type_id.push_str(">::");
457-
unique_type_id.push_str(token::get_name(projection.item_name).get());
458-
},
459438
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
460439
if unsafety == ast::Unsafety::Unsafe {
461440
unique_type_id.push_str("unsafe ");
@@ -499,10 +478,7 @@ impl<'tcx> TypeMap<'tcx> {
499478
closure_ty,
500479
&mut unique_type_id);
501480
},
502-
ty::ty_err |
503-
ty::ty_infer(_) |
504-
ty::ty_open(_) |
505-
ty::ty_param(_) => {
481+
_ => {
506482
cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}",
507483
&ppaux::ty_to_string(cx.tcx(), type_)[],
508484
type_.sty)[])
@@ -3879,22 +3855,10 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
38793855
ty::ty_unboxed_closure(..) => {
38803856
output.push_str("closure");
38813857
}
3882-
ty::ty_projection(ref projection) => {
3883-
output.push_str("<");
3884-
let self_ty = projection.trait_ref.self_ty();
3885-
push_debuginfo_type_name(cx, self_ty, true, output);
3886-
3887-
output.push_str(" as ");
3888-
3889-
push_item_name(cx, projection.trait_ref.def_id, false, output);
3890-
push_type_params(cx, projection.trait_ref.substs, output);
3891-
3892-
output.push_str(">::");
3893-
output.push_str(token::get_name(projection.item_name).get());
3894-
}
38953858
ty::ty_err |
38963859
ty::ty_infer(_) |
38973860
ty::ty_open(_) |
3861+
ty::ty_projection(..) |
38983862
ty::ty_param(_) => {
38993863
cx.sess().bug(&format!("debuginfo: Trying to create type name for \
39003864
unexpected type: {}", ppaux::ty_to_string(cx.tcx(), t))[]);

branches/batch/src/librustc_trans/trans/monomorphize.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
274274
ast_map::NodeArg(..) |
275275
ast_map::NodeBlock(..) |
276276
ast_map::NodePat(..) |
277-
ast_map::NodeViewItem(..) |
278277
ast_map::NodeLocal(..) => {
279278
ccx.sess().bug(&format!("can't monomorphize a {:?}",
280279
map_node)[])

branches/batch/src/librustc_typeck/check/_match.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,6 @@ pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
619619
}
620620
};
621621

622-
let field_type = pcx.fcx.normalize_associated_types_in(span, &field_type);
623-
624622
check_pat(pcx, &*field.pat, field_type);
625623
}
626624

branches/batch/src/libstd/sys/windows/condvar.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,16 @@ impl Condvar {
2727

2828
#[inline]
2929
pub unsafe fn wait(&self, mutex: &Mutex) {
30-
let r = ffi::SleepConditionVariableSRW(self.inner.get(),
31-
mutex::raw(mutex),
32-
libc::INFINITE,
33-
0);
30+
let r = ffi::SleepConditionVariableCS(self.inner.get(),
31+
mutex::raw(mutex),
32+
libc::INFINITE);
3433
debug_assert!(r != 0);
3534
}
3635

3736
pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
38-
let r = ffi::SleepConditionVariableSRW(self.inner.get(),
39-
mutex::raw(mutex),
40-
dur.num_milliseconds() as DWORD,
41-
0);
37+
let r = ffi::SleepConditionVariableCS(self.inner.get(),
38+
mutex::raw(mutex),
39+
dur.num_milliseconds() as DWORD);
4240
if r == 0 {
4341
const ERROR_TIMEOUT: DWORD = 0x5B4;
4442
debug_assert_eq!(os::errno() as uint, ERROR_TIMEOUT as uint);

branches/batch/src/libstd/sys/windows/mutex.rs

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,73 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use marker::Sync;
12-
use cell::UnsafeCell;
11+
use prelude::v1::*;
12+
13+
use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
14+
use alloc::{self, heap};
15+
16+
use libc::DWORD;
1317
use sys::sync as ffi;
1418

15-
pub struct Mutex { inner: UnsafeCell<ffi::SRWLOCK> }
19+
const SPIN_COUNT: DWORD = 4000;
1620

17-
pub const MUTEX_INIT: Mutex = Mutex {
18-
inner: UnsafeCell { value: ffi::SRWLOCK_INIT }
19-
};
21+
pub struct Mutex { inner: AtomicUsize }
22+
23+
pub const MUTEX_INIT: Mutex = Mutex { inner: ATOMIC_USIZE_INIT };
2024

2125
unsafe impl Sync for Mutex {}
2226

2327
#[inline]
24-
pub unsafe fn raw(m: &Mutex) -> ffi::PSRWLOCK {
25-
m.inner.get()
28+
pub unsafe fn raw(m: &Mutex) -> ffi::LPCRITICAL_SECTION {
29+
m.get()
2630
}
2731

28-
// So you might be asking why we're using SRWLock instead of CriticalSection?
29-
//
30-
// 1. SRWLock is several times faster than CriticalSection according to benchmarks performed on both
31-
// Windows 8 and Windows 7.
32-
//
33-
// 2. CriticalSection allows recursive locking while SRWLock deadlocks. The Unix implementation
34-
// deadlocks so consistency is preferred. See #19962 for more details.
35-
//
36-
// 3. While CriticalSection is fair and SRWLock is not, the current Rust policy is there there are
37-
// no guarantees of fairness.
38-
3932
impl Mutex {
4033
#[inline]
41-
pub unsafe fn new() -> Mutex { MUTEX_INIT }
34+
pub unsafe fn new() -> Mutex {
35+
Mutex { inner: AtomicUsize::new(init_lock() as uint) }
36+
}
4237
#[inline]
4338
pub unsafe fn lock(&self) {
44-
ffi::AcquireSRWLockExclusive(self.inner.get())
39+
ffi::EnterCriticalSection(self.get())
4540
}
4641
#[inline]
4742
pub unsafe fn try_lock(&self) -> bool {
48-
ffi::TryAcquireSRWLockExclusive(self.inner.get()) != 0
43+
ffi::TryEnterCriticalSection(self.get()) != 0
4944
}
5045
#[inline]
5146
pub unsafe fn unlock(&self) {
52-
ffi::ReleaseSRWLockExclusive(self.inner.get())
47+
ffi::LeaveCriticalSection(self.get())
5348
}
54-
#[inline]
5549
pub unsafe fn destroy(&self) {
56-
// ...
50+
let lock = self.inner.swap(0, Ordering::SeqCst);
51+
if lock != 0 { free_lock(lock as ffi::LPCRITICAL_SECTION) }
52+
}
53+
54+
unsafe fn get(&self) -> ffi::LPCRITICAL_SECTION {
55+
match self.inner.load(Ordering::SeqCst) {
56+
0 => {}
57+
n => return n as ffi::LPCRITICAL_SECTION
58+
}
59+
let lock = init_lock();
60+
match self.inner.compare_and_swap(0, lock as uint, Ordering::SeqCst) {
61+
0 => return lock as ffi::LPCRITICAL_SECTION,
62+
_ => {}
63+
}
64+
free_lock(lock);
65+
return self.inner.load(Ordering::SeqCst) as ffi::LPCRITICAL_SECTION;
5766
}
5867
}
68+
69+
unsafe fn init_lock() -> ffi::LPCRITICAL_SECTION {
70+
let block = heap::allocate(ffi::CRITICAL_SECTION_SIZE, 8)
71+
as ffi::LPCRITICAL_SECTION;
72+
if block.is_null() { alloc::oom() }
73+
ffi::InitializeCriticalSectionAndSpinCount(block, SPIN_COUNT);
74+
return block;
75+
}
76+
77+
unsafe fn free_lock(h: ffi::LPCRITICAL_SECTION) {
78+
ffi::DeleteCriticalSection(h);
79+
heap::deallocate(h as *mut _, ffi::CRITICAL_SECTION_SIZE, 8);
80+
}

0 commit comments

Comments
 (0)