Skip to content

Commit bd88d53

Browse files
committed
---
yaml --- r: 5905 b: refs/heads/master c: 2d71321 h: refs/heads/master i: 5903: 577b024 v: v3
1 parent 6308ba5 commit bd88d53

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
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: 6c4c33e0092ac14d75f1667ae4dcafeec9728273
2+
refs/heads/master: 2d713215a8fba320b2e5472d1ae6924e5a9d263c

trunk/src/rt/rust_cc.cpp

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ class irc : public shape::data<irc,shape::ptr> {
9595
}
9696

9797
void walk_fn() {
98-
shape::data<irc,shape::ptr>::walk_fn_contents(dp);
98+
// Record an irc for the environment box, but don't descend
99+
// into it since it will be walked via the box's allocation
100+
dp += sizeof(void *); // skip code pointer
101+
uint8_t * box_ptr = shape::bump_dp<uint8_t *>(dp);
102+
shape::ptr ref_count_dp(box_ptr);
103+
maybe_record_irc(ref_count_dp);
99104
}
100105

101106
void walk_obj() {
@@ -114,28 +119,32 @@ class irc : public shape::data<irc,shape::ptr> {
114119
void walk_subcontext(irc &sub) { sub.walk(); }
115120

116121
void walk_box_contents(irc &sub, shape::ptr &ref_count_dp) {
117-
if (!ref_count_dp)
118-
return;
119-
120-
// Bump the internal reference count of the box.
121-
if (ircs.find((void *)ref_count_dp) == ircs.end()) {
122-
LOG(task, gc,
123-
"setting internal reference count for %p to 1",
124-
(void *)ref_count_dp);
125-
ircs[(void *)ref_count_dp] = 1;
126-
} else {
127-
uintptr_t newcount = ircs[(void *)ref_count_dp] + 1;
128-
LOG(task, gc,
129-
"bumping internal reference count for %p to %lu",
130-
(void *)ref_count_dp, newcount);
131-
ircs[(void *)ref_count_dp] = newcount;
132-
}
122+
maybe_record_irc(ref_count_dp);
133123

134124
// Do not traverse the contents of this box; it's in the allocation
135125
// somewhere, so we're guaranteed to come back to it (if we haven't
136126
// traversed it already).
137127
}
138128

129+
void maybe_record_irc(shape::ptr &ref_count_dp) {
130+
if (!ref_count_dp)
131+
return;
132+
133+
// Bump the internal reference count of the box.
134+
if (ircs.find((void *)ref_count_dp) == ircs.end()) {
135+
LOG(task, gc,
136+
"setting internal reference count for %p to 1",
137+
(void *)ref_count_dp);
138+
ircs[(void *)ref_count_dp] = 1;
139+
} else {
140+
uintptr_t newcount = ircs[(void *)ref_count_dp] + 1;
141+
LOG(task, gc,
142+
"bumping internal reference count for %p to %lu",
143+
(void *)ref_count_dp, newcount);
144+
ircs[(void *)ref_count_dp] = newcount;
145+
}
146+
}
147+
139148
void walk_struct(const uint8_t *end_sp) {
140149
while (this->sp != end_sp) {
141150
this->walk();
@@ -231,8 +240,8 @@ find_roots(rust_task *task, irc_map &ircs, std::vector<void *> &roots) {
231240
} else {
232241
LOG(task, gc, "nonroot found: %p, irc %lu, ref count %lu",
233242
alloc, irc, ref_count);
234-
/*assert(irc == ref_count && "Internal reference count must be "
235-
"less than or equal to the total reference count!");*/
243+
assert(irc == ref_count && "Internal reference count must be "
244+
"less than or equal to the total reference count!");
236245
}
237246

238247
++begin;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
type foo = { mutable z : fn@() };
2+
3+
fn nop() { }
4+
fn nop_foo(_x : @foo) { }
5+
6+
fn main() {
7+
let w = @{ mutable z: bind nop() };
8+
let x = bind nop_foo(w);
9+
w.z = x;
10+
}

0 commit comments

Comments
 (0)