JVM_IR KT-50585 array constructor loop should end with IINC
This commit is contained in:
+16
-10
@@ -96,7 +96,11 @@ private class ArrayConstructorTransformer(
|
||||
putValueArgument(1, inlined)
|
||||
}
|
||||
val inc = index.type.getClass()!!.functions.single { it.name == OperatorNameConventions.INC }
|
||||
+irSet(index.symbol, irCallOp(inc.symbol, index.type, irGet(index)))
|
||||
+irSet(
|
||||
index.symbol,
|
||||
irCallOp(inc.symbol, index.type, irGet(index)),
|
||||
origin = IrStatementOrigin.PREFIX_INCR
|
||||
)
|
||||
}
|
||||
}
|
||||
+irGet(result)
|
||||
@@ -112,7 +116,11 @@ class ArrayConstructorReferenceLowering(val context: CommonBackendContext) : Bod
|
||||
irBody.transformChildrenVoid(ArrayConstructorReferenceTransformer(context, container as IrSymbolOwner))
|
||||
}
|
||||
|
||||
private class ArrayConstructorReferenceTransformer(val context: CommonBackendContext, val container: IrSymbolOwner) : IrElementTransformerVoid() {
|
||||
private class ArrayConstructorReferenceTransformer(
|
||||
val context: CommonBackendContext,
|
||||
val container: IrSymbolOwner
|
||||
) : IrElementTransformerVoid() {
|
||||
|
||||
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
|
||||
expression.transformChildrenVoid()
|
||||
val target = expression.symbol.owner
|
||||
@@ -127,14 +135,12 @@ class ArrayConstructorReferenceLowering(val context: CommonBackendContext) : Bod
|
||||
statements.add(wrapper)
|
||||
statements.add(
|
||||
IrFunctionReferenceImpl(
|
||||
startOffset,
|
||||
endOffset,
|
||||
type,
|
||||
wrapper.symbol,
|
||||
0,
|
||||
valueArgumentsCount,
|
||||
target.symbol,
|
||||
origin
|
||||
startOffset, endOffset, type,
|
||||
symbol = wrapper.symbol,
|
||||
typeArgumentsCount = 0,
|
||||
valueArgumentsCount = valueArgumentsCount,
|
||||
reflectionTarget = target.symbol,
|
||||
origin = origin
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+4
-4
@@ -38,8 +38,8 @@ fun testObjectArray(n: Int) =
|
||||
// 8 IF_ICMPGE
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 56 ILOAD
|
||||
// 24 ISTORE
|
||||
// 8 IADD
|
||||
// 48 ILOAD
|
||||
// 16 ISTORE
|
||||
// 0 IADD
|
||||
// 0 ISUB
|
||||
// 0 IINC
|
||||
// 8 IINC
|
||||
|
||||
+2
-2
@@ -11,5 +11,5 @@ fun test(): Int = "123".indexOfAny(CharArray(1000) { '1' })
|
||||
// JVM_IR_TEMPLATES:
|
||||
// 3 ALOAD
|
||||
// 3 ASTORE
|
||||
// 4 ILOAD
|
||||
// 3 ISTORE
|
||||
// 3 ILOAD
|
||||
// 2 ISTORE
|
||||
|
||||
Reference in New Issue
Block a user