Skip to content

Commit 7c19369

Browse files
committed
---
yaml --- r: 5550 b: refs/heads/master c: 5c97314 h: refs/heads/master v: v3
1 parent df541b5 commit 7c19369

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: ad19ab4c6fdf3ea74ac0ff3688d040a852f30760
2+
refs/heads/master: 5c973142df3661a23a085bfb655300c08ca19764

trunk/src/rt/rust_cc.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#undef DPRINT
1818
#define DPRINT(fmt,...) fprintf(stderr, fmt, ##__VA_ARGS__)
1919

20+
// The number of allocations Rust code performs before performing cycle
21+
// collection.
22+
#define RUST_CC_FREQUENCY 5000
23+
2024
namespace cc {
2125

2226
// Internal reference count computation
@@ -417,7 +421,7 @@ sweep(rust_task *task, const std::set<void *> &marked) {
417421
if (marked.find(alloc) == marked.end()) {
418422
const type_desc *tydesc = begin->second;
419423

420-
DPRINT("object is part of a cycle: %p\n", alloc);
424+
//DPRINT("object is part of a cycle: %p\n", alloc);
421425

422426
// Run the destructor.
423427
// TODO: What if it fails?
@@ -453,8 +457,18 @@ do_cc(rust_task *task) {
453457
void
454458
maybe_cc(rust_task *task) {
455459
static debug::flag zeal("RUST_CC_ZEAL");
456-
if (*zeal)
460+
if (*zeal) {
457461
do_cc(task);
462+
return;
463+
}
464+
465+
// FIXME: Needs a snapshot.
466+
#if 0
467+
if (task->cc_counter++ > RUST_CC_FREQUENCY) {
468+
task->cc_counter = 0;
469+
do_cc(task);
470+
}
471+
#endif
458472
}
459473

460474
} // end namespace cc

trunk/src/rt/rust_task.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#include "rust_internal.h"
3+
#include "rust_cc.h"
34

45
#include "valgrind.h"
56
#include "memcheck.h"
@@ -75,7 +76,8 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
7576
failed(false),
7677
killed(false),
7778
propagate_failure(true),
78-
dynastack(this)
79+
dynastack(this),
80+
cc_counter(0)
7981
{
8082
LOGPTR(sched, "new task", (uintptr_t)this);
8183
DLOG(sched, task, "sizeof(task) = %d (0x%x)", sizeof *this, sizeof *this);

trunk/src/rt/rust_task.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ rust_task : public kernel_owned<rust_task>, rust_cond
125125
rust_obstack dynastack;
126126

127127
std::map<void *,const type_desc *> local_allocs;
128+
uint32_t cc_counter;
128129

129130
debug::task_debug_info debug;
130131

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tag taggy {
2+
cons(@mutable taggy);
3+
nil;
4+
}
5+
6+
fn f() {
7+
let box = @mutable nil;
8+
*box = cons(box);
9+
}
10+
11+
fn main() {
12+
f();
13+
}
14+

0 commit comments

Comments
 (0)