diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-10-21 17:21:59 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-10-21 17:21:59 -0700 |
| commit | 739b1b5b53729085f91fbce0fa9fb0530c9d56ee (patch) | |
| tree | f684850ba4443574782fc13577a544c8bacf5737 | |
| parent | 020726c9816ff47fcdc16877a9256e5a765d6315 (diff) | |
| download | rust-739b1b5b53729085f91fbce0fa9fb0530c9d56ee.tar.gz rust-739b1b5b53729085f91fbce0fa9fb0530c9d56ee.zip | |
Cycle-collect objects
| -rw-r--r-- | src/rt/rust_cc.cpp | 7 | ||||
| -rw-r--r-- | src/test/run-pass/cycle-collection5.rs | 13 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/rt/rust_cc.cpp b/src/rt/rust_cc.cpp index 8982a4a312e..83ee0cd21e8 100644 --- a/src/rt/rust_cc.cpp +++ b/src/rt/rust_cc.cpp @@ -104,7 +104,10 @@ class irc : public shape::data<irc,shape::ptr> { } void walk_obj() { - shape::data<irc,shape::ptr>::walk_obj_contents(dp); + dp += sizeof(void *); // skip vtable + uint8_t *box_ptr = shape::bump_dp<uint8_t *>(dp); + shape::ptr ref_count_dp(box_ptr); + maybe_record_irc(ref_count_dp); } void walk_res(const shape::rust_fn *dtor, unsigned n_params, @@ -491,7 +494,7 @@ class sweep : public shape::data<sweep,shape::ptr> { } void walk_obj() { - shape::data<sweep,shape::ptr>::walk_obj_contents(dp); + return; } void walk_res(const shape::rust_fn *dtor, unsigned n_params, diff --git a/src/test/run-pass/cycle-collection5.rs b/src/test/run-pass/cycle-collection5.rs new file mode 100644 index 00000000000..b7bd635c220 --- /dev/null +++ b/src/test/run-pass/cycle-collection5.rs @@ -0,0 +1,13 @@ +type foo = { mutable z : fn@() }; + +fn nop() { } +fn nop_foo(_y: o, _x : @foo) { } + +obj o() { +} + +fn main() { + let w = @{ mutable z: bind nop() }; + let x = bind nop_foo(o(), w); + w.z = x; +} \ No newline at end of file |
