8148994: Replacing MH::invokeBasic with a direct call breaks LF customization
authorvlivanov
Mon, 15 Feb 2016 20:27:12 +0300
changeset 36120 192b3ccf06ba
parent 35973 eadb1818d0a1
child 36121 ba46027ccfb5
8148994: Replacing MH::invokeBasic with a direct call breaks LF customization Reviewed-by: jrose, redestad
jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
--- 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) {