Skip to content

Commit 21e7612

Browse files
committed
---
yaml --- r: 14661 b: refs/heads/try c: 958c321 h: refs/heads/master i: 14659: 4786aea v: v3
1 parent 37d481f commit 21e7612

File tree

7 files changed

+13
-21
lines changed

7 files changed

+13
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 1347d04bb086f6d76dd7287762d34ef4c57dbc00
5+
refs/heads/try: 958c32108313658740e89dfd32c5a96ba557c0a3
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/libcore/comm.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ native mod rustrt {
4444
fn del_port(po: *rust_port);
4545
fn rust_port_begin_detach(po: *rust_port,
4646
yield: *ctypes::uintptr_t);
47-
fn rust_port_end_detach(po: *rust_port);
4847
fn get_port_id(po: *rust_port) -> port_id;
4948
fn rust_port_size(po: *rust_port) -> ctypes::size_t;
5049
fn port_recv(dptr: *uint, po: *rust_port,
@@ -93,7 +92,6 @@ resource port_ptr<T: send>(po: *rust_port) {
9392
// in a bogus state.
9493
task::yield();
9594
}
96-
rustrt::rust_port_end_detach(po);
9795

9896
// Drain the port so that all the still-enqueued items get dropped
9997
while rustrt::rust_port_size(po) > 0u {

branches/try/src/rt/rust_builtin.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,16 +488,12 @@ rust_port_begin_detach(rust_port *port, uintptr_t *yield) {
488488
port->begin_detach(yield);
489489
}
490490

491-
extern "C" CDECL void
492-
rust_port_end_detach(rust_port *port) {
493-
port->end_detach();
494-
}
495-
496491
extern "C" CDECL void
497492
del_port(rust_port *port) {
498493
rust_task *task = rust_task_thread::get_task();
499494
LOG(task, comm, "del_port(0x%" PRIxPTR ")", (uintptr_t) port);
500495
A(task->thread, port->get_ref_count() == 0, "Expected port ref_count == 0");
496+
port->end_detach();
501497
delete port;
502498
}
503499

branches/try/src/rt/rust_internal.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,7 @@ public: \
113113
assert(old > 0); \
114114
} \
115115
void deref() { if(0 == sync::decrement(ref_count)) { delete_this(); } } \
116-
intptr_t get_ref_count() { \
117-
sync::increment(ref_count); \
118-
intptr_t current = sync::decrement(ref_count); \
119-
return current; \
120-
}
116+
intptr_t get_ref_count() { return sync::read(ref_count); }
121117

122118
template <typename T> struct task_owned {
123119
inline void *operator new(size_t size, rust_task *task, const char *tag);

branches/try/src/rt/rust_port.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ void rust_port::begin_detach(uintptr_t *yield) {
4444
}
4545

4646
void rust_port::end_detach() {
47-
// FIXME: For some reason, on rare occasion we can get here without
48-
// actually having the ref count go to 0. Possibly related to #1923
49-
bool done = false;
50-
while (!done) {
51-
done = get_ref_count() == 0;
52-
}
53-
5447
// Just take the lock to make sure that the thread that signaled
5548
// the detach_cond isn't still holding it
5649
scoped_lock with(detach_lock);

branches/try/src/rt/rustrt.def.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ rust_list_files
3535
rust_log_console_on
3636
rust_log_console_off
3737
rust_port_begin_detach
38-
rust_port_end_detach
3938
rust_port_size
4039
rust_process_wait
4140
rust_ptr_eq

branches/try/src/rt/sync/sync.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ class sync {
2929
static T decrement(T &address) {
3030
return __sync_sub_and_fetch(&address, 1);
3131
}
32+
33+
template <class T>
34+
static T read(T *address) {
35+
return __sync_add_and_fetch(address, 0);
36+
}
37+
38+
template <class T>
39+
static T read(T &address) {
40+
return __sync_add_and_fetch(&address, 0);
41+
}
3242
};
3343

3444
#endif /* SYNC_H */

0 commit comments

Comments
 (0)