[LL FIR] always use lockWithPCECheck for resolve to check possible PCE
This commit is contained in:
committed by
Space Team
parent
d7ee312b83
commit
c80221afd3
+1
-1
@@ -34,7 +34,7 @@ internal class SingleNonLocalDeclarationDiagnosticRetriever(
|
|||||||
moduleComponents: LLFirModuleResolveComponents,
|
moduleComponents: LLFirModuleResolveComponents,
|
||||||
): FileStructureElementDiagnosticList {
|
): FileStructureElementDiagnosticList {
|
||||||
val sessionHolder = SessionHolderImpl(moduleComponents.session, moduleComponents.scopeSessionProvider.getScopeSession())
|
val sessionHolder = SessionHolderImpl(moduleComponents.session, moduleComponents.scopeSessionProvider.getScopeSession())
|
||||||
val context = moduleComponents.globalResolveComponents.lockProvider.withWriteLock(firFile) {
|
val context = moduleComponents.globalResolveComponents.lockProvider.withLock(firFile) {
|
||||||
PersistenceContextCollector.collectContext(sessionHolder, firFile, structureElementDeclaration)
|
PersistenceContextCollector.collectContext(sessionHolder, firFile, structureElementDeclaration)
|
||||||
}
|
}
|
||||||
return withSourceCodeAnalysisExceptionUnwrapping {
|
return withSourceCodeAnalysisExceptionUnwrapping {
|
||||||
|
|||||||
+9
-8
@@ -8,25 +8,26 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.file.builder
|
|||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.lockWithPCECheck
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.lockWithPCECheck
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||||
import java.util.concurrent.locks.ReentrantLock
|
import java.util.concurrent.locks.ReentrantLock
|
||||||
import kotlin.concurrent.withLock
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keyed locks provider.
|
* Keyed locks provider.
|
||||||
*/
|
*/
|
||||||
internal class LLFirLockProvider {
|
internal class LLFirLockProvider {
|
||||||
|
|
||||||
//We temporarily disable multi-locks to fix deadlocks problem
|
//We temporarily disable multi-locks to fix deadlocks problem
|
||||||
private val globalLock = ReentrantLock()
|
private val globalLock = ReentrantLock()
|
||||||
|
|
||||||
inline fun <R> withWriteLock(@Suppress("UNUSED_PARAMETER") key: FirFile, action: () -> R): R {
|
inline fun <R> withLock(
|
||||||
return globalLock.withLock { action() }
|
@Suppress("UNUSED_PARAMETER") key: FirFile,
|
||||||
}
|
lockingIntervalMs: Long = DEFAULT_LOCKING_INTERVAL,
|
||||||
|
action: () -> R
|
||||||
|
): R {
|
||||||
inline fun <R> withWriteLockPCECheck(@Suppress("UNUSED_PARAMETER") key: FirFile, lockingIntervalMs: Long, action: () -> R): R {
|
|
||||||
return globalLock.lockWithPCECheck(lockingIntervalMs) { action() }
|
return globalLock.lockWithPCECheck(lockingIntervalMs) { action() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const val DEFAULT_LOCKING_INTERVAL = 50L
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs [resolve] function (which is considered to do some resolve on [firFile]) under a lock for [firFile]
|
* Runs [resolve] function (which is considered to do some resolve on [firFile]) under a lock for [firFile]
|
||||||
*/
|
*/
|
||||||
@@ -34,5 +35,5 @@ internal inline fun <R> LLFirLockProvider.runCustomResolveUnderLock(
|
|||||||
firFile: FirFile,
|
firFile: FirFile,
|
||||||
body: () -> R
|
body: () -> R
|
||||||
): R {
|
): R {
|
||||||
return withWriteLockPCECheck(key = firFile, lockingIntervalMs = 50L, body)
|
return withLock(key = firFile, lockingIntervalMs = DEFAULT_LOCKING_INTERVAL, body)
|
||||||
}
|
}
|
||||||
+2
-2
@@ -115,7 +115,7 @@ internal class ReanalyzableFunctionStructureElement(
|
|||||||
rootNonLocalDeclaration = newKtDeclaration,
|
rootNonLocalDeclaration = newKtDeclaration,
|
||||||
) as FirSimpleFunction
|
) as FirSimpleFunction
|
||||||
|
|
||||||
return moduleComponents.globalResolveComponents.lockProvider.withWriteLock(firFile) {
|
return moduleComponents.globalResolveComponents.lockProvider.withLock(firFile) {
|
||||||
val upgradedPhase = minOf(originalFunction.resolvePhase, FirResolvePhase.DECLARATIONS)
|
val upgradedPhase = minOf(originalFunction.resolvePhase, FirResolvePhase.DECLARATIONS)
|
||||||
|
|
||||||
moduleComponents.sessionInvalidator.withInvalidationOnException(moduleComponents.session) {
|
moduleComponents.sessionInvalidator.withInvalidationOnException(moduleComponents.session) {
|
||||||
@@ -162,7 +162,7 @@ internal class ReanalyzablePropertyStructureElement(
|
|||||||
rootNonLocalDeclaration = newKtDeclaration,
|
rootNonLocalDeclaration = newKtDeclaration,
|
||||||
) as FirProperty
|
) as FirProperty
|
||||||
|
|
||||||
return moduleComponents.globalResolveComponents.lockProvider.withWriteLock(firFile) {
|
return moduleComponents.globalResolveComponents.lockProvider.withLock(firFile) {
|
||||||
val getterPhase = originalProperty.getter?.resolvePhase ?: originalProperty.resolvePhase
|
val getterPhase = originalProperty.getter?.resolvePhase ?: originalProperty.resolvePhase
|
||||||
val setterPhase = originalProperty.setter?.resolvePhase ?: originalProperty.resolvePhase
|
val setterPhase = originalProperty.setter?.resolvePhase ?: originalProperty.resolvePhase
|
||||||
val upgradedPhase = minOf(originalProperty.resolvePhase, getterPhase, setterPhase, FirResolvePhase.DECLARATIONS)
|
val upgradedPhase = minOf(originalProperty.resolvePhase, getterPhase, setterPhase, FirResolvePhase.DECLARATIONS)
|
||||||
|
|||||||
Reference in New Issue
Block a user