JVM IR: clear BindingContext after psi2ir

This helps to reduce peak memory in lowerings/codegen by a lot.

A more robust approach would be to have a separate BindingContext for
each file, and clear each of them after running psi2ir on it. This would
also lower peak memory usage in psi2ir.

Provide a fallback workaround compiler argument
-Xir-do-not-clear-binding-context just in case BindingContext is in fact
used somewhere and it's not caught by tests.
This commit is contained in:
Alexander Udalov
2020-10-21 22:26:55 +02:00
parent bc76f1fec3
commit 382a0bd298
11 changed files with 66 additions and 29 deletions
@@ -34,10 +34,7 @@ import org.jetbrains.kotlin.checkers.diagnostics.factories.SyntaxErrorDiagnostic
import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil
import org.jetbrains.kotlin.checkers.utils.DiagnosticsRenderingConfiguration
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.diagnostics.*
@@ -269,6 +266,8 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
platform = null,
withNewInference,
languageVersionSettings,
// When using JVM IR, binding context is empty at the end of compilation, so debug info markers can't be computed.
environment.configuration.getBoolean(JVMConfigurationKeys.IR),
),
DataFlowValueFactoryImpl(languageVersionSettings),
moduleDescriptor,