From 9cc44ed5237a04cb17c7ca8d292ee0c3aedbdff3 Mon Sep 17 00:00:00 2001 From: Steven Schveighoffer Date: Sun, 21 Apr 2024 21:15:42 -0400 Subject: [PATCH] Remove all nostack remnants --- .../core/internal/gc/impl/conservative/gc.d | 52 ++++++++----------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/druntime/src/core/internal/gc/impl/conservative/gc.d b/druntime/src/core/internal/gc/impl/conservative/gc.d index 3c2fac2d6391..b1b270799aa7 100644 --- a/druntime/src/core/internal/gc/impl/conservative/gc.d +++ b/druntime/src/core/internal/gc/impl/conservative/gc.d @@ -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"); @@ -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"); @@ -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 @@ -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; } @@ -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); @@ -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 @@ -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: @@ -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); @@ -3163,7 +3157,7 @@ Lmark: updateCollectThresholds(); if (doFork && isFinal) - return fullcollect(true, true, false); + return fullcollect(true, false); return freedPages; } @@ -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;