Skip to content

Commit 739b1b5

Browse files
committed
Cycle-collect objects
1 parent 020726c commit 739b1b5

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/rt/rust_cc.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ class irc : public shape::data<irc,shape::ptr> {
104104
}
105105

106106
void walk_obj() {
107-
shape::data<irc,shape::ptr>::walk_obj_contents(dp);
107+
dp += sizeof(void *); // skip vtable
108+
uint8_t *box_ptr = shape::bump_dp<uint8_t *>(dp);
109+
shape::ptr ref_count_dp(box_ptr);
110+
maybe_record_irc(ref_count_dp);
108111
}
109112

110113
void walk_res(const shape::rust_fn *dtor, unsigned n_params,
@@ -491,7 +494,7 @@ class sweep : public shape::data<sweep,shape::ptr> {
491494
}
492495

493496
void walk_obj() {
494-
shape::data<sweep,shape::ptr>::walk_obj_contents(dp);
497+
return;
495498
}
496499

497500
void walk_res(const shape::rust_fn *dtor, unsigned n_params,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type foo = { mutable z : fn@() };
2+
3+
fn nop() { }
4+
fn nop_foo(_y: o, _x : @foo) { }
5+
6+
obj o() {
7+
}
8+
9+
fn main() {
10+
let w = @{ mutable z: bind nop() };
11+
let x = bind nop_foo(o(), w);
12+
w.z = x;
13+
}

0 commit comments

Comments
 (0)