about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-02-03 09:34:42 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-02-03 11:34:12 +0100
commitc1b075d042cabb90f804f3d73e6a4f4b512aa697 (patch)
treeac1501fb72bff6b04597c054c138ae2fc8ce24dc /src/rt
parent1ea184285eec782f90ecf4e77c854edfb0269e1b (diff)
downloadrust-c1b075d042cabb90f804f3d73e6a4f4b512aa697.tar.gz
rust-c1b075d042cabb90f804f3d73e6a4f4b512aa697.zip
Remove experimental GC code
It's been sitting unused long enough to have bitrotted completely.
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_builtin.cpp5
-rw-r--r--src/rt/rust_cc.cpp1
-rw-r--r--src/rt/rust_gc.cpp164
-rw-r--r--src/rt/rust_gc.h10
-rw-r--r--src/rt/rust_task.cpp4
-rw-r--r--src/rt/rust_task.h4
-rw-r--r--src/rt/rust_upcall.cpp9
-rw-r--r--src/rt/rustrt.def.in1
8 files changed, 7 insertions, 191 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 88f7aec8800..3c935c1ed4d 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -92,11 +92,6 @@ refcount(intptr_t *v) {
 }
 
 extern "C" CDECL void
-do_gc() {
-    // TODO
-}
-
-extern "C" CDECL void
 unsupervise() {
     rust_task *task = rust_scheduler::get_task();
     task->unsupervise();
diff --git a/src/rt/rust_cc.cpp b/src/rt/rust_cc.cpp
index 60b0b8d2fd0..03a4bed014e 100644
--- a/src/rt/rust_cc.cpp
+++ b/src/rt/rust_cc.cpp
@@ -2,7 +2,6 @@
 // time until LLVM's GC infrastructure is more mature.
 
 #include "rust_debug.h"
-#include "rust_gc.h"
 #include "rust_internal.h"
 #include "rust_shape.h"
 #include "rust_task.h"
diff --git a/src/rt/rust_gc.cpp b/src/rt/rust_gc.cpp
deleted file mode 100644
index 26e48857ecb..00000000000
--- a/src/rt/rust_gc.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-// Rust garbage collection.
-
-#include <algorithm>
-#include <iostream>
-#include <utility>
-#include <vector>
-#include <stdint.h>
-
-#include "rust_abi.h"
-#include "rust_debug.h"
-#include "rust_gc.h"
-#include "rust_internal.h"
-#include "rust_shape.h"
-
-#ifdef __WIN32__
-#include <windows.h>
-#else
-#include <dlfcn.h>
-#endif
-
-using namespace stack_walk;
-
-namespace gc {
-
-weak_symbol<const uintptr_t> safe_point_data("rust_gc_safe_points");
-
-struct root_info {
-    intptr_t frame_offset;
-    uintptr_t dynamic;  // 0 = static, 1 = dynamic
-    const type_desc *tydesc;
-};
-
-struct root {
-    const type_desc *tydesc;
-    uint8_t *data;
-
-    root(const root_info &info, const frame &frame)
-    : tydesc(info.tydesc),
-      data((uint8_t *)frame.bp + info.frame_offset) {}
-};
-
-struct safe_point {
-    uintptr_t n_roots;
-    root_info roots[0];
-};
-
-struct safe_point_index_entry {
-    void (*ra)();                   // The return address.
-    const struct safe_point *safe_point;   // The safe point.
-
-    struct cmp {
-        bool operator()(const safe_point_index_entry &entry, void (*ra)())
-                const {
-            return entry.ra < ra;
-        }
-        bool operator()(void (*ra)(), const safe_point_index_entry &entry)
-                const {
-            return ra < entry.ra;
-        }
-    };
-};
-
-class safe_point_map {
-    uintptr_t n_safe_points;
-    const safe_point_index_entry *index;
-    const safe_point *safe_points;
-
-public:
-    safe_point_map() {
-        const uintptr_t *data = *safe_point_data;
-        n_safe_points = *data++;
-        index = (const safe_point_index_entry *)data;
-        data += n_safe_points * 2;
-        safe_points = (const safe_point *)data;
-    }
-
-    const safe_point *get_safe_point(void (*addr)());
-};
-
-class gc {
-private:
-    rust_task *task;
-
-    void mark(std::vector<root> &roots);
-    void sweep();
-
-public:
-    gc(rust_task *in_task) : task(in_task) {}
-    void run();
-};
-
-const safe_point *
-safe_point_map::get_safe_point(void (*addr)()) {
-    safe_point_index_entry::cmp cmp;
-    const safe_point_index_entry *entry =
-        std::lower_bound(index, index + n_safe_points, addr, cmp);
-    return (entry && entry->ra == addr) ? entry->safe_point : NULL;
-}
-
-void
-gc::mark(std::vector<root> &roots) {
-    std::vector<root>::iterator ri = roots.begin(), rend = roots.end();
-    while (ri < rend) {
-        DPRINT("root: %p\n", ri->data);
-
-        shape::arena arena;
-        shape::type_param *params =
-            shape::type_param::from_tydesc_and_data(ri->tydesc, ri->data,
-                                                    arena);
-        shape::log log(task, true, ri->tydesc->shape, params,
-                       ri->tydesc->shape_tables, ri->data, std::cerr);
-        log.walk();
-        DPRINT("\n");
-
-        ++ri;
-    }
-    // TODO
-}
-
-void
-gc::sweep() {
-    // TODO
-}
-
-void
-gc::run() {
-    safe_point_map map;
-
-    // Find roots.
-    std::vector<root> roots;
-    std::vector<frame> call_stack = backtrace();
-    for (unsigned i = 0; i < call_stack.size(); i++) {
-        frame f = call_stack[i];
-        const safe_point *sp = map.get_safe_point(f.ra);
-        if (!sp)
-            continue;
-
-        DPRINT("%u: ra %p, ebp %p\n", i, call_stack[i].ra, call_stack[i].bp);
-        for (unsigned j = 0; j < sp->n_roots; j++) {
-            root r(sp->roots[j], f);
-            roots.push_back(r);
-        }
-    }
-
-    // Mark and sweep.
-    mark(roots);
-    sweep();
-}
-
-void
-maybe_gc(rust_task *task) {
-    if (*safe_point_data == NULL)
-        return;
-
-    static debug::flag zeal("RUST_GC_ZEAL");
-
-    if (*zeal) {
-        gc gc(task);
-        gc.run();
-    }
-}
-
-}
-
diff --git a/src/rt/rust_gc.h b/src/rt/rust_gc.h
deleted file mode 100644
index 45349dc0f91..00000000000
--- a/src/rt/rust_gc.h
+++ /dev/null
@@ -1,10 +0,0 @@
-// Rust garbage collection.
-
-struct rust_task;
-
-namespace gc {
-
-void maybe_gc(rust_task *task);
-
-}
-
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index a22b3ebc47a..9868d4f5750 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -523,13 +523,13 @@ rust_task::malloc(size_t sz, const char *tag, type_desc *td)
 }
 
 void *
-rust_task::realloc(void *data, size_t sz, bool is_gc)
+rust_task::realloc(void *data, size_t sz)
 {
     return local_region.realloc(data, sz);
 }
 
 void
-rust_task::free(void *p, bool is_gc)
+rust_task::free(void *p)
 {
     local_region.free(p);
 }
diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h
index c3a53ee4eac..f1296c15292 100644
--- a/src/rt/rust_task.h
+++ b/src/rt/rust_task.h
@@ -141,8 +141,8 @@ rust_task : public kernel_owned<rust_task>, rust_cond
     bool dead();
 
     void *malloc(size_t sz, const char *tag, type_desc *td=0);
-    void *realloc(void *data, size_t sz, bool gc_mem=false);
-    void free(void *p, bool gc_mem=false);
+    void *realloc(void *data, size_t sz);
+    void free(void *p);
 
     void transition(rust_task_list *src, rust_task_list *dst);
 
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index 09ad8d930c6..fc9e8af9f02 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -7,7 +7,6 @@
  */
 
 #include "rust_cc.h"
-#include "rust_gc.h"
 #include "rust_internal.h"
 #include "rust_scheduler.h"
 #include "rust_unwind.h"
@@ -122,7 +121,6 @@ upcall_s_malloc(s_malloc_args *args) {
 
     LOG(task, mem, "upcall malloc(0x%" PRIxPTR ")", args->td);
 
-    gc::maybe_gc(task);
     cc::maybe_cc(task);
 
     // FIXME--does this have to be calloc?
@@ -151,7 +149,6 @@ upcall_malloc(type_desc *td) {
 
 struct s_free_args {
     void *ptr;
-    uintptr_t is_gc;
 };
 
 extern "C" CDECL void
@@ -162,7 +159,7 @@ upcall_s_free(s_free_args *args) {
     rust_scheduler *sched = task->sched;
     DLOG(sched, mem,
              "upcall free(0x%" PRIxPTR ", is_gc=%" PRIdPTR ")",
-             (uintptr_t)args->ptr, args->is_gc);
+             (uintptr_t)args->ptr);
 
     debug::maybe_untrack_origin(task, args->ptr);
 
@@ -171,8 +168,8 @@ upcall_s_free(s_free_args *args) {
 }
 
 extern "C" CDECL void
-upcall_free(void* ptr, uintptr_t is_gc) {
-    s_free_args args = {ptr, is_gc};
+upcall_free(void* ptr) {
+    s_free_args args = {ptr};
     UPCALL_SWITCH_STACK(&args, upcall_s_free);
 }
 
diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in
index fea1a4e30ef..da6026ebb23 100644
--- a/src/rt/rustrt.def.in
+++ b/src/rt/rustrt.def.in
@@ -9,7 +9,6 @@ debug_ptrcast
 debug_tag
 debug_tydesc
 debug_get_stk_seg
-do_gc
 drop_task
 get_port_id
 get_task_id