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

ZGC: Don't use memset to initialize array of ZForwardingTableEntry

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 12
    • Component/s: hotspot
    • Labels:
    • Environment:

      --with-jvm-features=zgc

    • Subcomponent:
      gc
    • Resolved In Build:
      b23

      Description

      Use placement new instead of memset() to avoid compiler warning/error when using GCC 8 with -Werror=class-memaccess (memset to initialize non-trivial object).

      Fails in zForwardingTable.cpp:42:
       memset(_table, ZForwardingTableEntry::empty(), _size * sizeof(ZForwardingTableEntry));

      Note that this setup() function is a bit performance sensitive, so the memset() here likely performs much better than a for-loop with placement new. An alternative would be to turn ZForwardingTableEntry into a trivial object and continue using memset(), but that requires some more code restructuring.

      Once could perhaps also argue that (Mmap|Malloc)ArrayAllocator should do the placement new loop, so that it always returns a properly constructed array.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pliden Per Liden
                Reporter:
                dchuyko Dmitry Chuyko
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: