8071787: Don't block inlining when DONT_INLINE_THRESHOLD=0
authorvlivanov
Thu, 29 Jan 2015 10:29:43 -0800
changeset 29021 cf13db21f970
parent 29020 9f6d43586ccb
child 29022 31bbb5dcc603
8071787: Don't block inlining when DONT_INLINE_THRESHOLD=0 Reviewed-by: jrose
jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Thu Jan 29 10:27:30 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Thu Jan 29 10:29:43 2015 -0800
@@ -753,7 +753,7 @@
     static
     MethodHandle profile(MethodHandle target) {
         if (DONT_INLINE_THRESHOLD >= 0) {
-            return makeBlockInlningWrapper(target);
+            return makeBlockInliningWrapper(target);
         } else {
             return target;
         }
@@ -764,8 +764,13 @@
      * Corresponding LambdaForm has @DontInline when compiled into bytecode.
      */
     static
-    MethodHandle makeBlockInlningWrapper(MethodHandle target) {
-        LambdaForm lform = PRODUCE_BLOCK_INLINING_FORM.apply(target);
+    MethodHandle makeBlockInliningWrapper(MethodHandle target) {
+        LambdaForm lform;
+        if (DONT_INLINE_THRESHOLD > 0) {
+            lform = PRODUCE_BLOCK_INLINING_FORM.apply(target);
+        } else {
+            lform = PRODUCE_REINVOKER_FORM.apply(target);
+        }
         return new CountingWrapper(target, lform,
                 PRODUCE_BLOCK_INLINING_FORM, PRODUCE_REINVOKER_FORM,
                                    DONT_INLINE_THRESHOLD);
@@ -836,7 +841,8 @@
         }
 
         boolean countDown() {
-            if (count <= 0) {
+            int c = count;
+            if (c <= 1) {
                 // Try to limit number of updates. MethodHandle.updateForm() doesn't guarantee LF update visibility.
                 if (isCounting) {
                     isCounting = false;
@@ -845,7 +851,7 @@
                     return false;
                 }
             } else {
-                --count;
+                count = c - 1;
                 return false;
             }
         }