[K/N] Make GlobalData be initialized lazily ^KT-64313

This commit is contained in:
Alexander Shabalin
2024-01-04 12:20:27 +01:00
committed by Space Team
parent 7429dd4b94
commit 7d35c1087e
16 changed files with 172 additions and 61 deletions
@@ -78,6 +78,8 @@ object BinaryOptions : BinaryOptionRegistry() {
val packFields by booleanOption()
val cInterfaceMode by option<CInterfaceGenerationMode>()
val globalDataLazyInit by booleanOption()
}
open class BinaryOption<T : Any>(
@@ -262,6 +262,10 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
}
} ?: target.supportsSignposts
val globalDataLazyInit: Boolean by lazy {
configuration.get(BinaryOptions.globalDataLazyInit) ?: true
}
init {
if (!platformManager.isEnabled(target)) {
error("Target ${target.visibleName} is not available on the ${HostManager.hostName} host")
@@ -2819,6 +2819,7 @@ internal class CodeGeneratorVisitor(
overrideRuntimeGlobal("Kotlin_objcDisposeOnMain", llvm.constInt32(if (context.config.objcDisposeOnMain) 1 else 0))
overrideRuntimeGlobal("Kotlin_objcDisposeWithRunLoop", llvm.constInt32(if (context.config.objcDisposeWithRunLoop) 1 else 0))
overrideRuntimeGlobal("Kotlin_enableSafepointSignposts", llvm.constInt32(if (context.config.enableSafepointSignposts) 1 else 0))
overrideRuntimeGlobal("Kotlin_globalDataLazyInit", llvm.constInt32(if (context.config.globalDataLazyInit) 1 else 0))
}
//-------------------------------------------------------------------------//