8345569: [ubsan] adjustments to filemap.cpp and virtualspace.cpp for macOS aarch64

Reviewed-by: mdoerr, lucy, dholmes
This commit is contained in:
Matthias Baesken 2024-12-13 12:14:07 +00:00
parent a9a5f7cb0a
commit 1d2ccaeaa3
2 changed files with 3 additions and 3 deletions

View File

@ -2219,7 +2219,7 @@ address FileMapInfo::heap_region_dumptime_address() {
assert(CDSConfig::is_using_archive(), "runtime only");
assert(is_aligned(r->mapping_offset(), sizeof(HeapWord)), "must be");
if (UseCompressedOops) {
return /*dumptime*/ narrow_oop_base() + r->mapping_offset();
return /*dumptime*/ (address)((uintptr_t)narrow_oop_base() + r->mapping_offset());
} else {
return heap_region_requested_address();
}
@ -2245,7 +2245,7 @@ address FileMapInfo::heap_region_requested_address() {
// Runtime base = 0x4000 and shift is also 0. If we map this region at 0x5000, then
// the value P can remain 0x1200. The decoded address = (0x4000 + (0x1200 << 0)) = 0x5200,
// which is the runtime location of the referenced object.
return /*runtime*/ CompressedOops::base() + r->mapping_offset();
return /*runtime*/ (address)((uintptr_t)CompressedOops::base() + r->mapping_offset());
} else {
// This was the hard-coded requested base address used at dump time. With uncompressed oops,
// the heap range is assigned by the OS so we will most likely have to relocate anyway, no matter

View File

@ -443,7 +443,7 @@ void ReservedHeapSpace::try_reserve_range(char *highest_start,
while (attach_point >= lowest_start &&
attach_point <= highest_start && // Avoid wrap around.
((_base == nullptr) ||
(_base < aligned_heap_base_min_address || _base + size > upper_bound))) {
(_base < aligned_heap_base_min_address || size > (uintptr_t)(upper_bound - _base)))) {
try_reserve_heap(size, alignment, page_size, attach_point);
attach_point -= stepsize;
}