RFR: 8254807: Optimize startsWith() for String.substring() [v7]
Xin Liu
xliu at openjdk.java.net
Sat Dec 19 07:40:09 UTC 2020
> The optimization transforms code from s=substring(base, beg, end); s.startsWith(prefix)
> to substring(base, beg, end) | base.startsWith(prefix, beg).
>
> it reduces uses of substring. hopefully c2 optimizer can remove the used substring.
Xin Liu has updated the pull request incrementally with two additional commits since the last revision:
- fix crash when users disable inliner using -XX:-Inline
when inliner is off, substring optimization is skipped as well
because it depends on late_inliner.
- do api transformation for trivial substrings.
A substring is trivial if it is generated from String.substring(base, beginIndex)
String.substring(base, beginIndex, endIndex) is not trivial unless endIndex == base.length().
This patch fixes the wrong transformation like this because x isn't trivial here.
String s = "abcd"; String x = s.substring(1, 2); x.startsWith("bc");
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/974/files
- new: https://git.openjdk.java.net/jdk/pull/974/files/c5a25bfb..044fdb41
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=974&range=06
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=974&range=05-06
Stats: 83 lines in 4 files changed: 73 ins; 4 del; 6 mod
Patch: https://git.openjdk.java.net/jdk/pull/974.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/974/head:pull/974
PR: https://git.openjdk.java.net/jdk/pull/974
More information about the hotspot-compiler-dev
mailing list