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

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

    XMLWordPrintable

Details

    • Enhancement
    • Status: Resolved
    • P4
    • Resolution: Fixed
    • 16
    • 16
    • hotspot
    • b08

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: