RFR: 8273152: Refactor CDS FileMapHeader loading code [v5]
Ioi Lam
iklam at openjdk.java.net
Wed Oct 6 17:05:12 UTC 2021
On Wed, 6 Oct 2021 16:44:25 GMT, Yumin Qi <minqi at openjdk.org> wrote:
>> src/hotspot/share/cds/filemap.cpp line 1205:
>>
>>> 1203: }
>>> 1204:
>>> 1205: _header = (FileMapHeader*)os::malloc(gen_header->_header_size, mtInternal);
>>
>> There's no need to allocate and read the header again. It's already in gen_header. This should be enough:
>>
>>
>> _header = (FileMapHeader*)gen_header;
>
> see above reply. We need read the full _header_size for _header. Also note that helper class will delete gen_header when out of scope.
I see. I think your current code is fine.
Note that the current code writes the header as a FileMapHeader, but it reads it as both a FileMapHeader and a CDSFileMapHeaderBase. So it has the basic assumption `FileMapHeader::_generic_header` is at offset 0 of FileMapHeader. Therefore, in FileHeaderHelper::initialize, we should add an assert:
static_assert(offsetof(FileMapHeader, _generic_header) == 0, "must be");
-------------
PR: https://git.openjdk.java.net/jdk/pull/5768
More information about the serviceability-dev
mailing list