On Sun, 20 Sep 2026 22:21:02 GMT, Vladimir Kozlov <[email protected]> wrote:
>> src/hotspot/share/cds/aotCacheAccess.cpp line 84:
>>
>>> 82: uintptr_t low_bound = p2u(MetaspaceObj::aot_metaspace_base());
>>> 83: uintptr_t high_bound = p2u(MetaspaceObj::aot_metaspace_top());
>>> 84: if (base > low_bound || low_bound > high_bound) { // paranoid check
>>
>> These checks can be done just once during AOTCache setup, not needed on
>> every read.
>
> Moved to `AOTCacheAccess::map_aot_code_region()`
This is fine, but I was thinking these checks are not specific to AOTCode, and
if these checks fail then something is seriously wrong with mapping of the
AOTCache. We should not even reach this stage.
So my suggestion is to have these checks immediately after mapping the
AOTCache, perhaps in
`AOTMetaspace::initialize_runtime_shared_and_meta_spaces()` after the call to
`AOTMetaspace::set_aot_metaspace_range()`, like this:
void AOTMetaspace::initialize_runtime_shared_and_meta_spaces() {
...
set_aot_metaspace_range(cds_base, static_mapinfo->mapped_end(), cds_end);
guarantee(SharedBaseAddress == MetaspaceObj::aot_metaspace_base(), "must
be");
guarantee(MetaspaceObj::aot_metaspace_base() <=
MetaspaceObj::aot_metaspace_top(), "must be");
Also note that `AOTMetaspace::set_aot_metaspace_range` already has the assert
for the mapped range:
void AOTMetaspace::set_aot_metaspace_range(void* base, void *static_top, void*
top) {
assert(base <= static_top && static_top <= top, "must be");
_aot_metaspace_static_top = static_top;
MetaspaceObj::set_aot_metaspace_range(base, top);
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r4063896599