about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-09-02 12:21:01 -0700
committerBrian Anderson <banderson@mozilla.com>2011-09-02 15:13:41 -0700
commit72c14d5a4108e91dcdce17c8ccc6f7953fde8a70 (patch)
tree099f4e7f99b10f0033784b0b0265a1dc9a298d7f /src
parent99ee0fca6722bc8b78032605c2f6243340f6b04e (diff)
downloadrust-72c14d5a4108e91dcdce17c8ccc6f7953fde8a70.tar.gz
rust-72c14d5a4108e91dcdce17c8ccc6f7953fde8a70.zip
Eliminate const_refcount. Issue #855
Diffstat (limited to 'src')
-rw-r--r--src/comp/back/abi.rs4
-rw-r--r--src/comp/middle/trans.rs24
-rw-r--r--src/lib/dbg.rs3
-rw-r--r--src/rt/rust_builtin.cpp7
-rw-r--r--src/rt/rust_internal.h7
-rw-r--r--src/test/run-pass/alt-pattern-drop.rs4
6 files changed, 7 insertions, 42 deletions
diff --git a/src/comp/back/abi.rs b/src/comp/back/abi.rs
index b14afb0d594..e71ed2eeff9 100644
--- a/src/comp/back/abi.rs
+++ b/src/comp/back/abi.rs
@@ -4,10 +4,6 @@
 // FIXME: Most of these should be uints.
 const rc_base_field_refcnt: int = 0;
 
