[JVM_IR] Use direct field access to backing fields on current class.
The current backend uses direct field access to the backing field
instead of calling the companion object accessor, which calls
an accessibility bridge, which then gets the field for code such as:
```
class A {
companion object {
val s: String = "OK"
}
// f uses direct access to the A.s backing field.
fun f() = s
}
```
This change does the same for the IR backend.
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
class A {
|
||||
companion object {
|
||||
val s = "OK"
|
||||
var v = "NOT OK"
|
||||
}
|
||||
|
||||
fun f(): String = s
|
||||
|
||||
fun g() {
|
||||
v = "OK"
|
||||
}
|
||||
|
||||
inline fun i(j: () -> Unit) {
|
||||
j()
|
||||
}
|
||||
|
||||
fun h() {
|
||||
i {
|
||||
s
|
||||
v = "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// One direct `A.s` access in `f`.
|
||||
// One direct `A.s` access in the accessibility bridge `access$getS$cp`.
|
||||
// One direct `A.s` access in `h`.
|
||||
// 3 GETSTATIC A.s
|
||||
|
||||
// One direct `A.v` set in `g`.
|
||||
// One direct `A.v` set in the accessibility bridge `access$setV$cp`.
|
||||
// One direct `A.v` set in `A.<clinit>`
|
||||
// One direct `A.v` set in `h`.
|
||||
// 4 PUTSTATIC A.v
|
||||
|
||||
// No calls to the getter/setter on the companion object.
|
||||
// 0 INVOKEVIRTUAL A\$Companion.getS
|
||||
// 0 INVOKEVIRTUAL A\$Companion.setV
|
||||
Reference in New Issue
Block a user