RFR (S) 8134758: Final String field values should be trusted as stable

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Aug 31 17:15:51 UTC 2015


On 08/31/2015 07:25 PM, Vladimir Kozlov wrote:
> On 8/31/15 7:59 AM, Aleksey Shipilev wrote:
>> I would like to make a forward move and make VM to trust all final
>> String fields. I cannot quickly find the scenario where it helps current
>> JDK -- there is only String.value field, which components are not
>> treated as constants anyway. But, it helps a lot the upcoming Compact
>> Strings change, which introduces String.coder field.
> 
> Reflection?

Sorry? In Compact Strings, String.coder field defines how to interpret
String.value byte[] array. See the example in the bug:

    public int length() {
        return value.length >> coder;
    }

Ah, and if you worry about changing the field via Reflection, then like
String.value, which is already treated as "stable" by intrinsics,
String.coder is not supposed to be changed via Reflection (that is,
without potentially devastating consequences). Strings are also
deserialized via StringBuilder, so we are safe there as well.

>>
>> String.value is actually handled as stable in the GraphKit with
>> UseImplicitStableValues, but it does not affect "normal" Java code.
> 
> What do you mean by "normal" code?

The code that is not handled by intrinsics on any other special explicit
magic in a compiler. Just plain Java code, like the length() method
above. How do you call it?


>> Therefore, in a way, this change extends the same behavior to the normal
>> code. See more here:
>>    https://bugs.openjdk.java.net/browse/JDK-8134758
>>
>> Here is a patch:
>>    http://cr.openjdk.java.net/~shade/8134758/webrev.00/
> 
> Do we still need UseImplicitStableValues code in
> GraphKit::load_String_value() and library_call.cpp?

I think so. These seem to enforce that array components are also treated
as constants? Vladimir I., can you take a look?

Thanks,
-Aleksey


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20150831/f80cf98c/signature.asc>


More information about the hotspot-compiler-dev mailing list