[IR] Remove unused Ir.irModule property

It is required for the Native backend refactoring
where `Context` does not contain a reference for any
particular IrModuleFragment.
This commit is contained in:
Sergey Bogolepov
2022-12-28 12:14:27 +02:00
committed by Space Team
parent 3355f04fa1
commit c22285f824
10 changed files with 9 additions and 17 deletions
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
// This is what Context collects about IR. // This is what Context collects about IR.
abstract class Ir<out T : CommonBackendContext>(val context: T, val irModule: IrModuleFragment) { abstract class Ir<out T : CommonBackendContext>(val context: T) {
abstract val symbols: Symbols abstract val symbols: Symbols
@@ -59,7 +59,6 @@ class JsIrBackendContext(
val module: ModuleDescriptor, val module: ModuleDescriptor,
override val irBuiltIns: IrBuiltIns, override val irBuiltIns: IrBuiltIns,
val symbolTable: SymbolTable, val symbolTable: SymbolTable,
irModuleFragment: IrModuleFragment,
val additionalExportedDeclarationNames: Set<FqName>, val additionalExportedDeclarationNames: Set<FqName>,
keep: Set<String>, keep: Set<String>,
override val configuration: CompilerConfiguration, // TODO: remove configuration from backend context override val configuration: CompilerConfiguration, // TODO: remove configuration from backend context
@@ -193,7 +192,7 @@ class JsIrBackendContext(
.find { it.valueParameters.firstOrNull()?.type?.isFunctionType == true } .find { it.valueParameters.firstOrNull()?.type?.isFunctionType == true }
.let { symbolTable.referenceSimpleFunction(it!!) } .let { symbolTable.referenceSimpleFunction(it!!) }
override val ir = object : Ir<JsIrBackendContext>(this, irModuleFragment) { override val ir = object : Ir<JsIrBackendContext>(this) {
override val symbols = object : Symbols(irBuiltIns, symbolTable) { override val symbols = object : Symbols(irBuiltIns, symbolTable) {
private val context = this@JsIrBackendContext private val context = this@JsIrBackendContext
@@ -105,7 +105,6 @@ fun compileIr(
moduleDescriptor, moduleDescriptor,
irBuiltIns, irBuiltIns,
symbolTable, symbolTable,
allModules.first(),
exportedDeclarations, exportedDeclarations,
keep, keep,
configuration, configuration,
@@ -39,7 +39,6 @@ class JsIrCompilerWithIC(
mainModule.descriptor, mainModule.descriptor,
irBuiltIns, irBuiltIns,
symbolTable, symbolTable,
mainModule,
exportedDeclarations, exportedDeclarations,
keep = emptySet(), keep = emptySet(),
configuration = configuration, configuration = configuration,
@@ -284,7 +284,7 @@ open class JvmIrCodegenFactory(
val phases = if (evaluatorFragmentInfoForPsi2Ir != null) jvmFragmentLoweringPhases else jvmLoweringPhases val phases = if (evaluatorFragmentInfoForPsi2Ir != null) jvmFragmentLoweringPhases else jvmLoweringPhases
val phaseConfig = customPhaseConfig ?: PhaseConfig(phases) val phaseConfig = customPhaseConfig ?: PhaseConfig(phases)
val context = JvmBackendContext( val context = JvmBackendContext(
state, irModuleFragment.irBuiltins, irModuleFragment, symbolTable, phaseConfig, extensions, backendExtension, irSerializer, state, irModuleFragment.irBuiltins, symbolTable, phaseConfig, extensions, backendExtension, irSerializer,
) )
if (evaluatorFragmentInfoForPsi2Ir != null) { if (evaluatorFragmentInfoForPsi2Ir != null) {
context.localDeclarationsLoweringData = mutableMapOf() context.localDeclarationsLoweringData = mutableMapOf()
@@ -43,7 +43,6 @@ import java.util.concurrent.ConcurrentHashMap
class JvmBackendContext( class JvmBackendContext(
val state: GenerationState, val state: GenerationState,
override val irBuiltIns: IrBuiltIns, override val irBuiltIns: IrBuiltIns,
irModuleFragment: IrModuleFragment,
val symbolTable: SymbolTable, val symbolTable: SymbolTable,
val phaseConfig: PhaseConfig, val phaseConfig: PhaseConfig,
val generatorExtensions: JvmGeneratorExtensions, val generatorExtensions: JvmGeneratorExtensions,
@@ -85,7 +84,7 @@ class JvmBackendContext(
val ktDiagnosticReporter = KtDiagnosticReporterWithImplicitIrBasedContext(state.diagnosticReporter, state.languageVersionSettings) val ktDiagnosticReporter = KtDiagnosticReporterWithImplicitIrBasedContext(state.diagnosticReporter, state.languageVersionSettings)
override val ir = JvmIr(irModuleFragment, this.symbolTable) override val ir = JvmIr(this.symbolTable)
override val sharedVariablesManager = JvmSharedVariablesManager(state.module, ir.symbols, irBuiltIns, irFactory) override val sharedVariablesManager = JvmSharedVariablesManager(state.module, ir.symbols, irBuiltIns, irFactory)
@@ -270,9 +269,8 @@ class JvmBackendContext(
get() = false get() = false
inner class JvmIr( inner class JvmIr(
irModuleFragment: IrModuleFragment,
symbolTable: SymbolTable symbolTable: SymbolTable
) : Ir<JvmBackendContext>(this, irModuleFragment) { ) : Ir<JvmBackendContext>(this) {
override val symbols = JvmSymbols(this@JvmBackendContext, symbolTable) override val symbols = JvmSymbols(this@JvmBackendContext, symbolTable)
override fun unfoldInlineClassType(irType: IrType): IrType? { override fun unfoldInlineClassType(irType: IrType): IrType? {
@@ -123,7 +123,7 @@ class WasmBackendContext(
override val propertyLazyInitialization: PropertyLazyInitialization = override val propertyLazyInitialization: PropertyLazyInitialization =
PropertyLazyInitialization(enabled = propertyLazyInitialization, eagerInitialization = wasmSymbols.eagerInitialization) PropertyLazyInitialization(enabled = propertyLazyInitialization, eagerInitialization = wasmSymbols.eagerInitialization)
override val ir = object : Ir<WasmBackendContext>(this, irModuleFragment) { override val ir = object : Ir<WasmBackendContext>(this) {
override val symbols: Symbols = wasmSymbols override val symbols: Symbols = wasmSymbols
override fun shouldGenerateHandlerParameterForDefaultBodyFun() = true override fun shouldGenerateHandlerParameterForDefaultBodyFun() = true
} }
@@ -601,7 +601,6 @@ class GenerateIrRuntime {
module.descriptor, module.descriptor,
irBuiltIns, irBuiltIns,
symbolTable, symbolTable,
module,
additionalExportedDeclarationNames = emptySet(), additionalExportedDeclarationNames = emptySet(),
keep = emptySet(), keep = emptySet(),
configuration configuration
@@ -40,8 +40,6 @@ import org.jetbrains.kotlin.ir.util.SymbolTable
import org.jetbrains.kotlin.konan.library.KonanLibraryLayout import org.jetbrains.kotlin.konan.library.KonanLibraryLayout
import org.jetbrains.kotlin.konan.target.Architecture import org.jetbrains.kotlin.konan.target.Architecture
import org.jetbrains.kotlin.konan.target.KonanTarget import org.jetbrains.kotlin.konan.target.KonanTarget
import org.jetbrains.kotlin.library.SerializedIrModule
import org.jetbrains.kotlin.library.SerializedMetadata
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.BindingContext
@@ -83,7 +81,7 @@ internal class Context(
irModules = psiToIrOutput.irModules irModules = psiToIrOutput.irModules
irModule = psiToIrOutput.irModule irModule = psiToIrOutput.irModule
expectDescriptorToSymbol = psiToIrOutput.expectDescriptorToSymbol expectDescriptorToSymbol = psiToIrOutput.expectDescriptorToSymbol
ir = KonanIr(this, psiToIrOutput.irModule) ir = KonanIr(this)
ir.symbols = psiToIrOutput.symbols ir.symbols = psiToIrOutput.symbols
if (psiToIrOutput.irLinker is KonanIrLinker) { if (psiToIrOutput.irLinker is KonanIrLinker) {
irLinker = psiToIrOutput.irLinker irLinker = psiToIrOutput.irLinker
@@ -158,7 +156,7 @@ internal class Context(
throw Error("Another IrModule in the context.") throw Error("Another IrModule in the context.")
} }
field = module!! field = module!!
ir = KonanIr(this, module) ir = KonanIr(this)
} }
override lateinit var ir: KonanIr override lateinit var ir: KonanIr
@@ -41,7 +41,7 @@ object KonanNameConventions {
} }
// This is what Context collects about IR. // This is what Context collects about IR.
internal class KonanIr(context: Context, irModule: IrModuleFragment): Ir<Context>(context, irModule) { internal class KonanIr(context: Context): Ir<Context>(context) {
override var symbols: KonanSymbols by Delegates.notNull() override var symbols: KonanSymbols by Delegates.notNull()
} }