8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
Paul Sandoz
paul.sandoz at oracle.com
Tue Dec 1 11:13:27 UTC 2015
HI John, Remi,
AFAICT it’s implicitly supported but as John reminded me, it comes loaded with other semantics for array contents (which is currently also compiler dependent as C2 only supports that at the moment):
http://hg.openjdk.java.net/jdk9/dev/hotspot/file/tip/src/share/vm/ci/ciField.cpp#l204
void ciField::initialize_from(fieldDescriptor* fd) {
// Get the flags, offset, and canonical holder of the field.
_flags = ciFlags(fd->access_flags());
_offset = fd->offset();
_holder = CURRENT_ENV->get_instance_klass(fd->field_holder());
// Check to see if the field is constant.
bool is_final = this->is_final();
bool is_stable = FoldStableValues && this->is_stable();
if (_holder->is_initialized() && (is_final || is_stable)) {
if (!this->is_static()) {
// A field can be constant if it's a final static field or if
// it's a final non-static field of a trusted class (classes in
// java.lang.invoke and sun.invoke packages and subpackages).
if (is_stable || trust_final_non_static_fields(_holder)) {
_is_constant = true;
return;
}
_is_constant = false;
return;
}
For "final @Stable” on a non-arrays the documentation seems to imply the annotation is ignored:
* Fields which are declared {@code final} may also be annotated as stable.
* Since final fields already behave as stable values, such an annotation
* indicates no additional information, unless the type of the field is
* an array type.
* <p>
* It is (currently) undefined what happens if a field annotated as stable
* is given a third value. In practice, if the JVM relies on this annotation
* to promote a field reference to a constant, it may be that the Java memory
* model would appear to be broken, if such a constant (the second value of the field)
* is used as the value of the field even after the field value has changed.
I think we can get away with tweaking the above two paragraphs.
Paul.
> On 30 Nov 2015, at 22:34, John Rose <john.r.rose at oracle.com> wrote:
>
> On Nov 30, 2015, at 1:29 PM, Remi Forax <forax at univ-mlv.fr> wrote:
>>
>> One annotation is missing, @TrueFinal,
>> currently only the fields of the classes of java.lang.invoke are considered as true final.
>>
>> This annotation is also needed to improve the performance of the field updaters of j.u.c.a.
>> One can use @Stable instead but it seems awkward.
>
> Good idea! Let's use "final @Stable" for that. (It's gonna be awkward in any case, till we sort out final finally.)
>
> Paul, would you please file a followup bug for this? It may let us decouple the JVM from the TrustFinalFields special cases.
>
> — John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20151201/0d5ca433/signature.asc>
More information about the hotspot-compiler-dev
mailing list