|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
JDK-8149813 had exposed java.lang.String to the trusted classes, and that makes both C1 and C2 trust String.coder and String.value fields, making up a good length() folding.
However, that trust is not enough to constant fold the String.value *contents*. Which means the code like this is not folded:
static final String TEST_STRING_LATIN1 = "Foo";
@Benchmark
public int string_latin1() {
return TEST_STRING_LATIN1.charAt(0);
}
A simple change may force VM to trust String.value:
http://cr.openjdk.java.net/~shade/8150180/webrev.jdk.01/
http://cr.openjdk.java.net/~shade/8150180/webrev.hs.01/
Notes:
http://cr.openjdk.java.net/~shade/8150180/notes.txt