mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-13 07:57:51 +00:00
- delete all compile-time symbols for scripting after finishing compiling data.
Even the bare-bones gzdoom.pk3 gets rid of over 2000 symbols this way that otherwise would need to be tracked by the garbage collector.
This commit is contained in:
parent
c12dfd7e4d
commit
e3c36998b6
3 changed files with 51 additions and 0 deletions
|
@ -2517,6 +2517,9 @@ void D_DoomMain (void)
|
||||||
|
|
||||||
// Create replacements for dehacked pickups
|
// Create replacements for dehacked pickups
|
||||||
FinishDehPatch();
|
FinishDehPatch();
|
||||||
|
|
||||||
|
// clean up the compiler symbols which are not needed any longer.
|
||||||
|
RemoveUnusedSymbols();
|
||||||
|
|
||||||
InitActorNumsFromMapinfo();
|
InitActorNumsFromMapinfo();
|
||||||
InitSpawnablesFromMapinfo();
|
InitSpawnablesFromMapinfo();
|
||||||
|
|
|
@ -3898,3 +3898,45 @@ void FNamespaceManager::ReleaseSymbols()
|
||||||
GlobalNamespace = nullptr;
|
GlobalNamespace = nullptr;
|
||||||
AllNamespaces.Clear();
|
AllNamespaces.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// removes all symbols from the symbol tables.
|
||||||
|
// After running the compiler these are not needed anymore.
|
||||||
|
// Only the namespaces themselves are kept because the type table references them.
|
||||||
|
int FNamespaceManager::RemoveSymbols()
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (auto ns : AllNamespaces)
|
||||||
|
{
|
||||||
|
count += ns->Symbols.Symbols.CountUsed();
|
||||||
|
ns->Symbols.ReleaseSymbols();
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoveUnusedSymbols()
|
||||||
|
{
|
||||||
|
// Global symbols are not needed anymore after running the compiler.
|
||||||
|
int count = Namespaces.RemoveSymbols();
|
||||||
|
|
||||||
|
// We do not need any non-field and non-function symbols in structs and classes anymore.
|
||||||
|
for (size_t i = 0; i < countof(TypeTable.TypeHash); ++i)
|
||||||
|
{
|
||||||
|
for (PType *ty = TypeTable.TypeHash[i]; ty != NULL; ty = ty->HashNext)
|
||||||
|
{
|
||||||
|
if (ty->IsKindOf(RUNTIME_CLASS(PStruct)))
|
||||||
|
{
|
||||||
|
auto it = ty->Symbols.GetIterator();
|
||||||
|
PSymbolTable::MapType::Pair *pair;
|
||||||
|
while (it.NextPair(pair))
|
||||||
|
{
|
||||||
|
if (!pair->Value->IsKindOf(RUNTIME_CLASS(PField)) && !pair->Value->IsKindOf(RUNTIME_CLASS(PFunction)))
|
||||||
|
{
|
||||||
|
ty->Symbols.RemoveSymbol(pair->Value);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DPrintf(DMSG_SPAMMY, "%d symbols removed after compilation\n", count);
|
||||||
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ class VMFrameStack;
|
||||||
struct VMValue;
|
struct VMValue;
|
||||||
struct VMReturn;
|
struct VMReturn;
|
||||||
class VMFunction;
|
class VMFunction;
|
||||||
|
struct FNamespaceManager;
|
||||||
|
|
||||||
// A VM function ------------------------------------------------------------
|
// A VM function ------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -157,6 +158,7 @@ private:
|
||||||
MapType Symbols;
|
MapType Symbols;
|
||||||
|
|
||||||
friend class DObject;
|
friend class DObject;
|
||||||
|
friend struct FNamespaceManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
// A symbol for a compiler tree node ----------------------------------------
|
// A symbol for a compiler tree node ----------------------------------------
|
||||||
|
@ -1010,6 +1012,7 @@ struct FNamespaceManager
|
||||||
PNamespace *NewNamespace(int filenum);
|
PNamespace *NewNamespace(int filenum);
|
||||||
size_t MarkSymbols();
|
size_t MarkSymbols();
|
||||||
void ReleaseSymbols();
|
void ReleaseSymbols();
|
||||||
|
int RemoveSymbols();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern FNamespaceManager Namespaces;
|
extern FNamespaceManager Namespaces;
|
||||||
|
@ -1047,4 +1050,7 @@ inline T *&DObject::PointerVar(FName field)
|
||||||
{
|
{
|
||||||
return *(T**)ScriptVar(field, nullptr); // pointer check is more tricky and for the handful of uses in the DECORATE parser not worth the hassle.
|
return *(T**)ScriptVar(field, nullptr); // pointer check is more tricky and for the handful of uses in the DECORATE parser not worth the hassle.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoveUnusedSymbols();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue