JVM IR: Optimize type checks to null checks if possible

This commit is contained in:
Steven Schäfer
2020-01-29 15:43:14 +01:00
committed by Georgy Bronnikov
parent 07737f8fc6
commit 951b2fa770
3 changed files with 12 additions and 4 deletions
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
abstract class A8 : MutableCollection<Any> {
override fun contains(o: Any): Boolean {
throw UnsupportedOperationException()
@@ -8,5 +7,9 @@ abstract class A8 : MutableCollection<Any> {
// 1 bridge
// 1 public final bridge size
// 0 INSTANCEOF
/* Only 1 IFNULL should be within contains method */
/* Only 1 null check should be within the contains method */
// JVM_TEMPLATES:
// 1 IFNULL
// JVM_IR_TEMPLATES:
// 1 IFNONNULL
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
abstract class A<T : Any> : MutableCollection<T> {
override fun contains(o: T): Boolean {
throw UnsupportedOperationException()
@@ -8,5 +7,9 @@ abstract class A<T : Any> : MutableCollection<T> {
// 1 bridge
// 1 public final bridge size
// 0 INSTANCEOF
/* Only 1 IFNULL should be within contains method (because T is not nullable) */
/* Only 1 null check should be within the contains method (because T is not nullable) */
// JVM_TEMPLATES:
// 1 IFNULL
// JVM_IR_TEMPLATES:
// 1 IFNONNULL