[K/N] Remove unused old buggy intrinsic
This commit is contained in:
-7
@@ -363,13 +363,6 @@ internal val varargPhase = makeKonanFileLoweringPhase(
|
||||
prerequisite = setOf(functionReferencePhase, defaultParameterExtentPhase, interopPhase, functionsWithoutBoundCheck)
|
||||
)
|
||||
|
||||
internal val compileTimeEvaluatePhase = makeKonanFileLoweringPhase(
|
||||
::CompileTimeEvaluateLowering,
|
||||
name = "CompileTimeEvaluate",
|
||||
description = "Compile time evaluation lowering",
|
||||
prerequisite = setOf(varargPhase)
|
||||
)
|
||||
|
||||
internal val coroutinesPhase = makeKonanFileLoweringPhase(
|
||||
::NativeSuspendFunctionsLowering,
|
||||
name = "Coroutines",
|
||||
|
||||
-2
@@ -290,7 +290,6 @@ internal val allLoweringsPhase = NamedCompilerPhase(
|
||||
enumUsagePhase,
|
||||
interopPhase,
|
||||
varargPhase,
|
||||
compileTimeEvaluatePhase,
|
||||
kotlinNothingValueExceptionPhase,
|
||||
coroutinesPhase,
|
||||
typeOperatorPhase,
|
||||
@@ -510,7 +509,6 @@ internal fun PhaseConfig.disableUnless(phase: AnyNamedPhase, condition: Boolean)
|
||||
|
||||
internal fun PhaseConfig.konanPhasesConfig(config: KonanConfig) {
|
||||
with(config.configuration) {
|
||||
disable(compileTimeEvaluatePhase)
|
||||
disable(localEscapeAnalysisPhase)
|
||||
|
||||
// Don't serialize anything to a final executable.
|
||||
|
||||
-2
@@ -483,8 +483,6 @@ internal class KonanSymbols(
|
||||
val listOf = irBuiltIns.findFunctions(Name.identifier("listOf"), "kotlin", "collections")
|
||||
.single { it.descriptor.valueParameters.size == 1 && it.descriptor.valueParameters[0].isVararg }
|
||||
|
||||
val listOfInternal = internalFunction("listOfInternal")
|
||||
|
||||
val threadLocal = symbolTable.referenceClass(
|
||||
context.builtIns.builtInsModule.findClassAcrossModuleDependencies(
|
||||
ClassId.topLevel(KonanFqNames.threadLocal))!!)
|
||||
|
||||
-17
@@ -63,7 +63,6 @@ internal enum class IntrinsicType {
|
||||
// Other
|
||||
GET_CLASS_TYPE_INFO,
|
||||
CREATE_UNINITIALIZED_INSTANCE,
|
||||
LIST_OF_INTERNAL,
|
||||
IDENTITY,
|
||||
IMMUTABLE_BLOB,
|
||||
INIT_INSTANCE,
|
||||
@@ -253,7 +252,6 @@ internal class IntrinsicGenerator(private val environment: IntrinsicGeneratorEnv
|
||||
IntrinsicType.INTEROP_NATIVE_PTR_TO_LONG -> emitNativePtrToLong(callSite, args)
|
||||
IntrinsicType.INTEROP_NATIVE_PTR_PLUS_LONG -> emitNativePtrPlusLong(args)
|
||||
IntrinsicType.INTEROP_GET_NATIVE_NULL_PTR -> emitGetNativeNullPtr()
|
||||
IntrinsicType.LIST_OF_INTERNAL -> emitListOfInternal(callSite, args)
|
||||
IntrinsicType.IDENTITY -> emitIdentity(args)
|
||||
IntrinsicType.GET_CONTINUATION -> emitGetContinuation()
|
||||
IntrinsicType.INTEROP_MEMORY_COPY -> emitMemoryCopy(callSite, args)
|
||||
@@ -310,21 +308,6 @@ internal class IntrinsicGenerator(private val environment: IntrinsicGeneratorEnv
|
||||
private fun FunctionGenerationContext.emitIsExperimentalMM(): LLVMValueRef =
|
||||
Int1(context.memoryModel == MemoryModel.EXPERIMENTAL).llvm
|
||||
|
||||
private fun FunctionGenerationContext.emitListOfInternal(callSite: IrCall, args: List<LLVMValueRef>): LLVMValueRef {
|
||||
val varargExpression = callSite.getValueArgument(0) as IrVararg
|
||||
val vararg = args.single()
|
||||
|
||||
val length = varargExpression.elements.size
|
||||
// TODO: store length in `vararg` itself when more abstract types will be used for values.
|
||||
|
||||
val array = constPointer(vararg)
|
||||
// Note: dirty hack here: `vararg` has type `Array<out E>`, but `createConstArrayList` expects `Array<E>`;
|
||||
// however `vararg` is immutable, and in current implementation it has type `Array<E>`,
|
||||
// so let's ignore this mismatch currently for simplicity.
|
||||
|
||||
return context.llvm.staticData.createConstArrayList(array, length).llvm
|
||||
}
|
||||
|
||||
private fun FunctionGenerationContext.emitGetNativeNullPtr(): LLVMValueRef =
|
||||
kNullInt8Ptr
|
||||
|
||||
|
||||
-22
@@ -75,28 +75,6 @@ internal fun StaticData.createConstKotlinObject(type: IrClass, vararg fields: Co
|
||||
internal fun StaticData.createInitializer(type: IrClass, vararg fields: ConstValue): ConstValue =
|
||||
Struct(objHeader(type.typeInfoPtr), *fields)
|
||||
|
||||
/**
|
||||
* Creates static instance of `kotlin.collections.ArrayList<elementType>` with given values of fields.
|
||||
*
|
||||
* @param array value for `array: Array<E>` field.
|
||||
* @param length value for `length: Int` field.
|
||||
*/
|
||||
internal fun StaticData.createConstArrayList(array: ConstPointer, length: Int): ConstPointer {
|
||||
val arrayListClass = context.ir.symbols.arrayList.owner
|
||||
|
||||
val arrayListFields = mapOf(
|
||||
"array" to array,
|
||||
"offset" to Int32(0),
|
||||
"length" to Int32(length),
|
||||
"backing" to NullPointer(kObjHeader))
|
||||
|
||||
// Now sort these values according to the order of fields returned by getFields()
|
||||
// to match the sorting order of the real ArrayList().
|
||||
val sorted = context.getLayoutBuilder(arrayListClass).fields.map { arrayListFields[it.name]!! }
|
||||
|
||||
return createConstKotlinObject(arrayListClass, *sorted.toTypedArray())
|
||||
}
|
||||
|
||||
internal fun StaticData.createUniqueInstance(
|
||||
kind: UniqueKind, bodyType: LLVMTypeRef, typeInfo: ConstPointer): ConstPointer {
|
||||
assert (getStructElements(bodyType).size == 1) // ObjHeader only.
|
||||
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.lower
|
||||
|
||||
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.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
|
||||
|
||||
internal class CompileTimeEvaluateLowering(val context: Context): FileLoweringPass {
|
||||
|
||||
override fun lower(irFile: IrFile) {
|
||||
irFile.transformChildrenVoid(object: IrBuildingTransformer(context) {
|
||||
override fun visitCall(expression: IrCall): IrExpression {
|
||||
expression.transformChildrenVoid(this)
|
||||
|
||||
val callee = expression.symbol.owner
|
||||
// TODO
|
||||
if (callee.fqNameForIrSerialization.asString() != "kotlin.collections.listOf" || callee.valueParameters.size != 1)
|
||||
return expression
|
||||
val elementsArr = expression.getValueArgument(0) as? IrVararg
|
||||
?: return expression
|
||||
|
||||
// The function is kotlin.collections.listOf<T>(vararg args: T).
|
||||
// TODO: refer functions more reliably.
|
||||
|
||||
if (elementsArr.elements.any { it is IrSpreadElement }
|
||||
|| !elementsArr.elements.all { it is IrConst<*> && it.type.isString() })
|
||||
return expression
|
||||
|
||||
|
||||
builder.at(expression)
|
||||
|
||||
val typeArgument = expression.getTypeArgument(0)!!
|
||||
return builder.irCall(context.ir.symbols.listOfInternal.owner, listOf(typeArgument)).apply {
|
||||
putValueArgument(0, elementsArr)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,6 @@ class IntrinsicType {
|
||||
const val INTEROP_READ_BITS = "INTEROP_READ_BITS"
|
||||
const val INTEROP_WRITE_BITS = "INTEROP_WRITE_BITS"
|
||||
const val CREATE_UNINITIALIZED_INSTANCE = "CREATE_UNINITIALIZED_INSTANCE"
|
||||
const val LIST_OF_INTERNAL = "LIST_OF_INTERNAL"
|
||||
const val IDENTITY = "IDENTITY"
|
||||
const val IMMUTABLE_BLOB = "IMMUTABLE_BLOB"
|
||||
const val INIT_INSTANCE = "INIT_INSTANCE"
|
||||
|
||||
@@ -231,12 +231,3 @@ internal fun KonanObjectToUtf8Array(value: Any?): ByteArray {
|
||||
}
|
||||
return string.encodeToByteArray()
|
||||
}
|
||||
|
||||
@TypedIntrinsic(IntrinsicType.LIST_OF_INTERNAL)
|
||||
@PublishedApi
|
||||
internal fun <T> listOfInternal(vararg elements: T): List<T> {
|
||||
val result = ArrayList<T>(elements.size)
|
||||
for (i in 0 until elements.size)
|
||||
result.add(elements[i])
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user