Skip to content

Commit 89b0250

Browse files
committed
8231051: Remove check_obj_alignment() and replace with is_object_aligned()
Reviewed-by: tschatzl, shade
1 parent 2d6874b commit 89b0250

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/hotspot/share/gc/shared/collectedHeap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ bool CollectedHeap::request_concurrent_phase(const char* phase) {
174174
}
175175

176176
bool CollectedHeap::is_oop(oop object) const {
177-
if (!check_obj_alignment(object)) {
177+
if (!is_object_aligned(object)) {
178178
return false;
179179
}
180180

@@ -344,7 +344,7 @@ void CollectedHeap::check_for_non_bad_heap_word_value(HeapWord* addr, size_t siz
344344
#endif // PRODUCT
345345

346346
void CollectedHeap::check_oop_location(void* addr) const {
347-
assert(check_obj_alignment(addr), "address is not aligned");
347+
assert(is_object_aligned(addr), "address is not aligned");
348348
assert(_reserved.contains(addr), "address is not in reserved heap");
349349
}
350350

src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "memory/iterator.inline.hpp"
3636
#include "memory/resourceArea.hpp"
3737
#include "oops/compressedOops.inline.hpp"
38+
#include "utilities/align.hpp"
3839

3940
// Avoid name collision on verify_oop (defined in macroAssembler_arm.hpp)
4041
#ifdef verify_oop
@@ -98,7 +99,7 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
9899

99100
check(ShenandoahAsserts::_safe_unknown, obj, _heap->is_in(obj),
100101
"oop must be in heap");
101-
check(ShenandoahAsserts::_safe_unknown, obj, check_obj_alignment(obj),
102+
check(ShenandoahAsserts::_safe_unknown, obj, is_object_aligned(obj),
102103
"oop must be aligned");
103104

104105
ShenandoahHeapRegion *obj_reg = _heap->heap_region_containing(obj);
@@ -158,7 +159,7 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
158159
"Forwardee must be in heap");
159160
check(ShenandoahAsserts::_safe_oop, obj, !CompressedOops::is_null(fwd),
160161
"Forwardee is set");
161-
check(ShenandoahAsserts::_safe_oop, obj, check_obj_alignment(fwd),
162+
check(ShenandoahAsserts::_safe_oop, obj, is_object_aligned(fwd),
162163
"Forwardee must be aligned");
163164

164165
// Do this before touching fwd->size()

src/hotspot/share/gc/z/zCollectedHeap.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "gc/z/zUtils.inline.hpp"
3636
#include "memory/universe.hpp"
3737
#include "runtime/mutexLocker.hpp"
38+
#include "utilities/align.hpp"
3839

3940
ZCollectedHeap* ZCollectedHeap::heap() {
4041
CollectedHeap* heap = Universe::heap();
@@ -369,7 +370,7 @@ bool ZCollectedHeap::is_oop(oop object) const {
369370
}
370371

371372
void ZCollectedHeap::check_oop_location(void* addr) const {
372-
assert(check_obj_alignment(addr), "address is not aligned");
373+
assert(is_object_aligned(addr), "address is not aligned");
373374

374375
const uintptr_t addr_int = reinterpret_cast<uintptr_t>(addr);
375376
assert(addr_int >= ZAddressSpaceStart, "address is outside of the heap");

src/hotspot/share/memory/heapShared.inline.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "oops/compressedOops.inline.hpp"
2929
#include "memory/heapShared.hpp"
30+
#include "utilities/align.hpp"
3031
#if INCLUDE_G1GC
3132
#include "gc/g1/g1Allocator.inline.hpp"
3233
#endif
@@ -40,7 +41,7 @@ bool HeapShared::is_archived_object(oop p) {
4041
inline oop HeapShared::decode_from_archive(narrowOop v) {
4142
assert(!CompressedOops::is_null(v), "narrow oop value can never be zero");
4243
oop result = (oop)(void*)((uintptr_t)_narrow_oop_base + ((uintptr_t)v << _narrow_oop_shift));
43-
assert(check_obj_alignment(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
44+
assert(is_object_aligned(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
4445
return result;
4546
}
4647

src/hotspot/share/oops/compressedOops.inline.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
2929
#include "memory/universe.hpp"
3030
#include "oops/compressedOops.hpp"
3131
#include "oops/oop.hpp"
32+
#include "utilities/align.hpp"
3233

3334
// Functions for encoding and decoding compressed oops.
3435
// If the oops are compressed, the type passed to these overloaded functions
@@ -47,7 +48,7 @@ inline oop CompressedOops::decode_raw(narrowOop v) {
4748
inline oop CompressedOops::decode_not_null(narrowOop v) {
4849
assert(!is_null(v), "narrow oop value can never be zero");
4950
oop result = decode_raw(v);
50-
assert(check_obj_alignment(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
51+
assert(is_object_aligned(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
5152
return result;
5253
}
5354

src/hotspot/share/oops/oopsHierarchy.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,6 @@ template <class T> inline T cast_from_oop(oop o) {
190190
return (T)(CHECK_UNHANDLED_OOPS_ONLY((void*))o);
191191
}
192192

193-
inline bool check_obj_alignment(void* ptr) {
194-
return (uintptr_t(ptr) & MinObjAlignmentInBytesMask) == 0;
195-
}
196-
197193
// The metadata hierarchy is separate from the oop hierarchy
198194

199195
// class MetaspaceObj

0 commit comments

Comments
 (0)