mirror of
https://github.com/cc65/cc65.git
synced 2024-09-29 17:56:21 +00:00
Track cheap local symbols. Reduce initial collection size to one. This causes
a small increase in allocations, but about 20% decrease in allocated memory. Looks like many of the collections are rather small. git-svn-id: svn://svn.cc65.org/cc65/trunk@5199 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
6aae186f7f
commit
ae0fcbf345
@ -348,6 +348,7 @@ struct SymInfo {
|
|||||||
SymInfo* Info; /* Pointer to parent symbol if any */
|
SymInfo* Info; /* Pointer to parent symbol if any */
|
||||||
} Parent;
|
} Parent;
|
||||||
Collection* ImportList; /* List of imports if this is an export */
|
Collection* ImportList; /* List of imports if this is an export */
|
||||||
|
Collection* CheapLocals; /* List of cheap local symbols */
|
||||||
char Name[1]; /* Name of symbol */
|
char Name[1]; /* Name of symbol */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -706,7 +707,7 @@ static void CollPrepareInsert (Collection* C, unsigned Index)
|
|||||||
/* Grow the array if necessary */
|
/* Grow the array if necessary */
|
||||||
if (C->Count >= C->Size) {
|
if (C->Count >= C->Size) {
|
||||||
/* Must grow */
|
/* Must grow */
|
||||||
CollGrow (C, (C->Size == 0)? 8 : C->Size * 2);
|
CollGrow (C, (C->Size == 0)? 1 : C->Size * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move the existing elements if needed */
|
/* Move the existing elements if needed */
|
||||||
@ -768,7 +769,7 @@ static void CollReplaceExpand (Collection* C, void* Item, unsigned Index)
|
|||||||
/* Must expand the collection */
|
/* Must expand the collection */
|
||||||
unsigned Size = C->Size;
|
unsigned Size = C->Size;
|
||||||
if (Size == 0) {
|
if (Size == 0) {
|
||||||
Size = 8;
|
Size = 2;
|
||||||
}
|
}
|
||||||
while (Index >= Size) {
|
while (Index >= Size) {
|
||||||
Size *= 2;
|
Size *= 2;
|
||||||
@ -1527,6 +1528,7 @@ static SymInfo* NewSymInfo (const StrBuf* Name)
|
|||||||
|
|
||||||
/* Initialize it as necessary */
|
/* Initialize it as necessary */
|
||||||
S->ImportList = 0;
|
S->ImportList = 0;
|
||||||
|
S->CheapLocals = 0;
|
||||||
memcpy (S->Name, SB_GetConstBuf (Name), SB_GetLen (Name) + 1);
|
memcpy (S->Name, SB_GetConstBuf (Name), SB_GetLen (Name) + 1);
|
||||||
|
|
||||||
/* Return it */
|
/* Return it */
|
||||||
@ -1539,6 +1541,7 @@ static void FreeSymInfo (SymInfo* S)
|
|||||||
/* Free a SymInfo struct */
|
/* Free a SymInfo struct */
|
||||||
{
|
{
|
||||||
CollFree (S->ImportList);
|
CollFree (S->ImportList);
|
||||||
|
CollFree (S->CheapLocals);
|
||||||
xfree (S);
|
xfree (S);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4450,7 +4453,7 @@ static void ProcessSymInfo (InputData* D)
|
|||||||
CollAppend (&S->Scope.Info->SymInfoByName, S);
|
CollAppend (&S->Scope.Info->SymInfoByName, S);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Resolve the parent */
|
/* Resolve the parent for cheap locals */
|
||||||
if (S->Parent.Id == CC65_INV_ID) {
|
if (S->Parent.Id == CC65_INV_ID) {
|
||||||
S->Parent.Info = 0;
|
S->Parent.Info = 0;
|
||||||
} else if (S->Parent.Id >= CollCount (&D->Info->SymInfoById)) {
|
} else if (S->Parent.Id >= CollCount (&D->Info->SymInfoById)) {
|
||||||
@ -4461,6 +4464,12 @@ static void ProcessSymInfo (InputData* D)
|
|||||||
S->Parent.Info = 0;
|
S->Parent.Info = 0;
|
||||||
} else {
|
} else {
|
||||||
S->Parent.Info = CollAt (&D->Info->SymInfoById, S->Parent.Id);
|
S->Parent.Info = CollAt (&D->Info->SymInfoById, S->Parent.Id);
|
||||||
|
|
||||||
|
/* Place a backpointer to the cheap local into the parent */
|
||||||
|
if (S->Parent.Info->CheapLocals == 0) {
|
||||||
|
S->Parent.Info->CheapLocals = CollNew ();
|
||||||
|
}
|
||||||
|
CollAppend (S->Parent.Info->CheapLocals, S);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user