From 9f9bd0ee34422aceb9725276292a66b0e7934c6a Mon Sep 17 00:00:00 2001 From: Teddy Date: Thu, 15 Aug 2013 11:04:57 +0800 Subject: tail-rec for `if` and `and` --- gc.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'gc.cpp') diff --git a/gc.cpp b/gc.cpp index 4df2d46..28a7360 100644 --- a/gc.cpp +++ b/gc.cpp @@ -3,8 +3,8 @@ #include "consts.h" #include -#if defined(GC_DEBUG) || defined (GC_INFO) #include +#if defined(GC_DEBUG) || defined (GC_INFO) typedef unsigned long long ull; #endif @@ -24,16 +24,18 @@ GarbageCollector::PendingEntry::PendingEntry( void GarbageCollector::expose(EvalObj *ptr) { if (ptr == NULL) return; #ifdef GC_DEBUG - fprintf(stderr, "GC: 0x%llx exposed. count = %lu \"%s\"\n", + fprintf(stderr, "GC: 0x%llx exposed. count = %lu \"%s\"\n", (ull)ptr, ptr->gc_get_cnt() - 1, ptr->ext_repr().c_str()); #endif - if (ptr->gc_dec()) - { + /* if (ptr->gc_get_cnt() == 0) + puts("oops");*/ + if (ptr->gc_dec()) + { #ifdef GC_DEBUG - fprintf(stderr, "GC: 0x%llx pending. \n", (ull)ptr); + fprintf(stderr, "GC: 0x%llx pending. \n", (ull)ptr); #endif - pending_list = new PendingEntry(ptr, pending_list); - } + pending_list = new PendingEntry(ptr, pending_list); + } } void GarbageCollector::force() { -- cgit v1.2.3