Below is the calculate_header_size() implementation for JDK-8207812:
size_t SimpleCompactHashtable::calculate_header_size() {
// We have 5 fields. Each takes up sizeof(intptr_t). See WriteClosure::do_u4
size_t bytes = sizeof(intptr_t) * 5;
return bytes;
}
The 5 could be defined as a enum in SimpleCompactHashTable.hpp.
Ioi has the following addition suggestions:
For this one, I think we can modify the SerializeClosure class to return the number of bytes written/read, for all the do_xxx() functions. Something like
class SerializeClosure : public Closure {
// Read/write the void pointer pointed to by p.
virtual size_t do_ptr(void** p) = 0;
virtual size_t do_u4(u4* p) = 0;
...
};
Then we can have:
void SimpleCompactHashtable::serialize_header(SerializeClosure* soc) {
// NOTE: if you change this function, you MUST change the number 5 in
// calculate_header_size() accordingly.
size_t written_bytes = 0;
written_bytes += soc->do_ptr((void**)&_base_address);
written_bytes += soc->do_u4(&_entry_count);
written_bytes += soc->do_u4(&_bucket_count);
written_bytes += soc->do_ptr((void**)&_buckets);
written_bytes += soc->do_ptr((void**)&_entries);
assert(written_bytes <= calculate_header_size(), "must be");
}
size_t SimpleCompactHashtable::calculate_header_size() {
// We have 5 fields. Each takes up sizeof(intptr_t). See WriteClosure::do_u4
size_t bytes = sizeof(intptr_t) * 5;
return bytes;
}
The 5 could be defined as a enum in SimpleCompactHashTable.hpp.
Ioi has the following addition suggestions:
For this one, I think we can modify the SerializeClosure class to return the number of bytes written/read, for all the do_xxx() functions. Something like
class SerializeClosure : public Closure {
// Read/write the void pointer pointed to by p.
virtual size_t do_ptr(void** p) = 0;
virtual size_t do_u4(u4* p) = 0;
...
};
Then we can have:
void SimpleCompactHashtable::serialize_header(SerializeClosure* soc) {
// NOTE: if you change this function, you MUST change the number 5 in
// calculate_header_size() accordingly.
size_t written_bytes = 0;
written_bytes += soc->do_ptr((void**)&_base_address);
written_bytes += soc->do_u4(&_entry_count);
written_bytes += soc->do_u4(&_bucket_count);
written_bytes += soc->do_ptr((void**)&_buckets);
written_bytes += soc->do_ptr((void**)&_entries);
assert(written_bytes <= calculate_header_size(), "must be");
}
- relates to
-
JDK-8207812 Implement Dynamic CDS Archive
- Resolved