-
Enhancement
-
Resolution: Fixed
-
P4
-
9
-
b110
The golden example is String.length() over static final Strings:
static final String TEST_STRING = "Foo";
@Benchmark
public int string_length() {
return TEST_STRING.length();
}
C2 folds the underlying (byte[].length >> coder) fine, because it both trusts the final String.value/coder, and folds arraylength.
C1 trusts String.value/coder afterJDK-8149813, but does not fold arraylength yet.
Sample benchmark + generated code:
http://cr.openjdk.java.net/~shade/8150102/FoldArrayLength.java
Proof-of-concept webrev:
http://cr.openjdk.java.net/~shade/8150102/webrev.00
static final String TEST_STRING = "Foo";
@Benchmark
public int string_length() {
return TEST_STRING.length();
}
C2 folds the underlying (byte[].length >> coder) fine, because it both trusts the final String.value/coder, and folds arraylength.
C1 trusts String.value/coder after
Sample benchmark + generated code:
http://cr.openjdk.java.net/~shade/8150102/FoldArrayLength.java
Proof-of-concept webrev:
http://cr.openjdk.java.net/~shade/8150102/webrev.00
- relates to
-
JDK-8150534 C1 compilation fails with "Constant field loads are folded during parsing"
-
- Resolved
-
-
JDK-8150514 C1 crashes in Canonicalizer::do_ArrayLength() after fix for JDK-8150102
-
- Closed
-