aboutsummaryrefslogtreecommitdiffstats
path: root/gc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gc.cpp')
-rw-r--r--gc.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/gc.cpp b/gc.cpp
index 84ebab1..6311058 100644
--- a/gc.cpp
+++ b/gc.cpp
@@ -42,13 +42,15 @@ mark(const Object* obj)
return;
obj->mark(true);
- if (obj->tag() == GC::TAG_AST) {
- const AST* ast = static_cast<const AST*>(obj);
- const ATuple* tup = dynamic_cast<const ATuple*>(ast);
- if (tup) {
+ switch (obj->tag()) {
+ case GC::TAG_FRAME:
+ break;
+ case GC::TAG_AST:
+ const ATuple* tup = dynamic_cast<const ATuple*>((AST*)obj);
+ if (tup)
FOREACH(ATuple::const_iterator, i, *tup)
mark(*i);
- }
+ break;
}
}
@@ -61,26 +63,20 @@ GC::collect(const Roots& roots)
mark(*i);
for (Heap::iterator i = _heap.begin(); i != _heap.end();) {
- assert((*i)->tag() == GC::TAG_AST || (*i)->tag() == GC::TAG_FRAME
- ||(*i)->tag() == GC::TAG_TYPE);
+ assert((*i)->tag() == GC::TAG_AST || (*i)->tag() == GC::TAG_FRAME);
Heap::iterator next = i;
++next;
if ((*i)->marked()) {
(*i)->mark(false);
} else {
- AST* ast;
- switch ((GC::Tag)(*i)->tag()) {
+ switch ((*i)->tag()) {
case GC::TAG_FRAME:
free((char*)(*i) - sizeof(Object::Header));
_heap.erase(i);
break;
- case GC::TAG_TYPE:
- // Don't delete types that are keys in the current type substitution
- break;
case GC::TAG_AST:
- ast = (AST*)*i;
- assert(!ast->to<AType*>());
+ AST* ast = (AST*)*i;
(ast)->~AST();
free((char*)(*i) - sizeof(Object::Header));
_heap.erase(i);