Put GC implementations into separate modules.
The mm module now compiles separately for each GC implementation.
This commit is contained in:
committed by
Space
parent
41ab97ff1f
commit
5e456ed82b
@@ -206,7 +206,7 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
|
||||
put(ENABLE_ASSERTIONS, arguments.enableAssertions)
|
||||
|
||||
put(MEMORY_MODEL, when (arguments.memoryModel) {
|
||||
val memoryModel = when (arguments.memoryModel) {
|
||||
"relaxed" -> {
|
||||
configuration.report(STRONG_WARNING, "Relaxed memory model is not yet fully functional")
|
||||
MemoryModel.RELAXED
|
||||
@@ -217,7 +217,9 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
configuration.report(ERROR, "Unsupported memory model ${arguments.memoryModel}")
|
||||
MemoryModel.STRICT
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
put(MEMORY_MODEL, memoryModel)
|
||||
|
||||
when {
|
||||
arguments.generateWorkerTestRunner -> put(GENERATE_TEST_RUNNER, TestRunnerKind.WORKER)
|
||||
@@ -271,6 +273,26 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
DestroyRuntimeMode.ON_SHUTDOWN
|
||||
}
|
||||
})
|
||||
val assertGcSupported = {
|
||||
if (memoryModel != MemoryModel.EXPERIMENTAL) {
|
||||
configuration.report(ERROR, "-Xgc is only supported for -memory-model experimental")
|
||||
}
|
||||
}
|
||||
put(GARBAGE_COLLECTOR, when (arguments.gc) {
|
||||
null -> GC.SINGLE_THREAD_MARK_SWEEP
|
||||
"noop" -> {
|
||||
assertGcSupported()
|
||||
GC.NOOP
|
||||
}
|
||||
"stms" -> {
|
||||
assertGcSupported()
|
||||
GC.SINGLE_THREAD_MARK_SWEEP
|
||||
}
|
||||
else -> {
|
||||
configuration.report(ERROR, "Unsupported GC ${arguments.gc}")
|
||||
GC.SINGLE_THREAD_MARK_SWEEP
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -305,6 +305,9 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(value="-Xdestroy-runtime-mode", valueDescription = "<mode>", description = "When to destroy runtime. 'legacy' and 'on-shutdown' are currently supported. NOTE: 'legacy' mode is deprecated and will be removed.")
|
||||
var destroyRuntimeMode: String? = "on-shutdown"
|
||||
|
||||
@Argument(value="-Xgc", valueDescription = "<gc>", description = "GC to use, 'noop' and 'stms' are currently supported. Works only with -memory-model experimental")
|
||||
var gc: String? = null
|
||||
|
||||
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> =
|
||||
super.configureAnalysisFlags(collector).also {
|
||||
val useExperimental = it[AnalysisFlags.useExperimental] as List<*>
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan
|
||||
|
||||
enum class GC {
|
||||
NOOP,
|
||||
SINGLE_THREAD_MARK_SWEEP,
|
||||
}
|
||||
+12
-1
@@ -47,6 +47,7 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
||||
|
||||
val memoryModel: MemoryModel get() = configuration.get(KonanConfigKeys.MEMORY_MODEL)!!
|
||||
val destroyRuntimeMode: DestroyRuntimeMode get() = configuration.get(KonanConfigKeys.DESTROY_RUNTIME_MODE)!!
|
||||
val gc: GC get() = configuration.get(KonanConfigKeys.GARBAGE_COLLECTOR)!!
|
||||
|
||||
val needVerifyIr: Boolean
|
||||
get() = configuration.get(KonanConfigKeys.VERIFY_IR) == true
|
||||
@@ -161,7 +162,17 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
||||
add("legacy_memory_manager.bc")
|
||||
}
|
||||
MemoryModel.EXPERIMENTAL -> {
|
||||
add("experimental_memory_manager.bc")
|
||||
add("common_gc.bc")
|
||||
when (gc) {
|
||||
GC.SINGLE_THREAD_MARK_SWEEP -> {
|
||||
add("experimental_memory_manager_stms.bc")
|
||||
add("single_thread_ms_gc.bc")
|
||||
}
|
||||
GC.NOOP -> {
|
||||
add("experimental_memory_manager_noop.bc")
|
||||
add("noop_gc.bc")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shouldCoverLibraries || shouldCoverSources) add("profileRuntime.bc")
|
||||
|
||||
+2
-1
@@ -68,7 +68,7 @@ class KonanConfigKeys {
|
||||
= CompilerConfigurationKey.create("provide manifest addend file")
|
||||
val MEMORY_MODEL: CompilerConfigurationKey<MemoryModel>
|
||||
= CompilerConfigurationKey.create("memory model")
|
||||
val META_INFO: CompilerConfigurationKey<List<String>>
|
||||
val META_INFO: CompilerConfigurationKey<List<String>>
|
||||
= CompilerConfigurationKey.create("generate metadata")
|
||||
val METADATA_KLIB: CompilerConfigurationKey<Boolean>
|
||||
= CompilerConfigurationKey.create("metadata klib")
|
||||
@@ -154,6 +154,7 @@ class KonanConfigKeys {
|
||||
= CompilerConfigurationKey.create("override konan.properties values")
|
||||
val DESTROY_RUNTIME_MODE: CompilerConfigurationKey<DestroyRuntimeMode>
|
||||
= CompilerConfigurationKey.create("when to destroy runtime")
|
||||
val GARBAGE_COLLECTOR: CompilerConfigurationKey<GC> = CompilerConfigurationKey.create("gc")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user