psi2ir: Optimize generated data class members
- Access underlying fields directly, instead of using accessors. This is safe since data classes are always final. - Don't generate a temporary variable in hashCode to use as the accumulator. Both optimizations are effectively present in the current JVM backend and with these changes the generated code is much closer to what the current backend generates.
This commit is contained in:
committed by
Alexander Udalov
parent
7ccf314808
commit
76ab631214
+26
-34
@@ -42,33 +42,33 @@
|
||||
@1:8..18 VALUE_PARAMETER name:<this> type:<root>.C
|
||||
@1:8..18 BLOCK_BODY
|
||||
@1:8..18 RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int declared in <root>.C'
|
||||
@1:8..18 CALL 'public final fun <get-x> (): kotlin.Int declared in <root>.C' type=kotlin.Int origin=GET_PROPERTY
|
||||
@1:8..18 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
@1:8..18 GET_VAR '<this>: <root>.C declared in <root>.C.component1' type=<root>.C origin=null
|
||||
@2:8..21 FUN GENERATED_DATA_CLASS_MEMBER name:component2 visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.String
|
||||
@2:8..21 VALUE_PARAMETER name:<this> type:<root>.C
|
||||
@2:8..21 BLOCK_BODY
|
||||
@2:8..21 RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.String declared in <root>.C'
|
||||
@2:8..21 CALL 'public final fun <get-y> (): kotlin.String declared in <root>.C' type=kotlin.String origin=GET_PROPERTY
|
||||
@2:8..21 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
@2:8..21 GET_VAR '<this>: <root>.C declared in <root>.C.component2' type=<root>.C origin=null
|
||||
@3:8..18 FUN GENERATED_DATA_CLASS_MEMBER name:component3 visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Any
|
||||
@3:8..18 VALUE_PARAMETER name:<this> type:<root>.C
|
||||
@3:8..18 BLOCK_BODY
|
||||
@3:8..18 RETURN type=kotlin.Nothing from='public final fun component3 (): kotlin.Any declared in <root>.C'
|
||||
@3:8..18 CALL 'public final fun <get-z> (): kotlin.Any declared in <root>.C' type=kotlin.Any origin=GET_PROPERTY
|
||||
@3:8..18 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:z type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null
|
||||
@3:8..18 GET_VAR '<this>: <root>.C declared in <root>.C.component3' type=<root>.C origin=null
|
||||
@0:0..4:1 FUN GENERATED_DATA_CLASS_MEMBER name:copy visibility:public modality:FINAL <> ($this:<root>.C, x:kotlin.Int, y:kotlin.String, z:kotlin.Any) returnType:<root>.C
|
||||
@0:0..4:1 VALUE_PARAMETER name:<this> type:<root>.C
|
||||
@1:8..18 VALUE_PARAMETER name:x index:0 type:kotlin.Int
|
||||
@0:0..4:1 EXPRESSION_BODY
|
||||
@0:0..4:1 CALL 'public final fun <get-x> (): kotlin.Int declared in <root>.C' type=kotlin.Int origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.copy' type=<root>.C origin=null
|
||||
@2:8..21 VALUE_PARAMETER name:y index:1 type:kotlin.String
|
||||
@0:0..4:1 EXPRESSION_BODY
|
||||
@0:0..4:1 CALL 'public final fun <get-y> (): kotlin.String declared in <root>.C' type=kotlin.String origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.copy' type=<root>.C origin=null
|
||||
@3:8..18 VALUE_PARAMETER name:z index:2 type:kotlin.Any
|
||||
@0:0..4:1 EXPRESSION_BODY
|
||||
@0:0..4:1 CALL 'public final fun <get-z> (): kotlin.Any declared in <root>.C' type=kotlin.Any origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:z type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.copy' type=<root>.C origin=null
|
||||
@0:0..4:1 BLOCK_BODY
|
||||
@0:0..4:1 RETURN type=kotlin.Nothing from='public final fun copy (x: kotlin.Int, y: kotlin.String, z: kotlin.Any): <root>.C declared in <root>.C'
|
||||
@@ -83,44 +83,36 @@
|
||||
@0:0..4:1 STRING_CONCATENATION type=kotlin.String
|
||||
@0:0..4:1 CONST String type=kotlin.String value="C("
|
||||
@0:0..4:1 CONST String type=kotlin.String value="x="
|
||||
@0:0..4:1 CALL 'public final fun <get-x> (): kotlin.Int declared in <root>.C' type=kotlin.Int origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.toString' type=<root>.C origin=null
|
||||
@0:0..4:1 CONST String type=kotlin.String value=", "
|
||||
@0:0..4:1 CONST String type=kotlin.String value="y="
|
||||
@0:0..4:1 CALL 'public final fun <get-y> (): kotlin.String declared in <root>.C' type=kotlin.String origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.toString' type=<root>.C origin=null
|
||||
@0:0..4:1 CONST String type=kotlin.String value=", "
|
||||
@0:0..4:1 CONST String type=kotlin.String value="z="
|
||||
@0:0..4:1 CALL 'public final fun <get-z> (): kotlin.Any declared in <root>.C' type=kotlin.Any origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:z type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.toString' type=<root>.C origin=null
|
||||
@0:0..4:1 CONST String type=kotlin.String value=")"
|
||||
@0:0..4:1 FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:<root>.C) returnType:kotlin.Int
|
||||
@0:0..4:1 VALUE_PARAMETER name:<this> type:<root>.C
|
||||
@0:0..4:1 BLOCK_BODY
|
||||
@0:0..4:1 VAR IR_TEMPORARY_VARIABLE name:tmp0_result type:kotlin.Int [var]
|
||||
@0:0..4:1 CONST Int type=kotlin.Int value=0
|
||||
@0:0..4:1 SET_VAR 'var tmp0_result: kotlin.Int [var] declared in <root>.C.hashCode' type=kotlin.Unit origin=EQ
|
||||
@0:0..4:1 CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
@0:0..4:1 CALL 'public final fun <get-x> (): kotlin.Int declared in <root>.C' type=kotlin.Int origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.hashCode' type=<root>.C origin=null
|
||||
@0:0..4:1 SET_VAR 'var tmp0_result: kotlin.Int [var] declared in <root>.C.hashCode' type=kotlin.Unit origin=EQ
|
||||
@0:0..4:1 RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in <root>.C'
|
||||
@0:0..4:1 CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
@0:0..4:1 CALL 'public final fun times (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
@0:0..4:1 GET_VAR 'var tmp0_result: kotlin.Int [var] declared in <root>.C.hashCode' type=kotlin.Int origin=null
|
||||
@0:0..4:1 CONST Int type=kotlin.Int value=31
|
||||
@0:0..4:1 CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=null
|
||||
@0:0..4:1 CALL 'public final fun <get-y> (): kotlin.String declared in <root>.C' type=kotlin.String origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.hashCode' type=<root>.C origin=null
|
||||
@0:0..4:1 SET_VAR 'var tmp0_result: kotlin.Int [var] declared in <root>.C.hashCode' type=kotlin.Unit origin=EQ
|
||||
@0:0..4:1 CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
@0:0..4:1 CALL 'public final fun times (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
@0:0..4:1 GET_VAR 'var tmp0_result: kotlin.Int [var] declared in <root>.C.hashCode' type=kotlin.Int origin=null
|
||||
@0:0..4:1 CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
@0:0..4:1 CALL 'public final fun times (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
@0:0..4:1 CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.hashCode' type=<root>.C origin=null
|
||||
@0:0..4:1 CONST Int type=kotlin.Int value=31
|
||||
@0:0..4:1 CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=null
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.hashCode' type=<root>.C origin=null
|
||||
@0:0..4:1 CONST Int type=kotlin.Int value=31
|
||||
@0:0..4:1 CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null
|
||||
@0:0..4:1 CALL 'public final fun <get-z> (): kotlin.Any declared in <root>.C' type=kotlin.Any origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:z type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.hashCode' type=<root>.C origin=null
|
||||
@0:0..4:1 RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in <root>.C'
|
||||
@0:0..4:1 GET_VAR 'var tmp0_result: kotlin.Int [var] declared in <root>.C.hashCode' type=kotlin.Int origin=null
|
||||
@0:0..4:1 FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:<root>.C, other:kotlin.Any?) returnType:kotlin.Boolean
|
||||
@0:0..4:1 VALUE_PARAMETER name:<this> type:<root>.C
|
||||
@0:0..4:1 VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
@@ -145,9 +137,9 @@
|
||||
@0:0..4:1 BRANCH
|
||||
@0:0..4:1 CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
@0:0..4:1 CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
@0:0..4:1 CALL 'public final fun <get-x> (): kotlin.Int declared in <root>.C' type=kotlin.Int origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.equals' type=<root>.C origin=null
|
||||
@0:0..4:1 CALL 'public final fun <get-x> (): kotlin.Int declared in <root>.C' type=kotlin.Int origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
@0:0..4:1 GET_VAR 'val tmp0_other_with_cast: <root>.C [val] declared in <root>.C.equals' type=<root>.C origin=null
|
||||
@0:0..4:1 RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.C'
|
||||
@0:0..4:1 CONST Boolean type=kotlin.Boolean value=false
|
||||
@@ -155,9 +147,9 @@
|
||||
@0:0..4:1 BRANCH
|
||||
@0:0..4:1 CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
@0:0..4:1 CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
@0:0..4:1 CALL 'public final fun <get-y> (): kotlin.String declared in <root>.C' type=kotlin.String origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.equals' type=<root>.C origin=null
|
||||
@0:0..4:1 CALL 'public final fun <get-y> (): kotlin.String declared in <root>.C' type=kotlin.String origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
@0:0..4:1 GET_VAR 'val tmp0_other_with_cast: <root>.C [val] declared in <root>.C.equals' type=<root>.C origin=null
|
||||
@0:0..4:1 RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.C'
|
||||
@0:0..4:1 CONST Boolean type=kotlin.Boolean value=false
|
||||
@@ -165,9 +157,9 @@
|
||||
@0:0..4:1 BRANCH
|
||||
@0:0..4:1 CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
@0:0..4:1 CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
@0:0..4:1 CALL 'public final fun <get-z> (): kotlin.Any declared in <root>.C' type=kotlin.Any origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:z type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null
|
||||
@0:0..4:1 GET_VAR '<this>: <root>.C declared in <root>.C.equals' type=<root>.C origin=null
|
||||
@0:0..4:1 CALL 'public final fun <get-z> (): kotlin.Any declared in <root>.C' type=kotlin.Any origin=GET_PROPERTY
|
||||
@0:0..4:1 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:z type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null
|
||||
@0:0..4:1 GET_VAR 'val tmp0_other_with_cast: <root>.C [val] declared in <root>.C.equals' type=<root>.C origin=null
|
||||
@0:0..4:1 RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.C'
|
||||
@0:0..4:1 CONST Boolean type=kotlin.Boolean value=false
|
||||
|
||||
Reference in New Issue
Block a user