Skip to content

Commit 2f67784

Browse files
committed
8230759: ZGC: Fix integer types
Reviewed-by: pliden
1 parent 557f13e commit 2f67784

File tree

10 files changed

+32
-32
lines changed

10 files changed

+32
-32
lines changed

src/hotspot/share/gc/z/zAttachedArray.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
template <typename ObjectT, typename ArrayT>
3030
class ZAttachedArray {
3131
private:
32-
const uint32_t _length;
32+
const size_t _length;
3333

3434
static size_t object_size();
3535

@@ -39,7 +39,7 @@ class ZAttachedArray {
3939

4040
ZAttachedArray(size_t length);
4141

42-
uint32_t length() const;
42+
size_t length() const;
4343
ArrayT* operator()(const ObjectT* obj) const;
4444
};
4545

src/hotspot/share/gc/z/zAttachedArray.inline.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ inline ZAttachedArray<ObjectT, ArrayT>::ZAttachedArray(size_t length) :
5151
_length(length) {}
5252

5353
template <typename ObjectT, typename ArrayT>
54-
inline uint32_t ZAttachedArray<ObjectT, ArrayT>::length() const {
54+
inline size_t ZAttachedArray<ObjectT, ArrayT>::length() const {
5555
return _length;
5656
}
5757

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ ZForwarding* ZForwarding::create(ZPage* page) {
3434
// The table is sized to have a load factor of 50%, i.e. sized to have
3535
// double the number of entries actually inserted.
3636
assert(page->live_objects() > 0, "Invalid value");
37-
const uint32_t nentries = ZUtils::round_up_power_of_2(page->live_objects() * 2);
37+
const size_t nentries = ZUtils::round_up_power_of_2(page->live_objects() * 2);
3838
return ::new (AttachedArray::alloc(nentries)) ZForwarding(page, nentries);
3939
}
4040

4141
void ZForwarding::destroy(ZForwarding* forwarding) {
4242
AttachedArray::free(forwarding);
4343
}
4444

45-
ZForwarding::ZForwarding(ZPage* page, uint32_t nentries) :
45+
ZForwarding::ZForwarding(ZPage* page, size_t nentries) :
4646
_virtual(page->virtual_memory()),
4747
_object_alignment_shift(page->object_alignment_shift()),
4848
_entries(nentries),
@@ -54,7 +54,7 @@ void ZForwarding::verify() const {
5454
guarantee(_refcount > 0, "Invalid refcount");
5555
guarantee(_page != NULL, "Invalid page");
5656

57-
uint32_t live_objects = 0;
57+
size_t live_objects = 0;
5858

5959
for (ZForwardingCursor i = 0; i < _entries.length(); i++) {
6060
const ZForwardingEntry entry = at(&i);

src/hotspot/share/gc/z/zForwarding.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
class ZPage;
3232

33-
typedef uint32_t ZForwardingCursor;
33+
typedef size_t ZForwardingCursor;
3434

3535
class ZForwarding {
3636
friend class VMStructs;
@@ -54,7 +54,7 @@ class ZForwarding {
5454
ZForwardingEntry first(uintptr_t from_index, ZForwardingCursor* cursor) const;
5555
ZForwardingEntry next(ZForwardingCursor* cursor) const;
5656

57-
ZForwarding(ZPage* page, uint32_t nentries);
57+
ZForwarding(ZPage* page, size_t nentries);
5858

5959
public:
6060
static ZForwarding* create(ZPage* page);

src/hotspot/share/gc/z/zForwarding.inline.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ inline ZForwardingEntry ZForwarding::at(ZForwardingCursor* cursor) const {
9999
}
100100

101101
inline ZForwardingEntry ZForwarding::first(uintptr_t from_index, ZForwardingCursor* cursor) const {
102-
const uint32_t mask = _entries.length() - 1;
103-
const uint32_t hash = ZHash::uint32_to_uint32((uint32_t)from_index);
102+
const size_t mask = _entries.length() - 1;
103+
const size_t hash = ZHash::uint32_to_uint32((uint32_t)from_index);
104104
*cursor = hash & mask;
105105
return at(cursor);
106106
}
107107

108108
inline ZForwardingEntry ZForwarding::next(ZForwardingCursor* cursor) const {
109-
const uint32_t mask = _entries.length() - 1;
109+
const size_t mask = _entries.length() - 1;
110110
*cursor = (*cursor + 1) & mask;
111111
return at(cursor);
112112
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ ZNMethodDataOops::ZNMethodDataOops(const GrowableArray<oop*>& immediates, bool h
4545
_has_non_immediates(has_non_immediates) {
4646
// Save all immediate oops
4747
for (size_t i = 0; i < immediates_count(); i++) {
48-
immediates_begin()[i] = immediates.at(i);
48+
immediates_begin()[i] = immediates.at(int(i));
4949
}
5050
}
5151

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ uintptr_t ZRelocate::relocate_object_inner(ZForwarding* forwarding, uintptr_t fr
126126
// Relocation contention
127127
ZStatInc(ZCounterRelocationContention);
128128
log_trace(gc)("Relocation contention, thread: " PTR_FORMAT " (%s), forwarding: " PTR_FORMAT
129-
", entry: " UINT32_FORMAT ", oop: " PTR_FORMAT ", size: " SIZE_FORMAT,
129+
", entry: " SIZE_FORMAT ", oop: " PTR_FORMAT ", size: " SIZE_FORMAT,
130130
ZThread::id(), ZThread::name(), p2i(forwarding), cursor, from_good, size);
131131

132132
// Try undo allocation

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ T* ZStatValue::get_cpu_local(uint32_t cpu) const {
354354

355355
void ZStatValue::initialize() {
356356
// Finalize and align CPU offset
357-
_cpu_offset = align_up(_cpu_offset, ZCacheLineSize);
357+
_cpu_offset = align_up(_cpu_offset, (uint32_t)ZCacheLineSize);
358358

359359
// Allocation aligned memory
360360
const size_t size = _cpu_offset * ZCPU::count();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ZUncommitter::ZUncommitter() :
3636

3737
bool ZUncommitter::idle(uint64_t timeout) {
3838
// Idle for at least one second
39-
const uint64_t expires = os::elapsedTime() + MAX2(timeout, 1ul);
39+
const uint64_t expires = os::elapsedTime() + MAX2<uint64_t>(timeout, 1);
4040

4141
for (;;) {
4242
// We might wake up spuriously from wait, so always recalculate

test/hotspot/gtest/gc/z/test_zForwarding.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ class ZForwardingTest : public Test {
4040
public:
4141
// Helper functions
4242

43-
static bool is_power_of_2(uint32_t value) {
43+
static bool is_power_of_2(size_t value) {
4444
return ::is_power_of_2((intptr_t)value);
4545
}
4646

4747
class SequenceToFromIndex : AllStatic {
4848
public:
49-
static uintptr_t even(uint32_t sequence_number) {
49+
static uintptr_t even(size_t sequence_number) {
5050
return sequence_number * 2;
5151
}
52-
static uintptr_t odd(uint32_t sequence_number) {
52+
static uintptr_t odd(size_t sequence_number) {
5353
return even(sequence_number) + 1;
5454
}
55-
static uintptr_t one_to_one(uint32_t sequence_number) {
55+
static uintptr_t one_to_one(size_t sequence_number) {
5656
return sequence_number;
5757
}
5858
};
@@ -64,22 +64,22 @@ class ZForwardingTest : public Test {
6464
}
6565

6666
static void find_empty(ZForwarding* forwarding) {
67-
uint32_t size = forwarding->_entries.length();
68-
uint32_t entries_to_check = size * 2;
67+
size_t size = forwarding->_entries.length();
68+
size_t entries_to_check = size * 2;
6969

70-
for (uint32_t i = 0; i < entries_to_check; i++) {
70+
for (size_t i = 0; i < entries_to_check; i++) {
7171
uintptr_t from_index = SequenceToFromIndex::one_to_one(i);
7272

7373
EXPECT_FALSE(forwarding->find(from_index).populated()) << CAPTURE2(from_index, size);
7474
}
7575
}
7676

7777
static void find_full(ZForwarding* forwarding) {
78-
uint32_t size = forwarding->_entries.length();
79-
uint32_t entries_to_populate = size;
78+
size_t size = forwarding->_entries.length();
79+
size_t entries_to_populate = size;
8080

8181
// Populate
82-
for (uint32_t i = 0; i < entries_to_populate; i++) {
82+
for (size_t i = 0; i < entries_to_populate; i++) {
8383
uintptr_t from_index = SequenceToFromIndex::one_to_one(i);
8484

8585
ZForwardingCursor cursor;
@@ -90,7 +90,7 @@ class ZForwardingTest : public Test {
9090
}
9191

9292
// Verify
93-
for (uint32_t i = 0; i < entries_to_populate; i++) {
93+
for (size_t i = 0; i < entries_to_populate; i++) {
9494
uintptr_t from_index = SequenceToFromIndex::one_to_one(i);
9595

9696
ZForwardingEntry entry = forwarding->find(from_index);
@@ -102,11 +102,11 @@ class ZForwardingTest : public Test {
102102
}
103103

104104
static void find_every_other(ZForwarding* forwarding) {
105-
uint32_t size = forwarding->_entries.length();
106-
uint32_t entries_to_populate = size / 2;
105+
size_t size = forwarding->_entries.length();
106+
size_t entries_to_populate = size / 2;
107107

108108
// Populate even from indices
109-
for (uint32_t i = 0; i < entries_to_populate; i++) {
109+
for (size_t i = 0; i < entries_to_populate; i++) {
110110
uintptr_t from_index = SequenceToFromIndex::even(i);
111111

112112
ZForwardingCursor cursor;
@@ -117,7 +117,7 @@ class ZForwardingTest : public Test {
117117
}
118118

119119
// Verify populated even indices
120-
for (uint32_t i = 0; i < entries_to_populate; i++) {
120+
for (size_t i = 0; i < entries_to_populate; i++) {
121121
uintptr_t from_index = SequenceToFromIndex::even(i);
122122

123123
ZForwardingCursor cursor;
@@ -132,7 +132,7 @@ class ZForwardingTest : public Test {
132132
//
133133
// This check could be done on a larger range of sequence numbers,
134134
// but currently entries_to_populate is used.
135-
for (uint32_t i = 0; i < entries_to_populate; i++) {
135+
for (size_t i = 0; i < entries_to_populate; i++) {
136136
uintptr_t from_index = SequenceToFromIndex::odd(i);
137137

138138
ZForwardingEntry entry = forwarding->find(from_index);
@@ -158,7 +158,7 @@ class ZForwardingTest : public Test {
158158
page.mark_object(ZAddress::marked(object), dummy, dummy);
159159

160160
const uint32_t live_objects = size;
161-
const uint32_t live_bytes = live_objects * object_size;
161+
const size_t live_bytes = live_objects * object_size;
162162
page.inc_live_atomic(live_objects, live_bytes);
163163

164164
// Setup forwarding

0 commit comments

Comments
 (0)