Eliminate const_refcount. Issue #855
This commit is contained in:
parent
99ee0fca67
commit
72c14d5a41
6 changed files with 7 additions and 42 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue