Fix performance regression in NI by fixing totally incorrect hashCode
The actual problem was introduced in4f1e85b468, note how `hashCode` is implemented: ``` var currentHashCode = cachedHashCode if (currentHashCode == 0) return currentHashCode ... ``` It's a silly bug, there should be check `if (currentHashCode != 0) ...` because `0` is used a marker for "uncomputed value". Now, in the commit0219b86d06I added map with `KotlinType` as a key and because of constant `hash` for `KotlinType`, we basically got `List` instead of `Map`, which caused this performance regression #KT-34063 Fixed
This commit is contained in:
+5
@@ -10124,6 +10124,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/lessSpecificTypeForArgumentCallWithExactAnnotation_ni.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manyArgumentsForVararg.kt")
|
||||
public void testManyArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/manyArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedLambdas.kt")
|
||||
public void testNestedLambdas() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt");
|
||||
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
val prop = mapOf(
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b"),
|
||||
to("a", "b")
|
||||
)
|
||||
|
||||
fun <A, B> to(a: A, b: B): Pair<A, B> = TODO()
|
||||
fun <K, V> mapOf(vararg pairs: Pair<K, V>): Map<K, V> = TODO()
|
||||
|
||||
class Pair<out A, out B>
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public val prop: kotlin.collections.Map<kotlin.String, kotlin.String>
|
||||
public fun </*0*/ K, /*1*/ V> mapOf(/*0*/ vararg pairs: Pair<K, V> /*kotlin.Array<out Pair<K, V>>*/): kotlin.collections.Map<K, V>
|
||||
public fun </*0*/ A, /*1*/ B> to(/*0*/ a: A, /*1*/ b: B): Pair<A, B>
|
||||
|
||||
public final class Pair</*0*/ out A, /*1*/ out B> {
|
||||
public constructor Pair</*0*/ out A, /*1*/ out B>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -19,7 +19,7 @@ fun case_1(x: Any) {
|
||||
if (x is Interface1) {
|
||||
if (x is Interface2) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & Interface2 & kotlin.Any")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any"), DEBUG_INFO_SMARTCAST!>x<!>.itest()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any"), DEBUG_INFO_SMARTCAST!>x<!>.itest()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any"), DEBUG_INFO_SMARTCAST!>x<!>.itest1()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any"), DEBUG_INFO_SMARTCAST!>x<!>.itest2()
|
||||
}
|
||||
|
||||
@@ -1297,7 +1297,7 @@ fun case_71(t: Any?) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & Interface2 & kotlin.Any & kotlin.Any?")!>t<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest1()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest2()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest()
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.let { <!DEBUG_INFO_EXPRESSION_TYPE("{Any & Interface1 & Interface2}")!>it<!>.itest1(); <!DEBUG_INFO_EXPRESSION_TYPE("{Any & Interface1 & Interface2}")!>it<!>.itest2() }
|
||||
}
|
||||
@@ -1318,7 +1318,7 @@ fun case_72(t: Any?, z1: Nothing?) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & Interface2 & kotlin.Any & kotlin.Any?")!>t<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest1()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest2()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest()
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.let { <!DEBUG_INFO_EXPRESSION_TYPE("{Any & Interface1 & Interface2}")!>it<!>.itest1(); <!DEBUG_INFO_EXPRESSION_TYPE("{Any & Interface1 & Interface2}")!>it<!>.itest2() }
|
||||
}
|
||||
@@ -1340,7 +1340,7 @@ fun case_73(t: Any?) {
|
||||
if (t != <!DEBUG_INFO_CONSTANT!>`null`<!>) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest2()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest1()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface3 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.test1()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.test2()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel1 & ClassLevel2 & Interface1 & Interface2 & Interface3 & kotlin.Any & kotlin.Any?")!>t<!>
|
||||
@@ -1365,7 +1365,7 @@ fun case_74(t: Any?) {
|
||||
if (t is Interface3?) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest2()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest1()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface3 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.test1()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.test2()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel1 & ClassLevel2 & Interface1 & Interface2 & Interface3 & kotlin.Any & kotlin.Any?")!>t<!>
|
||||
@@ -1388,7 +1388,7 @@ fun case_75(t: Any?, z: Nothing?) {
|
||||
if (t !is Interface2? || t !is Interface3?) {} else {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest2()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest1()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Interface3 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.test1()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.test2()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>
|
||||
|
||||
@@ -10131,6 +10131,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/lessSpecificTypeForArgumentCallWithExactAnnotation_ni.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manyArgumentsForVararg.kt")
|
||||
public void testManyArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/manyArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedLambdas.kt")
|
||||
public void testNestedLambdas() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt");
|
||||
|
||||
Generated
+5
@@ -10126,6 +10126,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/lessSpecificTypeForArgumentCallWithExactAnnotation_ni.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manyArgumentsForVararg.kt")
|
||||
public void testManyArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/manyArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedLambdas.kt")
|
||||
public void testNestedLambdas() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt");
|
||||
|
||||
@@ -101,7 +101,7 @@ sealed class KotlinType : Annotated, KotlinTypeMarker {
|
||||
final override fun hashCode(): Int {
|
||||
// NB: make one read to prevent race
|
||||
var currentHashCode = cachedHashCode
|
||||
if (currentHashCode == 0) return currentHashCode
|
||||
if (currentHashCode != 0) return currentHashCode
|
||||
|
||||
currentHashCode = computeHashCode()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user