[K/N] ForLoopsLowering: Use get without bounds check in ArrayIterationHandler

This commit is contained in:
Elena Lepilkina
2021-06-08 15:39:12 +03:00
committed by Space
parent f33f3c769f
commit ac074207c7
3 changed files with 13 additions and 1 deletions
@@ -332,6 +332,10 @@ abstract class Symbols<out T : CommonBackendContext>(val context: T, irBuiltIns:
open val unsafeCoerceIntrinsic: IrSimpleFunctionSymbol? = null
open val getWithoutBCName: Name? = null
open val setWithoutBCName: Name? = null
companion object {
fun isLateinitIsInitializedPropertyGetter(symbol: IrFunctionSymbol): Boolean =
symbol is IrSimpleFunctionSymbol && symbol.owner.let { function ->
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.ir.util.getPropertyGetter
import org.jetbrains.kotlin.ir.util.getSimpleFunction
import org.jetbrains.kotlin.ir.util.isPrimitiveArray
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.util.OperatorNameConventions
/** Builds a [HeaderInfo] for iteration over iterables using the `get / []` operator and an index. */
@@ -79,9 +80,12 @@ internal class ArrayIterationHandler(context: CommonBackendContext) : IndexedGet
override val IrType.sizePropertyGetter
get() = getClass()!!.getPropertyGetter("size")!!.owner
private val getFunctionName: Name
get() = context.ir.symbols.getWithoutBCName ?: OperatorNameConventions.GET
override val IrType.getFunction
get() = getClass()!!.functions.single {
it.name == OperatorNameConventions.GET &&
it.name == getFunctionName &&
it.valueParameters.size == 1 &&
it.valueParameters[0].type.isInt()
}
@@ -575,6 +575,10 @@ internal class KonanSymbols(
val topLevelSuite = getKonanTestClass("TopLevelSuite")
val testFunctionKind = getKonanTestClass("TestFunctionKind")
override val getWithoutBCName: Name? = KonanNameConventions.getWithoutBC
override val setWithoutBCName: Name? = KonanNameConventions.setWithoutBC
private val testFunctionKindCache = TestProcessor.FunctionKind.values().associate {
val symbol = if (it.runtimeKindString.isEmpty())
null