Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8145579

SimpleThresholdPolicy assumes non-trivial methods to be trivial

    Details

    • Subcomponent:
    • Resolved In Build:
      b36

      Backports

        Description

        The relevant code in SimpleThresholdPolicy was apparently introduced by JDK-8056071. It now consults MDO to see if method is trivial. However, there are cases when that guess is wrong, notably when we are dealing with intrinsics or simple calls inside the method.

        bool SimpleThresholdPolicy::is_trivial(Method* method) {
          ...
          MethodData* mdo = method->method_data();
          if (mdo != NULL && !mdo->would_profile() &&
              (method->code_size() < 5 || (mdo->num_blocks() < 4))) {
              return true;
            }
          return false;
        }

        See e.g. the benchmark against Unsafe.putOrdered:
         http://cr.openjdk.java.net/~shade/8145579/BadMDOPolicy.java
         http://cr.openjdk.java.net/~shade/8145579/benchmarks.jar

        It works significantly worse with TieredCompilation enabled, because it gets to compile with C1 only.

        Update: Perhaps, even more alarming is that Object::<init> is accepted as trivial, which makes tiered mode slower than non-tiered mode, if Object::<init> had not inlined into a hotpath:
          http://cr.openjdk.java.net/~shade/8145579/ObjectInit.java

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  dlong Dean Long
                  Reporter:
                  shade Aleksey Shipilev
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: