[K/N][IR][codegen] Fixed a number of thread safety problems
This commit is contained in:
@@ -223,10 +223,12 @@ class NaiveSourceBasedFileEntryImpl(
|
||||
}
|
||||
}
|
||||
|
||||
private val lineNumberLock = Any()
|
||||
|
||||
override fun getLineNumber(offset: Int): Int {
|
||||
if (offset == SYNTHETIC_OFFSET) return 0
|
||||
if (offset < 0) return -1
|
||||
return calculatedBeforeLineNumbers.get(offset)
|
||||
return synchronized(lineNumberLock) { calculatedBeforeLineNumbers.get(offset) }
|
||||
}
|
||||
|
||||
override fun getColumnNumber(offset: Int): Int {
|
||||
|
||||
+3
-1
@@ -31,6 +31,8 @@ import org.jetbrains.kotlin.ir.types.IrTypeSystemContextImpl
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.LazyThreadSafetyMode.PUBLICATION
|
||||
|
||||
internal class NativeMapping : DefaultMapping() {
|
||||
data class BridgeKey(val target: IrSimpleFunction, val bridgeDirections: BridgeDirections)
|
||||
@@ -42,7 +44,7 @@ internal class NativeMapping : DefaultMapping() {
|
||||
val outerThisFields = DefaultDelegateFactory.newDeclarationToDeclarationMapping<IrClass, IrField>()
|
||||
val enumValueGetters = DefaultDelegateFactory.newDeclarationToDeclarationMapping<IrClass, IrFunction>()
|
||||
val enumEntriesMaps = mutableMapOf<IrClass, Map<Name, LoweredEnumEntryDescription>>()
|
||||
val bridges = mutableMapOf<BridgeKey, IrSimpleFunction>()
|
||||
val bridges = ConcurrentHashMap<BridgeKey, IrSimpleFunction>()
|
||||
val partiallyLoweredInlineFunctions = mutableMapOf<IrFunctionSymbol, IrFunction>()
|
||||
val outerThisCacheAccessors = DefaultDelegateFactory.newDeclarationToDeclarationMapping<IrClass, IrSimpleFunction>()
|
||||
val lateinitPropertyCacheAccessors = DefaultDelegateFactory.newDeclarationToDeclarationMapping<IrProperty, IrSimpleFunction>()
|
||||
|
||||
+3
-1
@@ -811,7 +811,9 @@ internal class KonanIrLinker(
|
||||
}
|
||||
}
|
||||
|
||||
fun deserializeClassFields(irClass: IrClass, outerThisFieldInfo: ClassLayoutBuilder.FieldInfo?): List<ClassLayoutBuilder.FieldInfo> {
|
||||
private val lock = Any()
|
||||
|
||||
fun deserializeClassFields(irClass: IrClass, outerThisFieldInfo: ClassLayoutBuilder.FieldInfo?): List<ClassLayoutBuilder.FieldInfo> = synchronized(lock) {
|
||||
irClass.getPackageFragment() as? IrExternalPackageFragment
|
||||
?: error("Expected an external package fragment for ${irClass.render()}")
|
||||
val signature = irClass.symbol.signature
|
||||
|
||||
Reference in New Issue
Block a user