- Fixed: DACSThinker::ActiveThinker was missing a read barrier.

- Loading a save game now initiates a collection.
- Added a finalization cost to the sweep stage.


SVN r801 (trunk)
This commit is contained in:
Randy Heit 2008-03-13 03:14:33 +00:00
parent ff387a952c
commit 6715b84d0d
7 changed files with 26 additions and 7 deletions

View file

@ -1,4 +1,7 @@
March 12, 2008
- Fixed: DACSThinker::ActiveThinker was missing a read barrier.
- Loading a save game now initiates a collection.
- Added a finalization cost to the sweep stage.
- Fixed: D_dehacked.cpp/PatchThing() allocated an actor on the stack.
- Changed the sentinels in the thinker lists into a proper thinker. The old
way wasn't playing well with the write barriers.

View file

@ -1842,7 +1842,6 @@ void TryRunTics (void)
M_Ticker ();
I_GetTime (true);
G_Ticker ();
GC::CheckGC ();
gametic++;
NetUpdate (); // check for new console commands

View file

@ -309,6 +309,12 @@ namespace GC
Step();
}
// Forces a collection to start now.
static inline void StartCollection()
{
Threshold = AllocBytes;
}
// Marks a white object gray. If the object wants to die, the pointer
// is NULLed instead.
void Mark(DObject **obj);

View file

@ -185,11 +185,11 @@ static size_t PropagateAll()
//
//==========================================================================
static DObject **SweepList(DObject **p, size_t count)
static DObject **SweepList(DObject **p, size_t count, size_t *finalize_count)
{
static int scount;
DObject *curr;
int deadmask = OtherWhite();
size_t finalized = 0;
while ((curr = *p) != NULL && count-- > 0)
{
@ -210,8 +210,13 @@ static DObject **SweepList(DObject **p, size_t count)
}
curr->ObjectFlags |= OF_Cleanup;
delete curr;
finalized++;
}
}
if (finalize_count != NULL)
{
*finalize_count = finalized;
}
return p;
}
@ -350,14 +355,15 @@ static size_t SingleStep()
case GCS_Sweep: {
size_t old = AllocBytes;
SweepPos = SweepList(SweepPos, GCSWEEPMAX);
size_t finalize_count;
SweepPos = SweepList(SweepPos, GCSWEEPMAX, &finalize_count);
if (*SweepPos == NULL)
{ // Nothing more to sweep?
State = GCS_Finalize;
}
assert(old >= AllocBytes);
Estimate -= old - AllocBytes;
return GCSWEEPMAX * GCSWEEPCOST;
return (GCSWEEPMAX - finalize_count) * GCSWEEPCOST + finalize_count * GCFINALIZECOST;
}
case GCS_Finalize:

View file

@ -1823,6 +1823,11 @@ void G_DoLoadGame ()
delete png;
fclose (stdfile);
// At this point, the GC threshold is likely a lot higher than the
// amount of memory in use, so bring it down now by starting a
// collection.
GC::StartCollection();
}

View file

@ -1562,7 +1562,7 @@ IMPLEMENT_POINTY_CLASS (DACSThinker)
DECLARE_POINTER(Scripts)
END_POINTERS
DACSThinker *DACSThinker::ActiveThinker = NULL;
TObjPtr<DACSThinker> DACSThinker::ActiveThinker;
DACSThinker::DACSThinker ()
{

View file

@ -710,7 +710,7 @@ public:
void Tick ();
DLevelScript *RunningScripts[1000]; // Array of all synchronous scripts
static DACSThinker *ActiveThinker;
static TObjPtr<DACSThinker> ActiveThinker;
void DumpScriptStatus();
void StopScriptsFor (AActor *actor);