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

Emit single post-constructor barrier for chain of superclass constructors

XMLWordPrintable

      In order to follow the conservative strategy in implementing Java Memory Model,
      the implementations needs to emit StoreStore barrier at the end of constructor.
      When there are multiple super-class constructors, we can emit the single
      StoreStore barrier at the end of the last constructor, before we publish the
      reference to newly constructed object.

      However, as far as our compilers go, we put the StoreStore/MemBarRelease
      at each constructor's exit path during the bytecode translation. Which means
      that chained super constructors will have the excess barriers. We need
      a pass over the code (presumably after super constructors had inlined) in
      order to coalesce redundant barriers.

      This has little-to-none performance effect on x86, because these barriers are reduced
      to compiler-only barrier. However, on weakly ordered architectures a full-fledged
      memory barrier is emitted and affects performance.

            cslucas Cesar Soares
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: