Skip to content

Commit e5b4836

Browse files
committed
---
yaml --- r: 5865 b: refs/heads/master c: 034408c h: refs/heads/master i: 5863: 92da217 v: v3
1 parent 5995bdf commit e5b4836

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
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: dcee98b0247e7143f99b1db007b30397fd07d1a7
2+
refs/heads/master: 034408c40a149033c7dd65149914ae311f998986

trunk/src/rt/rust_cc.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
#include <vector>
1515
#include <stdint.h>
1616

17-
#undef DPRINT
18-
#define DPRINT(fmt,...) fprintf(stderr, fmt, ##__VA_ARGS__)
19-
2017
// The number of allocations Rust code performs before performing cycle
2118
// collection.
2219
#define RUST_CC_FREQUENCY 5000
@@ -122,11 +119,16 @@ class irc : public shape::data<irc,shape::ptr> {
122119

123120
// Bump the internal reference count of the box.
124121
if (ircs.find((void *)ref_count_dp) == ircs.end()) {
125-
//DPRINT("setting internal reference count for %p\n",
126-
// (void *)ref_count_dp);
122+
LOG(task, gc,
123+
"setting internal reference count for %p to 1",
124+
(void *)ref_count_dp);
127125
ircs[(void *)ref_count_dp] = 1;
128126
} else {
129-
++ircs[(void *)ref_count_dp];
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;
130132
}
131133

132134
// Do not traverse the contents of this box; it's in the allocation
@@ -176,8 +178,8 @@ irc::compute_ircs(rust_task *task, irc_map &ircs) {
176178

177179
const type_desc *tydesc = begin->second;
178180

179-
//DPRINT("determining internal ref counts: %p, tydesc=%p\n", p,
180-
//tydesc);
181+
LOG(task, gc, "determining internal ref counts: %p, tydesc=%p", p,
182+
tydesc);
181183

182184
shape::arena arena;
183185
shape::type_param *params =
@@ -223,11 +225,12 @@ find_roots(rust_task *task, irc_map &ircs, std::vector<void *> &roots) {
223225
if (irc < ref_count) {
224226
// This allocation must be a root, because the internal reference
225227
// count is smaller than the total reference count.
226-
//DPRINT("root found: %p, irc %lu, ref count %lu\n", alloc, irc,
227-
// ref_count);
228+
LOG(task, gc,"root found: %p, irc %lu, ref count %lu",
229+
alloc, irc, ref_count);
228230
roots.push_back(alloc);
229231
} else {
230-
//DPRINT("nonroot found: %p, ref count %lu\n", alloc, ref_count);
232+
LOG(task, gc, "nonroot found: %p, irc %lu, ref count %lu",
233+
alloc, irc, ref_count);
231234
/*assert(irc == ref_count && "Internal reference count must be "
232235
"less than or equal to the total reference count!");*/
233236
}
@@ -385,7 +388,7 @@ mark::do_mark(rust_task *task, const std::vector<void *> &roots,
385388

386389
const type_desc *tydesc = task->local_allocs[alloc];
387390

388-
//DPRINT("marking: %p, tydesc=%p\n", p, tydesc);
391+
LOG(task, gc, "marking: %p, tydesc=%p", alloc, tydesc);
389392

390393
uint8_t *p = reinterpret_cast<uint8_t *>(alloc);
391394
shape::arena arena;
@@ -398,7 +401,6 @@ mark::do_mark(rust_task *task, const std::vector<void *> &roots,
398401
tydesc->shape_tables, p + sizeof(uintptr_t),
399402
std::cerr);
400403
log.walk();
401-
DPRINT("\n");
402404
#endif
403405

404406
// We skip over the reference count here.
@@ -419,7 +421,7 @@ sweep(rust_task *task, const std::set<void *> &marked) {
419421
while (begin != end) {
420422
void *alloc = begin->first;
421423
if (marked.find(alloc) == marked.end()) {
422-
//DPRINT("object is part of a cycle: %p\n", alloc);
424+
LOG(task, gc, "object is part of a cycle: %p", alloc);
423425

424426
// FIXME: Run the destructor, *if* it's a resource.
425427

@@ -432,8 +434,8 @@ sweep(rust_task *task, const std::set<void *> &marked) {
432434

433435
void
434436
do_cc(rust_task *task) {
435-
//DPRINT("cc; n allocs = %lu\n",
436-
// (long unsigned int)task->local_allocs.size());
437+
LOG(task, gc, "cc; n allocs = %lu",
438+
(long unsigned int)task->local_allocs.size());
437439

438440
irc_map ircs;
439441
irc::compute_ircs(task, ircs);

0 commit comments

Comments
 (0)