RFR: 8274983: Pattern.matcher performance regression after JDK-8238358
Xin Liu
xliu at openjdk.java.net
Thu Nov 18 06:20:56 UTC 2021
The root cause of the C1 regression is that regex generates multiple classes which all implement
an interface. In SlowStartupTest.java, the follwoing call happens frequently with different receivers.
9: invokeinterface #25, 3 // InterfaceMethod java/util/regex/Pattern$BmpCharPredicate.lambda$union$2:(Ljava/util/regex/Pattern$CharPredicate;I)Z
This patch allows c1 to generate the optimized virtual call for invokeinterface
whose targets are the private interface methods.
Before JDK-823835, LambdaMetaFactory generates invokespecial in this case. Because the private
interface methods can not be overrided, c1 generates the optimized virtual call. After JDK-823835,
LambdaMetaFactory generates invokeinterface instead. C1 generates the regular virtual call because
it can not recognize the new pattern. If a multiple of subclasses all implement a same interface,
it is possible that they trash the IC stub using their own concrete klass in runtime.
Optimized virtual call uses relocInfo::opt_virtual_call_type(3), It will call VM
'resolve_opt_virtual_call_C' once and resolve the target to the VEP of the nmethod.
Therefore, this patch can prevent the callsite from trashing.
-------------
Commit messages:
- 8274983: Pattern.matcher performance regression after JDK-823835
Changes: https://git.openjdk.java.net/jdk/pull/6445/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6445&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8274983
Stats: 23 lines in 3 files changed: 14 ins; 5 del; 4 mod
Patch: https://git.openjdk.java.net/jdk/pull/6445.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/6445/head:pull/6445
PR: https://git.openjdk.java.net/jdk/pull/6445
More information about the hotspot-compiler-dev
mailing list