aboutsummaryrefslogtreecommitdiff
path: root/gc.h
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2013-08-15 11:04:57 +0800
committerTeddy <ted.sybil@gmail.com>2013-08-15 11:04:57 +0800
commit9f9bd0ee34422aceb9725276292a66b0e7934c6a (patch)
tree4e9044237f3b7004b3b8598fe2c53546ab29dc25 /gc.h
parent06d014cb0e95f92945ea01610fd1c52a1b087502 (diff)
tail-rec for `if` and `and`
Diffstat (limited to 'gc.h')
-rw-r--r--gc.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/gc.h b/gc.h
index 2a0aac6..2d1c179 100644
--- a/gc.h
+++ b/gc.h
@@ -8,6 +8,7 @@ const int GC_QUEUE_SIZE = 262144;
const size_t GC_CYC_THRESHOLD = GC_QUEUE_SIZE >> 1;
typedef std::set<EvalObj*> EvalObjSet;
+class GarbageCollector;
#define GC_CYC_TRIGGER(ptr) \
do { \
@@ -21,6 +22,27 @@ do { \
static_cast<Container*>(ptr)->gc_refs--; \
} while (0)
+extern GarbageCollector gc;
+#define EXIT_CURRENT_ENVT(lenvt) \
+ do { \
+ gc.expose(lenvt); \
+ lenvt = cont->envt; \
+ gc.attach(lenvt); \
+ } while (0)
+#define EXIT_CURRENT_CONT(cont) \
+ do { \
+ gc.expose(cont); \
+ cont = cont->prev_cont; \
+ gc.attach(cont); \
+ } while (0)
+
+#define EXIT_CURRENT_EXEC(lenvt, cont, args) \
+ do { \
+ EXIT_CURRENT_ENVT(lenvt); \
+ EXIT_CURRENT_CONT(cont); \
+ gc.expose(args); \
+ gc.collect(); \
+ } while (0)
class GarbageCollector {
@@ -47,6 +69,5 @@ class GarbageCollector {
EvalObj *attach(EvalObj *ptr);
};
-extern GarbageCollector gc;
#endif