Drop LockBasedStorageManager.defaultDebugName, use meaningful name everywhere
Also, drop `createDelegatingWithSameLock` as it was unused
This commit is contained in:
committed by
Dmitry Savvinov
parent
893479bd5e
commit
69fff12384
@@ -16,7 +16,7 @@ import java.util.*
|
|||||||
abstract class TargetPlatform(val platformName: String) {
|
abstract class TargetPlatform(val platformName: String) {
|
||||||
private data class DefaultImportsKey(val includeKotlinComparisons: Boolean, val includeLowPriorityImports: Boolean)
|
private data class DefaultImportsKey(val includeKotlinComparisons: Boolean, val includeLowPriorityImports: Boolean)
|
||||||
|
|
||||||
private val defaultImports = LockBasedStorageManager().let { storageManager ->
|
private val defaultImports = LockBasedStorageManager("TargetPlatform").let { storageManager ->
|
||||||
storageManager.createMemoizedFunction<DefaultImportsKey, List<ImportPath>> { (includeKotlinComparisons, includeLowPriorityImports) ->
|
storageManager.createMemoizedFunction<DefaultImportsKey, List<ImportPath>> { (includeKotlinComparisons, includeLowPriorityImports) ->
|
||||||
ArrayList<ImportPath>().apply {
|
ArrayList<ImportPath>().apply {
|
||||||
listOf(
|
listOf(
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ internal fun String?.orAnonymous(kind: String = ""): String =
|
|||||||
this ?: "<anonymous" + (if (kind.isNotBlank()) " $kind" else "") + ">"
|
this ?: "<anonymous" + (if (kind.isNotBlank()) " $kind" else "") + ">"
|
||||||
|
|
||||||
internal fun constructAnnotation(psi: KtAnnotationEntry, targetClass: KClass<out Annotation>, project: Project): Annotation {
|
internal fun constructAnnotation(psi: KtAnnotationEntry, targetClass: KClass<out Annotation>, project: Project): Annotation {
|
||||||
val module = ModuleDescriptorImpl(Name.special("<script-annotations-preprocessing>"), LockBasedStorageManager(), DefaultBuiltIns.Instance)
|
val module = ModuleDescriptorImpl(Name.special("<script-annotations-preprocessing>"), LockBasedStorageManager("scriptAnnotationsPreprocessing"), DefaultBuiltIns.Instance)
|
||||||
val evaluator = ConstantExpressionEvaluator(module, LanguageVersionSettingsImpl.DEFAULT, project)
|
val evaluator = ConstantExpressionEvaluator(module, LanguageVersionSettingsImpl.DEFAULT, project)
|
||||||
val trace = BindingTraceContext()
|
val trace = BindingTraceContext()
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class MutableModuleContextImpl(
|
|||||||
|
|
||||||
fun GlobalContext(): GlobalContextImpl {
|
fun GlobalContext(): GlobalContextImpl {
|
||||||
val tracker = ExceptionTracker()
|
val tracker = ExceptionTracker()
|
||||||
return GlobalContextImpl(LockBasedStorageManager.createWithExceptionHandling(tracker), tracker)
|
return GlobalContextImpl(LockBasedStorageManager.createWithExceptionHandling("GlobalContext", tracker), tracker)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ProjectContext(project: Project): ProjectContext = ProjectContextImpl(project, GlobalContext())
|
fun ProjectContext(project: Project): ProjectContext = ProjectContextImpl(project, GlobalContext())
|
||||||
|
|||||||
+1
-1
@@ -215,7 +215,7 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
|||||||
// "-Xuse-experimental" arguments. However, it's not easy to do this. This should be solved in the future with the support of
|
// "-Xuse-experimental" arguments. However, it's not easy to do this. This should be solved in the future with the support of
|
||||||
// module annotations. For now, we only check deprecations because this is needed to correctly retire unneeded compiler arguments.
|
// module annotations. For now, we only check deprecations because this is needed to correctly retire unneeded compiler arguments.
|
||||||
val deprecationResolver =
|
val deprecationResolver =
|
||||||
DeprecationResolver(LockBasedStorageManager(), languageVersionSettings, CoroutineCompatibilitySupport.ENABLED)
|
DeprecationResolver(LockBasedStorageManager("ExperimentalUsageChecker"), languageVersionSettings, CoroutineCompatibilitySupport.ENABLED)
|
||||||
|
|
||||||
// Returns true if fqName refers to a valid experimental API marker.
|
// Returns true if fqName refers to a valid experimental API marker.
|
||||||
fun checkAnnotation(fqName: String): Boolean {
|
fun checkAnnotation(fqName: String): Boolean {
|
||||||
|
|||||||
+2
-2
@@ -84,11 +84,11 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
|
|||||||
if (files.any(TestFile::checkLazyLog)) {
|
if (files.any(TestFile::checkLazyLog)) {
|
||||||
lazyOperationsLog = LazyOperationsLog(HASH_SANITIZER)
|
lazyOperationsLog = LazyOperationsLog(HASH_SANITIZER)
|
||||||
storageManager = LoggingStorageManager(
|
storageManager = LoggingStorageManager(
|
||||||
LockBasedStorageManager.createWithExceptionHandling(tracker),
|
LockBasedStorageManager.createWithExceptionHandling("AbstractDiagnosticTest", tracker),
|
||||||
lazyOperationsLog.addRecordFunction
|
lazyOperationsLog.addRecordFunction
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
storageManager = LockBasedStorageManager.createWithExceptionHandling(tracker)
|
storageManager = LockBasedStorageManager.createWithExceptionHandling("AbstractDiagnosticTest", tracker)
|
||||||
}
|
}
|
||||||
|
|
||||||
val context = SimpleGlobalContext(storageManager, tracker)
|
val context = SimpleGlobalContext(storageManager, tracker)
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ class BuiltInsSerializerTest : TestCaseWithTmpdir() {
|
|||||||
val module = KotlinTestUtils.createEmptyModule("<module>", DefaultBuiltIns.Instance)
|
val module = KotlinTestUtils.createEmptyModule("<module>", DefaultBuiltIns.Instance)
|
||||||
|
|
||||||
val packageFragmentProvider = BuiltInsLoaderImpl().createBuiltInPackageFragmentProvider(
|
val packageFragmentProvider = BuiltInsLoaderImpl().createBuiltInPackageFragmentProvider(
|
||||||
LockBasedStorageManager(), module, setOf(TEST_PACKAGE_FQNAME), emptyList(), PlatformDependentDeclarationFilter.All
|
LockBasedStorageManager("BuiltInsSerializerTest"), module, setOf(TEST_PACKAGE_FQNAME), emptyList(), PlatformDependentDeclarationFilter.All
|
||||||
) {
|
) {
|
||||||
val file = File(tmpdir, it)
|
val file = File(tmpdir, it)
|
||||||
if (file.exists()) FileInputStream(file) else null
|
if (file.exists()) FileInputStream(file) else null
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class LoadBuiltinsTest extends KotlinTestWithEnvironment {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static PackageFragmentProvider createBuiltInsPackageFragmentProvider() {
|
private static PackageFragmentProvider createBuiltInsPackageFragmentProvider() {
|
||||||
LockBasedStorageManager storageManager = new LockBasedStorageManager();
|
LockBasedStorageManager storageManager = new LockBasedStorageManager("LoadBuiltinsTest");
|
||||||
ModuleDescriptorImpl builtInsModule =
|
ModuleDescriptorImpl builtInsModule =
|
||||||
new ModuleDescriptorImpl(KotlinBuiltIns.BUILTINS_MODULE_NAME, storageManager, DefaultBuiltIns.getInstance());
|
new ModuleDescriptorImpl(KotlinBuiltIns.BUILTINS_MODULE_NAME, storageManager, DefaultBuiltIns.getInstance());
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ class KotlinJavascriptSerializerTest : TestCaseWithTmpdir() {
|
|||||||
|
|
||||||
val (header, packageFragmentProtos) = readModuleAsProto(metadata.body, metadata.version)
|
val (header, packageFragmentProtos) = readModuleAsProto(metadata.body, metadata.version)
|
||||||
val provider = createKotlinJavascriptPackageFragmentProvider(
|
val provider = createKotlinJavascriptPackageFragmentProvider(
|
||||||
LockBasedStorageManager(), module, header, packageFragmentProtos, metadata.version,
|
LockBasedStorageManager("KotlinJavascriptrSerializerTest"), module, header, packageFragmentProtos, metadata.version,
|
||||||
DeserializationConfiguration.Default, LookupTracker.DO_NOTHING
|
DeserializationConfiguration.Default, LookupTracker.DO_NOTHING
|
||||||
).sure { "No package fragment provider was created" }
|
).sure { "No package fragment provider was created" }
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class StorageManagerTest extends TestCase {
|
|||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
m = new LockBasedStorageManager();
|
m = new LockBasedStorageManager("StorageManagerTest");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void doTestComputesOnce(Function0<T> v, T expected, Counter counter) throws Exception {
|
public static <T> void doTestComputesOnce(Function0<T> v, T expected, Counter counter) throws Exception {
|
||||||
@@ -416,7 +416,7 @@ public class StorageManagerTest extends TestCase {
|
|||||||
public void testExceptionHandlingStrategyForLazyValues() throws Exception {
|
public void testExceptionHandlingStrategyForLazyValues() throws Exception {
|
||||||
class RethrownException extends RuntimeException {}
|
class RethrownException extends RuntimeException {}
|
||||||
|
|
||||||
LockBasedStorageManager m = LockBasedStorageManager.createWithExceptionHandling(throwable -> {
|
LockBasedStorageManager m = LockBasedStorageManager.createWithExceptionHandling("StorageManagerTest", throwable -> {
|
||||||
throw new RethrownException();
|
throw new RethrownException();
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
@@ -432,7 +432,7 @@ public class StorageManagerTest extends TestCase {
|
|||||||
public void testExceptionHandlingStrategyForMemoizedFunctions() throws Exception {
|
public void testExceptionHandlingStrategyForMemoizedFunctions() throws Exception {
|
||||||
class RethrownException extends RuntimeException {}
|
class RethrownException extends RuntimeException {}
|
||||||
|
|
||||||
LockBasedStorageManager m = LockBasedStorageManager.createWithExceptionHandling(throwable -> {
|
LockBasedStorageManager m = LockBasedStorageManager.createWithExceptionHandling("StorageManagerTest", throwable -> {
|
||||||
throw new RethrownException();
|
throw new RethrownException();
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ open class JvmBuiltInsSettings(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FallbackBuiltIns private constructor() : KotlinBuiltIns(LockBasedStorageManager()) {
|
private class FallbackBuiltIns private constructor() : KotlinBuiltIns(LockBasedStorageManager("FallbackBuiltIns")) {
|
||||||
init {
|
init {
|
||||||
createBuiltInsModule()
|
createBuiltInsModule()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ class RuntimeModuleData private constructor(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun create(classLoader: ClassLoader): RuntimeModuleData {
|
fun create(classLoader: ClassLoader): RuntimeModuleData {
|
||||||
val storageManager = LockBasedStorageManager()
|
val storageManager = LockBasedStorageManager("RuntimeModuleData")
|
||||||
val builtIns = JvmBuiltIns(storageManager)
|
val builtIns = JvmBuiltIns(storageManager)
|
||||||
val module = ModuleDescriptorImpl(Name.special("<runtime module for $classLoader>"), storageManager, builtIns)
|
val module = ModuleDescriptorImpl(Name.special("<runtime module for $classLoader>"), storageManager, builtIns)
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.builtins
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||||
|
|
||||||
class DefaultBuiltIns private constructor() : KotlinBuiltIns(LockBasedStorageManager()) {
|
class DefaultBuiltIns private constructor() : KotlinBuiltIns(LockBasedStorageManager("DefaultBuiltIns")) {
|
||||||
init {
|
init {
|
||||||
createBuiltInsModule()
|
createBuiltInsModule()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static LockBasedStorageManager createWithExceptionHandling(@NotNull ExceptionHandlingStrategy exceptionHandlingStrategy) {
|
public static LockBasedStorageManager createWithExceptionHandling(@NotNull String debugText, @NotNull ExceptionHandlingStrategy exceptionHandlingStrategy) {
|
||||||
return new LockBasedStorageManager(exceptionHandlingStrategy);
|
return new LockBasedStorageManager(debugText, exceptionHandlingStrategy, new ReentrantLock());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Lock lock;
|
protected final Lock lock;
|
||||||
@@ -82,16 +82,8 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
this.debugText = debugText;
|
this.debugText = debugText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LockBasedStorageManager() {
|
public LockBasedStorageManager(String debugText) {
|
||||||
this(defaultDebugName(), ExceptionHandlingStrategy.THROW, new ReentrantLock());
|
this(debugText, ExceptionHandlingStrategy.THROW, new ReentrantLock());
|
||||||
}
|
|
||||||
|
|
||||||
protected LockBasedStorageManager(@NotNull ExceptionHandlingStrategy exceptionHandlingStrategy) {
|
|
||||||
this(defaultDebugName(), exceptionHandlingStrategy, new ReentrantLock());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String defaultDebugName() {
|
|
||||||
return "<unknown creating class>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -526,14 +518,6 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static LockBasedStorageManager createDelegatingWithSameLock(
|
|
||||||
@NotNull LockBasedStorageManager base,
|
|
||||||
@NotNull ExceptionHandlingStrategy newStrategy
|
|
||||||
) {
|
|
||||||
return new LockBasedStorageManager(defaultDebugName(), newStrategy, base.lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static <T extends Throwable> T sanitizeStackTrace(@NotNull T throwable) {
|
private static <T extends Throwable> T sanitizeStackTrace(@NotNull T throwable) {
|
||||||
StackTraceElement[] stackTrace = throwable.getStackTrace();
|
StackTraceElement[] stackTrace = throwable.getStackTrace();
|
||||||
|
|||||||
+4
-1
@@ -11,7 +11,10 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
|||||||
|
|
||||||
internal fun GlobalContextImpl.contextWithNewLockAndCompositeExceptionTracker(): GlobalContextImpl {
|
internal fun GlobalContextImpl.contextWithNewLockAndCompositeExceptionTracker(): GlobalContextImpl {
|
||||||
val newExceptionTracker = CompositeExceptionTracker(this.exceptionTracker)
|
val newExceptionTracker = CompositeExceptionTracker(this.exceptionTracker)
|
||||||
return GlobalContextImpl(LockBasedStorageManager.createWithExceptionHandling(newExceptionTracker), newExceptionTracker)
|
return GlobalContextImpl(
|
||||||
|
LockBasedStorageManager.createWithExceptionHandling("GlobalContextUtils", newExceptionTracker),
|
||||||
|
newExceptionTracker
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CompositeExceptionTracker(val delegate: ExceptionTracker) : ExceptionTracker() {
|
private class CompositeExceptionTracker(val delegate: ExceptionTracker) : ExceptionTracker() {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class JsConfig {
|
|||||||
|
|
||||||
private final Project project;
|
private final Project project;
|
||||||
private final CompilerConfiguration configuration;
|
private final CompilerConfiguration configuration;
|
||||||
private final LockBasedStorageManager storageManager = new LockBasedStorageManager();
|
private final LockBasedStorageManager storageManager = new LockBasedStorageManager("JsConfig");
|
||||||
|
|
||||||
private final List<KotlinJavascriptMetadata> metadata = new SmartList<>();
|
private final List<KotlinJavascriptMetadata> metadata = new SmartList<>();
|
||||||
private final List<KotlinJavascriptMetadata> friends = new SmartList<>();
|
private final List<KotlinJavascriptMetadata> friends = new SmartList<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user