@@ -95,7 +95,12 @@ class irc : public shape::data<irc,shape::ptr> {
95
95
}
96
96
97
97
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);
99
104
}
100
105
101
106
void walk_obj () {
@@ -114,28 +119,32 @@ class irc : public shape::data<irc,shape::ptr> {
114
119
void walk_subcontext (irc &sub) { sub.walk (); }
115
120
116
121
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);
133
123
134
124
// Do not traverse the contents of this box; it's in the allocation
135
125
// somewhere, so we're guaranteed to come back to it (if we haven't
136
126
// traversed it already).
137
127
}
138
128
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
+
139
148
void walk_struct (const uint8_t *end_sp) {
140
149
while (this ->sp != end_sp) {
141
150
this ->walk ();
@@ -231,8 +240,8 @@ find_roots(rust_task *task, irc_map &ircs, std::vector<void *> &roots) {
231
240
} else {
232
241
LOG (task, gc, " nonroot found: %p, irc %lu, ref count %lu" ,
233
242
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!" );
236
245
}
237
246
238
247
++begin;
0 commit comments