Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
revert pull 101 because it causes seg fault in stress.d
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Dec 6, 2011
1 parent fe8e4be commit e97e7eb
Showing 1 changed file with 17 additions and 45 deletions.
62 changes: 17 additions & 45 deletions src/gc/gcx.d
Expand Up @@ -2014,54 +2014,26 @@ struct Gcx
void minimize()
{
debug(PRINTF) printf("Minimizing.\n");
size_t n;
size_t pn;
Pool* pool;
size_t ncommitted;

static bool isUsed(Pool *pool)
{
return pool.freepages < pool.npages;
}

// semi-stable partition
for (size_t i = 0; i < npools; ++i)
{
auto pool = pooltable[i];
// find first unused pool
if (isUsed(pool)) continue;

// move used pools before unused ones
size_t j = i + 1;
for (; j < npools; ++j)
{
pool = pooltable[j];
if (!isUsed(pool)) continue;
// swap
pooltable[j] = pooltable[i];
pooltable[i] = pool;
++i;
}
// npooltable[0 .. i] => used
// npooltable[i + 1 .. npools] => free

// free unused pools
for (j = i + 1; j < npools; ++j)
{
pool = pooltable[j];
debug(PRINTF) printFreeInfo(pool);
pool.Dtor();
cstdlib.free(pool);
}
npools = i + 1;
}

if (npools)
{
minAddr = pooltable[0].baseAddr;
maxAddr = pooltable[npools - 1].topAddr;
}
else
Outer:
for (n = 0; n < npools; n++)
{
minAddr = maxAddr = null;
pool = pooltable[n];
debug(PRINTF) printFreeInfo(pool);
if(pool.freepages < pool.npages) continue;
pool.Dtor();
cstdlib.free(pool);
memmove(pooltable + n,
pooltable + n + 1,
(--npools - n) * (Pool*).sizeof);
n--;
}

minAddr = pooltable[0].baseAddr;
maxAddr = pooltable[npools - 1].topAddr;
debug(PRINTF) printf("Done minimizing.\n");
}

Expand Down

0 comments on commit e97e7eb

Please sign in to comment.