8148994: Replacing MH::invokeBasic with a direct call breaks LF customization
Reviewed-by: jrose, redestad
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Thu Feb 11 13:58:43 2016 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Mon Feb 15 20:27:12 2016 +0300
@@ -778,8 +778,21 @@
return (asTypeCache = wrapper);
}
+ // Customize target if counting happens for too long.
+ private int invocations = CUSTOMIZE_THRESHOLD;
+ private void maybeCustomizeTarget() {
+ int c = invocations;
+ if (c >= 0) {
+ if (c == 1) {
+ target.customize();
+ }
+ invocations = c - 1;
+ }
+ }
+
boolean countDown() {
int c = count;
+ maybeCustomizeTarget();
if (c <= 1) {
// Try to limit number of updates. MethodHandle.updateForm() doesn't guarantee LF update visibility.
if (isCounting) {