[kotlin compiler][update] 1.3.40-dev-661

Refactor CommonBackendContext, remove confusing methods
(cherry picked from commit 55f90d256d425490aa05dbe1de9730fe485a32a5)
This commit is contained in:
Vasily Levchenko
2019-03-18 15:58:58 +03:00
parent a16bddb421
commit 0dd71c979f
6 changed files with 46 additions and 60 deletions
@@ -201,10 +201,6 @@ internal class Context(config: KonanConfig) : KonanBackendContext(config) {
override val declarationFactory override val declarationFactory
get() = TODO("not implemented") get() = TODO("not implemented")
override fun getClass(fqName: FqName): ClassDescriptor {
TODO("not implemented")
}
lateinit var moduleDescriptor: ModuleDescriptor lateinit var moduleDescriptor: ModuleDescriptor
lateinit var objCExport: ObjCExport lateinit var objCExport: ObjCExport
@@ -36,10 +36,10 @@ abstract internal class KonanBackendContext(val config: KonanConfig) : CommonBac
KonanSharedVariablesManager(this) KonanSharedVariablesManager(this)
} }
override fun getInternalClass(name: String): ClassDescriptor = fun getKonanInternalClass(name: String): ClassDescriptor =
builtIns.kotlinNativeInternal.getContributedClassifier(Name.identifier(name), NoLookupLocation.FROM_BACKEND) as ClassDescriptor builtIns.kotlinNativeInternal.getContributedClassifier(Name.identifier(name), NoLookupLocation.FROM_BACKEND) as ClassDescriptor
override fun getInternalFunctions(name: String): List<FunctionDescriptor> = fun getKonanInternalFunctions(name: String): List<FunctionDescriptor> =
builtIns.kotlinNativeInternal.getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_BACKEND).toList() builtIns.kotlinNativeInternal.getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_BACKEND).toList()
val messageCollector: MessageCollector val messageCollector: MessageCollector
@@ -72,4 +72,4 @@ private fun createCompilerMessageLocation(containingFile: IrFile, startOffset: I
column = sourceRangeInfo.startColumnNumber + 1, column = sourceRangeInfo.startColumnNumber + 1,
lineContent = null // TODO: retrieve the line content. lineContent = null // TODO: retrieve the line content.
) )
} }
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.ir.declarations.IrEnumEntry
import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl
@@ -123,9 +124,6 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val
} && !it.isExpect } && !it.isExpect
} }
override val lateinitIsInitializedPropertyGetter: IrSimpleFunctionSymbol
= symbolTable.referenceSimpleFunction(isInitializedPropertyDescriptor.getter!!)
val entryPoint = findMainEntryPoint(context)?.let { symbolTable.referenceSimpleFunction(it) } val entryPoint = findMainEntryPoint(context)?.let { symbolTable.referenceSimpleFunction(it) }
override val externalSymbolTable = lazySymbolTable override val externalSymbolTable = lazySymbolTable
@@ -244,13 +242,11 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val
val getNativeNullPtr = symbolTable.referenceSimpleFunction(context.getNativeNullPtr) val getNativeNullPtr = symbolTable.referenceSimpleFunction(context.getNativeNullPtr)
val boxCachePredicates = BoxCache.values().associate { val boxCachePredicates = BoxCache.values().associate {
val name = "in${it.name.toLowerCase().capitalize()}BoxCache" it to internalFunction("in${it.name.toLowerCase().capitalize()}BoxCache")
it to symbolTable.referenceSimpleFunction(context.getInternalFunctions(name).single())
} }
val boxCacheGetters = BoxCache.values().associate { val boxCacheGetters = BoxCache.values().associate {
val name = "getCached${it.name.toLowerCase().capitalize()}Box" it to internalFunction("getCached${it.name.toLowerCase().capitalize()}Box")
it to symbolTable.referenceSimpleFunction(context.getInternalFunctions(name).single())
} }
val immutableBlob = symbolTable.referenceClass( val immutableBlob = symbolTable.referenceClass(
@@ -261,13 +257,13 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val
val executeImpl = symbolTable.referenceSimpleFunction(context.interopBuiltIns.executeImplFunction) val executeImpl = symbolTable.referenceSimpleFunction(context.interopBuiltIns.executeImplFunction)
val areEqualByValue = context.getInternalFunctions("areEqualByValue").map { val areEqualByValue = context.getKonanInternalFunctions("areEqualByValue").map {
symbolTable.referenceSimpleFunction(it) symbolTable.referenceSimpleFunction(it)
}.associateBy { it.descriptor.valueParameters[0].type.computePrimitiveBinaryTypeOrNull()!! } }.associateBy { it.descriptor.valueParameters[0].type.computePrimitiveBinaryTypeOrNull()!! }
val reinterpret = symbolTable.referenceSimpleFunction(context.getInternalFunctions("reinterpret").single()) val reinterpret = internalFunction("reinterpret")
val ieee754Equals = context.getInternalFunctions("ieee754Equals").map { val ieee754Equals = context.getKonanInternalFunctions("ieee754Equals").map {
symbolTable.referenceSimpleFunction(it) symbolTable.referenceSimpleFunction(it)
} }
@@ -275,26 +271,17 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val
.getContributedFunctions(Name.identifier("equals"), NoLookupLocation.FROM_BACKEND) .getContributedFunctions(Name.identifier("equals"), NoLookupLocation.FROM_BACKEND)
.single().let { symbolTable.referenceSimpleFunction(it) } .single().let { symbolTable.referenceSimpleFunction(it) }
override val areEqual get() = error("Must not be used") val throwArithmeticException = internalFunction("ThrowArithmeticException")
val throwArithmeticException = symbolTable.referenceSimpleFunction( override val ThrowNullPointerException = internalFunction("ThrowNullPointerException")
context.getInternalFunctions("ThrowArithmeticException").single())
override val ThrowNullPointerException = symbolTable.referenceSimpleFunction( override val ThrowNoWhenBranchMatchedException = internalFunction("ThrowNoWhenBranchMatchedException")
context.getInternalFunctions("ThrowNullPointerException").single())
override val ThrowNoWhenBranchMatchedException = symbolTable.referenceSimpleFunction( override val ThrowTypeCastException = internalFunction("ThrowTypeCastException")
context.getInternalFunctions("ThrowNoWhenBranchMatchedException").single())
override val ThrowTypeCastException = symbolTable.referenceSimpleFunction( val throwInvalidReceiverTypeException = internalFunction("ThrowInvalidReceiverTypeException")
context.getInternalFunctions("ThrowTypeCastException").single())
val throwInvalidReceiverTypeException = symbolTable.referenceSimpleFunction( override val ThrowUninitializedPropertyAccessException = internalFunction("ThrowUninitializedPropertyAccessException")
context.getInternalFunctions("ThrowInvalidReceiverTypeException").single())
override val ThrowUninitializedPropertyAccessException = symbolTable.referenceSimpleFunction(
context.getInternalFunctions("ThrowUninitializedPropertyAccessException").single()
)
override val stringBuilder = symbolTable.referenceClass( override val stringBuilder = symbolTable.referenceClass(
builtInsPackage("kotlin", "text").getContributedClassifier( builtInsPackage("kotlin", "text").getContributedClassifier(
@@ -302,9 +289,13 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val
) as ClassDescriptor ) as ClassDescriptor
) )
val checkProgressionStep = context.getInternalFunctions("checkProgressionStep") override val defaultConstructorMarker = symbolTable.referenceClass(
context.getKonanInternalClass("DefaultConstructorMarker")
)
val checkProgressionStep = context.getKonanInternalFunctions("checkProgressionStep")
.map { Pair(it.returnType, symbolTable.referenceSimpleFunction(it)) }.toMap() .map { Pair(it.returnType, symbolTable.referenceSimpleFunction(it)) }.toMap()
val getProgressionLast = context.getInternalFunctions("getProgressionLast") val getProgressionLast = context.getKonanInternalFunctions("getProgressionLast")
.map { Pair(it.returnType, symbolTable.referenceSimpleFunction(it)) }.toMap() .map { Pair(it.returnType, symbolTable.referenceSimpleFunction(it)) }.toMap()
val arrayContentToString = arrays.associateBy( val arrayContentToString = arrays.associateBy(
@@ -328,6 +319,12 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val
} }
override val copyRangeTo get() = TODO() override val copyRangeTo get() = TODO()
fun getNoParamFunction(name: Name, receiverType: KotlinType): IrFunctionSymbol {
val descriptor = receiverType.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_BACKEND)
.first { it.valueParameters.isEmpty() }
return symbolTable.referenceFunction(descriptor)
}
val copyInto = arrays.map { symbol -> val copyInto = arrays.map { symbol ->
val packageViewDescriptor = builtIns.builtInsModule.getPackage(KotlinBuiltIns.COLLECTIONS_PACKAGE_FQ_NAME) val packageViewDescriptor = builtIns.builtInsModule.getPackage(KotlinBuiltIns.COLLECTIONS_PACKAGE_FQ_NAME)
val functionDescriptor = packageViewDescriptor.memberScope val functionDescriptor = packageViewDescriptor.memberScope
@@ -353,11 +350,9 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val
.single().let { symbolTable.referenceSimpleFunction(it.getter!!) } } .single().let { symbolTable.referenceSimpleFunction(it.getter!!) } }
val valuesForEnum = symbolTable.referenceSimpleFunction( val valuesForEnum = internalFunction("valuesForEnum")
context.getInternalFunctions("valuesForEnum").single())
val valueOfForEnum = symbolTable.referenceSimpleFunction( val valueOfForEnum = internalFunction("valueOfForEnum")
context.getInternalFunctions("valueOfForEnum").single())
val enumValues = symbolTable.referenceSimpleFunction( val enumValues = symbolTable.referenceSimpleFunction(
builtInsPackage("kotlin").getContributedFunctions( builtInsPackage("kotlin").getContributedFunctions(
@@ -367,11 +362,9 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val
builtInsPackage("kotlin").getContributedFunctions( builtInsPackage("kotlin").getContributedFunctions(
Name.identifier("enumValueOf"), NoLookupLocation.FROM_BACKEND).single()) Name.identifier("enumValueOf"), NoLookupLocation.FROM_BACKEND).single())
val createUninitializedInstance = symbolTable.referenceSimpleFunction( val createUninitializedInstance = internalFunction("createUninitializedInstance")
context.getInternalFunctions("createUninitializedInstance").single())
val initInstance = symbolTable.referenceSimpleFunction( val initInstance = internalFunction("initInstance")
context.getInternalFunctions("initInstance").single())
val freeze = symbolTable.referenceSimpleFunction( val freeze = symbolTable.referenceSimpleFunction(
builtInsPackage("kotlin", "native", "concurrent").getContributedFunctions( builtInsPackage("kotlin", "native", "concurrent").getContributedFunctions(
@@ -387,17 +380,13 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val
Name.identifier("toString"), NoLookupLocation.FROM_BACKEND) Name.identifier("toString"), NoLookupLocation.FROM_BACKEND)
.single { it.extensionReceiverParameter?.type == builtIns.nullableAnyType}) .single { it.extensionReceiverParameter?.type == builtIns.nullableAnyType})
val getContinuation = symbolTable.referenceSimpleFunction( val getContinuation = internalFunction("getContinuation")
context.getInternalFunctions("getContinuation").single())
val returnIfSuspended = symbolTable.referenceSimpleFunction( val returnIfSuspended = internalFunction("returnIfSuspended")
context.getInternalFunctions("returnIfSuspended").single())
val konanSuspendCoroutineUninterceptedOrReturn = symbolTable.referenceSimpleFunction( val konanSuspendCoroutineUninterceptedOrReturn = internalFunction("suspendCoroutineUninterceptedOrReturn")
context.getInternalFunctions("suspendCoroutineUninterceptedOrReturn").single())
val konanCoroutineContextGetter = symbolTable.referenceSimpleFunction( val konanCoroutineContextGetter = internalFunction("getCoroutineContext")
context.getInternalFunctions("getCoroutineContext").single())
private val coroutinesIntrinsicsPackage = context.builtIns.builtInsModule.getPackage( private val coroutinesIntrinsicsPackage = context.builtIns.builtInsModule.getPackage(
context.config.configuration.languageVersionSettings.coroutinesIntrinsicsPackageFqName()).memberScope context.config.configuration.languageVersionSettings.coroutinesIntrinsicsPackageFqName()).memberScope
@@ -437,7 +426,7 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val
} }
) )
val refClass = symbolTable.referenceClass(context.getInternalClass("Ref")) val refClass = symbolTable.referenceClass(context.getKonanInternalClass("Ref"))
val kFunctionImpl = symbolTable.referenceClass(context.reflectionTypes.kFunctionImpl) val kFunctionImpl = symbolTable.referenceClass(context.reflectionTypes.kFunctionImpl)
@@ -479,10 +468,10 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable, val
symbolTable.referenceClass(builtIns.builtInsModule.findClassAcrossModuleDependencies(classId)!!) symbolTable.referenceClass(builtIns.builtInsModule.findClassAcrossModuleDependencies(classId)!!)
private fun internalFunction(name: String): IrSimpleFunctionSymbol = private fun internalFunction(name: String): IrSimpleFunctionSymbol =
symbolTable.referenceSimpleFunction(context.getInternalFunctions(name).single()) symbolTable.referenceSimpleFunction(context.getKonanInternalFunctions(name).single())
private fun internalClass(name: String): IrClassSymbol = private fun internalClass(name: String): IrClassSymbol =
symbolTable.referenceClass(context.getInternalClass(name)) symbolTable.referenceClass(context.getKonanInternalClass(name))
private fun getKonanTestClass(className: String) = symbolTable.referenceClass( private fun getKonanTestClass(className: String) = symbolTable.referenceClass(
builtInsPackage("kotlin", "native", "internal", "test").getContributedClassifier( builtInsPackage("kotlin", "native", "internal", "test").getContributedClassifier(
@@ -533,4 +522,4 @@ private fun getArrayListClassDescriptor(context: Context): ClassDescriptor {
NoLookupLocation.FROM_BACKEND) NoLookupLocation.FROM_BACKEND)
return classifier as ClassDescriptor return classifier as ClassDescriptor
} }
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.backend.konan.lower
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
import org.jetbrains.kotlin.backend.common.ScopeWithIr import org.jetbrains.kotlin.backend.common.ScopeWithIr
import org.jetbrains.kotlin.backend.common.ir.createTemporaryVariableWithWrappedDescriptor import org.jetbrains.kotlin.backend.common.ir.createTemporaryVariableWithWrappedDescriptor
import org.jetbrains.kotlin.backend.common.ir.Symbols
import org.jetbrains.kotlin.backend.common.isBuiltInIntercepted import org.jetbrains.kotlin.backend.common.isBuiltInIntercepted
import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineUninterceptedOrReturn import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineUninterceptedOrReturn
import org.jetbrains.kotlin.backend.common.lower.CoroutineIntrinsicLambdaOrigin import org.jetbrains.kotlin.backend.common.lower.CoroutineIntrinsicLambdaOrigin
@@ -42,7 +43,7 @@ internal class FunctionInlining(val context: Context) : IrElementTransformerVoid
val callSite = super.visitCall(expression) as IrCall val callSite = super.visitCall(expression) as IrCall
if (!callSite.symbol.owner.needsInlining) if (!callSite.symbol.owner.needsInlining)
return callSite return callSite
if (callSite.symbol == context.ir.symbols.lateinitIsInitializedPropertyGetter) if (Symbols.isLateinitIsInitializedPropertyGetter(callSite.symbol))
return callSite return callSite
val callee = getFunctionDeclaration(callSite.symbol) val callee = getFunctionDeclaration(callSite.symbol)
@@ -220,7 +220,7 @@ internal class HeaderProcessor(
return if (type.classifierOrNull == progressionType.elementType(context).classifierOrNull) { return if (type.classifierOrNull == progressionType.elementType(context).classifierOrNull) {
this this
} else { } else {
val function = symbols.getFunction(progressionType.numberCastFunctionName, type.toKotlinType()) val function = symbols.getNoParamFunction(progressionType.numberCastFunctionName, type.toKotlinType())
IrCallImpl(startOffset, endOffset, function.owner.returnType, function) IrCallImpl(startOffset, endOffset, function.owner.returnType, function)
.apply { dispatchReceiver = this@castIfNecessary } .apply { dispatchReceiver = this@castIfNecessary }
} }
@@ -266,4 +266,4 @@ internal class HeaderProcessor(
putValueArgument(2, IrGetValueImpl(startOffset, endOffset, step.type, step.symbol)) putValueArgument(2, IrGetValueImpl(startOffset, endOffset, step.type, step.symbol))
} }
} }
} }
+3 -3
View File
@@ -18,9 +18,9 @@
buildKotlinVersion=1.3.30-dev-1945 buildKotlinVersion=1.3.30-dev-1945
buildKotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_CompilerAllPlugins),number:1.3.30-dev-1945,pinned:true/artifacts/content/maven buildKotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_CompilerAllPlugins),number:1.3.30-dev-1945,pinned:true/artifacts/content/maven
remoteRoot=konan_tests remoteRoot=konan_tests
kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_CompilerAllPlugins),number:1.3.40-dev-605,branch:default:true,pinned:true/artifacts/content/maven kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_CompilerAllPlugins),number:1.3.40-dev-661,branch:default:true,pinned:true/artifacts/content/maven
kotlinVersion=1.3.40-dev-605 kotlinVersion=1.3.40-dev-661
testKotlinVersion=1.3.40-dev-605 testKotlinVersion=1.3.40-dev-661
sharedRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinNativeShared_BuildAndTest),number:1.0-dev-16,branch:default:true,pinned:true/artifacts/content/maven sharedRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinNativeShared_BuildAndTest),number:1.0-dev-16,branch:default:true,pinned:true/artifacts/content/maven
sharedVersion=1.0-dev-16 sharedVersion=1.0-dev-16
konanVersion=1.3.0 konanVersion=1.3.0