[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:
Mads Ager
2020-11-25 14:36:40 +01:00
committed by max-kammerer
parent 1d14926444
commit c922484758
19 changed files with 524 additions and 6 deletions
@@ -0,0 +1,23 @@
class A {
companion object {
val s: String
get() = "Ok"
var v : String
get() = "NOT OK"
set(value) {}
}
inline fun f(): String = s
inline fun g() {
v = "OK"
}
}
// No backing field on A and all accesses call the getter/setter.
// 0 GETSTATIC A.s
// 0 PUTSTATIC A.v
// One `getS` call in `f` and one `setV` call in `g`
// 1 INVOKEVIRTUAL A\$Companion.getS
// 1 INVOKEVIRTUAL A\$Companion.setV