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

Use size_t instead of int to represent object size in CDS code

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 13
    • Fix Version/s: tbd
    • Component/s: hotspot
    • Labels:

      Description

      Parts of the CDS code uses int to represent the size of an object. These should be change to size_t.

      Example:

      http://hg.openjdk.java.net/jdk/jdk/file/1512d88b24c6/src/hotspot/share/classfile/compactHashtable.cpp#l73

      size_t CompactHashtableWriter::estimate_size(int num_entries) {
        int num_buckets = calculate_num_buckets(num_entries);
        size_t bucket_bytes = MetaspaceShared::ro_array_bytesize<u4>(num_buckets + 1);

        // In worst case, we have no VALUE_ONLY_BUCKET_TYPE, so each entry takes 2 slots
        int entries_space = 2 * num_entries;
        size_t entry_bytes = MetaspaceShared::ro_array_bytesize<u4>(entries_space);

        return bucket_bytes
             + entry_bytes
             + SimpleCompactHashtable::calculate_header_size();
      }

      We should also add asserts to prevent integer overflow in the final addition expression.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              iklam Ioi Lam
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: