]> git.lizzy.rs Git - rust.git/commitdiff
rt: get rid of rust_fn and replace with fn_env_pair plus a little cleanup.
authorLuqman Aden <laden@csclub.uwaterloo.ca>
Wed, 13 Feb 2013 09:42:39 +0000 (04:42 -0500)
committerLuqman Aden <laden@csclub.uwaterloo.ca>
Wed, 13 Feb 2013 20:41:38 +0000 (15:41 -0500)
src/rt/rust_builtin.cpp
src/rt/rust_refcount.h
src/rt/rust_task.h
src/rt/rustrt.def.in

index 86f371a30f3ac8ca95ff14ec35f4ba1050880c33..22ebc52edf0907fac9507a88ee9d1673ce1a6eb0 100644 (file)
@@ -249,24 +249,16 @@ debug_opaque(type_desc *t, uint8_t *front) {
     }
 }
 
-// FIXME (#2667) this no longer reflects the actual structure of boxes!
-struct rust_box {
-    RUST_REFCOUNTED(rust_box)
-
-    // FIXME (#2667) `data` could be aligned differently from the actual
-    // box body data
-    uint8_t data[];
-};
-
 extern "C" CDECL void
-debug_box(type_desc *t, rust_box *box) {
+debug_box(type_desc *t, rust_opaque_box *box) {
     rust_task *task = rust_get_current_task();
     LOG(task, stdlib, "debug_box(0x%" PRIxPTR ")", box);
     debug_tydesc_helper(t);
     LOG(task, stdlib, "  refcount %" PRIdPTR,
         box->ref_count - 1);  // -1 because we ref'ed for this call
+    uint8_t *data = (uint8_t *)box_body(box);
     for (uintptr_t i = 0; i < t->size; ++i) {
-        LOG(task, stdlib, "  byte %" PRIdPTR ": 0x%" PRIx8, i, box->data[i]);
+        LOG(task, stdlib, "  byte %" PRIdPTR ": 0x%" PRIx8, i, data[i]);
     }
 }
 
@@ -288,20 +280,15 @@ debug_tag(type_desc *t, rust_tag *tag) {
             tag->variant[i]);
 }
 
-struct rust_fn {
-    uintptr_t *thunk;
-    rust_box *closure;
-};
-
 extern "C" CDECL void
-debug_fn(type_desc *t, rust_fn *fn) {
+debug_fn(type_desc *t, fn_env_pair *fn) {
     rust_task *task = rust_get_current_task();
     LOG(task, stdlib, "debug_fn");
     debug_tydesc_helper(t);
-    LOG(task, stdlib, "  thunk at 0x%" PRIxPTR, fn->thunk);
-    LOG(task, stdlib, "  closure at 0x%" PRIxPTR, fn->closure);
-    if (fn->closure) {
-        LOG(task, stdlib, "    refcount %" PRIdPTR, fn->closure->ref_count);
+    LOG(task, stdlib, " fn at 0x%" PRIxPTR, fn->f);
+    LOG(task, stdlib, "  env at 0x%" PRIxPTR, fn->env);
+    if (fn->env) {
+        LOG(task, stdlib, "    refcount %" PRIdPTR, fn->env->ref_count);
     }
 }
 
@@ -389,11 +376,6 @@ extern "C" CDECL FILE* rust_get_stdin() {return stdin;}
 extern "C" CDECL FILE* rust_get_stdout() {return stdout;}
 extern "C" CDECL FILE* rust_get_stderr() {return stderr;}
 
-extern "C" CDECL int
-rust_ptr_eq(type_desc *t, rust_box *a, rust_box *b) {
-    return a == b;
-}
-
 #if defined(__WIN32__)
 extern "C" CDECL void
 get_time(int64_t *sec, int32_t *nsec) {
index ef7ae1f35e3326ae4d5342dc0af63843d5d533a3..1ed05ec8339598279b25798cd78864fc4c7644dd 100644 (file)
 // Refcounting defines
 typedef unsigned long ref_cnt_t;
 
-#define RUST_REFCOUNTED(T) \
-  RUST_REFCOUNTED_WITH_DTOR(T, delete (T*)this)
-
-#define RUST_REFCOUNTED_WITH_DTOR(T, dtor)      \
-  intptr_t ref_count;      \
-  void ref() { ++ref_count; } \
-  void deref() { if (--ref_count == 0) { dtor; } }
-
 #define RUST_ATOMIC_REFCOUNT()                                             \
 private:                                                                   \
    intptr_t ref_count;                                                     \
index cbde863fa231950756d7e900423c62f489ddb727..23354918c50467d55f2f195dd2338e99bb38e294 100644 (file)
 #define RED_ZONE_SIZE RZ_MAC_32
 #endif
 
-struct rust_box;
-
 struct frame_glue_fns {
     uintptr_t mark_glue_off;
     uintptr_t drop_glue_off;
index c554489c4b35b97e90579fb1fd966cc1df6754c0..a19f9053cbeaa2f6279cef559d54f8e739063dcb 100644 (file)
@@ -39,7 +39,6 @@ rust_list_files2
 rust_log_console_on
 rust_log_console_off
 rust_process_wait
-rust_ptr_eq
 rust_run_program
 rust_sched_current_nonlazy_threads
 rust_sched_threads