If at least one of the range bounds is "pure", order doesn't matter
This commit is contained in:
@@ -52,8 +52,14 @@ class SimpleBoundedValue(
|
|||||||
) : this(codegen, rangeCall, lowBound, true, highBound, true)
|
) : this(codegen, rangeCall, lowBound, true, highBound, true)
|
||||||
|
|
||||||
override fun putHighLow(v: InstructionAdapter, type: Type) {
|
override fun putHighLow(v: InstructionAdapter, type: Type) {
|
||||||
lowBound.put(type, v)
|
if (!lowBound.canHaveSideEffects() || !highBound.canHaveSideEffects()) {
|
||||||
highBound.put(type, v)
|
highBound.put(type, v)
|
||||||
AsmUtil.swap(v, type, type)
|
lowBound.put(type, v)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lowBound.put(type, v)
|
||||||
|
highBound.put(type, v)
|
||||||
|
AsmUtil.swap(v, type, type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
fun test(a: Long) = a in 1L .. 10L
|
||||||
|
|
||||||
|
// One DUP2_X2 generated for 'in' operator,
|
||||||
|
// no DUP2_X2 generated for range on stack.
|
||||||
|
// 1 DUP2_X2
|
||||||
@@ -1912,6 +1912,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/ranges/inUntil.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/ranges/inUntil.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noSwap2ForConstLongRangeTo.kt")
|
||||||
|
public void testNoSwap2ForConstLongRangeTo() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/ranges/noSwap2ForConstLongRangeTo.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/bytecodeText/statements")
|
@TestMetadata("compiler/testData/codegen/bytecodeText/statements")
|
||||||
|
|||||||
Reference in New Issue
Block a user