From 618af397b4c636c89049f7398c14f37f0065df59 Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Tue, 13 Feb 2024 09:41:12 +0000 Subject: [PATCH] 8325633: Use stricter assertion in callers of Space::is_aligned Reviewed-by: tschatzl, sjohanss --- src/hotspot/share/gc/serial/defNewGeneration.cpp | 6 +++--- src/hotspot/share/gc/shared/space.cpp | 4 ++-- src/hotspot/share/gc/shared/space.hpp | 5 ----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp index b85041c80a5..52858683c08 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.cpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp @@ -335,9 +335,9 @@ void DefNewGeneration::compute_space_boundaries(uintx minimum_eden_size, char *to_end = to_start + survivor_size; assert(to_end == _virtual_space.high(), "just checking"); - assert(Space::is_aligned(eden_start), "checking alignment"); - assert(Space::is_aligned(from_start), "checking alignment"); - assert(Space::is_aligned(to_start), "checking alignment"); + assert(is_aligned(eden_start, SpaceAlignment), "checking alignment"); + assert(is_aligned(from_start, SpaceAlignment), "checking alignment"); + assert(is_aligned(to_start, SpaceAlignment), "checking alignment"); MemRegion edenMR((HeapWord*)eden_start, (HeapWord*)from_start); MemRegion fromMR((HeapWord*)from_start, (HeapWord*)to_start); diff --git a/src/hotspot/share/gc/shared/space.cpp b/src/hotspot/share/gc/shared/space.cpp index 069b672b544..82e32a17b43 100644 --- a/src/hotspot/share/gc/shared/space.cpp +++ b/src/hotspot/share/gc/shared/space.cpp @@ -197,7 +197,7 @@ inline HeapWord* ContiguousSpace::allocate_impl(size_t size) { if (pointer_delta(end(), obj) >= size) { HeapWord* new_top = obj + size; set_top(new_top); - assert(is_aligned(obj) && is_aligned(new_top), "checking alignment"); + assert(is_object_aligned(obj) && is_object_aligned(new_top), "checking alignment"); return obj; } else { return nullptr; @@ -215,7 +215,7 @@ inline HeapWord* ContiguousSpace::par_allocate_impl(size_t size) { // the old top value: the exchange succeeded // otherwise: the new value of the top is returned. if (result == obj) { - assert(is_aligned(obj) && is_aligned(new_top), "checking alignment"); + assert(is_object_aligned(obj) && is_object_aligned(new_top), "checking alignment"); return obj; } } else { diff --git a/src/hotspot/share/gc/shared/space.hpp b/src/hotspot/share/gc/shared/space.hpp index 8e6f4f88a6b..dbfed7fe759 100644 --- a/src/hotspot/share/gc/shared/space.hpp +++ b/src/hotspot/share/gc/shared/space.hpp @@ -122,11 +122,6 @@ class Space: public CHeapObj { // given address. bool is_in_reserved(const void* p) const { return _bottom <= p && p < _end; } - // Test whether p is double-aligned - static bool is_aligned(void* p) { - return ::is_aligned(p, sizeof(double)); - } - // Size computations. Sizes are in bytes. size_t capacity() const { return byte_size(bottom(), end()); } virtual size_t used() const = 0;