diff options
author | David Robillard <d@drobilla.net> | 2009-06-20 08:00:45 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-06-20 08:00:45 +0000 |
commit | 254168883050be511b924f200399785d258cab74 (patch) | |
tree | f277f370de0c139aa94f066c302d910981b72ad6 /gc.cpp | |
parent | fa0cdd6234aa73ab0680c37f23664ff8c73cc1cb (diff) | |
download | resp-254168883050be511b924f200399785d258cab74.tar.gz resp-254168883050be511b924f200399785d258cab74.tar.bz2 resp-254168883050be511b924f200399785d258cab74.zip |
Accurate garbage collection of types without special (kludge) tag.
git-svn-id: http://svn.drobilla.net/resp/tuplr@131 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'gc.cpp')
-rw-r--r-- | gc.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
@@ -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); |