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

Quadruple dmbs could be emitted after JDK-8324186

XMLWordPrintable

    • b08
    • aarch64

      While working on a JMH I noticed that with JDK-8324186, with -XX:-AlwaysMergeDMB I could get a sequence of multiple dmb combos. A simple example JMH is pasted at the bottom. This multiple dmb's does not happen with +AlwaysMergeDMB.

      I am not sure if this causes a regression in any established benchmark.

      ========

      From perfasm:

         0.06% 0x0000ffff9488c874: str w12, [x20, #12] ;*invokespecial <init> {reexecute=0 rethrow=0 return_oop=0}
                                                                              ; - org.openjdk.bench.vm.compiler.DoubleDMB$A::<init>@16 (line 30)
                                                                              ; - org.openjdk.bench.vm.compiler.DoubleDMB$C::getA@16 (line 39)
                                                                              ; - org.openjdk.bench.vm.compiler.DoubleDMB::action@14 (line 56)
                    0x0000ffff9488c878: dmb ishst
         0.01% 0x0000ffff9488c87c: dmb ishld
         1.28% 0x0000ffff9488c880: dmb ishst
         0.02% 0x0000ffff9488c884: dmb ishld ;*putstatic c {reexecute=0 rethrow=0 return_oop=0}
                                                                              ; - org.openjdk.bench.vm.compiler.DoubleDMB::action@8 (line 54)
                    0x0000ffff9488c888: ldrsb w10, [x28, #56]
         0.04% 0x0000ffff9488c88c: cbnz w10, 0x0000ffff9488c990
         1.10% 0x0000ffff9488c890: mov x10, x21




      =====

      package org.openjdk.bench.vm.compiler;

      import java.util.concurrent.TimeUnit;
      import org.openjdk.jmh.annotations.Benchmark;
      import org.openjdk.jmh.annotations.BenchmarkMode;
      import org.openjdk.jmh.annotations.CompilerControl;
      import org.openjdk.jmh.annotations.Fork;
      import org.openjdk.jmh.annotations.Group;
      import org.openjdk.jmh.annotations.GroupThreads;
      import org.openjdk.jmh.annotations.Measurement;
      import org.openjdk.jmh.annotations.Mode;
      import org.openjdk.jmh.annotations.OperationsPerInvocation;
      import org.openjdk.jmh.annotations.OutputTimeUnit;
      import org.openjdk.jmh.annotations.Param;
      import org.openjdk.jmh.annotations.Scope;
      import org.openjdk.jmh.annotations.Setup;
      import org.openjdk.jmh.annotations.State;
      import org.openjdk.jmh.annotations.Warmup;
      import org.openjdk.jmh.infra.Blackhole;

      @BenchmarkMode(Mode.Throughput)
      @State(Scope.Benchmark)
      @OutputTimeUnit(TimeUnit.MICROSECONDS)
      @Warmup(iterations = 8, time = 4)
      @Measurement(iterations = 6, time = 3)
      public class DoubleDMB {

        class A {

          final String b = new String("Hi there");
        }

        class C {

          private A a;

          public A getA() {
            if (a == null) {
              a = new A();
            }
            return a;
          }
        }

        static C c = null;

        @Setup
        public void setup() {
          c = new C();
        }

        @CompilerControl(CompilerControl.Mode.DONT_INLINE)
        void action(Blackhole b) throws Exception {
          c = new C();

          if (c.getA().b == null) {
            throw new Exception("a should not be null");
          }
          b.consume(c);
        }

        @Benchmark
        @Fork(value = 1, jvmArgsAppend = {
          "-XX:+UnlockDiagnosticVMOptions", "-XX:+AlwaysMergeDMB"})
        public void plusAlwaysMergeDMB(Blackhole b) throws Exception {

          action(b);
        }

        @Benchmark
        @Fork(value = 1, jvmArgsAppend = {
          "-XX:+UnlockDiagnosticVMOptions", "-XX:-AlwaysMergeDMB"})
        public void minusAlwaysMergeDMB(Blackhole b) throws Exception {

          action(b);
        }

      }

            Unassigned Unassigned
            ecaspole Eric Caspole
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: