Native: quick fix lazy init order problem
Initialize main-thread-bound properties along with shared properties ^KT-48364 Fixed
This commit is contained in:
committed by
Space
parent
ff46a63ffa
commit
7f12cda233
+2
-11
@@ -371,7 +371,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
using(parameterScope) usingParameterScope@{
|
using(parameterScope) usingParameterScope@{
|
||||||
using(VariableScope()) usingVariableScope@{
|
using(VariableScope()) usingVariableScope@{
|
||||||
context.llvm.initializersGenerationState.topLevelFields
|
context.llvm.initializersGenerationState.topLevelFields
|
||||||
.filter { it.storageKind == FieldStorageKind.SHARED_FROZEN }
|
.filter { it.storageKind != FieldStorageKind.THREAD_LOCAL }
|
||||||
.filterNot { it.shouldBeInitializedEagerly }
|
.filterNot { it.shouldBeInitializedEagerly }
|
||||||
.forEach { initGlobalField(it) }
|
.forEach { initGlobalField(it) }
|
||||||
ret(null)
|
ret(null)
|
||||||
@@ -387,16 +387,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
val parameterScope = ParameterScope(fileInitFunction, functionGenerationContext)
|
val parameterScope = ParameterScope(fileInitFunction, functionGenerationContext)
|
||||||
using(parameterScope) usingParameterScope@{
|
using(parameterScope) usingParameterScope@{
|
||||||
using(VariableScope()) usingVariableScope@{
|
using(VariableScope()) usingVariableScope@{
|
||||||
val bbInitGlobals = basicBlock("label_init_global", null, null)
|
// TODO: remove unused parameter.
|
||||||
val bbInitThreadLocals = basicBlock("label_init_thread_local", null, null)
|
|
||||||
condBr(param(0), bbInitGlobals, bbInitThreadLocals)
|
|
||||||
positionAtEnd(bbInitGlobals)
|
|
||||||
context.llvm.initializersGenerationState.topLevelFields
|
|
||||||
.filter { it.storageKind == FieldStorageKind.GLOBAL }
|
|
||||||
.filterNot { it.shouldBeInitializedEagerly }
|
|
||||||
.forEach { initGlobalField(it) }
|
|
||||||
br(bbInitThreadLocals)
|
|
||||||
positionAtEnd(bbInitThreadLocals)
|
|
||||||
context.llvm.initializersGenerationState.topLevelFields
|
context.llvm.initializersGenerationState.topLevelFields
|
||||||
.filter { it.storageKind == FieldStorageKind.THREAD_LOCAL }
|
.filter { it.storageKind == FieldStorageKind.THREAD_LOCAL }
|
||||||
.filterNot { it.shouldBeInitializedEagerly }
|
.filterNot { it.shouldBeInitializedEagerly }
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ internal class FileInitializersLowering(val context: Context) : FileLoweringPass
|
|||||||
for (declaration in irFile.declarations) {
|
for (declaration in irFile.declarations) {
|
||||||
val irField = (declaration as? IrField) ?: (declaration as? IrProperty)?.backingField
|
val irField = (declaration as? IrField) ?: (declaration as? IrProperty)?.backingField
|
||||||
if (irField == null || !irField.needsInitializationAtRuntime || irField.shouldBeInitializedEagerly) continue
|
if (irField == null || !irField.needsInitializationAtRuntime || irField.shouldBeInitializedEagerly) continue
|
||||||
if (irField.storageKind == FieldStorageKind.SHARED_FROZEN) {
|
if (irField.storageKind != FieldStorageKind.THREAD_LOCAL) {
|
||||||
requireGlobalInitializer = true
|
requireGlobalInitializer = true
|
||||||
} else {
|
} else {
|
||||||
requireThreadLocalInitializer = true // Either marked with thread local or only main thread visible.
|
requireThreadLocalInitializer = true // Either marked with thread local or only main thread visible.
|
||||||
|
|||||||
Reference in New Issue
Block a user