Skip to content

Commit ee72627

Browse files
committed
---
yaml --- r: 146263 b: refs/heads/try2 c: fc766ef h: refs/heads/master i: 146261: 56755f2 146259: 556d5bb 146255: 4ba70c8 v: v3
1 parent 1d399ed commit ee72627

File tree

18 files changed

+194
-253
lines changed

18 files changed

+194
-253
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: f6b236b9d2780edc1336ea5f62c2ba0fed6e34c5
8+
refs/heads/try2: fc766efd16231e521365a29a73bca7f2c4178e9c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/future.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ impl<A:Clone> Future<A> {
5151

5252
impl<A> Future<A> {
5353
/// Gets the value from this future, forcing evaluation.
54-
pub fn unwrap(self) -> A {
55-
let mut this = self;
56-
this.get_ref();
57-
let state = replace(&mut this.state, Evaluating);
54+
pub fn unwrap(mut self) -> A {
55+
self.get_ref();
56+
let state = replace(&mut self.state, Evaluating);
5857
match state {
5958
Forced(v) => v,
6059
_ => fail!( "Logic error." ),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ pub mod llvm {
693693
pub fn LLVMAddReturnAttribute(Fn: ValueRef, PA: c_uint);
694694
pub fn LLVMRemoveReturnAttribute(Fn: ValueRef, PA: c_uint);
695695

696+
pub fn LLVMAddColdAttribute(Fn: ValueRef);
697+
696698
pub fn LLVMRemoveFunctionAttr(Fn: ValueRef,
697699
PA: c_ulonglong,
698700
HighPA: c_ulonglong);

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,21 @@ pub fn get_extern_fn(externs: &mut ExternMap, llmod: ModuleRef, name: &str,
202202
f
203203
}
204204

205-
pub fn get_extern_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
206-
name: &str) -> ValueRef {
205+
fn get_extern_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
206+
name: &str, did: ast::DefId) -> ValueRef {
207207
match ccx.externs.find_equiv(&name) {
208208
Some(n) => return *n,
209209
None => ()
210210
}
211211
let f = decl_rust_fn(ccx, inputs, output, name);
212+
do csearch::get_item_attrs(ccx.tcx.cstore, did) |meta_items| {
213+
set_llvm_fn_attrs(meta_items.iter().map(|&x| attr::mk_attr(x)).to_owned_vec(), f)
214+
}
212215
ccx.externs.insert(name.to_owned(), f);
213216
f
214217
}
215218

216-
pub fn decl_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
217-
name: &str) -> ValueRef {
219+
fn decl_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t, name: &str) -> ValueRef {
218220
let llfty = type_of_rust_fn(ccx, inputs, output);
219221
let llfn = decl_cdecl_fn(ccx.llmod, name, llfty);
220222

@@ -481,6 +483,10 @@ pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
481483
if contains_name(attrs, "no_split_stack") {
482484
set_no_split_stack(llfn);
483485
}
486+
487+
if contains_name(attrs, "cold") {
488+
unsafe { llvm::LLVMAddColdAttribute(llfn) }
489+
}
484490
}
485491

486492
pub fn set_always_inline(f: ValueRef) {
@@ -840,7 +846,7 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
840846
ty::ty_bare_fn(ref fn_ty) => {
841847
match fn_ty.abis.for_arch(ccx.sess.targ_cfg.arch) {
842848
Some(Rust) | Some(RustIntrinsic) => {
843-
get_extern_rust_fn(ccx, fn_ty.sig.inputs, fn_ty.sig.output, name)
849+
get_extern_rust_fn(ccx, fn_ty.sig.inputs, fn_ty.sig.output, name, did)
844850
}
845851
Some(*) | None => {
846852
let c = foreign::llvm_calling_convention(ccx, fn_ty.abis);
@@ -851,7 +857,7 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
851857
}
852858
}
853859
ty::ty_closure(ref f) => {
854-
get_extern_rust_fn(ccx, f.sig.inputs, f.sig.output, name)
860+
get_extern_rust_fn(ccx, f.sig.inputs, f.sig.output, name, did)
855861
}
856862
_ => {
857863
let llty = type_of(ccx, t);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pub fn clear_task_borrow_list() {
5757
let _ = try_take_task_borrow_list();
5858
}
5959

60+
#[cold]
6061
unsafe fn fail_borrowed(box: *mut raw::Box<()>, file: *c_char, line: size_t) -> ! {
6162
debug_borrow("fail_borrowed: ", box, 0, 0, file, line);
6263

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

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<T> ChanOne<T> {
113113

114114
// 'do_resched' configures whether the scheduler immediately switches to
115115
// the receiving task, or leaves the sending task still running.
116-
fn try_send_inner(self, val: T, do_resched: bool) -> bool {
116+
fn try_send_inner(mut self, val: T, do_resched: bool) -> bool {
117117
if do_resched {
118118
rtassert!(!rt::in_sched_context());
119119
}
@@ -129,9 +129,8 @@ impl<T> ChanOne<T> {
129129
sched.maybe_yield();
130130
}
131131

132-
let mut this = self;
133132
let mut recvr_active = true;
134-
let packet = this.packet();
133+
let packet = self.packet();
135134

136135
unsafe {
137136

@@ -150,15 +149,15 @@ impl<T> ChanOne<T> {
150149
// done with the packet. NB: In case of do_resched, this *must*
151150
// happen before waking up a blocked task (or be unkillable),
152151
// because we might get a kill signal during the reschedule.
153-
this.suppress_finalize = true;
152+
self.suppress_finalize = true;
154153

155154
match oldstate {
156155
STATE_BOTH => {
157156
// Port is not waiting yet. Nothing to do
158157
}
159158
STATE_ONE => {
160159
// Port has closed. Need to clean up.
161-
let _packet: ~Packet<T> = cast::transmute(this.void_packet);
160+
let _packet: ~Packet<T> = cast::transmute(self.void_packet);
162161
recvr_active = false;
163162
}
164163
task_as_state => {
@@ -202,22 +201,20 @@ impl<T> PortOne<T> {
202201
}
203202

204203
/// As `recv`, but returns `None` if the send end is closed rather than failing.
205-
pub fn try_recv(self) -> Option<T> {
206-
let mut this = self;
207-
204+
pub fn try_recv(mut self) -> Option<T> {
208205
// Optimistic check. If data was sent already, we don't even need to block.
209206
// No release barrier needed here; we're not handing off our task pointer yet.
210-
if !this.optimistic_check() {
207+
if !self.optimistic_check() {
211208
// No data available yet.
212209
// Switch to the scheduler to put the ~Task into the Packet state.
213210
let sched: ~Scheduler = Local::take();
214211
do sched.deschedule_running_task_and_then |sched, task| {
215-
this.block_on(sched, task);
212+
self.block_on(sched, task);
216213
}
217214
}
218215

219216
// Task resumes.
220-
this.recv_ready()
217+
self.recv_ready()
221218
}
222219
}
223220

@@ -325,9 +322,8 @@ impl<T> SelectInner for PortOne<T> {
325322
impl<T> Select for PortOne<T> { }
326323

327324
impl<T> SelectPortInner<T> for PortOne<T> {
328-
fn recv_ready(self) -> Option<T> {
329-
let mut this = self;
330-
let packet = this.packet();
325+
fn recv_ready(mut self) -> Option<T> {
326+
let packet = self.packet();
331327

332328
// No further memory barrier is needed here to access the
333329
// payload. Some scenarios:
@@ -348,9 +344,9 @@ impl<T> SelectPortInner<T> for PortOne<T> {
348344
let payload = (*packet).payload.take();
349345

350346
// The sender has closed up shop. Drop the packet.
351-
let _packet: ~Packet<T> = cast::transmute(this.void_packet);
347+
let _packet: ~Packet<T> = cast::transmute(self.void_packet);
352348
// Suppress the synchronizing actions in the finalizer. We're done with the packet.
353-
this.suppress_finalize = true;
349+
self.suppress_finalize = true;
354350
return payload;
355351
}
356352
}
@@ -378,18 +374,17 @@ impl<T> Drop for ChanOne<T> {
378374
if self.suppress_finalize { return }
379375

380376
unsafe {
381-
let this = cast::transmute_mut(self);
382-
let oldstate = (*this.packet()).state.swap(STATE_ONE, SeqCst);
377+
let oldstate = (*self.packet()).state.swap(STATE_ONE, SeqCst);
383378
match oldstate {
384379
STATE_BOTH => {
385380
// Port still active. It will destroy the Packet.
386381
},
387382
STATE_ONE => {
388-
let _packet: ~Packet<T> = cast::transmute(this.void_packet);
383+
let _packet: ~Packet<T> = cast::transmute(self.void_packet);
389384
},
390385
task_as_state => {
391386
// The port is blocked waiting for a message we will never send. Wake it.
392-
rtassert!((*this.packet()).payload.is_none());
387+
rtassert!((*self.packet()).payload.is_none());
393388
let recvr = BlockedTask::cast_from_uint(task_as_state);
394389
do recvr.wake().map |woken_task| {
395390
Scheduler::run_task(woken_task);
@@ -406,14 +401,13 @@ impl<T> Drop for PortOne<T> {
406401
if self.suppress_finalize { return }
407402

408403
unsafe {
409-
let this = cast::transmute_mut(self);
410-
let oldstate = (*this.packet()).state.swap(STATE_ONE, SeqCst);
404+
let oldstate = (*self.packet()).state.swap(STATE_ONE, SeqCst);
411405
match oldstate {
412406
STATE_BOTH => {
413407
// Chan still active. It will destroy the packet.
414408
},
415409
STATE_ONE => {
416-
let _packet: ~Packet<T> = cast::transmute(this.void_packet);
410+
let _packet: ~Packet<T> = cast::transmute(self.void_packet);
417411
}
418412
task_as_state => {
419413
// This case occurs during unwinding, when the blocked

branches/try2/src/libstd/rt/io/net/unix.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ mod tests {
243243
let mut stop = false;
244244
while !stop{
245245
do io_error::cond.trap(|e| {
246-
assert_eq!(e.kind, BrokenPipe);
246+
assert!(e.kind == BrokenPipe || e.kind == NotConnected,
247+
"unknown error {:?}", e);
247248
stop = true;
248249
}).inside {
249250
server.write(buf);

0 commit comments

Comments
 (0)