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

Always initialize _body[0..1] in Symbol constructor

XMLWordPrintable

    • b08

        http://hg.openjdk.java.net/jdk/jdk/file/a5852eb26137/src/hotspot/share/oops/symbol.cpp#l53

        Symbol::Symbol(const u1* name, int length, int refcount) {
          _hash_and_refcount = pack_hash_and_refcount((short)os::random(), refcount);
          _length = length;
          _body[0] = 0; // in case length == 0 <<<<<< HERE
          for (int i = 0; i < length; i++) {
            byte_at_put(i, name[i]);
          }
        }

        Per Kim Barrett:
        The first two elements of _body are used by identity_hash().
        That seems like a possible reason to force initialization of both
        elements, which currently isn't done for length <= 1. But maybe it
        doesn't matter that identity_hash isn't consistent between processes,
        in which case forcing the initialization of _body[0] also shouldn't
        be needed.

              iklam Ioi Lam
              iklam Ioi Lam
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: