about summary refs log tree commit diff
path: root/src/rt/rust_cc.cpp
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-09-23 17:56:55 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-09-23 17:57:25 -0700
commit7979bbbf5132104ca3359919f7c515e3a9d8dcd6 (patch)
tree455b2b1fb7c1d1cefbeebabd9bfa60296411b47d /src/rt/rust_cc.cpp
parent41082c6b83a399b79f1c3efe21c94d80b9ae9a08 (diff)
downloadrust-7979bbbf5132104ca3359919f7c515e3a9d8dcd6.tar.gz
rust-7979bbbf5132104ca3359919f7c515e3a9d8dcd6.zip
rt: Sweep in cycle collection
Diffstat (limited to 'src/rt/rust_cc.cpp')
-rw-r--r--src/rt/rust_cc.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/rt/rust_cc.cpp b/src/rt/rust_cc.cpp
index c0a7c4b4740..9d6c4992b17 100644
--- a/src/rt/rust_cc.cpp
+++ b/src/rt/rust_cc.cpp
@@ -409,7 +409,18 @@ sweep(rust_task *task, const std::set<void *> &marked) {
     while (begin != end) {
         void *alloc = begin->first;
         if (marked.find(alloc) == marked.end()) {
+            const type_desc *tydesc = begin->second;
+
             DPRINT("object is part of a cycle: %p\n", alloc);
+
+            // Run the destructor.
+            // TODO: What if it fails?
+            if (tydesc->drop_glue) {
+                tydesc->drop_glue(NULL, task, (void *)tydesc,
+                                  tydesc->first_param, alloc);
+            }
+
+            task->free(alloc);
         }
         ++begin;
     }
@@ -418,8 +429,8 @@ sweep(rust_task *task, const std::set<void *> &marked) {
 
 void
 do_cc(rust_task *task) {
-    DPRINT("cc; n allocs = %lu\n",
-           (long unsigned int)task->local_allocs.size());
+    //DPRINT("cc; n allocs = %lu\n",
+    //       (long unsigned int)task->local_allocs.size());
 
     irc_map ircs;
     irc::compute_ircs(task, ircs);