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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 12
    • None
    • hotspot
    • --with-jvm-features=zgc

    • gc
    • b23

      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.

            pliden Per Liden (Inactive)
            dchuyko Dmitry Chuyko
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: