Optimize range operations for 'until' extension from stdlib (KT-9900)

NB: for-in-until loop is generated as precondition loop, because the
corresponding range is right-exclusive (and thus we have no problems
with integer overflows).
This commit is contained in:
Dmitry Petrov
2017-05-02 15:00:14 +03:00
parent b83620fdb9
commit 506941e7e0
27 changed files with 533 additions and 8 deletions
@@ -13364,6 +13364,69 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInUntil")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInUntil extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInForInUntil() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInUntil"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("forInUntilChar.kt")
public void testForInUntilChar() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar.kt");
doTest(fileName);
}
@TestMetadata("forInUntilChar0.kt")
public void testForInUntilChar0() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar0.kt");
doTest(fileName);
}
@TestMetadata("forInUntilInt.kt")
public void testForInUntilInt() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilInt.kt");
doTest(fileName);
}
@TestMetadata("forInUntilLesserInt.kt")
public void testForInUntilLesserInt() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLesserInt.kt");
doTest(fileName);
}
@TestMetadata("forInUntilLong.kt")
public void testForInUntilLong() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLong.kt");
doTest(fileName);
}
@TestMetadata("forInUntilMaxint.kt")
public void testForInUntilMaxint() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMaxint.kt");
doTest(fileName);
}
@TestMetadata("forInUntilMinint.kt")
public void testForInUntilMinint() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinint.kt");
doTest(fileName);
}
@TestMetadata("forInUntilMinlong.kt")
public void testForInUntilMinlong() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinlong.kt");
doTest(fileName);
}
@TestMetadata("forIntInIntUntilSmartcastInt.kt")
public void testForIntInIntUntilSmartcastInt() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forIntInIntUntilSmartcastInt.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/literal")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1151,6 +1151,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
doTest(fileName);
}
@TestMetadata("forInUntil.kt")
public void testForInUntil() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/forInUntil.kt");
doTest(fileName);
}
@TestMetadata("forIntInDownTo.kt")
public void testForIntInDownTo() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/forIntInDownTo.kt");
@@ -13364,6 +13364,69 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInUntil")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInUntil extends AbstractLightAnalysisModeTest {
public void testAllFilesPresentInForInUntil() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInUntil"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("forInUntilChar.kt")
public void testForInUntilChar() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar.kt");
doTest(fileName);
}
@TestMetadata("forInUntilChar0.kt")
public void testForInUntilChar0() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar0.kt");
doTest(fileName);
}
@TestMetadata("forInUntilInt.kt")
public void testForInUntilInt() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilInt.kt");
doTest(fileName);
}
@TestMetadata("forInUntilLesserInt.kt")
public void testForInUntilLesserInt() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLesserInt.kt");
doTest(fileName);
}
@TestMetadata("forInUntilLong.kt")
public void testForInUntilLong() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLong.kt");
doTest(fileName);
}
@TestMetadata("forInUntilMaxint.kt")
public void testForInUntilMaxint() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMaxint.kt");
doTest(fileName);
}
@TestMetadata("forInUntilMinint.kt")
public void testForInUntilMinint() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinint.kt");
doTest(fileName);
}
@TestMetadata("forInUntilMinlong.kt")
public void testForInUntilMinlong() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinlong.kt");
doTest(fileName);
}
@TestMetadata("forIntInIntUntilSmartcastInt.kt")
public void testForIntInIntUntilSmartcastInt() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forIntInIntUntilSmartcastInt.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/literal")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)