Skip to content

Commit 1d2ccae

Browse files
committed
8345569: [ubsan] adjustments to filemap.cpp and virtualspace.cpp for macOS aarch64
Reviewed-by: mdoerr, lucy, dholmes
1 parent a9a5f7c commit 1d2ccae

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/hotspot/share/cds/filemap.cpp

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

src/hotspot/share/memory/virtualspace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ void ReservedHeapSpace::try_reserve_range(char *highest_start,
443443
while (attach_point >= lowest_start &&
444444
attach_point <= highest_start && // Avoid wrap around.
445445
((_base == nullptr) ||
446-
(_base < aligned_heap_base_min_address || _base + size > upper_bound))) {
446+
(_base < aligned_heap_base_min_address || size > (uintptr_t)(upper_bound - _base)))) {
447447
try_reserve_heap(size, alignment, page_size, attach_point);
448448
attach_point -= stepsize;
449449
}

0 commit comments

Comments
 (0)