Make all progression headers inclusive, and decrement last for

last-exclusive progressions (i.e., "until" progressions and loop over
array indices).

This change makes it possible to correctly implement the handling of
"step" progressions. Computing the last element of a stepped progression
requires that the last is inclusive.

Also invert the while loop (into if + do-while) that is used when
lowering for-loops over progressions that cannot overflow. This keeps
the performance characteristics closer to the ForLoopsLowering in
kotlin-native, since the goal is to converge to this shared version.

Also used IrType instead of KotlinType, where possible.

 https://github.com/JetBrains/kotlin/pull/2390
 https://github.com/JetBrains/kotlin/pull/2305
This commit is contained in:
Mark Punzalan
2019-06-14 00:59:47 -07:00
committed by Mikhael Bogdanov
parent 39f6416757
commit de1e27c584
75 changed files with 1873 additions and 377 deletions
@@ -1742,26 +1742,6 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInStringSpecialized.kt");
}
@TestMetadata("forInUntil.kt")
public void testForInUntil() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil.kt");
}
@TestMetadata("forInUntilCharMaxValue.kt")
public void testForInUntilCharMaxValue() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntilCharMaxValue.kt");
}
@TestMetadata("forInUntilIntMaxValue.kt")
public void testForInUntilIntMaxValue() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntilIntMaxValue.kt");
}
@TestMetadata("forInUntilLongMaxValue.kt")
public void testForInUntilLongMaxValue() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntilLongMaxValue.kt");
}
@TestMetadata("forIntInDownTo.kt")
public void testForIntInDownTo() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forIntInDownTo.kt");
@@ -2079,6 +2059,49 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInSequenceWithIndexWithExplicitlyTypedIndexVariable.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/forLoop/forInUntil")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInUntil extends AbstractBytecodeTextTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInForInUntil() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/forLoop/forInUntil"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("forInUntilChar.kt")
public void testForInUntilChar() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilChar.kt");
}
@TestMetadata("forInUntilCharMaxValue.kt")
public void testForInUntilCharMaxValue() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMaxValue.kt");
}
@TestMetadata("forInUntilInt.kt")
public void testForInUntilInt() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilInt.kt");
}
@TestMetadata("forInUntilIntMaxValue.kt")
public void testForInUntilIntMaxValue() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMaxValue.kt");
}
@TestMetadata("forInUntilLong.kt")
public void testForInUntilLong() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLong.kt");
}
@TestMetadata("forInUntilLongMaxValue.kt")
public void testForInUntilLongMaxValue() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMaxValue.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/hashCode")