From 89946609f2de815ea87df3b001fff0caf9efa0d5 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 9 Nov 2010 14:15:07 -0800 Subject: Support a special const-value refcount, use it for const strings. --- src/rt/rust_builtin.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/rt/rust_builtin.cpp') diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index d221e6e5..cb16fbf0 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -61,8 +61,12 @@ align_of(rust_task *task, type_desc *t) { return t->align; } -extern "C" CDECL size_t -refcount(rust_task *task, type_desc *t, size_t *v) { +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; @@ -277,7 +281,9 @@ debug_box(rust_task *task, type_desc *t, rust_box *box) task->log(rust_log::STDLIB, "debug_box(0x%" PRIxPTR ")", box); debug_tydesc_helper(task, t); task->log(rust_log::STDLIB, " refcount %" PRIdPTR, - box->ref_count - 1); // -1 because we ref'ed for this call + box->ref_count == CONST_REFCOUNT + ? CONST_REFCOUNT + : box->ref_count - 1); // -1 because we ref'ed for this call for (uintptr_t i = 0; i < t->size; ++i) { task->log(rust_log::STDLIB, " byte %" PRIdPTR ": 0x%" PRIx8, i, box->data[i]); -- cgit v1.2.3