Constant propagation & withfield updation.
Srikanth
srikanth.adayapalam at oracle.com
Wed Mar 7 06:48:37 UTC 2018
At the moment, javac allows updates to both blank final and non-blank
final instance fields of a value class via the __WithField operator.
I am trying to confirm that we want to allow updates to initialized
non-blank final fields too. (Or not)
Such allowance interferes with constant propagation - I was searching
for the text in JLS that says what the compiler must do when a final
field is initialized with a compile time constant expression - I located
only the slightly oblique reference in 17.5.3, which reads:
"If a final field is initialized to a constant expression (§15.28) in
the field declaration, changes to the final
field may not be observed, since uses of that final field are replaced
at compile time with the value of the
constant expression."
This passage which occurs in the context of deserialization and
reflection based updates to final fields will also be relevant for
WithField updates.
ATM, I have disabled such propagation of constants for value class's
final instance fields initialized with constant expressions and reads of
these fields result in fresh getfield instructions.
I don't yet know what all the side effects of disabling this propagation.
FWIW, in the orignal Valhalla prototype, withfield updates were
permitted only for blank finals, so this was not an issue.
Comments ?
Thanks in advance.
Srikanth
More information about the valhalla-dev
mailing list