[K/N] Disable cms for targets not supporting threads

This commit is contained in:
Pavel Kunyavskiy
2021-12-10 11:54:02 +03:00
committed by Space
parent 42aaa86f10
commit 3a8b4059c9
4 changed files with 29 additions and 20 deletions
@@ -300,28 +300,17 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
DestroyRuntimeMode.ON_SHUTDOWN
}
})
val assertGcSupported = {
if (memoryModel != MemoryModel.EXPERIMENTAL) {
configuration.report(ERROR, "-Xgc is only supported for -memory-model experimental")
}
if (arguments.gc != null && memoryModel != MemoryModel.EXPERIMENTAL) {
configuration.report(ERROR, "-Xgc is only supported for -memory-model experimental")
}
put(GARBAGE_COLLECTOR, when (arguments.gc) {
null -> GC.SAME_THREAD_MARK_AND_SWEEP
"noop" -> {
assertGcSupported()
GC.NOOP
}
"stms" -> {
assertGcSupported()
GC.SAME_THREAD_MARK_AND_SWEEP
}
"cms" -> {
assertGcSupported()
GC.CONCURRENT_MARK_AND_SWEEP
}
putIfNotNull(GARBAGE_COLLECTOR, when (arguments.gc) {
null -> null
"noop" -> GC.NOOP
"stms" -> GC.SAME_THREAD_MARK_AND_SWEEP
"cms" -> GC.CONCURRENT_MARK_AND_SWEEP
else -> {
configuration.report(ERROR, "Unsupported GC ${arguments.gc}")
GC.SAME_THREAD_MARK_AND_SWEEP
null
}
})
if (memoryModel != MemoryModel.EXPERIMENTAL && arguments.gcAggressive) {
@@ -81,7 +81,19 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
}
}
val destroyRuntimeMode: DestroyRuntimeMode get() = configuration.get(KonanConfigKeys.DESTROY_RUNTIME_MODE)!!
val gc: GC get() = configuration.get(KonanConfigKeys.GARBAGE_COLLECTOR)!!
val gc: GC by lazy {
val configGc = configuration.get(KonanConfigKeys.GARBAGE_COLLECTOR)
val (gcFallbackReason, realGc) = when {
configGc == GC.CONCURRENT_MARK_AND_SWEEP && !target.supportsThreads() ->
"Concurrent mark and sweep gc is not supported for this target. Fallback to Same thread mark and sweep is done" to GC.SAME_THREAD_MARK_AND_SWEEP
configGc == null -> null to GC.SAME_THREAD_MARK_AND_SWEEP
else -> null to configGc
}
if (gcFallbackReason != null) {
configuration.report(CompilerMessageSeverity.STRONG_WARNING, gcFallbackReason)
}
realGc
}
val gcAggressive: Boolean get() = configuration.get(KonanConfigKeys.GARBAGE_COLLECTOR_AGRESSIVE)!!
val runtimeAssertsMode: RuntimeAssertsMode get() = configuration.get(BinaryOptions.runtimeAssertionsMode) ?: RuntimeAssertsMode.IGNORE
val workerExceptionHandling: WorkerExceptionHandling get() = configuration.get(KonanConfigKeys.WORKER_EXCEPTION_HANDLING)!!
@@ -386,6 +386,8 @@ fun targetSupportsLibBacktrace(targetName: String) =
fun targetSupportsCoreSymbolication(targetName: String) =
HostManager().targetByName(targetName).supportsCoreSymbolication()
fun targetSupportsThreads(targetName: String) =
HostManager().targetByName(targetName).supportsThreads()
fun Project.mergeManifestsByTargets(source: File, destination: File) {
logger.info("Merging manifests: $source -> $destination")
+6
View File
@@ -188,6 +188,8 @@ bitcode {
create("experimental_memory_manager_cms", file("src/mm")) {
headersDirs += files("src/gc/cms/cpp", "src/gc/common/cpp")
includeRuntime()
onlyIf { targetSupportsThreads(target) }
}
create("common_gc_noop", file("src/gc/common")) {
@@ -203,6 +205,8 @@ bitcode {
create("common_gc_cms", file("src/gc/common")) {
headersDirs += files("src/gc/cms/cpp", "src/mm/cpp")
includeRuntime()
onlyIf { targetSupportsThreads(target) }
}
create("noop_gc", file("src/gc/noop")) {
@@ -218,6 +222,8 @@ bitcode {
create("concurrent_ms_gc", file("src/gc/cms")) {
headersDirs += files("src/gc/cms/cpp", "src/gc/common/cpp", "src/mm/cpp")
includeRuntime()
onlyIf { targetSupportsThreads(target) }
}
}