[K/N] Disable cms for targets not supporting threads
This commit is contained in:
@@ -300,28 +300,17 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
|||||||
DestroyRuntimeMode.ON_SHUTDOWN
|
DestroyRuntimeMode.ON_SHUTDOWN
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
val assertGcSupported = {
|
if (arguments.gc != null && memoryModel != MemoryModel.EXPERIMENTAL) {
|
||||||
if (memoryModel != MemoryModel.EXPERIMENTAL) {
|
configuration.report(ERROR, "-Xgc is only supported for -memory-model experimental")
|
||||||
configuration.report(ERROR, "-Xgc is only supported for -memory-model experimental")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
put(GARBAGE_COLLECTOR, when (arguments.gc) {
|
putIfNotNull(GARBAGE_COLLECTOR, when (arguments.gc) {
|
||||||
null -> GC.SAME_THREAD_MARK_AND_SWEEP
|
null -> null
|
||||||
"noop" -> {
|
"noop" -> GC.NOOP
|
||||||
assertGcSupported()
|
"stms" -> GC.SAME_THREAD_MARK_AND_SWEEP
|
||||||
GC.NOOP
|
"cms" -> GC.CONCURRENT_MARK_AND_SWEEP
|
||||||
}
|
|
||||||
"stms" -> {
|
|
||||||
assertGcSupported()
|
|
||||||
GC.SAME_THREAD_MARK_AND_SWEEP
|
|
||||||
}
|
|
||||||
"cms" -> {
|
|
||||||
assertGcSupported()
|
|
||||||
GC.CONCURRENT_MARK_AND_SWEEP
|
|
||||||
}
|
|
||||||
else -> {
|
else -> {
|
||||||
configuration.report(ERROR, "Unsupported GC ${arguments.gc}")
|
configuration.report(ERROR, "Unsupported GC ${arguments.gc}")
|
||||||
GC.SAME_THREAD_MARK_AND_SWEEP
|
null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (memoryModel != MemoryModel.EXPERIMENTAL && arguments.gcAggressive) {
|
if (memoryModel != MemoryModel.EXPERIMENTAL && arguments.gcAggressive) {
|
||||||
|
|||||||
+13
-1
@@ -81,7 +81,19 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val destroyRuntimeMode: DestroyRuntimeMode get() = configuration.get(KonanConfigKeys.DESTROY_RUNTIME_MODE)!!
|
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 gcAggressive: Boolean get() = configuration.get(KonanConfigKeys.GARBAGE_COLLECTOR_AGRESSIVE)!!
|
||||||
val runtimeAssertsMode: RuntimeAssertsMode get() = configuration.get(BinaryOptions.runtimeAssertionsMode) ?: RuntimeAssertsMode.IGNORE
|
val runtimeAssertsMode: RuntimeAssertsMode get() = configuration.get(BinaryOptions.runtimeAssertionsMode) ?: RuntimeAssertsMode.IGNORE
|
||||||
val workerExceptionHandling: WorkerExceptionHandling get() = configuration.get(KonanConfigKeys.WORKER_EXCEPTION_HANDLING)!!
|
val workerExceptionHandling: WorkerExceptionHandling get() = configuration.get(KonanConfigKeys.WORKER_EXCEPTION_HANDLING)!!
|
||||||
|
|||||||
@@ -386,6 +386,8 @@ fun targetSupportsLibBacktrace(targetName: String) =
|
|||||||
fun targetSupportsCoreSymbolication(targetName: String) =
|
fun targetSupportsCoreSymbolication(targetName: String) =
|
||||||
HostManager().targetByName(targetName).supportsCoreSymbolication()
|
HostManager().targetByName(targetName).supportsCoreSymbolication()
|
||||||
|
|
||||||
|
fun targetSupportsThreads(targetName: String) =
|
||||||
|
HostManager().targetByName(targetName).supportsThreads()
|
||||||
|
|
||||||
fun Project.mergeManifestsByTargets(source: File, destination: File) {
|
fun Project.mergeManifestsByTargets(source: File, destination: File) {
|
||||||
logger.info("Merging manifests: $source -> $destination")
|
logger.info("Merging manifests: $source -> $destination")
|
||||||
|
|||||||
@@ -188,6 +188,8 @@ bitcode {
|
|||||||
create("experimental_memory_manager_cms", file("src/mm")) {
|
create("experimental_memory_manager_cms", file("src/mm")) {
|
||||||
headersDirs += files("src/gc/cms/cpp", "src/gc/common/cpp")
|
headersDirs += files("src/gc/cms/cpp", "src/gc/common/cpp")
|
||||||
includeRuntime()
|
includeRuntime()
|
||||||
|
|
||||||
|
onlyIf { targetSupportsThreads(target) }
|
||||||
}
|
}
|
||||||
|
|
||||||
create("common_gc_noop", file("src/gc/common")) {
|
create("common_gc_noop", file("src/gc/common")) {
|
||||||
@@ -203,6 +205,8 @@ bitcode {
|
|||||||
create("common_gc_cms", file("src/gc/common")) {
|
create("common_gc_cms", file("src/gc/common")) {
|
||||||
headersDirs += files("src/gc/cms/cpp", "src/mm/cpp")
|
headersDirs += files("src/gc/cms/cpp", "src/mm/cpp")
|
||||||
includeRuntime()
|
includeRuntime()
|
||||||
|
|
||||||
|
onlyIf { targetSupportsThreads(target) }
|
||||||
}
|
}
|
||||||
|
|
||||||
create("noop_gc", file("src/gc/noop")) {
|
create("noop_gc", file("src/gc/noop")) {
|
||||||
@@ -218,6 +222,8 @@ bitcode {
|
|||||||
create("concurrent_ms_gc", file("src/gc/cms")) {
|
create("concurrent_ms_gc", file("src/gc/cms")) {
|
||||||
headersDirs += files("src/gc/cms/cpp", "src/gc/common/cpp", "src/mm/cpp")
|
headersDirs += files("src/gc/cms/cpp", "src/gc/common/cpp", "src/mm/cpp")
|
||||||
includeRuntime()
|
includeRuntime()
|
||||||
|
|
||||||
|
onlyIf { targetSupportsThreads(target) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user