[K/N] Exapnd concurrent part of the GC mark phase (KT-58865)

* Build mark closure completely concurrent.
    * Reintroduce concurrent weak processing.
    * Request the second STW only to preare the heap for sweeping.
This commit is contained in:
Aleksei.Glushko
2024-01-31 15:07:30 +01:00
committed by Space Team
parent b7067e0980
commit 69127b4483
19 changed files with 419 additions and 119 deletions
@@ -47,6 +47,8 @@ object BinaryOptions : BinaryOptionRegistry() {
val concurrentWeakSweep by booleanOption()
val concurrentMarkMaxIterations by uintOption()
val gcMutatorsCooperate by booleanOption()
val auxGCThreads by uintOption()
@@ -197,6 +197,9 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
val concurrentWeakSweep: Boolean
get() = configuration.get(BinaryOptions.concurrentWeakSweep) ?: true
val concurrentMarkMaxIterations: UInt
get() = configuration.get(BinaryOptions.concurrentMarkMaxIterations) ?: 100U
val gcMutatorsCooperate: Boolean by lazy {
val mutatorsCooperate = configuration.get(BinaryOptions.gcMutatorsCooperate)
if (gcMarkSingleThreaded) {
@@ -2795,6 +2795,7 @@ internal class CodeGeneratorVisitor(
overrideRuntimeGlobal("Kotlin_destroyRuntimeMode", llvm.constInt32(context.config.destroyRuntimeMode.value))
overrideRuntimeGlobal("Kotlin_gcMutatorsCooperate", llvm.constInt32(if (context.config.gcMutatorsCooperate) 1 else 0))
overrideRuntimeGlobal("Kotlin_auxGCThreads", llvm.constInt32(context.config.auxGCThreads.toInt()))
overrideRuntimeGlobal("Kotlin_concurrentMarkMaxIterations", llvm.constInt32(context.config.concurrentMarkMaxIterations.toInt()))
overrideRuntimeGlobal("Kotlin_workerExceptionHandling", llvm.constInt32(context.config.workerExceptionHandling.value))
overrideRuntimeGlobal("Kotlin_suspendFunctionsFromAnyThreadFromObjC", llvm.constInt32(if (context.config.suspendFunctionsFromAnyThreadFromObjC) 1 else 0))
val getSourceInfoFunctionName = when (context.config.sourceInfoType) {