Skip to content

Commit

Permalink
Remove all nostack remnants
Browse files Browse the repository at this point in the history
  • Loading branch information
schveiguy committed Apr 22, 2024
1 parent 782e6ad commit 9cc44ed
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions druntime/src/core/internal/gc/impl/conservative/gc.d
Original file line number Diff line number Diff line change
Expand Up @@ -2535,14 +2535,11 @@ struct Gcx
}

// collection step 2: mark roots and heap
void markAll(alias markFn)(bool nostack) nothrow
void markAll(alias markFn)() nothrow
{
if (!nostack)
{
debug(COLLECT_PRINTF) printf("\tscan stacks.\n");
// Scan stacks and registers for each paused thread
thread_scanAll(&markFn);
}
debug(COLLECT_PRINTF) printf("\tscan stacks.\n");
// Scan stacks registers, and TLS for each paused thread
thread_scanAll(&markFn);

// Scan roots[]
debug(COLLECT_PRINTF) printf("\tscan roots[]\n");
Expand All @@ -2563,14 +2560,11 @@ struct Gcx
}

version (COLLECT_PARALLEL)
void collectAllRoots(bool nostack) nothrow
void collectAllRoots() nothrow
{
if (!nostack)
{
debug(COLLECT_PRINTF) printf("\tcollect stacks.\n");
// Scan stacks and registers for each paused thread
thread_scanAll(&collectRoots);
}
debug(COLLECT_PRINTF) printf("\tcollect stacks.\n");
// Scan stacks registers and TLS for each paused thread
thread_scanAll(&collectRoots);

// Scan roots[]
debug(COLLECT_PRINTF) printf("\tcollect roots[]\n");
Expand Down Expand Up @@ -2899,7 +2893,7 @@ struct Gcx
}

version (COLLECT_FORK)
ChildStatus markFork(bool nostack, bool block, bool doParallel) nothrow
ChildStatus markFork(bool block, bool doParallel) nothrow
{
// Forking is enabled, so we fork() and start a new concurrent mark phase
// in the child. If the collection should not block, the parent process
Expand All @@ -2915,11 +2909,11 @@ struct Gcx
int child_mark() scope
{
if (doParallel)
markParallel(nostack);
markParallel();
else if (ConservativeGC.isPrecise)
markAll!(markPrecise!true)(nostack);
markAll!(markPrecise!true)();
else
markAll!(markConservative!true)(nostack);
markAll!(markConservative!true)();
return 0;
}

Expand Down Expand Up @@ -2978,11 +2972,11 @@ struct Gcx
// do the marking in this thread
disableFork();
if (doParallel)
markParallel(nostack);
markParallel();
else if (ConservativeGC.isPrecise)
markAll!(markPrecise!false)(nostack);
markAll!(markPrecise!false)();
else
markAll!(markConservative!false)(nostack);
markAll!(markConservative!false)();
} else {
assert(r == ChildStatus.done);
assert(r != ChildStatus.running);
Expand All @@ -2995,7 +2989,7 @@ struct Gcx
* Return number of full pages free'd.
* The collection is done concurrently only if block and isFinal are false.
*/
size_t fullcollect(bool nostack = false, bool block = false, bool isFinal = false) nothrow
size_t fullcollect(bool block = false, bool isFinal = false) nothrow
{
// It is possible that `fullcollect` will be called from a thread which
// is not yet registered in runtime (because allocating `new Thread` is
Expand Down Expand Up @@ -3077,7 +3071,7 @@ Lmark:
{
version (COLLECT_FORK)
{
auto forkResult = markFork(nostack, block, doParallel);
auto forkResult = markFork(block, doParallel);
final switch (forkResult)
{
case ChildStatus.error:
Expand All @@ -3104,14 +3098,14 @@ Lmark:
else if (doParallel)
{
version (COLLECT_PARALLEL)
markParallel(nostack);
markParallel();
}
else
{
if (ConservativeGC.isPrecise)
markAll!(markPrecise!false)(nostack);
markAll!(markPrecise!false)();
else
markAll!(markConservative!false)(nostack);
markAll!(markConservative!false)();
}

thread_processGCMarks(&isMarked);
Expand Down Expand Up @@ -3163,7 +3157,7 @@ Lmark:

updateCollectThresholds();
if (doFork && isFinal)
return fullcollect(true, true, false);
return fullcollect(true, false);
return freedPages;
}

Expand Down Expand Up @@ -3279,10 +3273,10 @@ Lmark:
shared uint stoppedThreads;
bool stopGC;

void markParallel(bool nostack) nothrow
void markParallel() nothrow
{
toscanRoots.clear();
collectAllRoots(nostack);
collectAllRoots();
if (toscanRoots.empty)
return;

Expand Down

0 comments on commit 9cc44ed

Please sign in to comment.