[K/N] Enable custom allocator by default ^KT-55364

This commit is contained in:
Alexander Shabalin
2023-05-11 17:30:49 +02:00
committed by Space Team
parent 1e09e8663c
commit da1fde2477
7 changed files with 32 additions and 0 deletions
@@ -63,6 +63,7 @@ internal enum class ClassLevelProperty(shortName: String) {
USE_THREAD_STATE_CHECKER("useThreadStateChecker"),
GC_TYPE("gcType"),
GC_SCHEDULER("gcScheduler"),
ALLOCATOR("alloc"),
CACHE_MODE("cacheMode"),
EXECUTION_TIMEOUT("executionTimeout"),
SANITIZER("sanitizer"),
@@ -163,6 +163,8 @@ private object NativeTestSupport {
val gcScheduler = computeGCScheduler(enforcedProperties)
val allocator = computeAllocator(enforcedProperties)
val nativeHome = getOrCreateTestProcessSettings().get<KotlinNativeHome>()
val distribution = Distribution(nativeHome.dir.path)
@@ -183,6 +185,7 @@ private object NativeTestSupport {
output += threadStateChecker
output += gcType
output += gcScheduler
output += allocator
output += nativeTargets
output += sanitizer
output += CacheMode::class to cacheMode
@@ -228,6 +231,9 @@ private object NativeTestSupport {
private fun computeGCScheduler(enforcedProperties: EnforcedProperties): GCScheduler =
ClassLevelProperty.GC_SCHEDULER.readValue(enforcedProperties, GCScheduler.values(), default = GCScheduler.UNSPECIFIED)
private fun computeAllocator(enforcedProperties: EnforcedProperties): Allocator =
ClassLevelProperty.ALLOCATOR.readValue(enforcedProperties, Allocator.values(), default = Allocator.UNSPECIFIED)
private fun computeNativeTargets(enforcedProperties: EnforcedProperties, hostManager: HostManager): KotlinNativeTargets {
val hostTarget = HostManager.host
return KotlinNativeTargets(
@@ -132,6 +132,7 @@ internal abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
private val sanitizer: Sanitizer,
private val gcType: GCType,
private val gcScheduler: GCScheduler,
private val allocator: Allocator,
private val pipelineType: PipelineType,
freeCompilerArgs: TestCompilerArgs,
override val sourceModules: Collection<TestModule>,
@@ -193,6 +194,7 @@ internal class LibraryCompilation(
sanitizer = settings.get(),
gcType = settings.get(),
gcScheduler = settings.get(),
allocator = settings.get(),
pipelineType = settings.get(),
freeCompilerArgs = freeCompilerArgs,
sourceModules = sourceModules,
@@ -226,6 +228,7 @@ internal class ObjCFrameworkCompilation(
sanitizer = settings.get(),
gcType = settings.get(),
gcScheduler = settings.get(),
allocator = settings.get(),
pipelineType = settings.getStageDependentPipelineType(),
freeCompilerArgs = freeCompilerArgs,
sourceModules = sourceModules,
@@ -310,6 +313,7 @@ internal class ExecutableCompilation(
sanitizer = settings.get(),
gcType = settings.get(),
gcScheduler = settings.get(),
allocator = settings.get(),
pipelineType = settings.getStageDependentPipelineType(),
freeCompilerArgs = freeCompilerArgs,
sourceModules = sourceModules,
@@ -166,6 +166,15 @@ internal enum class GCScheduler(val compilerFlag: String?) {
override fun toString() = compilerFlag?.let { "($it)" }.orEmpty()
}
internal enum class Allocator(val compilerFlag: String?) {
UNSPECIFIED(null),
STD("-Xallocator=std"),
MIMALLOC("-Xallocator=mimalloc"),
CUSTOM("-Xallocator=custom");
override fun toString() = compilerFlag?.let { "($it)" }.orEmpty()
}
/**
* Current project's directories.
*/