Native: use binary options machinery for runtime assertions mode

This commit is contained in:
Svyatoslav Scherbina
2021-08-10 11:34:05 +03:00
committed by Space
parent 7cc1ea8801
commit ee3663afa4
6 changed files with 4 additions and 16 deletions
@@ -319,15 +319,6 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
configuration.report(ERROR, "-Xgc-aggressive is only supported for -memory-model experimental") configuration.report(ERROR, "-Xgc-aggressive is only supported for -memory-model experimental")
} }
put(GARBAGE_COLLECTOR_AGRESSIVE, arguments.gcAggressive) put(GARBAGE_COLLECTOR_AGRESSIVE, arguments.gcAggressive)
put(RUNTIME_ASSERTS_MODE, when (arguments.runtimeAssertsMode) {
"ignore" -> RuntimeAssertsMode.IGNORE
"log" -> RuntimeAssertsMode.LOG
"panic" -> RuntimeAssertsMode.PANIC
else -> {
configuration.report(ERROR, "Unsupported runtime asserts mode ${arguments.runtimeAssertsMode}")
RuntimeAssertsMode.IGNORE
}
})
put(PROPERTY_LAZY_INITIALIZATION, when (arguments.propertyLazyInitialization) { put(PROPERTY_LAZY_INITIALIZATION, when (arguments.propertyLazyInitialization) {
null -> { null -> {
when (memoryModel) { when (memoryModel) {
@@ -326,9 +326,6 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-Xir-property-lazy-initialization", valueDescription = "{disable|enable}", description = "Initialize top level properties lazily per file") @Argument(value = "-Xir-property-lazy-initialization", valueDescription = "{disable|enable}", description = "Initialize top level properties lazily per file")
var propertyLazyInitialization: String? = null var propertyLazyInitialization: String? = null
@Argument(value="-Xruntime-asserts-mode", valueDescription = "<mode>", description = "Enable asserts in runtime. Possible values: 'ignore', 'log', 'panic'")
var runtimeAssertsMode: String? = "ignore"
// TODO: Remove when legacy MM is gone. // TODO: Remove when legacy MM is gone.
@Argument( @Argument(
value = "-Xworker-exception-handling", value = "-Xworker-exception-handling",
@@ -12,6 +12,7 @@ import kotlin.properties.ReadOnlyProperty
// Note: options defined in this class are a part of user interface, including the names: // Note: options defined in this class are a part of user interface, including the names:
// users can pass these options using a -Xbinary=name=value compiler argument or corresponding Gradle DSL. // users can pass these options using a -Xbinary=name=value compiler argument or corresponding Gradle DSL.
object BinaryOptions : BinaryOptionRegistry() { object BinaryOptions : BinaryOptionRegistry() {
val runtimeAssertionsMode by option<RuntimeAssertsMode>()
} }
open class BinaryOption<T : Any>( open class BinaryOption<T : Any>(
@@ -60,7 +60,7 @@ 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 get() = configuration.get(KonanConfigKeys.GARBAGE_COLLECTOR)!!
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(KonanConfigKeys.RUNTIME_ASSERTS_MODE)!! 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)!!
val needVerifyIr: Boolean val needVerifyIr: Boolean
@@ -161,7 +161,6 @@ class KonanConfigKeys {
val GARBAGE_COLLECTOR: CompilerConfigurationKey<GC> = CompilerConfigurationKey.create("gc") val GARBAGE_COLLECTOR: CompilerConfigurationKey<GC> = CompilerConfigurationKey.create("gc")
val GARBAGE_COLLECTOR_AGRESSIVE: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("turn on agressive GC mode") val GARBAGE_COLLECTOR_AGRESSIVE: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("turn on agressive GC mode")
val CHECK_LLD_COMPATIBILITY: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("check compatibility with LLD") val CHECK_LLD_COMPATIBILITY: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("check compatibility with LLD")
val RUNTIME_ASSERTS_MODE: CompilerConfigurationKey<RuntimeAssertsMode> = CompilerConfigurationKey.create("enable runtime asserts")
val PROPERTY_LAZY_INITIALIZATION: CompilerConfigurationKey<Boolean> val PROPERTY_LAZY_INITIALIZATION: CompilerConfigurationKey<Boolean>
= CompilerConfigurationKey.create("lazy top level properties initialization") = CompilerConfigurationKey.create("lazy top level properties initialization")
val WORKER_EXCEPTION_HANDLING: CompilerConfigurationKey<WorkerExceptionHandling> = CompilerConfigurationKey.create("unhandled exception processing in Worker.executeAfter") val WORKER_EXCEPTION_HANDLING: CompilerConfigurationKey<WorkerExceptionHandling> = CompilerConfigurationKey.create("unhandled exception processing in Worker.executeAfter")
@@ -120,11 +120,11 @@ if (ext.isExperimentalMM) {
// TODO: It also makes sense to test -g without asserts, and also to test -opt with asserts. // TODO: It also makes sense to test -g without asserts, and also to test -opt with asserts.
if (project.globalTestArgs.contains("-g")) { if (project.globalTestArgs.contains("-g")) {
tasks.withType(KonanCompileNativeBinary.class).configureEach { tasks.withType(KonanCompileNativeBinary.class).configureEach {
extraOpts "-Xruntime-asserts-mode=panic" extraOpts "-Xbinary=runtimeAssertionsMode=panic"
} }
tasks.withType(RunExternalTestGroup.class).configureEach { tasks.withType(RunExternalTestGroup.class).configureEach {
flags = (flags ?: []) + "-Xruntime-asserts-mode=panic" flags = (flags ?: []) + "-Xbinary=runtimeAssertionsMode=panic"
} }
} }