[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,
|
||||
): FileStructureElementDiagnosticList {
|
||||
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)
|
||||
}
|
||||
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.fir.declarations.FirFile
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import kotlin.concurrent.withLock
|
||||
|
||||
/**
|
||||
* Keyed locks provider.
|
||||
*/
|
||||
internal class LLFirLockProvider {
|
||||
|
||||
//We temporarily disable multi-locks to fix deadlocks problem
|
||||
private val globalLock = ReentrantLock()
|
||||
|
||||
inline fun <R> withWriteLock(@Suppress("UNUSED_PARAMETER") key: FirFile, action: () -> R): R {
|
||||
return globalLock.withLock { action() }
|
||||
}
|
||||
|
||||
|
||||
inline fun <R> withWriteLockPCECheck(@Suppress("UNUSED_PARAMETER") key: FirFile, lockingIntervalMs: Long, action: () -> R): R {
|
||||
inline fun <R> withLock(
|
||||
@Suppress("UNUSED_PARAMETER") key: FirFile,
|
||||
lockingIntervalMs: Long = DEFAULT_LOCKING_INTERVAL,
|
||||
action: () -> R
|
||||
): R {
|
||||
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]
|
||||
*/
|
||||
@@ -34,5 +35,5 @@ internal inline fun <R> LLFirLockProvider.runCustomResolveUnderLock(
|
||||
firFile: FirFile,
|
||||
body: () -> 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,
|
||||
) as FirSimpleFunction
|
||||
|
||||
return moduleComponents.globalResolveComponents.lockProvider.withWriteLock(firFile) {
|
||||
return moduleComponents.globalResolveComponents.lockProvider.withLock(firFile) {
|
||||
val upgradedPhase = minOf(originalFunction.resolvePhase, FirResolvePhase.DECLARATIONS)
|
||||
|
||||
moduleComponents.sessionInvalidator.withInvalidationOnException(moduleComponents.session) {
|
||||
@@ -162,7 +162,7 @@ internal class ReanalyzablePropertyStructureElement(
|
||||
rootNonLocalDeclaration = newKtDeclaration,
|
||||
) as FirProperty
|
||||
|
||||
return moduleComponents.globalResolveComponents.lockProvider.withWriteLock(firFile) {
|
||||
return moduleComponents.globalResolveComponents.lockProvider.withLock(firFile) {
|
||||
val getterPhase = originalProperty.getter?.resolvePhase ?: originalProperty.resolvePhase
|
||||
val setterPhase = originalProperty.setter?.resolvePhase ?: originalProperty.resolvePhase
|
||||
val upgradedPhase = minOf(originalProperty.resolvePhase, getterPhase, setterPhase, FirResolvePhase.DECLARATIONS)
|
||||
|
||||
Reference in New Issue
Block a user