- remove all symbols that get linked into the symbol table from the garbage collector.

Symbols are very easy to manage once they are in a symbol table and there's lots of them so this reduces the amount of work the GC needs to do quite considerably.
After cleaning out compile-time-only symbols there will still be more than 2000 left, one for each function and one for each member variable of a class or struct.
This means more than 2000 object that won't need to tracked constantly by the garbage collector.

Note that loose fields which do occur during code generation will be GC'd just as before.
This commit is contained in:
Christoph Oelckers 2017-02-08 14:34:39 +01:00
commit 31223ca180
9 changed files with 61 additions and 113 deletions

View file

@ -301,42 +301,17 @@ DObject::~DObject ()
PClass *type = GetClass();
if (!(ObjectFlags & OF_Cleanup) && !PClass::bShutdown)
{
DObject **probe;
if (!(ObjectFlags & OF_YesReallyDelete))
if (!(ObjectFlags & (OF_YesReallyDelete|OF_Released)))
{
Printf("Warning: '%s' is freed outside the GC process.\n",
type != NULL ? type->TypeName.GetChars() : "==some object==");
}
// Find all pointers that reference this object and NULL them.
StaticPointerSubstitution(this, NULL);
// Now unlink this object from the GC list.
for (probe = &GC::Root; *probe != NULL; probe = &((*probe)->ObjNext))
if (!(ObjectFlags & OF_Released))
{
if (*probe == this)
{
*probe = ObjNext;
if (&ObjNext == GC::SweepPos)
{
GC::SweepPos = probe;
}
break;
}
}
// If it's gray, also unlink it from the gray list.
if (this->IsGray())
{
for (probe = &GC::Gray; *probe != NULL; probe = &((*probe)->GCNext))
{
if (*probe == this)
{
*probe = GCNext;
break;
}
}
// Find all pointers that reference this object and NULL them.
StaticPointerSubstitution(this, NULL);
Release();
}
}
@ -347,6 +322,41 @@ DObject::~DObject ()
}
}
void DObject::Release()
{
DObject **probe;
// Unlink this object from the GC list.
for (probe = &GC::Root; *probe != NULL; probe = &((*probe)->ObjNext))
{
if (*probe == this)
{
*probe = ObjNext;
if (&ObjNext == GC::SweepPos)
{
GC::SweepPos = probe;
}
break;
}
}
// If it's gray, also unlink it from the gray list.
if (this->IsGray())
{
for (probe = &GC::Gray; *probe != NULL; probe = &((*probe)->GCNext))
{
if (*probe == this)
{
*probe = GCNext;
break;
}
}
}
ObjNext = nullptr;
GCNext = nullptr;
ObjectFlags |= OF_Released;
}
//==========================================================================
//
//