Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8141907 | emb-9 | Aleksey Shipilev | P4 | Resolved | Fixed | team |
We have an UseImplicitStableValues option that enables treating some known VM fields as stable. However, for String.value, it does only seem to matter in GraphKit, and therefore only the targeted compiler optimizations benefit from this, not the normal Java code. This gets in the way with Compact String work, which has a new "byte coder" field, that participates in every hot method, e.g.:
public int length() {
return value.length >> coder;
}
This method is compiled normally, and so escapes the provisions of UseImplicitStableValues. When we ask for "someconstantstring".length(), the coder field would always be read. To solve this, we might want to mark all final String fields as stable. It is not sufficient, however, to put @Stable over them (even if @Stable was a public annotation), because one of the legitimate values for "coder" is zero, which is coincidentally the default value for byte field. Therefore, we might need to put final String fields to TrustFinalNonStaticFields exceptions, to fold every value of coder.
public int length() {
return value.length >> coder;
}
This method is compiled normally, and so escapes the provisions of UseImplicitStableValues. When we ask for "someconstantstring".length(), the coder field would always be read. To solve this, we might want to mark all final String fields as stable. It is not sufficient, however, to put @Stable over them (even if @Stable was a public annotation), because one of the legitimate values for "coder" is zero, which is coincidentally the default value for byte field. Therefore, we might need to put final String fields to TrustFinalNonStaticFields exceptions, to fold every value of coder.
- backported by
-
JDK-8141907 Final String field values should be trusted as stable
- Resolved
- relates to
-
JDK-8233873 final field values should be trusted as constant
- Open
-
JDK-8054307 JEP 254: Compact Strings
- Closed