Fix warnings in compiler and interop
This commit is contained in:
committed by
Pavel Punegov
parent
c1fa7f0f79
commit
3e153e5937
@@ -74,7 +74,7 @@ sourceSets.main.kotlin.srcDirs += "src/jvm/kotlin"
|
|||||||
|
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
freeCompilerArgs = ['-Xuse-experimental=kotlin.ExperimentalUnsignedTypes']
|
freeCompilerArgs = ['-Xuse-experimental=kotlin.ExperimentalUnsignedTypes', "-XXLanguage:+InlineClasses"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,5 +73,4 @@ public inline class StableRef<out T : Any> @PublishedApi internal constructor(
|
|||||||
/**
|
/**
|
||||||
* Converts to [StableRef] this opaque pointer produced by [StableRef.asCPointer].
|
* Converts to [StableRef] this opaque pointer produced by [StableRef.asCPointer].
|
||||||
*/
|
*/
|
||||||
inline fun <reified T : Any> CPointer<*>.asStableRef(): StableRef<T> = StableRef<T>(this)
|
inline fun <reified T : Any> CPointer<*>.asStableRef(): StableRef<T> = StableRef<T>(this).also { it.get() }
|
||||||
.also { it.get() as T }
|
|
||||||
|
|||||||
+1
@@ -398,6 +398,7 @@ private val ObjCClassOrProtocol.superTypes: Sequence<ObjCClassOrProtocol>
|
|||||||
private fun ObjCClassOrProtocol.declaredMethods(isClass: Boolean): Sequence<ObjCMethod> =
|
private fun ObjCClassOrProtocol.declaredMethods(isClass: Boolean): Sequence<ObjCMethod> =
|
||||||
this.methods.asSequence().filter { it.isClass == isClass }
|
this.methods.asSequence().filter { it.isClass == isClass }
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
private fun Sequence<ObjCMethod>.inheritedTo(container: ObjCClassOrProtocol, isMeta: Boolean): Sequence<ObjCMethod> =
|
private fun Sequence<ObjCMethod>.inheritedTo(container: ObjCClassOrProtocol, isMeta: Boolean): Sequence<ObjCMethod> =
|
||||||
this // TODO: exclude methods that are marked as unavailable in [container].
|
this // TODO: exclude methods that are marked as unavailable in [container].
|
||||||
|
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ targetList.each { target ->
|
|||||||
args = [*konanArgs,
|
args = [*konanArgs,
|
||||||
'-output', project(':runtime').file("build/${target}Stdlib"),
|
'-output', project(':runtime').file("build/${target}Stdlib"),
|
||||||
'-produce', 'library', '-module-name', 'stdlib', '-XXLanguage:+AllowContractsForCustomFunctions',
|
'-produce', 'library', '-module-name', 'stdlib', '-XXLanguage:+AllowContractsForCustomFunctions',
|
||||||
'-Xmulti-platform', '-Xuse-experimental=kotlin.Experimental',
|
'-Xmulti-platform', '-Xuse-experimental=kotlin.Experimental', '-XXLanguage:+InlineClasses',
|
||||||
'-Xuse-experimental=kotlin.contracts.ExperimentalContracts',
|
'-Xuse-experimental=kotlin.contracts.ExperimentalContracts',
|
||||||
'-Xuse-experimental=kotlin.ExperimentalMultiplatform',
|
'-Xuse-experimental=kotlin.ExperimentalMultiplatform',
|
||||||
'-Xallow-result-return-type',
|
'-Xallow-result-return-type',
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.serialization.konan.KonanMetadataVersion
|
|||||||
|
|
||||||
private class K2NativeCompilerPerformanceManager: CommonCompilerPerformanceManager("Kotlin to Native Compiler")
|
private class K2NativeCompilerPerformanceManager: CommonCompilerPerformanceManager("Kotlin to Native Compiler")
|
||||||
class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||||
override fun createMetadataVersion(p0: IntArray): BinaryVersion = KonanMetadataVersion(*p0)
|
override fun createMetadataVersion(versionArray: IntArray): BinaryVersion = KonanMetadataVersion(*versionArray)
|
||||||
|
|
||||||
override val performanceManager:CommonCompilerPerformanceManager by lazy {
|
override val performanceManager:CommonCompilerPerformanceManager by lazy {
|
||||||
K2NativeCompilerPerformanceManager()
|
K2NativeCompilerPerformanceManager()
|
||||||
|
|||||||
+1
-1
@@ -299,7 +299,7 @@ internal class Context(config: KonanConfig) : KonanBackendContext(config) {
|
|||||||
get() = ir.irModule.irBuiltins
|
get() = ir.irModule.irBuiltins
|
||||||
|
|
||||||
val interopBuiltIns by lazy {
|
val interopBuiltIns by lazy {
|
||||||
InteropBuiltIns(this.builtIns, nativePtr)
|
InteropBuiltIns(this.builtIns)
|
||||||
}
|
}
|
||||||
|
|
||||||
var llvmModule: LLVMModuleRef? = null
|
var llvmModule: LLVMModuleRef? = null
|
||||||
|
|||||||
+1
-2
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
|
||||||
|
|
||||||
object InteropFqNames {
|
object InteropFqNames {
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@ object InteropFqNames {
|
|||||||
val nativePointed = packageName.child(Name.identifier(nativePointedName)).toUnsafe()
|
val nativePointed = packageName.child(Name.identifier(nativePointedName)).toUnsafe()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class InteropBuiltIns(builtIns: KonanBuiltIns, vararg konanPrimitives: ClassDescriptor) {
|
internal class InteropBuiltIns(builtIns: KonanBuiltIns) {
|
||||||
|
|
||||||
val packageScope = builtIns.builtInsModule.getPackage(InteropFqNames.packageName).memberScope
|
val packageScope = builtIns.builtInsModule.getPackage(InteropFqNames.packageName).memberScope
|
||||||
|
|
||||||
|
|||||||
-1
@@ -193,7 +193,6 @@ internal class LinkStage(val context: Context, val phaser: PhaseManager) {
|
|||||||
}
|
}
|
||||||
} catch (e: KonanExternalToolFailure) {
|
} catch (e: KonanExternalToolFailure) {
|
||||||
context.reportCompilationError("${e.toolName} invocation reported errors")
|
context.reportCompilationError("${e.toolName} invocation reported errors")
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
return executable
|
return executable
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-10
@@ -7,19 +7,15 @@ package org.jetbrains.kotlin.backend.konan.llvm
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.backend.konan.*
|
import org.jetbrains.kotlin.backend.konan.*
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.isArray
|
import org.jetbrains.kotlin.backend.konan.descriptors.isArray
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
|
||||||
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.name.Name
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||||
import org.jetbrains.kotlin.utils.alwaysTrue
|
|
||||||
|
|
||||||
internal fun findMainEntryPoint(context: Context): FunctionDescriptor? {
|
internal fun findMainEntryPoint(context: Context): FunctionDescriptor? {
|
||||||
|
|
||||||
@@ -43,14 +39,10 @@ internal fun findMainEntryPoint(context: Context): FunctionDescriptor? {
|
|||||||
val main =
|
val main =
|
||||||
candidates.singleOrNull { it.hasSingleArrayOfStringParameter } ?:
|
candidates.singleOrNull { it.hasSingleArrayOfStringParameter } ?:
|
||||||
candidates.singleOrNull { it.hasNoParameters } ?:
|
candidates.singleOrNull { it.hasNoParameters } ?:
|
||||||
run {
|
context.reportCompilationError("Could not find '$entryName' in '$packageName' package.")
|
||||||
context.reportCompilationError("Could not find '$entryName' in '$packageName' package.")
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (main != null && main.isSuspend) {
|
if (main.isSuspend) {
|
||||||
context.reportCompilationError("Entry point can not be a suspend function.")
|
context.reportCompilationError("Entry point can not be a suspend function.")
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return main
|
return main
|
||||||
|
|||||||
+2
-2
@@ -1016,7 +1016,7 @@ internal object Devirtualization {
|
|||||||
.asSequence()
|
.asSequence()
|
||||||
.filter { it.key.irCallSite != null }
|
.filter { it.key.irCallSite != null }
|
||||||
.associate { it.key.irCallSite!! to it.value }
|
.associate { it.key.irCallSite!! to it.value }
|
||||||
devirtualize(irModule, context, moduleDFG, externalModulesDFG, devirtualizedCallSites)
|
devirtualize(irModule, context, externalModulesDFG, devirtualizedCallSites)
|
||||||
removeRedundantCoercions(irModule, context, moduleDFG, externalModulesDFG)
|
removeRedundantCoercions(irModule, context, moduleDFG, externalModulesDFG)
|
||||||
return AnalysisResult(devirtualizationAnalysisResult)
|
return AnalysisResult(devirtualizationAnalysisResult)
|
||||||
}
|
}
|
||||||
@@ -1040,7 +1040,7 @@ internal object Devirtualization {
|
|||||||
|| (this is IrPrivateFunctionCall && specialNames.any { dfgSymbol.name?.contains(it) == true })
|
|| (this is IrPrivateFunctionCall && specialNames.any { dfgSymbol.name?.contains(it) == true })
|
||||||
|
|
||||||
private fun devirtualize(irModule: IrModuleFragment, context: Context,
|
private fun devirtualize(irModule: IrModuleFragment, context: Context,
|
||||||
moduleDFG: ModuleDFG, externalModulesDFG: ExternalModulesDFG,
|
externalModulesDFG: ExternalModulesDFG,
|
||||||
devirtualizedCallSites: Map<IrCall, DevirtualizedCallSite>) {
|
devirtualizedCallSites: Map<IrCall, DevirtualizedCallSite>) {
|
||||||
val symbols = context.ir.symbols
|
val symbols = context.ir.symbols
|
||||||
val nativePtrEqualityOperatorSymbol = symbols.areEqualByValue[PrimitiveBinaryType.POINTER]!!
|
val nativePtrEqualityOperatorSymbol = symbols.areEqualByValue[PrimitiveBinaryType.POINTER]!!
|
||||||
|
|||||||
Reference in New Issue
Block a user