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

[lworld] CDS should not force the computation of identity hash code for value instances

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • tbd
    • repo-valhalla
    • hotspot

       In HeapShared::archive_object(oop obj), CDS unconditionally invokes identity_hash() on objects being archived:

          // The archived objects are discovered in a predictable order. Compute
          // their identity_hash() as soon as we see them. This ensures that the
          // the identity_hash in the object header will have a predictable value,
          // making the archive reproducible.
          obj->identity_hash();

      This is an issue for value instances because the computation of the identity hash code for instances of value classes is delegated to Java code (method handle generated by ValueObjects.valueTypeHashCode()), but HeapShared::archive_object() is executed by the VM Thread, which cannot execute Java code.

      As explained in the comment, the goal of CDS is to improve the archive reproducibility, but CDS itself doesn't depend on this identity hash code. The identity hash code of value instance depends on its fields content, so there's no need to force its computation, its value being already reproducible from the value object's content.

            fparain Frederic Parain
            fparain Frederic Parain
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: