[SLC] migrate from AtomicFieldUpdater to AtomicReferenceFieldUpdater
^KT-56046
This commit is contained in:
committed by
Space Team
parent
cf713d31ef
commit
0928a5be08
+6
-2
@@ -7,11 +7,11 @@ package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.util.concurrency.AtomicFieldUpdater
|
||||
import org.jetbrains.kotlin.light.classes.symbol.toArrayIfNotEmptyOrDefault
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
|
||||
internal class LazyAnnotationsBox(
|
||||
private val annotationsProvider: AnnotationsProvider,
|
||||
@@ -83,7 +83,11 @@ internal class LazyAnnotationsBox(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val fieldUpdater = AtomicFieldUpdater.forFieldOfType(LazyAnnotationsBox::class.java, Collection::class.java)
|
||||
private val fieldUpdater = AtomicReferenceFieldUpdater.newUpdater(
|
||||
/* tclass = */ LazyAnnotationsBox::class.java,
|
||||
/* vclass = */ Collection::class.java,
|
||||
/* fieldName = */ "cachedAnnotations",
|
||||
)
|
||||
|
||||
/**
|
||||
* @see org.jetbrains.kotlin.fir.resolve.transformers.plugin.CompilerRequiredAnnotationsHelper
|
||||
|
||||
+6
-2
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.util.concurrency.AtomicFieldUpdater
|
||||
import org.jetbrains.kotlin.light.classes.symbol.toArrayIfNotEmptyOrDefault
|
||||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
|
||||
internal class SimpleAnnotationsBox(private val annotationsComputer: (PsiModifierList) -> Collection<PsiAnnotation>) : AnnotationsBox {
|
||||
@Volatile
|
||||
@@ -33,6 +33,10 @@ internal class SimpleAnnotationsBox(private val annotationsComputer: (PsiModifie
|
||||
): PsiAnnotation? = getOrComputeAnnotations(owner).find { it.qualifiedName == qualifiedName }
|
||||
|
||||
companion object {
|
||||
private val fieldUpdater = AtomicFieldUpdater.forFieldOfType(SimpleAnnotationsBox::class.java, Collection::class.java)
|
||||
private val fieldUpdater = AtomicReferenceFieldUpdater.newUpdater(
|
||||
/* tclass = */ SimpleAnnotationsBox::class.java,
|
||||
/* vclass = */ Collection::class.java,
|
||||
/* fieldName = */ "cachedAnnotations",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.light.classes.symbol.modifierLists
|
||||
|
||||
import com.intellij.psi.PsiModifier
|
||||
import com.intellij.util.concurrency.AtomicFieldUpdater
|
||||
import kotlinx.collections.immutable.PersistentMap
|
||||
import kotlinx.collections.immutable.toPersistentHashMap
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithModality
|
||||
@@ -17,6 +16,7 @@ import org.jetbrains.kotlin.light.classes.symbol.computeSimpleModality
|
||||
import org.jetbrains.kotlin.light.classes.symbol.toPsiVisibilityForMember
|
||||
import org.jetbrains.kotlin.light.classes.symbol.withSymbol
|
||||
import org.jetbrains.kotlin.utils.keysToMap
|
||||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
|
||||
internal typealias LazyModifiersComputer = (modifier: String) -> Map<String, Boolean>?
|
||||
|
||||
@@ -36,13 +36,17 @@ internal class LazyModifiersBox(
|
||||
currentMap[modifier]?.let { return it }
|
||||
|
||||
val newMap = currentMap.putAll(newValues)
|
||||
} while (fieldUpdater.compareAndSet(/* owner = */ this, /* expected = */ currentMap, /* newValue = */ newMap))
|
||||
} while (fieldUpdater.weakCompareAndSet(/* obj = */ this, /* expect = */ currentMap, /* update = */ newMap))
|
||||
|
||||
return newValues[modifier] ?: error("Inconsistent state: $modifier")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val fieldUpdater = AtomicFieldUpdater.forFieldOfType(LazyModifiersBox::class.java, PersistentMap::class.java)
|
||||
private val fieldUpdater = AtomicReferenceFieldUpdater.newUpdater(
|
||||
/* tclass = */ LazyModifiersBox::class.java,
|
||||
/* vclass = */ PersistentMap::class.java,
|
||||
/* fieldName = */ "modifiersMapReference",
|
||||
)
|
||||
|
||||
internal val VISIBILITY_MODIFIERS = setOf(PsiModifier.PUBLIC, PsiModifier.PACKAGE_LOCAL, PsiModifier.PROTECTED, PsiModifier.PRIVATE)
|
||||
internal val VISIBILITY_MODIFIERS_MAP: PersistentMap<String, Boolean> =
|
||||
|
||||
Reference in New Issue
Block a user