-
-// FIXME: import from std::dbg when imported consts work.
-const const_refcount: uint = 0x7bad_face_u;
-
 const task_field_refcnt: int = 0;
 
 const task_field_stk: int = 2;
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 6363d44a30e..e03b23bf43c 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -1318,16 +1318,9 @@ fn incr_refcnt_of_boxed(cx: &@block_ctxt, box_ptr: ValueRef) -> @block_ctxt {
     let rc_ptr =
         GEP(cx, box_ptr, [C_int(0), C_int(abi::box_rc_field_refcnt)]);
     let rc = Load(cx, rc_ptr);
-    let rc_adj_cx = new_sub_block_ctxt(cx, ~"rc++");
-    let next_cx = new_sub_block_ctxt(cx, ~"next");
-    let const_test =
-        ICmp(cx, lib::llvm::LLVMIntEQ, C_int(abi::const_refcount as int),
-                      rc);
-    CondBr(cx, const_test, next_cx.llbb, rc_adj_cx.llbb);
-    rc = Add(rc_adj_cx, rc, C_int(1));
-    Store(rc_adj_cx, rc, rc_ptr);
-    Br(rc_adj_cx, next_cx.llbb);
-    ret next_cx;
+    rc = Add(cx, rc, C_int(1));
+    Store(cx, rc, rc_ptr);
+    ret cx;
 }
 
 fn make_free_glue(bcx: &@block_ctxt, v0: ValueRef, t: ty::t) {
@@ -1466,7 +1459,6 @@ fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: &ast::def_id,
 fn decr_refcnt_maybe_free(cx: &@block_ctxt, box_ptr_alias: ValueRef,
                           full_alias: ValueRef, t: ty::t) -> @block_ctxt {
     let ccx = bcx_ccx(cx);
-    let load_rc_cx = new_sub_block_ctxt(cx, ~"load rc");
     let rc_adj_cx = new_sub_block_ctxt(cx, ~"rc--");
     let free_cx = new_sub_block_ctxt(cx, ~"free");
     let next_cx = new_sub_block_ctxt(cx, ~"next");
@@ -1474,15 +1466,11 @@ fn decr_refcnt_maybe_free(cx: &@block_ctxt, box_ptr_alias: ValueRef,
     let llbox_ty = T_opaque_obj_ptr(*ccx);
     box_ptr = PointerCast(cx, box_ptr, llbox_ty);
     let null_test = IsNull(cx, box_ptr);
-    CondBr(cx, null_test, next_cx.llbb, load_rc_cx.llbb);
+    CondBr(cx, null_test, next_cx.llbb, rc_adj_cx.llbb);
     let rc_ptr =
-        GEP(load_rc_cx, box_ptr,
+        GEP(rc_adj_cx, box_ptr,
                              [C_int(0), C_int(abi::box_rc_field_refcnt)]);
-    let rc = Load(load_rc_cx, rc_ptr);
-    let const_test =
-        ICmp(load_rc_cx, lib::llvm::LLVMIntEQ,
-                              C_int(abi::const_refcount as int), rc);
-    CondBr(load_rc_cx, const_test, next_cx.llbb, rc_adj_cx.llbb);
+    let rc = Load(rc_adj_cx, rc_ptr);
     rc = Sub(rc_adj_cx, rc, C_int(1));
     Store(rc_adj_cx, rc, rc_ptr);
     let zero_test = ICmp(rc_adj_cx, lib::llvm::LLVMIntEQ, C_int(0), rc);
diff --git a/src/lib/dbg.rs b/src/lib/dbg.rs
index 77587bd058c..6858b30419a 100644
--- a/src/lib/dbg.rs
+++ b/src/lib/dbg.rs
@@ -8,9 +8,6 @@
  * logging.
  */
 
-// FIXME: handle 64-bit case.
-const const_refcount: uint = 0x7bad_face_u;
-
 native "rust" mod rustrt {
     fn debug_tydesc<T>();
     fn debug_opaque<T>(x: &T);
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 814822e8f1e..0ed30a8cbf6 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -90,9 +90,6 @@ leak(rust_task *task, type_desc *t, void *thing) {
 extern "C" CDECL intptr_t
 refcount(rust_task *task, type_desc *t, intptr_t *v) {
 
-    if (*v == CONST_REFCOUNT)
-        return CONST_REFCOUNT;
-
     // Passed-in value has refcount 1 too high
     // because it was ref'ed while making the call.
     return (*v) - 1;
@@ -249,9 +246,7 @@ debug_box(rust_task *task, type_desc *t, rust_box *box)
     LOG(task, stdlib, "debug_box(0x%" PRIxPTR ")", box);
     debug_tydesc_helper(task, t);
     LOG(task, stdlib, "  refcount %" PRIdPTR,
-        box->ref_count == CONST_REFCOUNT
-        ? CONST_REFCOUNT
-        : box->ref_count - 1);  // -1 because we ref'ed for this call
+        box->ref_count - 1);  // -1 because we ref'ed for this call
     for (uintptr_t i = 0; i < t->size; ++i) {
         LOG(task, stdlib, "  byte %" PRIdPTR ": 0x%" PRIx8, i, box->data[i]);
     }
diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h
index 4a5d208915d..d2c8574280b 100644
--- a/src/rt/rust_internal.h
+++ b/src/rt/rust_internal.h
@@ -95,13 +95,6 @@ struct chan_handle {
 
 static size_t const TIME_SLICE_IN_MS = 10;
 
-// Since every refcounted object is > 4 bytes, any refcount with any of the
-// top two bits set is invalid. We reserve a particular bit pattern in this
-// set for indicating objects that are "constant" as far as the memory model
-// knows.
-
-static intptr_t const CONST_REFCOUNT = 0x7badface;
-
 // This accounts for logging buffers.
 
 static size_t const BUF_BYTES = 2048;
diff --git a/src/test/run-pass/alt-pattern-drop.rs b/src/test/run-pass/alt-pattern-drop.rs
index 28067b6d7cd..1447b48d515 100644
--- a/src/test/run-pass/alt-pattern-drop.rs
+++ b/src/test/run-pass/alt-pattern-drop.rs
@@ -5,10 +5,6 @@ use std;
 
 import std::dbg;
 
-// FIXME: import std::dbg.const_refcount. Currently
-// cross-crate const references don't work.
-const const_refcount: uint = 0x7bad_face_u;
-
 tag t { make_t(@int); clam; }
 
 fn foo(s: @int) {