[K/N] Custom allocator for all GCs ^KT-55364

Also enables the integration tests for custom allocator and the
currently available GCs.

Co-authored-by: Troels Bjerre Lund <troels@google.com>

Merge-request: KT-MR-11199
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
This commit is contained in:
Troels Bjerre Lund
2023-07-24 16:28:47 +00:00
committed by Space Team
parent 9864c5c386
commit 2818957689
41 changed files with 552 additions and 87 deletions
@@ -232,15 +232,11 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
val shouldCoverSources = configuration.getBoolean(KonanConfigKeys.COVERAGE)
private val shouldCoverLibraries = !configuration.getList(KonanConfigKeys.LIBRARIES_TO_COVER).isNullOrEmpty()
private val defaultAllocationMode get() = when {
gc == GC.PARALLEL_MARK_CONCURRENT_SWEEP && sanitizer == null -> {
private val defaultAllocationMode get() =
if (sanitizer == null)
AllocationMode.CUSTOM
}
target.supportsMimallocAllocator() && sanitizer == null -> {
AllocationMode.MIMALLOC
}
else -> AllocationMode.STD
}
else
AllocationMode.STD
val allocationMode by lazy {
when (configuration.get(KonanConfigKeys.ALLOCATION_MODE)) {
@@ -262,13 +258,7 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
if (sanitizer != null) {
configuration.report(CompilerMessageSeverity.STRONG_WARNING, "Sanitizers are useful only with the std allocator")
}
if (gc == GC.PARALLEL_MARK_CONCURRENT_SWEEP) {
AllocationMode.CUSTOM
} else {
configuration.report(CompilerMessageSeverity.STRONG_WARNING,
"Custom allocator is currently only integrated with concurrent mark and sweep gc. Using default mode.")
defaultAllocationMode
}
AllocationMode.CUSTOM
}
}
}
@@ -293,19 +283,17 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
}
if (allocationMode == AllocationMode.CUSTOM) {
add("experimental_memory_manager_custom.bc")
add("concurrent_ms_gc_custom.bc")
when (gc) {
GC.STOP_THE_WORLD_MARK_AND_SWEEP -> add("same_thread_ms_gc_custom.bc")
GC.NOOP -> add("noop_gc_custom.bc")
GC.PARALLEL_MARK_CONCURRENT_SWEEP -> add("concurrent_ms_gc_custom.bc")
}
} else {
add("experimental_memory_manager.bc")
when (gc) {
GC.STOP_THE_WORLD_MARK_AND_SWEEP -> {
add("same_thread_ms_gc.bc")
}
GC.NOOP -> {
add("noop_gc.bc")
}
GC.PARALLEL_MARK_CONCURRENT_SWEEP -> {
add("concurrent_ms_gc.bc")
}
GC.STOP_THE_WORLD_MARK_AND_SWEEP -> add("same_thread_ms_gc.bc")
GC.NOOP -> add("noop_gc.bc")
GC.PARALLEL_MARK_CONCURRENT_SWEEP -> add("concurrent_ms_gc.bc")
}
}
if (shouldCoverLibraries || shouldCoverSources) add("profileRuntime.bc")