changeset 36120:192b3ccf06ba

8148994: Replacing MH::invokeBasic with a direct call breaks LF customization Reviewed-by: jrose, redestad
author vlivanov
date Mon, 15 Feb 2016 20:27:12 +0300
parents eadb1818d0a1
children ba46027ccfb5
files jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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) {