Simplify generated code for rangeTo/concat intrinsics

The main reason is avoiding complicated operations like
dup + dup_x2 + pop2 for instances obtained by NEW instruction.

Otherwise it leads to problems in performRefinedTypeAnalysis
because code there has a sensible assumption that NEW instances
can be only dupped or stored into a local (rare cases)

 #KT-17457 Fixed
This commit is contained in:
Denis Zharkov
2017-05-19 16:16:08 +03:00
parent 419f12f1b7
commit 52b2e632df
12 changed files with 134 additions and 25 deletions
@@ -116,10 +116,8 @@ class Concat : IntrinsicMethod() {
}
}
override fun afterReceiverGeneration(v: InstructionAdapter) {
v.visitTypeInsn(Opcodes.NEW, "java/lang/StringBuilder")
v.dupX1()
v.swap()
override fun afterReceiverGeneration(v: InstructionAdapter, frameMap: FrameMap) {
v.generateNewInstanceDupAndPlaceBeforeStackTop(frameMap, AsmTypes.JAVA_STRING_TYPE, "java/lang/StringBuilder")
v.invokespecial("java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false)
}