When valhalla drops, I assume it will introduce ne...
# getting-started
u
When valhalla drops, I assume it will introduce new byte code, so kotlin compiler will need to be updated to emit such bytecode But what about android? I'd assume ART needs to implement such new bytecode -- does that mean the new true value classes will be bound to latest android version?
e
no new bytecode

https://youtu.be/IF9l8fYfSnI

the final approach they're taking is that code in a specific shape ("value class") will be marked as such (with verification that they follow the rules), but otherwise look like plain old objects. the behavior of value classes is then just a runtime optimization, and everything works the same (just maybe slower) without the optimizations
u
Hmm, I thought the point was to get rid of object headers etc, so it can be vectorized more easily and stuff like that. But okay I don't know enough. thank you!
e
if the class is verified to be a "value class" then the runtime will be able to optimize away the object headers and use a flat representation in some places. but if it doesn't do that, the code is still correct, it's just a difference in performance
u
okay but that still means vms have to implement ..something, right? so what do you think android would do?
e
the VM could implement nothing new. then you wouldn't get any benefits of value classes but your code would run
u
i know im just wondering how would ART do it to benefit afaik they can update vms remotely but only to android 12 i thino
e
it might have to be a new DEX file version because of the additional access modifiers, and then you can't deliver it to older devices
also other bootstraps already don't work on ART
g
> I'd assume ART needs to implement such new bytecode -- does that mean the new true value classes will be bound to latest android version? In general, it's not necessary, depending what you expect, most of the new JVM features are desugared by D8, to let class files to be compiled to older DEX, but in case of valhalla for example, it will not bring any advantages
u
yea im mostly looking at the perf gains rather than semantics, im already treating data classes as values
g
Yeah, I don't think it would give any performance gains for older versions, only for new ones Though, who knows, maybe some smart optimizations on level of R8 become possible