## For x86 code
Before calling the runtime to handle a full buffer, the code in G1BarrierSetAssembler::g1_write_barrier_post pushes and afterwards pops the register new_val.
This is either unnecessary and/or a bug:
It's caller, G1BarrierSetAssembler::oop_store_at(), depending on compressed oop mode moves the uncompressed new reference value into new_val since g1_write_barrier_post needs it to perform the out-of-region check.
It does so because store_at() modifies the given val.
That caller uses tmp2 for that, which is also used and modified in g1_write_barrier_post.
So the value we save and restore before the call is some temporary value, which should not be needed, the save/restore is unnecessary (particularly with compressed oops).
On the other hand, the caller of oop_store_at (or actually any caller of store_at()) might expect that the val register is not modified at all. In this case this save/restore is at the wrong place.
## For aarch64 code
The same problem.
Before calling the runtime to handle a full buffer, the code in G1BarrierSetAssembler::g1_write_barrier_post pushes and afterwards pops the register new_val.
This is either unnecessary and/or a bug:
It's caller, G1BarrierSetAssembler::oop_store_at(), depending on compressed oop mode moves the uncompressed new reference value into new_val since g1_write_barrier_post needs it to perform the out-of-region check.
It does so because store_at() modifies the given val.
That caller uses tmp2 for that, which is also used and modified in g1_write_barrier_post.
So the value we save and restore before the call is some temporary value, which should not be needed, the save/restore is unnecessary (particularly with compressed oops).
On the other hand, the caller of oop_store_at (or actually any caller of store_at()) might expect that the val register is not modified at all. In this case this save/restore is at the wrong place.
## For aarch64 code
The same problem.