Parts of the CDS code uses int in the calculation of buffer sizes. 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.
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.