Use NoScopeRecordCliBindingTrace as default trace in GenerationUtils

NB we use 'Intrinsics.areEqual(Double, Double)' and
'Intrinsics.areEqual(Float, Float)', because right now we take
nullability from the inferred type of the expression (which is 'Any?' in
the test cases).
We should probably reconsider this in case of more exact information
available from the data flow analysis, e.g., in case of

  fun test(x: Any?) =
    x is Serializable && x is Double? && x == 0.0

We statically know that 'x' is not null in 'x == 0.0' (although it's
neither nullability of it's numeric type 'Double?' nor the nullability
of the inferred type 'Any?').

There might be some edge effects in the performance related to byte code
size and preventive unboxing and so on.
This commit is contained in:
Dmitry Petrov
2018-04-09 15:24:46 +03:00
parent 665d6c82ad
commit 7cf6c70fbf
10 changed files with 18 additions and 20 deletions

View File

@@ -1,3 +1,4 @@
// !LANGUAGE: +ProperIeee754Comparisons
fun equals5(a: Any?, b: Any?) = if (a is Double && b is Double?) a == b else null!!
fun equals6(a: Any?, b: Any?) = if (a is Double? && b is Double) a == b else null!!
@@ -17,7 +18,5 @@ fun box(): String {
return "OK"
}
// 1 areEqual \(Ljava/lang/Double;Ljava/lang/Double;\)Z
// 1 areEqual \(DLjava/lang/Double;\)Z
// 1 areEqual \(Ljava/lang/Double;D\)Z
// 3 areEqual \(Ljava/lang/Double;Ljava/lang/Double;\)Z
// 3 areEqual

View File

@@ -19,4 +19,5 @@ fun box(): String {
return "OK"
}
// 0 areEqual
// 3 areEqual \(Ljava/lang/Object;Ljava/lang/Object;\)Z
// 3 areEqual

View File

@@ -1,3 +1,4 @@
// !LANGUAGE: +ProperIeee754Comparisons
fun equals5(a: Any?, b: Any?) = if (a is Float && b is Float?) a == b else null!!
fun equals6(a: Any?, b: Any?) = if (a is Float? && b is Float) a == b else null!!
@@ -17,7 +18,5 @@ fun box(): String {
return "OK"
}
// 1 areEqual \(Ljava/lang/Float;Ljava/lang/Float;\)Z
// 1 areEqual \(FLjava/lang/Float;\)Z
// 1 areEqual \(Ljava/lang/Float;F\)Z
// 3 areEqual \(Ljava/lang/Float;Ljava/lang/Float;\)Z
// 3 areEqual

View File

@@ -19,4 +19,5 @@ fun box(): String {
return "OK"
}
// 0 areEqual
// 3 areEqual \(Ljava/lang/Object;Ljava/lang/Object;\)Z
// 3 areEqual

View File

@@ -1,3 +1,4 @@
// !LANGUAGE: +ProperIeee754Comparisons
fun box(): String {
val plusZero: Any = 0.0
val minusZero: Any = -0.0

View File

@@ -28,4 +28,5 @@ fun box(): String {
return "OK"
}
// 0 areEqual
// 4 areEqual \(Ljava/lang/Object;Ljava/lang/Object;\)Z
// 4 areEqual

View File

@@ -1,3 +1,4 @@
// !LANGUAGE: +ProperIeee754Comparisons
fun box(): String {
val nullValue: Any? = null
val nullDouble: Double? = null

View File

@@ -26,4 +26,5 @@ fun box(): String {
}
return "OK"
}
// 0 areEqual
// 4 areEqual \(Ljava/lang/Object;Ljava/lang/Object;\)Z
// 4 areEqual