[kotlin compiler][update] 1.3.70-dev-1526

* 9a55f418fa - (tag: build-1.3.70-dev-1526) IR: extract StaticInitializersLowering out of InitializersLowering (15 hours ago) <Alexander Udalov>
* 098561dd5f - IR: cleanup InitializersLowering.kt (15 hours ago) <Alexander Udalov>
* 9772de0088 - JVM IR: generate kotlin.Metadata.packageName value for JvmPackageName files (16 hours ago) <Alexander Udalov>
* 808000e458 - (tag: build-1.3.70-dev-1525) Implement warning when non-abstract classes containing abstract members invisible from that classes (16 hours ago) <Ilya Chernikov>
* eae3688c61 - (tag: build-1.3.70-dev-1524) [FIR] Fix collecting approved data flow info from rhs of boolean operator (16 hours ago) <Dmitriy Novozhilov>
* 8d6cfdf0b1 - [FIR] Fix passing data flow info from while loop condition (16 hours ago) <Dmitriy Novozhilov>
* 7ef13caa33 - [FIR] Add test for ambiguity in nested class constructor call (16 hours ago) <Dmitriy Novozhilov>
* e9551e2022 - [FIR] Don't generate setter by delegate for vals (16 hours ago) <Dmitriy Novozhilov>
* 2f2aa4ae83 - [FIR] Create error type instead of implicit type for incorrect functional types (16 hours ago) <Dmitriy Novozhilov>
* cf61a6c30f - [FIR] Add support of multiple condition branches to exhaustiveness checker (16 hours ago) <Dmitriy Novozhilov>
* 86570a2f91 - [KLIB] Promote ABI version (16 hours ago) <Roman Artemev>
* 63110ab636 - [IR] Remove deprecated `correspondingProperty` from IrField (16 hours ago) <Roman Artemev>
* 646df8d40a - [IR BE] Get rid of descriptor usage in KCallable name property lowering (16 hours ago) <Roman Artemev>
* ec1c2eb42d - [IR] Remove deprecated `correspondingProperty` from IrSimpleFunction (16 hours ago) <Roman Artemev>
* a343a57207 - [IR] Refactor ir infrastructure  - Remove range-based uniq id indexes using to link built ins  - Limit KotlinType usages, replace them with corresponding IrType (16 hours ago) <Roman Artemev>
* 90d07eee53 - [IR] Move wrapped descriptors from `backend.common` to `ir.descriptors` (16 hours ago) <Roman Artemev>
* ed79ab68ab - [IR] Remove DeclarationDescriptor from IrExpression* tree API (16 hours ago) <Roman Artemev>
* d4fc7fcd96 - [IR] Get rid of substituted descriptor from IrMemberAccessExpression interface (16 hours ago) <Roman Artemev>
* b391c066d6 - [IR] Pass class Type Parameters into IrConstructorCall factory explicitly  to avoid unexpected crash on uninitialized parent in psi2ir phase (16 hours ago) <Roman Artemev>
* ba373c67d7 - [IR] Remove FunctionDescriptor from IrCall-like node's constructor interface (16 hours ago) <Roman Artemev>
* bf367003f9 - [IR] Make IrMemberAccessExpression be IrDeclarationReference (16 hours ago) <Roman Artemev>
* eee594101a - [IR] Remove superQualifier property from IrCall (16 hours ago) <Roman Artemev>
* ea5b529d19 - (tag: build-1.3.70-dev-1522) Check default parameters of expect suspend functions on original (17 hours ago) <Ilmir Usmanov>
*   633d1c9ea3 - (tag: build-1.3.70-dev-1518) Merge pull request #2773 from t-kameyama/KT-28607 (18 hours ago) <igoriakovlev>
|\
| * d04f88ff66 - (origin/rr/Alefas/KT-28607) Extract/Introduce variable: fix to work correctly if caret is before right parenthesis or comment (31 hours ago) <Toshiaki Kameyama>
* | 42c4591df8 - (tag: build-1.3.70-dev-1510) [JS IR] Add -Xgenerate-dts CLI argument (18 hours ago) <Svyatoslav Kuzmich>
* | e81fbe0a05 - (tag: build-1.3.70-dev-1501) Folding: fold function with expression body (KT-6316) (21 hours ago) <Toshiaki Kameyama>
* | 58fb1dede3 - Multiline string enter handler: do not insert 'trimIndent()' in const (KT-34785) (21 hours ago) <Toshiaki Kameyama>
* | ce0fb662c0 - (tag: build-1.3.70-dev-1497) JVM_IR: fold inline lambdas when computing OUTERCLASS (22 hours ago) <pyos>
* | f906524d76 - (tag: build-1.3.70-dev-1495) Mark a SAM conversion test as JVM-only (22 hours ago) <pyos>
* | c66b6b6a3a - (tag: build-1.3.70-dev-1485, tag: build-1.3.70-dev-1481) FIR visibility check: support companion private members correctly (25 hours ago) <Mikhail Glukhikh>
* | e96aeb77a6 - FIR visibility check: support private class members (25 hours ago) <Mikhail Glukhikh>
* | a5ad05083a - Add some stubs for FIR visibility checking (25 hours ago) <Mikhail Glukhikh>
* | 7e07b88eab - (tag: build-1.3.70-dev-1480) Code cleanup: FirCallResolver (26 hours ago) <Mikhail Glukhikh>
* | ac13a8c8b2 - Cone conflict resolver: extract JVM equivalent call filtering to a separate class (26 hours ago) <Mikhail Glukhikh>
* | 96c5003a13 - Cone conflict resolver: filter equivalent top-level callables (26 hours ago) <Mikhail Glukhikh>
* | dc10d25661 - (tag: build-1.3.70-dev-1479) Ensure ForLoopsLowering only handles the CharSequence.iterator() extension function from the standard library (kotlin.text.iterator()). (27 hours ago) <Mark Punzalan>
|/
* 1bd861c5eb - (tag: build-1.3.70-dev-1471) Save use_ni key state to log (2 days ago) <Simon Ogorodnik>
* 57a674e9e6 - (tag: build-1.3.70-dev-1468) Make fast class files reading mode default in compiler tests (2 days ago) <Alexander Udalov>
* dde2d08cfc - (tag: build-1.3.70-dev-1460) FIR resolve: add extra test for generic with bounds in Java (2 days ago) <Mikhail Glukhikh>
* f66b2ca772 - FIR resolve: add forgotten constraint subsystem from generic qualified access (2 days ago) <Mikhail Glukhikh>
* 26281bfe89 - FIR Java: use different names for anonymous parameters (p0, p1, p2, ...) (2 days ago) <Mikhail Glukhikh>
* c657d46437 - FIR Java: add nullable (instead of not-null) type parameter bounds (2 days ago) <Mikhail Glukhikh>
* db11c14fee - FIR Java: don't add type parameter bounds multiple times (2 days ago) <Mikhail Glukhikh>
* a18da68171 - (tag: build-1.3.70-dev-1457) Remove redundant `toList` call in `LazyJavaPackageScope` (2 days ago) <Roman Golyshev>
* 82fb5c4d19 - (tag: build-1.3.70-dev-1456) JVM_IR: move lambda captures to end of signature when inlining (2 days ago) <pyos>
* 433e0e4740 - (tag: build-1.3.70-dev-1455) JVM_IR: remember facade fqnames of imported classes (2 days ago) <pyos>
* 42cb53a380 - (tag: build-1.3.70-dev-1454) Always apply new script configuration in tests (2 days ago) <Natalia Selezneva>
* 423f1909fa - Disable script configuration update in AbstractInspectionTest (2 days ago) <Natalia Selezneva>
* 698d675efe - Scripting: fix saving to file attributes (2 days ago) <Sergey Rostov>
* 05e8acffa7 - Scripting: restore reports for applied configuration in case of previous error (2 days ago) <Sergey Rostov>
* 96b4ceb067 - scripting: skip loading when reverting to applied configuration (2 days ago) <Sergey Rostov>
* 2499c42ac4 - scripting: PsiModificationStamp add virtual file modification stamp (2 days ago) <Sergey Rostov>
* 789ad23e8d - Minor: isScriptDependenciesUpdaterDisabled -> isScriptChangesNotifierDisabled (2 days ago) <Sergey Rostov>
* 61b17de625 - Minor: change ScriptConfigurationCache.kt declarations order for better readability, more docs (2 days ago) <Sergey Rostov>
* fbb2b260dd - Split script configuration state into applied and loaded to make markUpToDate more clear (2 days ago) <Sergey Rostov>
* fde1d3fdf7 - Wrap exceptions from external script configuration loader with error handling (2 days ago) <Natalia Selezneva>
* 56eb86b7c6 - Remove KotlinGradleBuildScriptsResolver for IDEA < 191 (2 days ago) <Natalia Selezneva>
* 2a22cc23e9 - KotlinGradleBuildScriptsResolver: update to new API from IDEA Gradle plugin (2 days ago) <Natalia Selezneva>
* 8bb6cf81c5 - Extract logic common for different platforms to simplify bunch process (2 days ago) <Natalia Selezneva>
* e2928550ca - Fix retrieving virtual file (2 days ago) <Sergey Rostov>
* 9105e38041 - Mark not applied configuration as up-to-date, simplify concurrency handling (2 days ago) <Sergey Rostov>
* 0422abdb7b - LoadedScriptConfiguration and CachedConfigurationSnapshot are merged to ScriptConfigurationSnapshot (2 days ago) <Sergey Rostov>
* a89ce4c590 - BackgroundExecutor: cancel all tasks on user cancel, remove useless updateProgress call (2 days ago) <Sergey Rostov>
* 19d35d7f27 - Implement Gradle specific behavior for script configuration update logic (2 days ago) <Sergey Rostov>
* 548e8e27dc - Minor: rename parameter (2 days ago) <Natalia Selezneva>
* f0053ee34c - Minor: use properties instead of string constants (2 days ago) <Natalia Selezneva>
* 9d2cc484aa - ide, scripting: rework script configuration caching, introduce persistent fs cache (2 days ago) <Sergey Rostov>
* 915c9c367c - Minor: rename script related classes (2 days ago) <Natalia Selezneva>
* 33475f30bc - Minor: move files (2 days ago) <Natalia Selezneva>
* 9f3c2d0292 - build.gradle.kts: import script dependencies on Gradle Project sync (2 days ago) <Sergey Rostov>
* de54e549af - (tag: build-1.3.70-dev-1451) Refactor CHECK_BYTECODE_LISTING directive for JVM IR tests (2 days ago) <Alexander Udalov>
* ce09be3f59 - Add TargetBackend.isIR, simplify JVM IR test configuration (2 days ago) <Alexander Udalov>
* ab65a6bc6c - (tag: build-1.3.70-dev-1447) Build fix, tests regenerated (2 days ago) <Vladimir Ilmov>
* 608885d118 - (tag: build-1.3.70-dev-1445, origin/sbogolepov/metadata_only_libraries_support) [Linker] Extend KotlinIrLinker infrastructure to support libraries that doesn't contain IR. Also bump ABI version because of addition of `ir_provider` property (2 days ago) <Sergey Bogolepov>
* 5629627cca - (tag: build-1.3.70-dev-1444) Mobile MPP: Initialize Mobile MPP plugin (2 days ago) <Kirill Shmakov>
* f3770314c5 - (tag: build-1.3.70-dev-1443) Pill: Fix reflect dependency in compiler/fir.resolve module (2 days ago) <Yan Zhulanow>
* ef8b3cb72a - Prefer Kotlin Junit test run configurations when possible (KT-33787) (2 days ago) <Yan Zhulanow>
* 987307cf92 - Prefer Kotlin Gradle test run configurations when possible (KT-33787) (2 days ago) <Yan Zhulanow>
* 214810ca01 - (tag: build-1.3.70-dev-1439) Suspend test removed. Will be added later as part of appropriate ticket. (3 days ago) <Vladimir Ilmov>
This commit is contained in:
Igor Chevdar
2019-11-08 17:44:22 +03:00
parent 2358edf4e8
commit d6b20598e8
34 changed files with 183 additions and 178 deletions
@@ -93,7 +93,7 @@ internal abstract class AbstractValueUsageTransformer(
with(expression) {
dispatchReceiver = dispatchReceiver?.useAsDispatchReceiver(expression)
extensionReceiver = extensionReceiver?.useAsExtensionReceiver(expression)
for (index in descriptor.valueParameters.indices) {
for (index in symbol.owner.valueParameters.indices) {
val argument = getValueArgument(index) ?: continue
val parameter = symbol.owner.valueParameters[index]
putValueArgument(index, argument.useAsValueArgument(expression, parameter))
@@ -70,10 +70,6 @@ internal class InteropBuiltIns(builtIns: KonanBuiltIns) {
val typeOf = packageScope.getContributedFunctions("typeOf").single()
val concurrentPackageScope = builtIns.builtInsModule.getPackage(FqName("kotlin.native.concurrent")).memberScope
val executeImplFunction = concurrentPackageScope.getContributedFunctions("executeImpl").single()
private fun KonanBuiltIns.getUnsignedClass(unsignedType: UnsignedType): ClassDescriptor =
this.builtInsModule.findClassAcrossModuleDependencies(unsignedType.classId)!!
@@ -7,12 +7,15 @@ package org.jetbrains.kotlin.backend.konan
import org.jetbrains.kotlin.backend.konan.descriptors.findPackage
import org.jetbrains.kotlin.backend.konan.descriptors.getArgumentValueOrNull
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationValueOrNull
import org.jetbrains.kotlin.backend.konan.descriptors.getStringValue
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationStringValue
import org.jetbrains.kotlin.backend.konan.descriptors.getStringValueOrNull
import org.jetbrains.kotlin.backend.konan.ir.*
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.types.classifierOrFail
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.name.FqName
@@ -44,7 +47,6 @@ fun ClassDescriptor.isObjCClass(): Boolean =
fun KotlinType.isObjCObjectType(): Boolean =
(this.supertypes() + this).any { TypeUtils.getClassDescriptor(it)?.fqNameSafe == objCObjectFqName }
private fun IrClass.getAllSuperClassifiers(): List<IrClass> =
listOf(this) + this.superTypes.flatMap { (it.classifierOrFail.owner as IrClass).getAllSuperClassifiers() }
@@ -68,6 +70,10 @@ fun ClassDescriptor.isObjCMetaClass(): Boolean = this.getAllSuperClassifiers().a
it.fqNameSafe == objCClassFqName
}
fun IrClass.isObjCMetaClass(): Boolean = this.getAllSuperClassifiers().any {
it.fqNameForIrSerialization == objCClassFqName
}
fun IrClass.isObjCProtocolClass(): Boolean =
this.fqNameForIrSerialization == objCProtocolFqName
@@ -77,6 +83,9 @@ fun ClassDescriptor.isObjCProtocolClass(): Boolean =
fun FunctionDescriptor.isObjCClassMethod() =
this.containingDeclaration.let { it is ClassDescriptor && it.isObjCClass() }
fun IrFunction.isObjCClassMethod() =
this.parent.let { it is IrClass && it.isObjCClass() }
@Deprecated("Use IR version rather than descriptor version")
fun FunctionDescriptor.isExternalObjCClassMethod() =
this.containingDeclaration.let { it is ClassDescriptor && it.isExternalObjCClass() }
@@ -108,12 +117,24 @@ private fun FunctionDescriptor.decodeObjCMethodAnnotation(): ObjCMethodInfo? {
return objCMethodInfo(methodAnnotation)
}
private fun IrFunction.decodeObjCMethodAnnotation(): ObjCMethodInfo? {
assert (this.isReal)
val methodAnnotation = this.annotations.findAnnotation(objCMethodFqName) ?: return null
return objCMethodInfo(methodAnnotation)
}
private fun objCMethodInfo(annotation: AnnotationDescriptor) = ObjCMethodInfo(
selector = annotation.getStringValue("selector"),
encoding = annotation.getStringValue("encoding"),
isStret = annotation.getArgumentValueOrNull<Boolean>("isStret") ?: false
)
private fun objCMethodInfo(annotation: IrConstructorCall) = ObjCMethodInfo(
selector = annotation.getAnnotationStringValue("selector"),
encoding = annotation.getAnnotationStringValue("encoding"),
isStret = annotation.getAnnotationValueOrNull<Boolean>("isStret") ?: false
)
/**
* @param onlyExternal indicates whether to accept overriding methods from Kotlin classes
*/
@@ -129,10 +150,29 @@ private fun FunctionDescriptor.getObjCMethodInfo(onlyExternal: Boolean): ObjCMet
return this.overriddenDescriptors.asSequence().mapNotNull { it.getObjCMethodInfo(onlyExternal) }.firstOrNull()
}
/**
* @param onlyExternal indicates whether to accept overriding methods from Kotlin classes
*/
private fun IrSimpleFunction.getObjCMethodInfo(onlyExternal: Boolean): ObjCMethodInfo? {
if (this.isReal) {
this.decodeObjCMethodAnnotation()?.let { return it }
if (onlyExternal) {
return null
}
}
return this.overriddenSymbols.mapNotNull { it.owner.getObjCMethodInfo(onlyExternal) }.firstOrNull()
}
fun FunctionDescriptor.getExternalObjCMethodInfo(): ObjCMethodInfo? = this.getObjCMethodInfo(onlyExternal = true)
fun IrFunction.getExternalObjCMethodInfo(): ObjCMethodInfo? = (this as? IrSimpleFunction)?.getObjCMethodInfo(onlyExternal = true)
fun FunctionDescriptor.getObjCMethodInfo(): ObjCMethodInfo? = this.getObjCMethodInfo(onlyExternal = false)
fun IrFunction.getObjCMethodInfo(): ObjCMethodInfo? = (this as? IrSimpleFunction)?.getObjCMethodInfo(onlyExternal = false)
fun IrFunction.isObjCBridgeBased(): Boolean {
assert(this.isReal)
@@ -223,7 +263,7 @@ val IrConstructor.isObjCConstructor get() = this.annotations.hasAnnotation(objCC
// TODO-DCE-OBJC-INIT: Selector should be preserved by DCE.
fun IrConstructor.getObjCInitMethod(): IrSimpleFunction? {
return this.annotations.findAnnotation(objCConstructorFqName)?.let {
val initSelector = it.getStringValue("initSelector")
val initSelector = it.getAnnotationStringValue("initSelector")
this.constructedClass.declarations.asSequence()
.filterIsInstance<IrSimpleFunction>()
.single { it.getExternalObjCMethodInfo()?.selector == initSelector }
@@ -239,6 +279,11 @@ fun FunctionDescriptor.getObjCFactoryInitMethodInfo(): ObjCMethodInfo? {
return objCMethodInfo(factoryAnnotation)
}
fun IrFunction.getObjCFactoryInitMethodInfo(): ObjCMethodInfo? {
val factoryAnnotation = this.annotations.findAnnotation(objCFactoryFqName) ?: return null
return objCMethodInfo(factoryAnnotation)
}
fun inferObjCSelector(descriptor: FunctionDescriptor): String = if (descriptor.valueParameters.isEmpty()) {
descriptor.name.asString()
} else {
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.kotlin.backend.konan.getObjCMethodInfo
internal interface KotlinStubs {
val irBuiltIns: IrBuiltIns
@@ -538,7 +539,6 @@ internal fun KotlinStubs.generateCFunctionPointer(
expression.endOffset,
expression.type,
fakeFunction.symbol,
fakeFunction.descriptor,
0
)
}
@@ -1511,6 +1511,6 @@ private fun KotlinStubs.reportUnsupportedType(reason: String, type: IrType, loca
val typeLocation: String = location.render()
reportError(location.element, "type ${type.toKotlinType()}$typeLocation is not supported here" +
reportError(location.element, "type ${type.render()} $typeLocation is not supported here" +
if (reason.isNotEmpty()) ": $reason" else "")
}
@@ -5,20 +5,21 @@
package org.jetbrains.kotlin.backend.konan.descriptors
import org.jetbrains.kotlin.backend.common.atMostOne
import org.jetbrains.kotlin.backend.konan.*
import org.jetbrains.kotlin.backend.konan.descriptors.resolveFakeOverride
import org.jetbrains.kotlin.backend.konan.ir.*
import org.jetbrains.kotlin.backend.konan.isObjCClass
import org.jetbrains.kotlin.backend.konan.llvm.longName
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.expressions.IrConst
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.isUnit
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.types.SimpleType
/**
* List of all implemented interfaces (including those which implemented by a super class)
@@ -219,14 +220,14 @@ internal tailrec fun IrDeclaration.findPackage(): IrPackageFragment {
?: (parent as IrDeclaration).findPackage()
}
fun IrFunctionSymbol.isComparisonFunction(map: Map<SimpleType, IrSimpleFunctionSymbol>): Boolean =
fun IrFunctionSymbol.isComparisonFunction(map: Map<IrClassifierSymbol, IrSimpleFunctionSymbol>): Boolean =
this in map.values
val IrDeclaration.isPropertyAccessor get() =
this is IrSimpleFunction && this.correspondingProperty != null
this is IrSimpleFunction && this.correspondingPropertySymbol != null
val IrDeclaration.isPropertyField get() =
this is IrField && this.correspondingProperty != null
this is IrField && this.correspondingPropertySymbol != null
val IrDeclaration.isTopLevelDeclaration get() =
parent !is IrDeclaration && !this.isPropertyAccessor && !this.isPropertyField
@@ -235,9 +236,9 @@ fun IrDeclaration.findTopLevelDeclaration(): IrDeclaration = when {
this.isTopLevelDeclaration ->
this
this.isPropertyAccessor ->
(this as IrSimpleFunction).correspondingProperty!!.findTopLevelDeclaration()
(this as IrSimpleFunction).correspondingPropertySymbol!!.owner.findTopLevelDeclaration()
this.isPropertyField ->
(this as IrField).correspondingProperty!!.findTopLevelDeclaration()
(this as IrField).correspondingPropertySymbol!!.owner.findTopLevelDeclaration()
else ->
(this.parent as IrDeclaration).findTopLevelDeclaration()
}
@@ -247,15 +248,20 @@ internal val IrClass.isFrozen: Boolean
// RTTI is used for non-reference type box or Objective-C object wrapper:
!this.defaultType.binaryTypeIsReference() || this.isObjCClass()
fun IrConstructorCall.getAnnotationValue() = (getValueArgument(0) as? IrConst<String>)?.value
fun IrConstructorCall.getAnnotationStringValue() = (getValueArgument(0) as? IrConst<String>)?.value
fun IrConstructorCall.getStringValue(name: String): String {
fun IrConstructorCall.getAnnotationStringValue(name: String): String {
val parameter = symbol.owner.valueParameters.single { it.name.asString() == name }
return (getValueArgument(parameter.index) as IrConst<String>).value
}
fun <T> IrConstructorCall.getAnnotationValueOrNull(name: String): T? {
val parameter = symbol.owner.valueParameters.atMostOne { it.name.asString() == name }
return parameter?.let { getValueArgument(it.index)?.let { (it as IrConst<T>).value } }
}
fun IrFunction.externalSymbolOrThrow(): String? {
annotations.findAnnotation(RuntimeNames.symbolNameAnnotation)?.let { return it.getAnnotationValue() }
annotations.findAnnotation(RuntimeNames.symbolNameAnnotation)?.let { return it.getAnnotationStringValue() }
if (annotations.hasAnnotation(KonanFqNames.objCMethod)) return null
@@ -265,3 +271,5 @@ fun IrFunction.externalSymbolOrThrow(): String? {
throw Error("external function ${this.longName} must have @TypedIntrinsic, @SymbolName or @ObjCMethod annotation")
}
val IrFunction.isBuiltInOperator get() = origin == IrBuiltIns.BUILTIN_OPERATOR
@@ -8,14 +8,11 @@ package org.jetbrains.kotlin.backend.konan.descriptors
import org.jetbrains.kotlin.backend.common.ir.SharedVariablesManager
import org.jetbrains.kotlin.backend.konan.KonanBackendContext
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrGetValue
import org.jetbrains.kotlin.ir.expressions.IrSetVariable
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
@@ -39,14 +36,6 @@ internal class KonanSharedVariablesManager(val context: KonanBackendContext) : S
return refClass.descriptor.defaultType.replace(listOf(TypeProjectionImpl(elementType)))
}
private fun getElementPropertyDescriptor(sharedVariableDescriptor: VariableDescriptor): PropertyDescriptor {
return sharedVariableDescriptor.type.memberScope.getContributedDescriptors()
.filterIsInstance<PropertyDescriptor>()
.single {
it.name.asString() == "element"
}
}
override fun declareSharedVariable(originalDeclaration: IrVariable): IrVariable {
val variableDescriptor = originalDeclaration.descriptor
val sharedVariableDescriptor = LocalVariableDescriptor(
@@ -76,12 +65,9 @@ internal class KonanSharedVariablesManager(val context: KonanBackendContext) : S
override fun defineSharedValue(originalDeclaration: IrVariable, sharedVariableDeclaration: IrVariable): IrStatement {
val initializer = originalDeclaration.initializer ?: return sharedVariableDeclaration
val elementPropertyDescriptor = getElementPropertyDescriptor(sharedVariableDeclaration.descriptor)
val sharedVariableInitialization =
IrCallImpl(initializer.startOffset, initializer.endOffset,
context.irBuiltIns.unitType, elementProperty.setter!!.symbol,
elementPropertyDescriptor.setter!!)
context.irBuiltIns.unitType, elementProperty.setter!!.symbol)
sharedVariableInitialization.dispatchReceiver =
IrGetValueImpl(initializer.startOffset, initializer.endOffset,
@@ -95,31 +81,23 @@ internal class KonanSharedVariablesManager(val context: KonanBackendContext) : S
)
}
override fun getSharedValue(sharedVariableSymbol: IrVariableSymbol, originalGet: IrGetValue): IrExpression {
override fun getSharedValue(sharedVariableSymbol: IrVariableSymbol, originalGet: IrGetValue) =
IrCallImpl(originalGet.startOffset, originalGet.endOffset,
originalGet.type, elementProperty.getter!!.symbol).apply {
dispatchReceiver = IrGetValueImpl(
originalGet.startOffset, originalGet.endOffset,
sharedVariableSymbol.owner.type, sharedVariableSymbol
)
}
val elementPropertyDescriptor = getElementPropertyDescriptor(sharedVariableSymbol.descriptor)
return IrCallImpl(originalGet.startOffset, originalGet.endOffset,
originalGet.type, elementProperty.getter!!.symbol,
elementPropertyDescriptor.getter!!).apply {
dispatchReceiver = IrGetValueImpl(
originalGet.startOffset, originalGet.endOffset,
sharedVariableSymbol.owner.type, sharedVariableSymbol
)
}
}
override fun setSharedValue(sharedVariableSymbol: IrVariableSymbol, originalSet: IrSetVariable): IrExpression {
val elementPropertyDescriptor = getElementPropertyDescriptor(sharedVariableSymbol.descriptor)
return IrCallImpl(originalSet.startOffset, originalSet.endOffset, context.irBuiltIns.unitType,
elementProperty.setter!!.symbol, elementPropertyDescriptor.setter!!).apply {
dispatchReceiver = IrGetValueImpl(
originalSet.startOffset, originalSet.endOffset,
sharedVariableSymbol.owner.type, sharedVariableSymbol
)
putValueArgument(0, originalSet.value)
}
}
override fun setSharedValue(sharedVariableSymbol: IrVariableSymbol, originalSet: IrSetVariable) =
IrCallImpl(originalSet.startOffset, originalSet.endOffset, context.irBuiltIns.unitType,
elementProperty.setter!!.symbol).apply {
dispatchReceiver = IrGetValueImpl(
originalSet.startOffset, originalSet.endOffset,
sharedVariableSymbol.owner.type, sharedVariableSymbol
)
putValueArgument(0, originalSet.value)
}
}
@@ -10,20 +10,12 @@ import org.jetbrains.kotlin.backend.konan.llvm.llvmSymbolOrigin
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.toKotlinType
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.module
import org.jetbrains.kotlin.ir.util.file
// This file contains some IR utilities which actually use descriptors.
// TODO: port this code to IR.
internal fun IrFunction.getObjCMethodInfo() = this.descriptor.getObjCMethodInfo()
internal fun IrFunction.getExternalObjCMethodInfo() = this.descriptor.getExternalObjCMethodInfo()
internal fun IrFunction.isObjCClassMethod() = this.descriptor.isObjCClassMethod()
internal fun IrClass.isObjCMetaClass() = this.descriptor.isObjCMetaClass()
internal val IrDeclaration.llvmSymbolOrigin get() = this.descriptor.llvmSymbolOrigin
internal val IrDeclaration.llvmSymbolOrigin get() = this.file.packageFragmentDescriptor.llvmSymbolOrigin
internal fun IrType.isObjCObjectType() = this.toKotlinType().isObjCObjectType()
@@ -60,6 +60,8 @@ internal class KonanSymbols(
val nativePtrType = nativePtr.typeWith(arguments = emptyList())
val nonNullNativePtr = symbolTable.referenceClass(context.nonNullNativePtr)
val immutableBlobOf = symbolTable.referenceSimpleFunction(context.immutableBlobOf)
private fun unsignedClass(unsignedType: UnsignedType): IrClassSymbol = classById(unsignedType.classId)
val uByte = unsignedClass(UnsignedType.UBYTE)
@@ -130,6 +132,8 @@ internal class KonanSymbols(
val interopCValueRead = symbolTable.referenceSimpleFunction(context.interopBuiltIns.cValueRead)
val interopAllocType = symbolTable.referenceSimpleFunction(context.interopBuiltIns.allocType)
val interopTypeOf = symbolTable.referenceSimpleFunction(context.interopBuiltIns.typeOf)
val interopCPointerGetRawValue = symbolTable.referenceSimpleFunction(context.interopBuiltIns.cPointerGetRawValue)
val interopAllocObjCObject = symbolTable.referenceSimpleFunction(context.interopBuiltIns.allocObjCObject)
@@ -168,6 +172,12 @@ internal class KonanSymbols(
val interopObjCObjectRawValueGetter =
symbolTable.referenceSimpleFunction(context.interopBuiltIns.objCObjectRawPtr)
val interopNativePointedRawPtrGetter =
symbolTable.referenceSimpleFunction(context.interopBuiltIns.nativePointedRawPtrGetter)
val interopCPointerRawValue =
symbolTable.referenceProperty(context.interopBuiltIns.cPointerRawValue)
val interopInterpretObjCPointer =
symbolTable.referenceSimpleFunction(context.interopBuiltIns.interpretObjCPointer)
@@ -201,7 +211,11 @@ internal class KonanSymbols(
) as ClassDescriptor
)
val executeImpl = symbolTable.referenceSimpleFunction(context.interopBuiltIns.executeImplFunction)
val executeImpl = symbolTable.referenceSimpleFunction(
builtIns.builtInsModule.getPackage(FqName("kotlin.native.concurrent")).memberScope
.getContributedFunctions(Name.identifier("executeImpl"), NoLookupLocation.FROM_BACKEND)
.single()
)
val areEqualByValue = context.getKonanInternalFunctions("areEqualByValue").map {
symbolTable.referenceSimpleFunction(it)
@@ -9,11 +9,11 @@ import llvm.LLVMTypeRef
import org.jetbrains.kotlin.backend.common.serialization.KotlinManglerImpl
import org.jetbrains.kotlin.backend.konan.*
import org.jetbrains.kotlin.backend.konan.descriptors.externalSymbolOrThrow
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationValue
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationStringValue
import org.jetbrains.kotlin.backend.konan.descriptors.isAbstract
import org.jetbrains.kotlin.backend.konan.ir.allParameters
import org.jetbrains.kotlin.backend.konan.ir.getObjCMethodInfo
import org.jetbrains.kotlin.backend.konan.ir.isObjCClassMethod
import org.jetbrains.kotlin.backend.konan.getObjCMethodInfo
import org.jetbrains.kotlin.backend.konan.isObjCClassMethod
import org.jetbrains.kotlin.backend.konan.ir.isUnit
import org.jetbrains.kotlin.backend.konan.llvm.KonanMangler.isExported
import org.jetbrains.kotlin.ir.declarations.*
@@ -89,7 +89,7 @@ object KonanMangler : KotlinManglerImpl() {
append(it.selector)
if (this@platformSpecificFunctionName is IrConstructor && this@platformSpecificFunctionName.isObjCConstructor) append("#Constructor")
if ((this@platformSpecificFunctionName as? IrSimpleFunction)?.correspondingProperty != null) {
if ((this@platformSpecificFunctionName as? IrSimpleFunction)?.correspondingPropertySymbol != null) {
append("#Accessor")
}
}
@@ -110,7 +110,7 @@ object KonanMangler : KotlinManglerImpl() {
}
this.annotations.findAnnotation(RuntimeNames.exportForCppRuntime)?.let {
val name = it.getAnnotationValue() ?: this.name.asString()
val name = it.getAnnotationStringValue() ?: this.name.asString()
return name // no wrapping currently required
}
@@ -3,7 +3,7 @@ package org.jetbrains.kotlin.backend.konan.llvm
import kotlinx.cinterop.cValuesOf
import llvm.*
import org.jetbrains.kotlin.backend.konan.RuntimeNames
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationValue
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationStringValue
import org.jetbrains.kotlin.backend.konan.descriptors.isTypedIntrinsic
import org.jetbrains.kotlin.backend.konan.llvm.objc.genObjCSelector
import org.jetbrains.kotlin.backend.konan.reportCompilationError
@@ -107,7 +107,7 @@ internal interface IntrinsicGeneratorEnvironment {
fun evaluateCall(function: IrFunction, args: List<LLVMValueRef>, resultLifetime: Lifetime, superClass: IrClass? = null): LLVMValueRef
fun evaluateExplicitArgs(expression: IrMemberAccessExpression): List<LLVMValueRef>
fun evaluateExplicitArgs(expression: IrFunctionAccessExpression): List<LLVMValueRef>
fun evaluateExpression(value: IrExpression): LLVMValueRef
}
@@ -118,7 +118,7 @@ internal fun tryGetIntrinsicType(callSite: IrFunctionAccessExpression): Intrinsi
private fun getIntrinsicType(callSite: IrFunctionAccessExpression): IntrinsicType {
val function = callSite.symbol.owner
val annotation = function.annotations.findAnnotation(RuntimeNames.typedIntrinsicAnnotation)!!
val value = annotation.getAnnotationValue()!!
val value = annotation.getAnnotationStringValue()!!
return IntrinsicType.valueOf(value)
}
@@ -452,8 +452,7 @@ internal class IntrinsicGenerator(private val environment: IntrinsicGeneratorEnv
private val kImmOne = LLVMConstInt(int32Type, 1, 1)!!
private fun FunctionGenerationContext.emitGetObjCClass(callSite: IrCall): LLVMValueRef {
val descriptor = callSite.descriptor.original
val typeArgument = callSite.getTypeArgument(descriptor.typeParameters.single())
val typeArgument = callSite.getTypeArgument(0)
return getObjCClass(typeArgument!!.getClass()!!, environment.exceptionHandler)
}
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.backend.konan.llvm
import kotlinx.cinterop.*
import llvm.*
import org.jetbrains.kotlin.backend.common.descriptors.allParameters
import org.jetbrains.kotlin.backend.common.ir.ir2string
import org.jetbrains.kotlin.backend.common.lower.inline.InlinerExpressionLocationHint
import org.jetbrains.kotlin.backend.konan.*
@@ -208,7 +207,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
override fun evaluateCall(function: IrFunction, args: List<LLVMValueRef>, resultLifetime: Lifetime, superClass: IrClass?) =
evaluateSimpleFunctionCall(function, args, resultLifetime, superClass)
override fun evaluateExplicitArgs(expression: IrMemberAccessExpression): List<LLVMValueRef> =
override fun evaluateExplicitArgs(expression: IrFunctionAccessExpression): List<LLVMValueRef> =
this@CodeGeneratorVisitor.evaluateExplicitArgs(expression)
override fun evaluateExpression(value: IrExpression): LLVMValueRef =
@@ -1481,17 +1480,17 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
if (!value.symbol.owner.isStatic) {
val thisPtr = evaluateExpression(value.receiver!!)
return functionGenerationContext.loadSlot(
fieldPtrOfClass(thisPtr, value.symbol.owner), value.descriptor.isVar())
fieldPtrOfClass(thisPtr, value.symbol.owner), !value.symbol.owner.isFinal)
} else {
assert(value.receiver == null)
return if (value.symbol.owner.correspondingProperty?.isConst == true) {
return if (value.symbol.owner.correspondingPropertySymbol?.owner?.isConst == true) {
evaluateConst(value.symbol.owner.initializer?.expression as IrConst<*>)
} else {
if (context.config.threadsAreAllowed && value.symbol.owner.isMainOnlyNonPrimitive) {
functionGenerationContext.checkMainThread(currentCodeContext.exceptionHandler)
}
val ptr = context.llvmDeclarations.forStaticField(value.symbol.owner).storage
functionGenerationContext.loadSlot(ptr, value.descriptor.isVar())
functionGenerationContext.loadSlot(ptr, !value.symbol.owner.isFinal)
}
}
}
@@ -1941,12 +1940,12 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
* Returns results in the same order as LLVM function expects, assuming that all explicit arguments
* exactly correspond to a tail of LLVM parameters.
*/
private fun evaluateExplicitArgs(expression: IrMemberAccessExpression): List<LLVMValueRef> {
val evaluatedArgs = expression.getArguments().map { (param, argExpr) ->
private fun evaluateExplicitArgs(expression: IrFunctionAccessExpression): List<LLVMValueRef> {
val evaluatedArgs = expression.getArgumentsWithIr().map { (param, argExpr) ->
param to evaluateExpression(argExpr)
}.toMap()
val allValueParameters = expression.descriptor.allParameters
val allValueParameters = expression.symbol.owner.allParameters
return allValueParameters.dropWhile { it !in evaluatedArgs }.map {
evaluatedArgs[it]!!
@@ -2051,7 +2050,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
else args
return when {
function.isTypedIntrinsic -> intrinsicGenerator.evaluateCall(callee, args)
function.symbol in context.irBuiltIns.irBuiltInsSymbols -> evaluateOperatorCall(callee, argsWithContinuationIfNeeded)
function.isBuiltInOperator -> evaluateOperatorCall(callee, argsWithContinuationIfNeeded)
else -> evaluateSimpleFunctionCall(function, argsWithContinuationIfNeeded, resultLifetime, callee.superQualifierSymbol?.owner)
}
}
@@ -2133,7 +2132,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
assert(irClass.isExternalObjCClass())
val annotation = irClass.annotations.findAnnotation(externalObjCClassFqName)!!
val protocolGetterName = annotation.getStringValue("protocolGetter")
val protocolGetterName = annotation.getAnnotationStringValue("protocolGetter")
val protocolGetter = context.llvm.externalFunction(
protocolGetterName,
functionType(int8TypePtr, false),
@@ -9,7 +9,7 @@ import llvm.LLVMStoreSizeOfType
import llvm.LLVMValueRef
import org.jetbrains.kotlin.backend.common.atMostOne
import org.jetbrains.kotlin.backend.konan.*
import org.jetbrains.kotlin.backend.konan.descriptors.getStringValue
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationStringValue
import org.jetbrains.kotlin.backend.konan.ir.*
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
@@ -127,8 +127,8 @@ internal class KotlinObjCClassInfoGenerator(override val context: Context) : Con
return@mapNotNull null
ObjCMethodDesc(
annotation.getStringValue("selector"),
annotation.getStringValue("encoding"),
annotation.getAnnotationStringValue("selector"),
annotation.getAnnotationStringValue("encoding"),
it.llvmFunction
)
}
@@ -139,7 +139,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
private fun exportTypeInfoIfRequired(irClass: IrClass, typeInfoGlobal: LLVMValueRef?) {
val annotation = irClass.annotations.findAnnotation(EXPORT_TYPE_INFO_FQ_NAME)
if (annotation != null) {
val name = annotation.getAnnotationValue()!!
val name = annotation.getAnnotationStringValue()!!
// TODO: use LLVMAddAlias.
val global = addGlobal(name, pointerType(runtime.typeInfoType), isExported = true)
LLVMSetInitializer(global, typeInfoGlobal)
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.backend.konan.llvm
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationValue
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationStringValue
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.util.findAnnotation
import org.jetbrains.kotlin.konan.target.KonanTarget
@@ -17,6 +17,6 @@ private val retainForTargetAnnotationName = FqName("kotlin.native.RetainForTarge
internal fun IrFunction.retainAnnotation(target: KonanTarget): Boolean {
if (this.annotations.findAnnotation(retainAnnotationName) != null) return true
val forTarget = this.annotations.findAnnotation(retainForTargetAnnotationName)
if (forTarget != null && forTarget.getAnnotationValue() == target.name) return true
if (forTarget != null && forTarget.getAnnotationStringValue() == target.name) return true
return false
}
@@ -136,7 +136,7 @@ private class AutoboxingTransformer(val context: Context) : AbstractValueUsageTr
}
private val IrCall.callTarget: IrFunction
get() = if (superQualifier == null && symbol.owner.isOverridable) {
get() = if (superQualifierSymbol == null && symbol.owner.isOverridable) {
// A virtual call.
symbol.owner
} else {
@@ -37,9 +37,7 @@ import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature
internal class WorkersBridgesBuilding(val context: Context) : DeclarationContainerLoweringPass, IrElementTransformerVoid() {
val interop = context.interopBuiltIns
val symbols = context.ir.symbols
val nullableAnyType = context.builtIns.nullableAnyType
lateinit var runtimeJobFunction: IrSimpleFunction
override fun lower(irDeclarationContainer: IrDeclarationContainer) {
@@ -59,8 +57,7 @@ internal class WorkersBridgesBuilding(val context: Context) : DeclarationContain
override fun visitCall(expression: IrCall): IrExpression {
expression.transformChildrenVoid(this)
val descriptor = expression.descriptor.original
if (descriptor != interop.executeImplFunction)
if (expression.symbol != symbols.executeImpl)
return expression
val job = expression.getValueArgument(3) as IrFunctionReference
@@ -118,7 +115,6 @@ internal class WorkersBridgesBuilding(val context: Context) : DeclarationContain
endOffset = job.endOffset,
type = job.type,
symbol = bridge.symbol,
descriptor = bridge.descriptor,
typeArgumentsCount = 0)
)
return expression
@@ -238,7 +234,6 @@ private fun Context.buildBridge(startOffset: Int, endOffset: Int,
endOffset,
targetSymbol.owner.returnType,
targetSymbol,
targetSymbol.descriptor,
superQualifierSymbol = superQualifierSymbol /* Call non-virtually */
).apply {
bridge.dispatchReceiverParameter?.let {
@@ -9,13 +9,12 @@ import org.jetbrains.kotlin.backend.common.FileLoweringPass
import org.jetbrains.kotlin.backend.common.lower.IrBuildingTransformer
import org.jetbrains.kotlin.backend.common.lower.at
import org.jetbrains.kotlin.backend.konan.Context
import org.jetbrains.kotlin.ir.builders.irCall
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.types.isString
import org.jetbrains.kotlin.ir.util.fqNameForIrSerialization
import org.jetbrains.kotlin.ir.util.irCall
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
internal class CompileTimeEvaluateLowering(val context: Context): FileLoweringPass {
@@ -24,9 +23,9 @@ internal class CompileTimeEvaluateLowering(val context: Context): FileLoweringPa
override fun visitCall(expression: IrCall): IrExpression {
expression.transformChildrenVoid(this)
val descriptor = expression.descriptor.original
val callee = expression.symbol.owner
// TODO
if (descriptor.fqNameSafe.asString() != "kotlin.collections.listOf" || descriptor.valueParameters.size != 1)
if (callee.fqNameForIrSerialization.asString() != "kotlin.collections.listOf" || callee.valueParameters.size != 1)
return expression
val elementsArr = expression.getValueArgument(0) as? IrVararg
?: return expression
@@ -28,9 +28,8 @@ internal class DataClassOperatorsLowering(val context: Context): FunctionLowerin
override fun visitCall(expression: IrCall): IrExpression {
expression.transformChildrenVoid(this)
val descriptor = expression.descriptor.original
if (descriptor != irBuiltins.dataClassArrayMemberToString
&& descriptor != irBuiltins.dataClassArrayMemberHashCode)
if (expression.symbol != irBuiltins.dataClassArrayMemberToStringSymbol
&& expression.symbol != irBuiltins.dataClassArrayMemberHashCodeSymbol)
return expression
val argument = expression.getValueArgument(0)!!
@@ -12,13 +12,8 @@ import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
import org.jetbrains.kotlin.backend.common.lower.irBlock
import org.jetbrains.kotlin.backend.konan.Context
import org.jetbrains.kotlin.backend.konan.descriptors.synthesizedName
import org.jetbrains.kotlin.backend.konan.KonanBackendContext
import org.jetbrains.kotlin.backend.konan.ir.buildSimpleAnnotation
import org.jetbrains.kotlin.backend.konan.ir.typeWithStarProjections
import org.jetbrains.kotlin.backend.konan.isObjCClass
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
@@ -123,7 +118,7 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
return when (receiversCount) {
1 -> createKProperty(expression, this) // Has receiver.
2 -> error("Callable reference to properties with two receivers is not allowed: ${expression.descriptor}")
2 -> error("Callable reference to properties with two receivers is not allowed: ${expression.symbol.owner.name}")
else -> { // Cache KProperties with no arguments.
val field = kProperties.getOrPut(expression.symbol.owner) {
@@ -195,7 +190,6 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
else
irTemporary(value = it, nameHint = "\$extensionReceiver${tempIndex++}")
}
val propertyDescriptor = expression.descriptor
val returnType = expression.getter?.owner?.returnType ?: expression.field!!.owner.type
val getterCallableReference = expression.getter?.owner?.let { getter ->
@@ -216,7 +210,6 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
endOffset = endOffset,
type = getterKFunctionType,
symbol = expression.getter!!,
descriptor = getter.descriptor,
typeArgumentsCount = getter.typeParameters.size,
valueArgumentsCount = getter.valueParameters.size
).apply {
@@ -239,7 +232,6 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
endOffset = endOffset,
type = setterKFunctionType,
symbol = expression.setter!!,
descriptor = setter.descriptor,
typeArgumentsCount = setter.typeParameters.size,
valueArgumentsCount = setter.valueParameters.size
).apply {
@@ -257,7 +249,7 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
isLocal = false,
isMutable = setterCallableReference != null)
val initializer = irCall(symbol.owner, constructorTypeArguments).apply {
putValueArgument(0, irString(propertyDescriptor.name.asString()))
putValueArgument(0, irString(expression.symbol.owner.name.asString()))
putValueArgument(1, with(kTypeGenerator) { irKType(returnType) })
if (getterCallableReference != null)
putValueArgument(2, getterCallableReference)
@@ -127,7 +127,7 @@ internal class EnumUsageLowering(val context: Context)
val ordinal = loweredEnum.entriesMap[name]!!
return IrCallImpl(
startOffset, endOffset, enumClass.defaultType,
loweredEnum.itemGetterSymbol.owner.symbol, loweredEnum.itemGetterSymbol.descriptor,
loweredEnum.itemGetterSymbol.owner.symbol,
typeArgumentsCount = 0
).apply {
dispatchReceiver = IrCallImpl(startOffset, endOffset, loweredEnum.valuesGetter.returnType, loweredEnum.valuesGetter.symbol)
@@ -134,7 +134,7 @@ internal class ExpectToActualDefaultValueCopier(private val irModule: IrModuleFr
symbol.descriptor.isExpect -> symbol.owner.findActualForExpected().symbol
symbol.descriptor.propertyIfAccessor.isExpect -> {
val property = symbol.owner.correspondingProperty!!
val property = symbol.owner.correspondingPropertySymbol!!.owner
val actualPropertyDescriptor = property.descriptor.findActualForExpect()
val accessorDescriptor = when (symbol.owner) {
property.getter -> actualPropertyDescriptor.getter!!
@@ -18,12 +18,12 @@ import org.jetbrains.kotlin.backend.common.push
import org.jetbrains.kotlin.backend.konan.*
import org.jetbrains.kotlin.backend.konan.cgen.*
import org.jetbrains.kotlin.backend.konan.descriptors.allOverriddenFunctions
import org.jetbrains.kotlin.backend.konan.descriptors.isInterface
import org.jetbrains.kotlin.backend.konan.descriptors.synthesizedName
import org.jetbrains.kotlin.backend.konan.ir.*
import org.jetbrains.kotlin.backend.konan.ir.companionObject
import org.jetbrains.kotlin.backend.konan.llvm.IntrinsicType
import org.jetbrains.kotlin.backend.konan.llvm.tryGetIntrinsicType
import org.jetbrains.kotlin.backend.konan.serialization.resolveFakeOverrideMaybeAbstract
import org.jetbrains.kotlin.builtins.UnsignedTypes
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.ir.IrElement
@@ -47,7 +47,6 @@ import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.OverridingUtil
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
internal abstract class BaseInteropIrTransformer(private val context: Context) : IrBuildingTransformer(context) {
@@ -569,7 +568,6 @@ internal class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfo
endOffset,
context.irBuiltIns.unitType,
superConstructor,
superConstructor.descriptor,
0
)
@@ -645,11 +643,9 @@ internal class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfo
override fun visitCall(expression: IrCall): IrExpression {
expression.transformChildrenVoid()
val descriptor = expression.descriptor.original
val callee = expression.symbol.owner
descriptor.getObjCFactoryInitMethodInfo()?.let { initMethodInfo ->
callee.getObjCFactoryInitMethodInfo()?.let { initMethodInfo ->
val arguments = (0 until expression.valueArgumentsCount)
.map { index -> expression.getValueArgument(index) }
@@ -659,7 +655,7 @@ internal class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfo
}
}
descriptor.getExternalObjCMethodInfo()?.let { methodInfo ->
callee.getExternalObjCMethodInfo()?.let { methodInfo ->
val isInteropStubsFile =
currentFile.annotations.hasAnnotation(FqName("kotlinx.cinterop.InteropStubs"))
@@ -672,14 +668,14 @@ internal class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfo
val arguments = callee.valueParameters.map { expression.getValueArgument(it.index) }
assert(expression.dispatchReceiver == null || expression.extensionReceiver == null)
if (expression.superQualifier?.isObjCMetaClass() == true) {
if (expression.superQualifierSymbol?.owner?.isObjCMetaClass() == true) {
context.reportCompilationError(
"Super calls to Objective-C meta classes are not supported yet",
currentFile, expression
)
}
if (expression.superQualifier?.isInterface == true) {
if (expression.superQualifierSymbol?.owner?.isInterface == true) {
context.reportCompilationError(
"Super calls to Objective-C protocols are not allowed",
currentFile, expression
@@ -698,8 +694,8 @@ internal class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfo
}
}
return when (descriptor) {
context.interopBuiltIns.typeOf -> {
return when (callee.symbol) {
symbols.interopTypeOf -> {
val typeArgument = expression.getSingleTypeArgument()
val classSymbol = typeArgument.classifierOrNull as? IrClassSymbol
@@ -839,11 +835,10 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi
expression.transformChildrenVoid(this)
builder.at(expression)
val descriptor = expression.descriptor.original
val function = expression.symbol.owner
if (descriptor == interop.nativePointedRawPtrGetter ||
OverridingUtil.overrides(descriptor, interop.nativePointedRawPtrGetter, false)) {
if ((function as? IrSimpleFunction)?.resolveFakeOverrideMaybeAbstract()?.symbol
== symbols.interopNativePointedRawPtrGetter) {
// Replace by the intrinsic call to be handled by code generator:
return builder.irCall(symbols.interopNativePointedGetRawPointer).apply {
@@ -884,7 +879,7 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi
if (irCallableReference == null || irCallableReference.getArguments().isNotEmpty()
|| irCallableReference.symbol !is IrSimpleFunctionSymbol) {
context.reportCompilationError(
"${descriptor.fqNameSafe} must take an unbound, non-capturing function or lambda",
"${function.fqNameForIrSerialization} must take an unbound, non-capturing function or lambda",
irFile, expression
)
// TODO: should probably be reported during analysis.
@@ -894,8 +889,8 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi
val target = targetSymbol.owner
val signatureTypes = target.allParameters.map { it.type } + target.returnType
descriptor.typeParameters.forEachIndexed { index, typeParameterDescriptor ->
val typeArgument = expression.getTypeArgument(typeParameterDescriptor)!!.toKotlinType()
function.typeParameters.indices.forEach { index ->
val typeArgument = expression.getTypeArgument(index)!!.toKotlinType()
val signatureType = signatureTypes[index].toKotlinType()
if (typeArgument.constructor != signatureType.constructor ||
typeArgument.isMarkedNullable != signatureType.isMarkedNullable) {
@@ -1020,17 +1015,16 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi
if (irCallableReference == null || irCallableReference.getArguments().isNotEmpty()) {
context.reportCompilationError(
"${descriptor.fqNameSafe} must take an unbound, non-capturing function or lambda",
"${function.fqNameForIrSerialization} must take an unbound, non-capturing function or lambda",
irFile, expression
)
}
val targetSymbol = irCallableReference.symbol
val target = targetSymbol.descriptor
val jobPointer = IrFunctionReferenceImpl(
builder.startOffset, builder.endOffset,
symbols.executeImpl.owner.valueParameters[3].type,
targetSymbol, target,
targetSymbol,
typeArgumentsCount = 0)
builder.irCall(symbols.executeImpl).apply {
@@ -1043,8 +1037,8 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi
else -> expression
}
}
return when (descriptor) {
interop.cPointerRawValue.getter ->
return when (function) {
symbols.interopCPointerRawValue.owner.getter ->
// Replace by the intrinsic call to be handled by code generator:
builder.irCall(symbols.interopCPointerGetRawValue).apply {
extensionReceiver = expression.dispatchReceiver
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
import org.jetbrains.kotlin.backend.konan.Context
import org.jetbrains.kotlin.backend.konan.error
import org.jetbrains.kotlin.backend.konan.ir.typeWithoutArguments
import org.jetbrains.kotlin.backend.konan.reportCompilationError
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.IrFile
@@ -74,11 +73,11 @@ internal class PostInlineLowering(val context: Context) : FileLoweringPass {
// Function inlining is changing function symbol at callsite
// and unbound symbol replacement is happening later.
// So we compare descriptors for now.
if (expression.descriptor == context.immutableBlobOf) {
if (expression.symbol == symbols.immutableBlobOf) {
// Convert arguments of the binary blob to special IrConst<String> structure, so that
// vararg lowering will not affect it.
val args = expression.getValueArgument(0) as? IrVararg
if (args == null) throw Error("varargs shall not be lowered yet")
?: throw Error("varargs shall not be lowered yet")
if (args.elements.any { it is IrSpreadElement }) {
context.reportCompilationError("no spread elements allowed here", irFile, args)
}
@@ -106,7 +106,6 @@ internal class TestProcessor (val context: Context) {
it.function.endOffset,
registerTestCase.valueParameters[1].type,
it.function.symbol,
it.function.descriptor,
typeArgumentsCount = 0,
valueArgumentsCount = 0))
putValueArgument(2, irBoolean(it.ignored))
@@ -127,7 +126,6 @@ internal class TestProcessor (val context: Context) {
it.function.endOffset,
registerFunction.valueParameters[1].type,
it.function.symbol,
it.function.descriptor,
typeArgumentsCount = 0,
valueArgumentsCount = 0))
}
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
@@ -65,12 +64,13 @@ internal class VarargInjectionLowering constructor(val context: KonanBackendCont
val transformer = this
private fun replaceEmptyParameterWithEmptyArray(expression: IrFunctionAccessExpression) {
log { "call of: ${expression.descriptor}" }
val callee = expression.symbol.owner
log { "call of: ${callee.fqNameForIrSerialization}" }
context.createIrBuilder(owner, expression.startOffset, expression.endOffset).apply {
expression.descriptor.valueParameters.forEach {
log { "varargElementType: ${it.varargElementType} expr: ${ir2string(expression.getValueArgument(it))}" }
callee.valueParameters.forEach {
log { "varargElementType: ${it.varargElementType} expr: ${ir2string(expression.getValueArgument(it.index))}" }
}
expression.symbol.owner.valueParameters
callee.valueParameters
.filter { it.varargElementType != null && expression.getValueArgument(it.index) == null }
.forEach {
expression.putValueArgument(
@@ -644,7 +644,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
error("Constructor call should be done with IrConstructorCall")
} else {
callee as IrSimpleFunction
if (callee.isOverridable && value.superQualifier == null) {
if (callee.isOverridable && value.superQualifierSymbol == null) {
val owner = callee.parentAsClass
val actualReceiverType = value.dispatchReceiver!!.type
val actualReceiverClassifier = actualReceiverType.classifierOrFail
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.backend.konan.descriptors.isAbstract
import org.jetbrains.kotlin.backend.konan.descriptors.target
import org.jetbrains.kotlin.backend.konan.ir.*
import org.jetbrains.kotlin.backend.konan.llvm.*
import org.jetbrains.kotlin.backend.konan.llvm.KonanMangler.functionName
import org.jetbrains.kotlin.backend.konan.llvm.KonanMangler.symbolName
import org.jetbrains.kotlin.backend.konan.lower.DECLARATION_ORIGIN_BRIDGE_METHOD
import org.jetbrains.kotlin.backend.konan.lower.bridgeTarget
@@ -30,8 +29,7 @@ import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.constants.ConstantValue
import org.jetbrains.kotlin.resolve.constants.IntValue
import org.jetbrains.kotlin.backend.konan.descriptors.isBuiltInOperator
internal object DataFlowIR {
@@ -599,7 +597,7 @@ internal object DataFlowIR {
attributes = attributes or FunctionAttributes.EXPLICITLY_EXPORTED
}
val symbol = when {
it.isExternal || (it.symbol in context.irBuiltIns.irBuiltInsSymbols) -> {
it.isExternal || it.isBuiltInOperator -> {
val escapesAnnotation = it.annotations.findAnnotation(FQ_NAME_ESCAPES)
val pointsToAnnotation = it.annotations.findAnnotation(FQ_NAME_POINTS_TO)
@Suppress("UNCHECKED_CAST")
@@ -13,8 +13,6 @@ import org.jetbrains.kotlin.backend.common.push
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
import org.jetbrains.kotlin.backend.common.lower.irBlock
import org.jetbrains.kotlin.backend.konan.*
import org.jetbrains.kotlin.backend.konan.descriptors.isInterface
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.declarations.*
@@ -1312,7 +1310,6 @@ internal object Devirtualization {
callSite.startOffset, callSite.endOffset,
actualType,
actualCallee.symbol,
actualCallee.descriptor,
actualCallee.typeParameters.size,
actualCallee.valueParameters.size,
callSite.origin,
@@ -1369,8 +1366,8 @@ internal object Devirtualization {
|| possibleCallees.any { it.receiverType is DataFlowIR.Type.External })
return expression
val descriptor = expression.descriptor
val owner = (descriptor.containingDeclaration as ClassDescriptor)
val callee = expression.symbol.owner
val owner = callee.parentAsClass
// TODO: Think how to evaluate different unfold factors (in terms of both execution speed and code size).
val classMaxUnfoldFactor = 3
val interfaceMaxUnfoldFactor = 3
@@ -1383,7 +1380,7 @@ internal object Devirtualization {
val startOffset = expression.startOffset
val endOffset = expression.endOffset
val function = expression.symbol.owner
val type = if (descriptor.isSuspend)
val type = if (callee.isSuspend)
context.irBuiltIns.anyNType
else function.returnType
val irBuilder = context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, startOffset, endOffset)
@@ -1492,7 +1489,7 @@ internal object Devirtualization {
typeOperand, typeOperandClassifier, expression)
}
with (coercion) {
return IrCallImpl(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, origin).apply {
return IrCallImpl(startOffset, endOffset, type, symbol, typeArgumentsCount, origin).apply {
putValueArgument(0, castedExpression)
}
}
@@ -30,9 +30,11 @@ import org.jetbrains.kotlin.resolve.OverridingUtil
*/
internal fun IrSimpleFunction.resolveFakeOverrideMaybeAbstract() = this.resolveFakeOverride(allowAbstract = true)
internal fun IrProperty.resolveFakeOverrideMaybeAbstract() = this.getter!!.resolveFakeOverrideMaybeAbstract().correspondingProperty!!
internal fun IrProperty.resolveFakeOverrideMaybeAbstract() =
this.getter!!.resolveFakeOverrideMaybeAbstract().correspondingPropertySymbol!!.owner
internal fun IrField.resolveFakeOverrideMaybeAbstract() = this.correspondingProperty!!.getter!!.resolveFakeOverrideMaybeAbstract().correspondingProperty!!.backingField
internal fun IrField.resolveFakeOverrideMaybeAbstract() =
this.correspondingPropertySymbol!!.owner.resolveFakeOverrideMaybeAbstract().backingField
/**
* Implementation of given method.
@@ -8,6 +8,6 @@ import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
class KonanGlobalDeclarationTable(builtIns: IrBuiltIns) : GlobalDeclarationTable(KonanMangler) {
init {
loadKnownBuiltins(builtIns, 0)
loadKnownBuiltins(builtIns)
}
}
@@ -33,7 +33,7 @@ class KonanIrLinker(
symbolTable: SymbolTable,
forwardModuleDescriptor: ModuleDescriptor?,
exportedDependencies: List<ModuleDescriptor>
) : KotlinIrLinker(logger, builtIns, symbolTable, exportedDependencies, forwardModuleDescriptor, 0L),
) : KotlinIrLinker(logger, builtIns, symbolTable, exportedDependencies, forwardModuleDescriptor, KonanMangler),
DescriptorUniqIdAware by DeserializedDescriptorUniqIdAware {
override val descriptorReferenceDeserializer =
@@ -254,7 +254,7 @@ fun IrBuilderWithScope.irCall(irFunction: IrFunction, typeArguments: List<IrType
internal fun irCall(startOffset: Int, endOffset: Int, irFunction: IrFunction, typeArguments: List<IrType>): IrCall =
IrCallImpl(
startOffset, endOffset, irFunction.substitutedReturnType(typeArguments),
irFunction.symbol, irFunction.descriptor.substitute(typeArguments), typeArguments.size
irFunction.symbol, typeArguments.size
).apply {
typeArguments.forEachIndexed { index, irType ->
this.putTypeArgument(index, irType)
+6 -6
View File
@@ -18,12 +18,12 @@
buildKotlinVersion=1.3.70-dev-1070
buildKotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1070,branch:default:any,pinned:true/artifacts/content/maven
remoteRoot=konan_tests
kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1438,branch:default:any,pinned:true/artifacts/content/maven
kotlinVersion=1.3.70-dev-1438
kotlinStdlibRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1438,branch:default:any,pinned:true/artifacts/content/maven
kotlinStdlibVersion=1.3.70-dev-1438
kotlinStdlibTestsVersion=1.3.70-dev-1438
testKotlinCompilerVersion=1.3.70-dev-1438
kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1526,branch:default:any,pinned:true/artifacts/content/maven
kotlinVersion=1.3.70-dev-1526
kotlinStdlibRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1526,branch:default:any,pinned:true/artifacts/content/maven
kotlinStdlibVersion=1.3.70-dev-1526
kotlinStdlibTestsVersion=1.3.70-dev-1526
testKotlinCompilerVersion=1.3.70-dev-1526
konanVersion=1.3.70
# A version of Xcode required to build the Kotlin/Native compiler.
@@ -80,7 +80,8 @@ internal class KonanLibraryProperResolver(
distributionKlib,
localKonanDir,
skipCurrentDir,
logger
logger,
emptyList()
), SearchPathResolverWithTarget<KonanLibrary>
{
override fun libraryBuilder(file: File, isDefault: Boolean) = createKonanLibrary(file, target, isDefault)