[K/N] Drop obsolete static driver
This commit is contained in:
committed by
Space Team
parent
7706ad8cb3
commit
366edcfe3c
-3
@@ -391,9 +391,6 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
|
|||||||
@Argument(value = "-Xomit-framework-binary", description = "Omit binary when compiling framework")
|
@Argument(value = "-Xomit-framework-binary", description = "Omit binary when compiling framework")
|
||||||
var omitFrameworkBinary: Boolean = false
|
var omitFrameworkBinary: Boolean = false
|
||||||
|
|
||||||
@Argument(value = "-Xforce-compiler-driver", description = "Force compiler to use specific compiler driver: static or dynamic")
|
|
||||||
var forceCompilerDriver: String? = null
|
|
||||||
|
|
||||||
override fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap<AnalysisFlag<*>, Any> =
|
override fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap<AnalysisFlag<*>, Any> =
|
||||||
super.configureAnalysisFlags(collector, languageVersion).also {
|
super.configureAnalysisFlags(collector, languageVersion).also {
|
||||||
val optInList = it[AnalysisFlags.optIn] as List<*>
|
val optInList = it[AnalysisFlags.optIn] as List<*>
|
||||||
|
|||||||
@@ -67,9 +67,6 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
|||||||
messageCollector.report(ERROR, "K2 does not support Native target right now")
|
messageCollector.report(ERROR, "K2 does not support Native target right now")
|
||||||
return ExitCode.COMPILATION_ERROR
|
return ExitCode.COMPILATION_ERROR
|
||||||
}
|
}
|
||||||
// TODO: Should be either of two, or PHASE_CONFIG will go away with the old driver.
|
|
||||||
// TODO: -Xlist-phases does not work correctly for now.
|
|
||||||
configuration.put(CLIConfigurationKeys.PHASE_CONFIG, createPhaseConfig(toplevelPhaseErased, arguments, messageCollector))
|
|
||||||
configuration.put(CLIConfigurationKeys.FLEXIBLE_PHASE_CONFIG, createFlexiblePhaseConfig(arguments))
|
configuration.put(CLIConfigurationKeys.FLEXIBLE_PHASE_CONFIG, createFlexiblePhaseConfig(arguments))
|
||||||
|
|
||||||
|
|
||||||
@@ -369,7 +366,6 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
|||||||
arguments.testDumpOutputPath?.let { put(TEST_DUMP_OUTPUT_PATH, it) }
|
arguments.testDumpOutputPath?.let { put(TEST_DUMP_OUTPUT_PATH, it) }
|
||||||
put(PARTIAL_LINKAGE, arguments.partialLinkage)
|
put(PARTIAL_LINKAGE, arguments.partialLinkage)
|
||||||
put(OMIT_FRAMEWORK_BINARY, arguments.omitFrameworkBinary)
|
put(OMIT_FRAMEWORK_BINARY, arguments.omitFrameworkBinary)
|
||||||
putIfNotNull(FORCE_COMPILER_DRIVER, arguments.forceCompilerDriver)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-81
@@ -204,87 +204,6 @@ internal fun linkBitcodeDependencies(generationState: NativeGenerationState) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove this function after dynamic driver is complete.
|
|
||||||
internal fun produceOutput(generationState: NativeGenerationState) {
|
|
||||||
val context = generationState.context
|
|
||||||
val config = context.config
|
|
||||||
val tempFiles = generationState.tempFiles
|
|
||||||
val produce = config.produce
|
|
||||||
if (produce == CompilerOutputKind.FRAMEWORK) {
|
|
||||||
generationState.objCExport.produceFrameworkInterface()
|
|
||||||
if (config.omitFrameworkBinary) {
|
|
||||||
// Compiler does not compile anything in this mode, so return early.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
when (produce) {
|
|
||||||
CompilerOutputKind.STATIC,
|
|
||||||
CompilerOutputKind.DYNAMIC,
|
|
||||||
CompilerOutputKind.FRAMEWORK,
|
|
||||||
CompilerOutputKind.DYNAMIC_CACHE,
|
|
||||||
CompilerOutputKind.STATIC_CACHE,
|
|
||||||
CompilerOutputKind.PROGRAM -> {
|
|
||||||
val output = tempFiles.nativeBinaryFileName
|
|
||||||
generationState.bitcodeFileName = output
|
|
||||||
// Insert `_main` after pipeline so we won't worry about optimizations
|
|
||||||
// corrupting entry point.
|
|
||||||
insertAliasToEntryPoint(generationState)
|
|
||||||
LLVMWriteBitcodeToFile(generationState.llvm.module, output)
|
|
||||||
}
|
|
||||||
CompilerOutputKind.LIBRARY -> {
|
|
||||||
val nopack = config.configuration.getBoolean(KonanConfigKeys.NOPACK)
|
|
||||||
val output = generationState.outputFiles.klibOutputFileName(!nopack)
|
|
||||||
val libraryName = config.moduleId
|
|
||||||
val shortLibraryName = config.shortModuleName
|
|
||||||
val neededLibraries = context.librariesWithDependencies
|
|
||||||
val abiVersion = KotlinAbiVersion.CURRENT
|
|
||||||
val compilerVersion = CompilerVersion.CURRENT.toString()
|
|
||||||
val libraryVersion = config.configuration.get(KonanConfigKeys.LIBRARY_VERSION)
|
|
||||||
val metadataVersion = KlibMetadataVersion.INSTANCE.toString()
|
|
||||||
val irVersion = KlibIrVersion.INSTANCE.toString()
|
|
||||||
val versions = KotlinLibraryVersioning(
|
|
||||||
abiVersion = abiVersion,
|
|
||||||
libraryVersion = libraryVersion,
|
|
||||||
compilerVersion = compilerVersion,
|
|
||||||
metadataVersion = metadataVersion,
|
|
||||||
irVersion = irVersion
|
|
||||||
)
|
|
||||||
val target = config.target
|
|
||||||
val manifestProperties = config.manifestProperties
|
|
||||||
|
|
||||||
if (!nopack) {
|
|
||||||
val suffix = config.produce.suffix(target)
|
|
||||||
if (!output.endsWith(suffix)) {
|
|
||||||
error("please specify correct output: packed: ${!nopack}, $output$suffix")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val library = buildLibrary(
|
|
||||||
config.nativeLibraries,
|
|
||||||
config.includeBinaries,
|
|
||||||
neededLibraries,
|
|
||||||
context.serializedMetadata!!,
|
|
||||||
context.serializedIr,
|
|
||||||
versions,
|
|
||||||
target,
|
|
||||||
output,
|
|
||||||
libraryName,
|
|
||||||
nopack,
|
|
||||||
shortLibraryName,
|
|
||||||
manifestProperties,
|
|
||||||
context.dataFlowGraph)
|
|
||||||
|
|
||||||
generationState.bitcodeFileName = library.mainBitcodeFileName
|
|
||||||
}
|
|
||||||
CompilerOutputKind.BITCODE -> {
|
|
||||||
val output = generationState.outputFile
|
|
||||||
generationState.bitcodeFileName = output
|
|
||||||
LLVMWriteBitcodeToFile(generationState.llvm.module, output)
|
|
||||||
}
|
|
||||||
else -> error("not supported: $produce")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun parseAndLinkBitcodeFile(generationState: NativeGenerationState, llvmModule: LLVMModuleRef, path: String) {
|
private fun parseAndLinkBitcodeFile(generationState: NativeGenerationState, llvmModule: LLVMModuleRef, path: String) {
|
||||||
val parsedModule = parseBitcodeFile(generationState.llvmContext, path)
|
val parsedModule = parseBitcodeFile(generationState.llvmContext, path)
|
||||||
if (!generationState.shouldUseDebugInfoFromNativeLibs()) {
|
if (!generationState.shouldUseDebugInfoFromNativeLibs()) {
|
||||||
|
|||||||
-22
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.backend.common.DefaultDelegateFactory
|
|||||||
import org.jetbrains.kotlin.backend.common.DefaultMapping
|
import org.jetbrains.kotlin.backend.common.DefaultMapping
|
||||||
import org.jetbrains.kotlin.backend.common.LoggingContext
|
import org.jetbrains.kotlin.backend.common.LoggingContext
|
||||||
import org.jetbrains.kotlin.backend.konan.cexport.CAdapterExportedElements
|
import org.jetbrains.kotlin.backend.konan.cexport.CAdapterExportedElements
|
||||||
import org.jetbrains.kotlin.backend.konan.cexport.CAdapterGenerator
|
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.BridgeDirections
|
import org.jetbrains.kotlin.backend.konan.descriptors.BridgeDirections
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.ClassLayoutBuilder
|
import org.jetbrains.kotlin.backend.konan.descriptors.ClassLayoutBuilder
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.GlobalHierarchyAnalysisResult
|
import org.jetbrains.kotlin.backend.konan.descriptors.GlobalHierarchyAnalysisResult
|
||||||
@@ -68,7 +67,6 @@ internal class NativeMapping : DefaultMapping() {
|
|||||||
internal class Context(
|
internal class Context(
|
||||||
config: KonanConfig,
|
config: KonanConfig,
|
||||||
val environment: KotlinCoreEnvironment,
|
val environment: KotlinCoreEnvironment,
|
||||||
val frontendServices: FrontendServices,
|
|
||||||
override var bindingContext: BindingContext,
|
override var bindingContext: BindingContext,
|
||||||
val moduleDescriptor: ModuleDescriptor,
|
val moduleDescriptor: ModuleDescriptor,
|
||||||
) : KonanBackendContext(config), PsiToIrContext {
|
) : KonanBackendContext(config), PsiToIrContext {
|
||||||
@@ -86,9 +84,6 @@ internal class Context(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Valid from [createSymbolTablePhase] until [destroySymbolTablePhase].
|
|
||||||
*/
|
|
||||||
override var symbolTable: SymbolTable? = null
|
override var symbolTable: SymbolTable? = null
|
||||||
|
|
||||||
lateinit var cAdapterExportedElements: CAdapterExportedElements
|
lateinit var cAdapterExportedElements: CAdapterExportedElements
|
||||||
@@ -109,12 +104,6 @@ internal class Context(
|
|||||||
// generationStates at the same time.
|
// generationStates at the same time.
|
||||||
lateinit var generationState: NativeGenerationState
|
lateinit var generationState: NativeGenerationState
|
||||||
|
|
||||||
fun disposeGenerationState() {
|
|
||||||
if (::generationState.isInitialized) generationState.dispose()
|
|
||||||
}
|
|
||||||
|
|
||||||
val phaseConfig = config.phaseConfig
|
|
||||||
|
|
||||||
val innerClassesSupport by lazy { InnerClassesSupport(mapping, irFactory) }
|
val innerClassesSupport by lazy { InnerClassesSupport(mapping, irFactory) }
|
||||||
val bridgesSupport by lazy { BridgesSupport(mapping, irBuiltIns, irFactory) }
|
val bridgesSupport by lazy { BridgesSupport(mapping, irBuiltIns, irFactory) }
|
||||||
val inlineFunctionsSupport by lazy { InlineFunctionsSupport(mapping) }
|
val inlineFunctionsSupport by lazy { InlineFunctionsSupport(mapping) }
|
||||||
@@ -143,13 +132,6 @@ internal class Context(
|
|||||||
|
|
||||||
lateinit var globalHierarchyAnalysisResult: GlobalHierarchyAnalysisResult
|
lateinit var globalHierarchyAnalysisResult: GlobalHierarchyAnalysisResult
|
||||||
|
|
||||||
// We serialize untouched descriptor tree and IR.
|
|
||||||
// But we have to wait until the code generation phase,
|
|
||||||
// to dump this information into generated file.
|
|
||||||
var serializedMetadata: SerializedMetadata? = null
|
|
||||||
var serializedIr: SerializedIrModule? = null
|
|
||||||
var dataFlowGraph: ByteArray? = null
|
|
||||||
|
|
||||||
val librariesWithDependencies by lazy {
|
val librariesWithDependencies by lazy {
|
||||||
config.librariesWithDependencies(moduleDescriptor)
|
config.librariesWithDependencies(moduleDescriptor)
|
||||||
}
|
}
|
||||||
@@ -190,10 +172,6 @@ internal class Context(
|
|||||||
|
|
||||||
lateinit var library: KonanLibraryLayout
|
lateinit var library: KonanLibraryLayout
|
||||||
|
|
||||||
fun separator(title: String) {
|
|
||||||
println("\n\n--- ${title} ----------------------\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun verifyBitCode() {
|
fun verifyBitCode() {
|
||||||
if (::generationState.isInitialized)
|
if (::generationState.isInitialized)
|
||||||
generationState.verifyBitCode()
|
generationState.verifyBitCode()
|
||||||
|
|||||||
-1
@@ -47,7 +47,6 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
|||||||
internal val targetManager = platformManager.targetManager(configuration.get(KonanConfigKeys.TARGET))
|
internal val targetManager = platformManager.targetManager(configuration.get(KonanConfigKeys.TARGET))
|
||||||
internal val target = targetManager.target
|
internal val target = targetManager.target
|
||||||
val targetHasAddressDependency get() = target.hasAddressDependencyInMemoryModel()
|
val targetHasAddressDependency get() = target.hasAddressDependencyInMemoryModel()
|
||||||
internal val phaseConfig = configuration.get(CLIConfigurationKeys.PHASE_CONFIG)!!
|
|
||||||
internal val flexiblePhaseConfig = configuration.get(CLIConfigurationKeys.FLEXIBLE_PHASE_CONFIG)!!
|
internal val flexiblePhaseConfig = configuration.get(CLIConfigurationKeys.FLEXIBLE_PHASE_CONFIG)!!
|
||||||
|
|
||||||
// TODO: debug info generation mode and debug/release variant selection probably requires some refactoring.
|
// TODO: debug info generation mode and debug/release variant selection probably requires some refactoring.
|
||||||
|
|||||||
-1
@@ -157,7 +157,6 @@ class KonanConfigKeys {
|
|||||||
val PARTIAL_LINKAGE: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("allows some symbols in klibs be missed")
|
val PARTIAL_LINKAGE: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("allows some symbols in klibs be missed")
|
||||||
val TEST_DUMP_OUTPUT_PATH: CompilerConfigurationKey<String?> = CompilerConfigurationKey.create("path to a file to dump the list of all available tests")
|
val TEST_DUMP_OUTPUT_PATH: CompilerConfigurationKey<String?> = CompilerConfigurationKey.create("path to a file to dump the list of all available tests")
|
||||||
val OMIT_FRAMEWORK_BINARY: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("do not generate binary in framework")
|
val OMIT_FRAMEWORK_BINARY: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("do not generate binary in framework")
|
||||||
val FORCE_COMPILER_DRIVER: CompilerConfigurationKey<String?> = CompilerConfigurationKey.create("explicitly pick compiler driver")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-20
@@ -8,9 +8,7 @@ package org.jetbrains.kotlin.backend.konan
|
|||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.codedInputStream
|
import org.jetbrains.kotlin.backend.common.serialization.codedInputStream
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.proto.IrFile
|
import org.jetbrains.kotlin.backend.common.serialization.proto.IrFile
|
||||||
import org.jetbrains.kotlin.backend.konan.driver.CompilerDriver
|
|
||||||
import org.jetbrains.kotlin.backend.konan.driver.DynamicCompilerDriver
|
import org.jetbrains.kotlin.backend.konan.driver.DynamicCompilerDriver
|
||||||
import org.jetbrains.kotlin.backend.konan.driver.StaticCompilerDriver
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||||
import org.jetbrains.kotlin.konan.file.File
|
import org.jetbrains.kotlin.konan.file.File
|
||||||
@@ -35,10 +33,15 @@ class KonanDriver(val project: Project, val environment: KotlinCoreEnvironment,
|
|||||||
configuration.put(KonanConfigKeys.MAKE_PER_FILE_CACHE, true)
|
configuration.put(KonanConfigKeys.MAKE_PER_FILE_CACHE, true)
|
||||||
configuration.put(KonanConfigKeys.FILES_TO_CACHE, fileNames)
|
configuration.put(KonanConfigKeys.FILES_TO_CACHE, fileNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
val konanConfig = KonanConfig(project, configuration)
|
val konanConfig = KonanConfig(project, configuration)
|
||||||
|
|
||||||
|
if (configuration.get(KonanConfigKeys.LIST_TARGETS) == true) {
|
||||||
|
konanConfig.targetManager.list()
|
||||||
|
}
|
||||||
|
if (konanConfig.infoArgsOnly) return
|
||||||
|
|
||||||
ensureModuleName(konanConfig)
|
ensureModuleName(konanConfig)
|
||||||
pickCompilerDriver(konanConfig).run(konanConfig, environment)
|
DynamicCompilerDriver().run(konanConfig, environment)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ensureModuleName(config: KonanConfig) {
|
private fun ensureModuleName(config: KonanConfig) {
|
||||||
@@ -52,20 +55,4 @@ class KonanDriver(val project: Project, val environment: KotlinCoreEnvironment,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pickCompilerDriver(config: KonanConfig): CompilerDriver {
|
|
||||||
config.configuration[KonanConfigKeys.FORCE_COMPILER_DRIVER]?.let {
|
|
||||||
return when (it) {
|
|
||||||
"dynamic" -> DynamicCompilerDriver()
|
|
||||||
"static" -> StaticCompilerDriver()
|
|
||||||
else -> error("Unknown compiler driver. Possible values: dynamic, static")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Dynamic driver is WIP, so it might not support all possible configurations.
|
|
||||||
return if (DynamicCompilerDriver.supportsConfig(config)) {
|
|
||||||
DynamicCompilerDriver()
|
|
||||||
} else {
|
|
||||||
StaticCompilerDriver()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
-252
@@ -9,33 +9,15 @@ import org.jetbrains.kotlin.backend.common.IrValidator
|
|||||||
import org.jetbrains.kotlin.backend.common.IrValidatorConfig
|
import org.jetbrains.kotlin.backend.common.IrValidatorConfig
|
||||||
import org.jetbrains.kotlin.backend.common.checkDeclarationParents
|
import org.jetbrains.kotlin.backend.common.checkDeclarationParents
|
||||||
import org.jetbrains.kotlin.backend.common.phaser.*
|
import org.jetbrains.kotlin.backend.common.phaser.*
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.CompatibilityMode
|
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataMonolithicSerializer
|
|
||||||
import org.jetbrains.kotlin.backend.konan.cexport.CAdapterExportedElements
|
|
||||||
import org.jetbrains.kotlin.backend.konan.cexport.CAdapterGenerator
|
|
||||||
import org.jetbrains.kotlin.backend.konan.cexport.CAdapterTypeTranslator
|
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.isFromInteropLibrary
|
import org.jetbrains.kotlin.backend.konan.descriptors.isFromInteropLibrary
|
||||||
import org.jetbrains.kotlin.backend.konan.driver.phases.PsiToIrInput
|
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.*
|
import org.jetbrains.kotlin.backend.konan.llvm.*
|
||||||
import org.jetbrains.kotlin.backend.konan.lower.CacheInfoBuilder
|
import org.jetbrains.kotlin.backend.konan.lower.CacheInfoBuilder
|
||||||
import org.jetbrains.kotlin.backend.konan.lower.ExpectToActualDefaultValueCopier
|
|
||||||
import org.jetbrains.kotlin.backend.konan.lower.SamSuperTypesChecker
|
import org.jetbrains.kotlin.backend.konan.lower.SamSuperTypesChecker
|
||||||
import org.jetbrains.kotlin.backend.konan.objcexport.createCodeSpec
|
|
||||||
import org.jetbrains.kotlin.backend.konan.objcexport.produceObjCExportInterface
|
|
||||||
import org.jetbrains.kotlin.backend.konan.serialization.KonanIdSignaturer
|
|
||||||
import org.jetbrains.kotlin.backend.konan.serialization.KonanIrModuleSerializer
|
|
||||||
import org.jetbrains.kotlin.backend.konan.serialization.KonanManglerDesc
|
|
||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
|
||||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.path
|
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
|
||||||
import org.jetbrains.kotlin.resolve.CleanableBindingContext
|
|
||||||
|
|
||||||
internal fun moduleValidationCallback(state: ActionState, module: IrModuleFragment, context: Context) {
|
internal fun moduleValidationCallback(state: ActionState, module: IrModuleFragment, context: Context) {
|
||||||
if (!context.config.needVerifyIr) return
|
if (!context.config.needVerifyIr) return
|
||||||
@@ -82,54 +64,6 @@ internal fun konanUnitPhase(
|
|||||||
op: Context.() -> Unit
|
op: Context.() -> Unit
|
||||||
) = namedOpUnitPhase(name, description, prerequisite, op)
|
) = namedOpUnitPhase(name, description, prerequisite, op)
|
||||||
|
|
||||||
internal val createSymbolTablePhase = konanUnitPhase(
|
|
||||||
op = {
|
|
||||||
this.symbolTable = SymbolTable(KonanIdSignaturer(KonanManglerDesc), IrFactoryImpl)
|
|
||||||
},
|
|
||||||
name = "CreateSymbolTable",
|
|
||||||
description = "Create SymbolTable"
|
|
||||||
)
|
|
||||||
|
|
||||||
internal val objCExportPhase = konanUnitPhase(
|
|
||||||
op = {
|
|
||||||
objCExportedInterface = when {
|
|
||||||
!config.target.family.isAppleFamily -> null
|
|
||||||
config.produce != CompilerOutputKind.FRAMEWORK -> null
|
|
||||||
else -> produceObjCExportInterface(this, this.moduleDescriptor, this.frontendServices)
|
|
||||||
}
|
|
||||||
objCExportCodeSpec = objCExportedInterface?.createCodeSpec(symbolTable!!)
|
|
||||||
},
|
|
||||||
name = "ObjCExport",
|
|
||||||
description = "Objective-C header generation",
|
|
||||||
prerequisite = setOf(createSymbolTablePhase)
|
|
||||||
)
|
|
||||||
|
|
||||||
internal val buildCExportsPhase = konanUnitPhase(
|
|
||||||
op = {
|
|
||||||
val prefix = config.fullExportedNamePrefix.replace("-|\\.".toRegex(), "_")
|
|
||||||
val cAdapterTypeTranslator = CAdapterTypeTranslator(prefix, this.builtIns)
|
|
||||||
this.cAdapterExportedElements = CAdapterGenerator(this, cAdapterTypeTranslator).buildExports(this.moduleDescriptor)
|
|
||||||
},
|
|
||||||
name = "BuildCExports",
|
|
||||||
description = "Build C exports",
|
|
||||||
prerequisite = setOf(createSymbolTablePhase)
|
|
||||||
)
|
|
||||||
|
|
||||||
internal val psiToIrPhase = konanUnitPhase(
|
|
||||||
op = {
|
|
||||||
val input = PsiToIrInput(moduleDescriptor, environment, isProducingLibrary = config.produce == CompilerOutputKind.LIBRARY)
|
|
||||||
val psiToIrOutput = this.psiToIr(input, useLinkerWhenProducingLibrary = false)
|
|
||||||
this.populateAfterPsiToIr(psiToIrOutput)
|
|
||||||
val originalBindingContext = bindingContext as? CleanableBindingContext
|
|
||||||
?: error("BindingContext should be cleanable in K/N IR to avoid leaking memory: $bindingContext")
|
|
||||||
originalBindingContext.clear()
|
|
||||||
this.bindingContext = BindingContext.EMPTY
|
|
||||||
},
|
|
||||||
name = "Psi2Ir",
|
|
||||||
description = "Psi to IR conversion and klib linkage",
|
|
||||||
prerequisite = setOf(createSymbolTablePhase)
|
|
||||||
)
|
|
||||||
|
|
||||||
internal val buildAdditionalCacheInfoPhase = konanUnitPhase(
|
internal val buildAdditionalCacheInfoPhase = konanUnitPhase(
|
||||||
op = {
|
op = {
|
||||||
val module = irModules[config.libraryToCache!!.klib.libraryName]
|
val module = irModules[config.libraryToCache!!.klib.libraryName]
|
||||||
@@ -147,26 +81,6 @@ internal val buildAdditionalCacheInfoPhase = konanUnitPhase(
|
|||||||
// prerequisite = setOf(psiToIrPhase)
|
// prerequisite = setOf(psiToIrPhase)
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val destroySymbolTablePhase = konanUnitPhase(
|
|
||||||
op = {
|
|
||||||
this.symbolTable = null // TODO: invalidate symbolTable itself.
|
|
||||||
},
|
|
||||||
name = "DestroySymbolTable",
|
|
||||||
description = "Destroy SymbolTable",
|
|
||||||
prerequisite = setOf(createSymbolTablePhase)
|
|
||||||
)
|
|
||||||
|
|
||||||
// TODO: We copy default value expressions from expects to actuals before IR serialization,
|
|
||||||
// because the current infrastructure doesn't allow us to get them at deserialization stage.
|
|
||||||
// That requires some design and implementation work.
|
|
||||||
internal val copyDefaultValuesToActualPhase = konanUnitPhase(
|
|
||||||
op = {
|
|
||||||
ExpectToActualDefaultValueCopier(irModule!!).process()
|
|
||||||
},
|
|
||||||
name = "CopyDefaultValuesToActual",
|
|
||||||
description = "Copy default values from expect to actual declarations"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sometimes psi2ir produces IR with non-trivial variance in super types of SAM conversions (this is a language design issue).
|
* Sometimes psi2ir produces IR with non-trivial variance in super types of SAM conversions (this is a language design issue).
|
||||||
* Earlier this was solved with just erasing all such variances but this might lead to some other hard to debug problems,
|
* Earlier this was solved with just erasing all such variances but this might lead to some other hard to debug problems,
|
||||||
@@ -194,31 +108,6 @@ internal val checkSamSuperTypesPhase = konanUnitPhase(
|
|||||||
description = "Check SAM conversions super types"
|
description = "Check SAM conversions super types"
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val serializerPhase = konanUnitPhase(
|
|
||||||
op = {
|
|
||||||
val expectActualLinker = config.configuration.get(CommonConfigurationKeys.EXPECT_ACTUAL_LINKER) ?: false
|
|
||||||
val messageLogger = config.configuration.get(IrMessageLogger.IR_MESSAGE_LOGGER) ?: IrMessageLogger.None
|
|
||||||
val relativePathBase = config.configuration.get(CommonConfigurationKeys.KLIB_RELATIVE_PATH_BASES) ?: emptyList()
|
|
||||||
val normalizeAbsolutePaths = config.configuration.get(CommonConfigurationKeys.KLIB_NORMALIZE_ABSOLUTE_PATH) ?: false
|
|
||||||
|
|
||||||
serializedIr = irModule?.let { ir ->
|
|
||||||
KonanIrModuleSerializer(
|
|
||||||
messageLogger, ir.irBuiltins, expectDescriptorToSymbol, skipExpects = !expectActualLinker, compatibilityMode = CompatibilityMode.CURRENT, normalizeAbsolutePaths = normalizeAbsolutePaths, sourceBaseDirs = relativePathBase
|
|
||||||
).serializedIrModule(ir)
|
|
||||||
}
|
|
||||||
|
|
||||||
val serializer = KlibMetadataMonolithicSerializer(
|
|
||||||
this.config.configuration.languageVersionSettings,
|
|
||||||
config.configuration.get(CommonConfigurationKeys.METADATA_VERSION)!!,
|
|
||||||
config.project,
|
|
||||||
exportKDoc = this.shouldExportKDoc(),
|
|
||||||
!expectActualLinker, includeOnlyModuleContent = true)
|
|
||||||
serializedMetadata = serializer.serializeModule(moduleDescriptor)
|
|
||||||
},
|
|
||||||
name = "Serializer",
|
|
||||||
description = "Serialize descriptor tree and inline IR bodies"
|
|
||||||
)
|
|
||||||
|
|
||||||
internal val saveAdditionalCacheInfoPhase = konanUnitPhase(
|
internal val saveAdditionalCacheInfoPhase = konanUnitPhase(
|
||||||
op = { CacheStorage(generationState).saveAdditionalCacheInfo() },
|
op = { CacheStorage(generationState).saveAdditionalCacheInfo() },
|
||||||
name = "SaveAdditionalCacheInfo",
|
name = "SaveAdditionalCacheInfo",
|
||||||
@@ -349,42 +238,6 @@ internal val dependenciesLowerPhase = SameTypeNamedCompilerPhase(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
internal val umbrellaCompilation = SameTypeNamedCompilerPhase(
|
|
||||||
name = "UmbrellaCompilation",
|
|
||||||
description = "A batched compilation with shared FE and ME phases",
|
|
||||||
prerequisite = emptySet(),
|
|
||||||
lower = object : CompilerPhase<Context, Unit, Unit> {
|
|
||||||
override fun invoke(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Unit>, context: Context, input: Unit) {
|
|
||||||
val module = context.irModules[context.config.libraryToCache!!.klib.libraryName]
|
|
||||||
?: error("No module for the library being cached: ${context.config.libraryToCache!!.klib.libraryName}")
|
|
||||||
|
|
||||||
val files = module.files.toList()
|
|
||||||
module.files.clear()
|
|
||||||
val functionInterfaceFiles = files.filter { it.isFunctionInterfaceFile }
|
|
||||||
|
|
||||||
for (file in files) {
|
|
||||||
if (file.isFunctionInterfaceFile) continue
|
|
||||||
|
|
||||||
context.generationState = NativeGenerationState(
|
|
||||||
context.config,
|
|
||||||
context,
|
|
||||||
CacheDeserializationStrategy.SingleFile(file.path, file.fqName.asString())
|
|
||||||
)
|
|
||||||
|
|
||||||
module.files += file
|
|
||||||
if (context.generationState.shouldDefineFunctionClasses)
|
|
||||||
module.files += functionInterfaceFiles
|
|
||||||
|
|
||||||
entireBackend.invoke(phaseConfig, phaserState, context, Unit)
|
|
||||||
|
|
||||||
module.files.clear()
|
|
||||||
context.irModule!!.files.clear() // [dependenciesLowerPhase] puts all files to [context.irModule] for codegen.
|
|
||||||
}
|
|
||||||
|
|
||||||
module.files += files
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
internal val entryPointPhase = makeCustomPhase<Context, IrModuleFragment>(
|
internal val entryPointPhase = makeCustomPhase<Context, IrModuleFragment>(
|
||||||
name = "addEntryPoint",
|
name = "addEntryPoint",
|
||||||
description = "Add entry point for program",
|
description = "Add entry point for program",
|
||||||
@@ -438,96 +291,6 @@ internal val bitcodePostprocessingPhase = SameTypeNamedCompilerPhase(
|
|||||||
rewriteExternalCallsCheckerGlobals
|
rewriteExternalCallsCheckerGlobals
|
||||||
)
|
)
|
||||||
|
|
||||||
private val backendCodegen = SameTypeNamedCompilerPhase(
|
|
||||||
name = "Backend codegen",
|
|
||||||
description = "Backend code generation",
|
|
||||||
lower = entryPointPhase then
|
|
||||||
allLoweringsPhase then // Lower current module first.
|
|
||||||
dependenciesLowerPhase then // Then lower all libraries in topological order.
|
|
||||||
// With that we guarantee that inline functions are unlowered while being inlined.
|
|
||||||
bitcodePhase then
|
|
||||||
verifyBitcodePhase then
|
|
||||||
printBitcodePhase then
|
|
||||||
linkBitcodeDependenciesPhase then
|
|
||||||
bitcodePostprocessingPhase
|
|
||||||
)
|
|
||||||
|
|
||||||
internal val createGenerationStatePhase = namedUnitPhase(
|
|
||||||
name = "CreateGenerationState",
|
|
||||||
description = "Create generation state",
|
|
||||||
lower = object : CompilerPhase<Context, Unit, Unit> {
|
|
||||||
override fun invoke(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Unit>, context: Context, input: Unit) {
|
|
||||||
context.generationState = NativeGenerationState(context.config, context, context.config.libraryToCache?.strategy)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
internal val disposeGenerationStatePhase = namedUnitPhase(
|
|
||||||
name = "DisposeGenerationState",
|
|
||||||
description = "Dispose generation state",
|
|
||||||
lower = object : CompilerPhase<Context, Unit, Unit> {
|
|
||||||
override fun invoke(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Unit>, context: Context, input: Unit) {
|
|
||||||
context.disposeGenerationState()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
private val phasesOverMainModule = SameTypeNamedCompilerPhase(
|
|
||||||
name = "PhasesOverMainModule",
|
|
||||||
description = "Phases over main module",
|
|
||||||
lower = takeFromContext<Context, Unit, IrModuleFragment> { it.irModule!! } then
|
|
||||||
specialBackendChecksPhase then
|
|
||||||
backendCodegen then
|
|
||||||
unitSink(),
|
|
||||||
prerequisite = setOf(psiToIrPhase)
|
|
||||||
)
|
|
||||||
|
|
||||||
private val entireBackend = SameTypeNamedCompilerPhase(
|
|
||||||
name = "EntireBackend",
|
|
||||||
description = "Entire backend",
|
|
||||||
lower = buildAdditionalCacheInfoPhase then
|
|
||||||
phasesOverMainModule then
|
|
||||||
saveAdditionalCacheInfoPhase then
|
|
||||||
produceOutputPhase then
|
|
||||||
objectFilesPhase then
|
|
||||||
linkerPhase then
|
|
||||||
finalizeCachePhase then
|
|
||||||
disposeGenerationStatePhase
|
|
||||||
)
|
|
||||||
|
|
||||||
private val middleEnd = SameTypeNamedCompilerPhase(
|
|
||||||
name = "MiddleEnd",
|
|
||||||
description = "Build and prepare IR for back end",
|
|
||||||
lower = createSymbolTablePhase then
|
|
||||||
objCExportPhase then
|
|
||||||
buildCExportsPhase then
|
|
||||||
psiToIrPhase then
|
|
||||||
destroySymbolTablePhase then
|
|
||||||
copyDefaultValuesToActualPhase then
|
|
||||||
checkSamSuperTypesPhase then
|
|
||||||
serializerPhase then
|
|
||||||
functionsWithoutBoundCheck
|
|
||||||
)
|
|
||||||
|
|
||||||
private val singleCompilation = SameTypeNamedCompilerPhase(
|
|
||||||
name = "SingleCompilation",
|
|
||||||
description = "Single compilation",
|
|
||||||
lower = createGenerationStatePhase then
|
|
||||||
entireBackend
|
|
||||||
)
|
|
||||||
|
|
||||||
internal val toplevelPhase: CompilerPhase<Context, Unit, Unit> = namedUnitPhase(
|
|
||||||
name = "Compiler",
|
|
||||||
description = "The whole compilation process",
|
|
||||||
lower = middleEnd then
|
|
||||||
singleCompilation then
|
|
||||||
umbrellaCompilation
|
|
||||||
)
|
|
||||||
|
|
||||||
// Have to hide Context as type parameter in order to expose toplevelPhase outside of this module.
|
|
||||||
val toplevelPhaseErased: CompilerPhase<*, Unit, Unit>
|
|
||||||
get() = toplevelPhase
|
|
||||||
|
|
||||||
internal fun PhaseConfigurationService.disableIf(phase: AnyNamedPhase, condition: Boolean) {
|
internal fun PhaseConfigurationService.disableIf(phase: AnyNamedPhase, condition: Boolean) {
|
||||||
if (condition) disable(phase)
|
if (condition) disable(phase)
|
||||||
}
|
}
|
||||||
@@ -544,19 +307,11 @@ internal fun PhaseConfigurationService.konanPhasesConfig(config: KonanConfig) {
|
|||||||
// Also see https://youtrack.jetbrains.com/issue/KT-50399 for more details.
|
// Also see https://youtrack.jetbrains.com/issue/KT-50399 for more details.
|
||||||
disable(checkSamSuperTypesPhase)
|
disable(checkSamSuperTypesPhase)
|
||||||
|
|
||||||
disableIf(singleCompilation, config.producePerFileCache)
|
|
||||||
disableUnless(umbrellaCompilation, config.producePerFileCache)
|
|
||||||
|
|
||||||
// Don't serialize anything to a final executable.
|
|
||||||
disableUnless(serializerPhase, config.produce == CompilerOutputKind.LIBRARY)
|
|
||||||
disableUnless(entryPointPhase, config.produce == CompilerOutputKind.PROGRAM)
|
|
||||||
disableUnless(buildAdditionalCacheInfoPhase, config.produce.isCache)
|
disableUnless(buildAdditionalCacheInfoPhase, config.produce.isCache)
|
||||||
disableUnless(saveAdditionalCacheInfoPhase, config.produce.isCache)
|
disableUnless(saveAdditionalCacheInfoPhase, config.produce.isCache)
|
||||||
disableUnless(finalizeCachePhase, config.produce.isCache)
|
disableUnless(finalizeCachePhase, config.produce.isCache)
|
||||||
disableUnless(exportInternalAbiPhase, config.produce.isCache)
|
disableUnless(exportInternalAbiPhase, config.produce.isCache)
|
||||||
disableUnless(buildCExportsPhase, config.produce.isNativeLibrary)
|
|
||||||
disableUnless(functionsWithoutBoundCheck, config.involvesCodegen)
|
disableUnless(functionsWithoutBoundCheck, config.involvesCodegen)
|
||||||
disableUnless(backendCodegen, config.involvesCodegen)
|
|
||||||
disableUnless(checkExternalCallsPhase, getBoolean(KonanConfigKeys.CHECK_EXTERNAL_CALLS))
|
disableUnless(checkExternalCallsPhase, getBoolean(KonanConfigKeys.CHECK_EXTERNAL_CALLS))
|
||||||
disableUnless(rewriteExternalCallsCheckerGlobals, getBoolean(KonanConfigKeys.CHECK_EXTERNAL_CALLS))
|
disableUnless(rewriteExternalCallsCheckerGlobals, getBoolean(KonanConfigKeys.CHECK_EXTERNAL_CALLS))
|
||||||
disableUnless(stringConcatenationTypeNarrowingPhase, config.optimizationsEnabled)
|
disableUnless(stringConcatenationTypeNarrowingPhase, config.optimizationsEnabled)
|
||||||
@@ -586,12 +341,5 @@ internal fun PhaseConfigurationService.konanPhasesConfig(config: KonanConfig) {
|
|||||||
|
|
||||||
|
|
||||||
disableUnless(removeRedundantSafepointsPhase, config.memoryModel == MemoryModel.EXPERIMENTAL)
|
disableUnless(removeRedundantSafepointsPhase, config.memoryModel == MemoryModel.EXPERIMENTAL)
|
||||||
|
|
||||||
if (config.metadataKlib || config.omitFrameworkBinary) {
|
|
||||||
disable(psiToIrPhase)
|
|
||||||
disable(copyDefaultValuesToActualPhase)
|
|
||||||
disable(phasesOverMainModule)
|
|
||||||
disable(checkSamSuperTypesPhase)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-15
@@ -18,19 +18,6 @@ import org.jetbrains.kotlin.konan.util.usingNativeMemoryAllocator
|
|||||||
*/
|
*/
|
||||||
internal class DynamicCompilerDriver : CompilerDriver() {
|
internal class DynamicCompilerDriver : CompilerDriver() {
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun supportsConfig(config: KonanConfig): Boolean =
|
|
||||||
config.produce in setOf(
|
|
||||||
CompilerOutputKind.PROGRAM,
|
|
||||||
CompilerOutputKind.LIBRARY,
|
|
||||||
CompilerOutputKind.DYNAMIC_CACHE,
|
|
||||||
CompilerOutputKind.STATIC_CACHE,
|
|
||||||
CompilerOutputKind.FRAMEWORK,
|
|
||||||
CompilerOutputKind.DYNAMIC,
|
|
||||||
CompilerOutputKind.STATIC,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun run(config: KonanConfig, environment: KotlinCoreEnvironment) {
|
override fun run(config: KonanConfig, environment: KotlinCoreEnvironment) {
|
||||||
usingNativeMemoryAllocator {
|
usingNativeMemoryAllocator {
|
||||||
usingJvmCInteropCallbacks {
|
usingJvmCInteropCallbacks {
|
||||||
@@ -41,7 +28,7 @@ internal class DynamicCompilerDriver : CompilerDriver() {
|
|||||||
CompilerOutputKind.STATIC -> produceCLibrary(engine, config, environment)
|
CompilerOutputKind.STATIC -> produceCLibrary(engine, config, environment)
|
||||||
CompilerOutputKind.FRAMEWORK -> produceObjCFramework(engine, config, environment)
|
CompilerOutputKind.FRAMEWORK -> produceObjCFramework(engine, config, environment)
|
||||||
CompilerOutputKind.LIBRARY -> produceKlib(engine, config, environment)
|
CompilerOutputKind.LIBRARY -> produceKlib(engine, config, environment)
|
||||||
CompilerOutputKind.BITCODE -> error("Dynamic compiler driver does not support `bitcode` output yet.")
|
CompilerOutputKind.BITCODE -> error("Bitcode output kind is obsolete.")
|
||||||
CompilerOutputKind.DYNAMIC_CACHE -> produceBinary(engine, config, environment)
|
CompilerOutputKind.DYNAMIC_CACHE -> produceBinary(engine, config, environment)
|
||||||
CompilerOutputKind.STATIC_CACHE -> produceBinary(engine, config, environment)
|
CompilerOutputKind.STATIC_CACHE -> produceBinary(engine, config, environment)
|
||||||
CompilerOutputKind.PRELIMINARY_CACHE -> TODO()
|
CompilerOutputKind.PRELIMINARY_CACHE -> TODO()
|
||||||
@@ -114,7 +101,6 @@ internal class DynamicCompilerDriver : CompilerDriver() {
|
|||||||
) = Context(
|
) = Context(
|
||||||
config,
|
config,
|
||||||
frontendOutput.environment,
|
frontendOutput.environment,
|
||||||
frontendOutput.frontendServices,
|
|
||||||
frontendOutput.bindingContext,
|
frontendOutput.bindingContext,
|
||||||
frontendOutput.moduleDescriptor
|
frontendOutput.moduleDescriptor
|
||||||
).also {
|
).also {
|
||||||
|
|||||||
-62
@@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.backend.konan.driver
|
|
||||||
|
|
||||||
import kotlinx.cinterop.usingJvmCInteropCallbacks
|
|
||||||
import org.jetbrains.kotlin.backend.common.phaser.invokeToplevel
|
|
||||||
import org.jetbrains.kotlin.backend.konan.*
|
|
||||||
import org.jetbrains.kotlin.backend.konan.driver.phases.FrontendContextImpl
|
|
||||||
import org.jetbrains.kotlin.backend.konan.driver.phases.FrontendPhase
|
|
||||||
import org.jetbrains.kotlin.backend.konan.driver.phases.FrontendPhaseOutput
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
|
||||||
import org.jetbrains.kotlin.konan.util.usingNativeMemoryAllocator
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static compiler uses statically-defined compilation pipeline and a single Context during whole compilation.
|
|
||||||
* Superseded by [DynamicCompilerDriver] and will be removed once dynamic driver become complete.
|
|
||||||
*/
|
|
||||||
internal class StaticCompilerDriver : CompilerDriver() {
|
|
||||||
override fun run(config: KonanConfig, environment: KotlinCoreEnvironment) {
|
|
||||||
runTopLevelPhases(config, environment)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun runTopLevelPhases(konanConfig: KonanConfig, environment: KotlinCoreEnvironment) {
|
|
||||||
|
|
||||||
val config = konanConfig.configuration
|
|
||||||
|
|
||||||
val targets = konanConfig.targetManager
|
|
||||||
if (config.get(KonanConfigKeys.LIST_TARGETS) ?: false) {
|
|
||||||
targets.list()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (konanConfig.infoArgsOnly) return
|
|
||||||
|
|
||||||
val frontendContext = FrontendContextImpl(konanConfig)
|
|
||||||
val frontendOutput = FrontendPhase.phaseBody(frontendContext, environment)
|
|
||||||
if (frontendOutput is FrontendPhaseOutput.ShouldNotGenerateCode) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
require(frontendOutput is FrontendPhaseOutput.Full)
|
|
||||||
val context = Context(
|
|
||||||
konanConfig,
|
|
||||||
environment,
|
|
||||||
frontendOutput.frontendServices,
|
|
||||||
frontendOutput.bindingContext,
|
|
||||||
frontendOutput.moduleDescriptor,
|
|
||||||
)
|
|
||||||
context.phaseConfig.konanPhasesConfig(konanConfig) // TODO: Wrong place to call it
|
|
||||||
|
|
||||||
usingNativeMemoryAllocator {
|
|
||||||
usingJvmCInteropCallbacks {
|
|
||||||
try {
|
|
||||||
toplevelPhase.invokeToplevel(context.phaseConfig, context, Unit)
|
|
||||||
} finally {
|
|
||||||
context.disposeGenerationState()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-10
@@ -310,16 +310,6 @@ internal val optimizeTLSDataLoadsPhase = makeKonanModuleOpPhase(
|
|||||||
op = { context, _ -> removeMultipleThreadDataLoads(context.generationState) }
|
op = { context, _ -> removeMultipleThreadDataLoads(context.generationState) }
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val produceOutputPhase = namedUnitPhase(
|
|
||||||
name = "ProduceOutput",
|
|
||||||
description = "Produce output",
|
|
||||||
lower = object : CompilerPhase<Context, Unit, Unit> {
|
|
||||||
override fun invoke(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Unit>, context: Context, input: Unit) {
|
|
||||||
produceOutput(context.generationState)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
internal val removeRedundantSafepointsPhase = makeKonanModuleOpPhase(
|
internal val removeRedundantSafepointsPhase = makeKonanModuleOpPhase(
|
||||||
name = "RemoveRedundantSafepoints",
|
name = "RemoveRedundantSafepoints",
|
||||||
description = "Remove function prologue safepoints inlined to another function",
|
description = "Remove function prologue safepoints inlined to another function",
|
||||||
|
|||||||
Reference in New Issue
Block a user