KT-6916 Slow bytecode for downTo iteration like for (i in max downTo min)
#KT-6916 fixed
This commit is contained in:
@@ -107,12 +107,7 @@ public class RangeCodegenUtil {
|
||||
@NotNull ImmutableMap<FqName, PrimitiveType> map
|
||||
) {
|
||||
ClassifierDescriptor declarationDescriptor = rangeOrProgression.getConstructor().getDeclarationDescriptor();
|
||||
assert declarationDescriptor != null;
|
||||
if (declarationDescriptor != KotlinBuiltIns.getInstance().getBuiltInsPackageScope().getClassifier(declarationDescriptor.getName())) {
|
||||
// Must be a standard library class
|
||||
return null;
|
||||
}
|
||||
return map.get(DescriptorUtils.getFqNameSafe(declarationDescriptor));
|
||||
return declarationDescriptor == null ? null : map.get(DescriptorUtils.getFqNameSafe(declarationDescriptor));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fun f() {
|
||||
for (i in 1..2) {
|
||||
}
|
||||
}
|
||||
|
||||
// 0 iterator
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
@@ -0,0 +1,8 @@
|
||||
fun f(a: Int, b: Int) {
|
||||
for (i in a..b) {
|
||||
}
|
||||
}
|
||||
|
||||
// 0 iterator
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
@@ -0,0 +1,11 @@
|
||||
fun f() {
|
||||
for (i in 0..5 step 2) {
|
||||
}
|
||||
for (i in 5 downTo 1) {
|
||||
}
|
||||
}
|
||||
|
||||
// 0 iterator
|
||||
// 2 getStart
|
||||
// 2 getEnd
|
||||
// 2 getIncrement
|
||||
@@ -0,0 +1,8 @@
|
||||
fun f(r: IntRange) {
|
||||
for (i in r) {
|
||||
}
|
||||
}
|
||||
|
||||
// 0 iterator
|
||||
// 1 getStart
|
||||
// 1 getEnd
|
||||
@@ -35,6 +35,7 @@ import java.util.regex.Pattern;
|
||||
BytecodeTextTestGenerated.Constants.class,
|
||||
BytecodeTextTestGenerated.DeadCodeElimination.class,
|
||||
BytecodeTextTestGenerated.DirectInvoke.class,
|
||||
BytecodeTextTestGenerated.ForLoop.class,
|
||||
BytecodeTextTestGenerated.Inline.class,
|
||||
BytecodeTextTestGenerated.LazyCodegen.class,
|
||||
BytecodeTextTestGenerated.LineNumbers.class,
|
||||
@@ -405,6 +406,39 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/forLoop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ForLoop extends AbstractBytecodeTextTest {
|
||||
public void testAllFilesPresentInForLoop() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/forLoop"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveLiteralRange1.kt")
|
||||
public void testPrimitiveLiteralRange1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange1.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveLiteralRange2.kt")
|
||||
public void testPrimitiveLiteralRange2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveProgression.kt")
|
||||
public void testPrimitiveProgression() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/primitiveProgression.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveRange.kt")
|
||||
public void testPrimitiveRange() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/primitiveRange.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/inline")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user