mirror of
https://github.com/darlinghq/darling-openjdk.git
synced 2024-12-13 07:06:42 +00:00
8230759: ZGC: Fix integer types
Reviewed-by: pliden
This commit is contained in:
parent
557f13e994
commit
2f67784a45
@ -29,7 +29,7 @@
|
||||
template <typename ObjectT, typename ArrayT>
|
||||
class ZAttachedArray {
|
||||
private:
|
||||
const uint32_t _length;
|
||||
const size_t _length;
|
||||
|
||||
static size_t object_size();
|
||||
|
||||
@ -39,7 +39,7 @@ public:
|
||||
|
||||
ZAttachedArray(size_t length);
|
||||
|
||||
uint32_t length() const;
|
||||
size_t length() const;
|
||||
ArrayT* operator()(const ObjectT* obj) const;
|
||||
};
|
||||
|
||||
|
@ -51,7 +51,7 @@ inline ZAttachedArray<ObjectT, ArrayT>::ZAttachedArray(size_t length) :
|
||||
_length(length) {}
|
||||
|
||||
template <typename ObjectT, typename ArrayT>
|
||||
inline uint32_t ZAttachedArray<ObjectT, ArrayT>::length() const {
|
||||
inline size_t ZAttachedArray<ObjectT, ArrayT>::length() const {
|
||||
return _length;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ ZForwarding* ZForwarding::create(ZPage* page) {
|
||||
// The table is sized to have a load factor of 50%, i.e. sized to have
|
||||
// double the number of entries actually inserted.
|
||||
assert(page->live_objects() > 0, "Invalid value");
|
||||
const uint32_t nentries = ZUtils::round_up_power_of_2(page->live_objects() * 2);
|
||||
const size_t nentries = ZUtils::round_up_power_of_2(page->live_objects() * 2);
|
||||
return ::new (AttachedArray::alloc(nentries)) ZForwarding(page, nentries);
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ void ZForwarding::destroy(ZForwarding* forwarding) {
|
||||
AttachedArray::free(forwarding);
|
||||
}
|
||||
|
||||
ZForwarding::ZForwarding(ZPage* page, uint32_t nentries) :
|
||||
ZForwarding::ZForwarding(ZPage* page, size_t nentries) :
|
||||
_virtual(page->virtual_memory()),
|
||||
_object_alignment_shift(page->object_alignment_shift()),
|
||||
_entries(nentries),
|
||||
@ -54,7 +54,7 @@ void ZForwarding::verify() const {
|
||||
guarantee(_refcount > 0, "Invalid refcount");
|
||||
guarantee(_page != NULL, "Invalid page");
|
||||
|
||||
uint32_t live_objects = 0;
|
||||
size_t live_objects = 0;
|
||||
|
||||
for (ZForwardingCursor i = 0; i < _entries.length(); i++) {
|
||||
const ZForwardingEntry entry = at(&i);
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
class ZPage;
|
||||
|
||||
typedef uint32_t ZForwardingCursor;
|
||||
typedef size_t ZForwardingCursor;
|
||||
|
||||
class ZForwarding {
|
||||
friend class VMStructs;
|
||||
@ -54,7 +54,7 @@ private:
|
||||
ZForwardingEntry first(uintptr_t from_index, ZForwardingCursor* cursor) const;
|
||||
ZForwardingEntry next(ZForwardingCursor* cursor) const;
|
||||
|
||||
ZForwarding(ZPage* page, uint32_t nentries);
|
||||
ZForwarding(ZPage* page, size_t nentries);
|
||||
|
||||
public:
|
||||
static ZForwarding* create(ZPage* page);
|
||||
|
@ -99,14 +99,14 @@ inline ZForwardingEntry ZForwarding::at(ZForwardingCursor* cursor) const {
|
||||
}
|
||||
|
||||
inline ZForwardingEntry ZForwarding::first(uintptr_t from_index, ZForwardingCursor* cursor) const {
|
||||
const uint32_t mask = _entries.length() - 1;
|
||||
const uint32_t hash = ZHash::uint32_to_uint32((uint32_t)from_index);
|
||||
const size_t mask = _entries.length() - 1;
|
||||
const size_t hash = ZHash::uint32_to_uint32((uint32_t)from_index);
|
||||
*cursor = hash & mask;
|
||||
return at(cursor);
|
||||
}
|
||||
|
||||
inline ZForwardingEntry ZForwarding::next(ZForwardingCursor* cursor) const {
|
||||
const uint32_t mask = _entries.length() - 1;
|
||||
const size_t mask = _entries.length() - 1;
|
||||
*cursor = (*cursor + 1) & mask;
|
||||
return at(cursor);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ ZNMethodDataOops::ZNMethodDataOops(const GrowableArray<oop*>& immediates, bool h
|
||||
_has_non_immediates(has_non_immediates) {
|
||||
// Save all immediate oops
|
||||
for (size_t i = 0; i < immediates_count(); i++) {
|
||||
immediates_begin()[i] = immediates.at(i);
|
||||
immediates_begin()[i] = immediates.at(int(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ uintptr_t ZRelocate::relocate_object_inner(ZForwarding* forwarding, uintptr_t fr
|
||||
// Relocation contention
|
||||
ZStatInc(ZCounterRelocationContention);
|
||||
log_trace(gc)("Relocation contention, thread: " PTR_FORMAT " (%s), forwarding: " PTR_FORMAT
|
||||
", entry: " UINT32_FORMAT ", oop: " PTR_FORMAT ", size: " SIZE_FORMAT,
|
||||
", entry: " SIZE_FORMAT ", oop: " PTR_FORMAT ", size: " SIZE_FORMAT,
|
||||
ZThread::id(), ZThread::name(), p2i(forwarding), cursor, from_good, size);
|
||||
|
||||
// Try undo allocation
|
||||
|
@ -354,7 +354,7 @@ T* ZStatValue::get_cpu_local(uint32_t cpu) const {
|
||||
|
||||
void ZStatValue::initialize() {
|
||||
// Finalize and align CPU offset
|
||||
_cpu_offset = align_up(_cpu_offset, ZCacheLineSize);
|
||||
_cpu_offset = align_up(_cpu_offset, (uint32_t)ZCacheLineSize);
|
||||
|
||||
// Allocation aligned memory
|
||||
const size_t size = _cpu_offset * ZCPU::count();
|
||||
|
@ -36,7 +36,7 @@ ZUncommitter::ZUncommitter() :
|
||||
|
||||
bool ZUncommitter::idle(uint64_t timeout) {
|
||||
// Idle for at least one second
|
||||
const uint64_t expires = os::elapsedTime() + MAX2(timeout, 1ul);
|
||||
const uint64_t expires = os::elapsedTime() + MAX2<uint64_t>(timeout, 1);
|
||||
|
||||
for (;;) {
|
||||
// We might wake up spuriously from wait, so always recalculate
|
||||
|
@ -40,19 +40,19 @@ class ZForwardingTest : public Test {
|
||||
public:
|
||||
// Helper functions
|
||||
|
||||
static bool is_power_of_2(uint32_t value) {
|
||||
static bool is_power_of_2(size_t value) {
|
||||
return ::is_power_of_2((intptr_t)value);
|
||||
}
|
||||
|
||||
class SequenceToFromIndex : AllStatic {
|
||||
public:
|
||||
static uintptr_t even(uint32_t sequence_number) {
|
||||
static uintptr_t even(size_t sequence_number) {
|
||||
return sequence_number * 2;
|
||||
}
|
||||
static uintptr_t odd(uint32_t sequence_number) {
|
||||
static uintptr_t odd(size_t sequence_number) {
|
||||
return even(sequence_number) + 1;
|
||||
}
|
||||
static uintptr_t one_to_one(uint32_t sequence_number) {
|
||||
static uintptr_t one_to_one(size_t sequence_number) {
|
||||
return sequence_number;
|
||||
}
|
||||
};
|
||||
@ -64,10 +64,10 @@ public:
|
||||
}
|
||||
|
||||
static void find_empty(ZForwarding* forwarding) {
|
||||
uint32_t size = forwarding->_entries.length();
|
||||
uint32_t entries_to_check = size * 2;
|
||||
size_t size = forwarding->_entries.length();
|
||||
size_t entries_to_check = size * 2;
|
||||
|
||||
for (uint32_t i = 0; i < entries_to_check; i++) {
|
||||
for (size_t i = 0; i < entries_to_check; i++) {
|
||||
uintptr_t from_index = SequenceToFromIndex::one_to_one(i);
|
||||
|
||||
EXPECT_FALSE(forwarding->find(from_index).populated()) << CAPTURE2(from_index, size);
|
||||
@ -75,11 +75,11 @@ public:
|
||||
}
|
||||
|
||||
static void find_full(ZForwarding* forwarding) {
|
||||
uint32_t size = forwarding->_entries.length();
|
||||
uint32_t entries_to_populate = size;
|
||||
size_t size = forwarding->_entries.length();
|
||||
size_t entries_to_populate = size;
|
||||
|
||||
// Populate
|
||||
for (uint32_t i = 0; i < entries_to_populate; i++) {
|
||||
for (size_t i = 0; i < entries_to_populate; i++) {
|
||||
uintptr_t from_index = SequenceToFromIndex::one_to_one(i);
|
||||
|
||||
ZForwardingCursor cursor;
|
||||
@ -90,7 +90,7 @@ public:
|
||||
}
|
||||
|
||||
// Verify
|
||||
for (uint32_t i = 0; i < entries_to_populate; i++) {
|
||||
for (size_t i = 0; i < entries_to_populate; i++) {
|
||||
uintptr_t from_index = SequenceToFromIndex::one_to_one(i);
|
||||
|
||||
ZForwardingEntry entry = forwarding->find(from_index);
|
||||
@ -102,11 +102,11 @@ public:
|
||||
}
|
||||
|
||||
static void find_every_other(ZForwarding* forwarding) {
|
||||
uint32_t size = forwarding->_entries.length();
|
||||
uint32_t entries_to_populate = size / 2;
|
||||
size_t size = forwarding->_entries.length();
|
||||
size_t entries_to_populate = size / 2;
|
||||
|
||||
// Populate even from indices
|
||||
for (uint32_t i = 0; i < entries_to_populate; i++) {
|
||||
for (size_t i = 0; i < entries_to_populate; i++) {
|
||||
uintptr_t from_index = SequenceToFromIndex::even(i);
|
||||
|
||||
ZForwardingCursor cursor;
|
||||
@ -117,7 +117,7 @@ public:
|
||||
}
|
||||
|
||||
// Verify populated even indices
|
||||
for (uint32_t i = 0; i < entries_to_populate; i++) {
|
||||
for (size_t i = 0; i < entries_to_populate; i++) {
|
||||
uintptr_t from_index = SequenceToFromIndex::even(i);
|
||||
|
||||
ZForwardingCursor cursor;
|
||||
@ -132,7 +132,7 @@ public:
|
||||
//
|
||||
// This check could be done on a larger range of sequence numbers,
|
||||
// but currently entries_to_populate is used.
|
||||
for (uint32_t i = 0; i < entries_to_populate; i++) {
|
||||
for (size_t i = 0; i < entries_to_populate; i++) {
|
||||
uintptr_t from_index = SequenceToFromIndex::odd(i);
|
||||
|
||||
ZForwardingEntry entry = forwarding->find(from_index);
|
||||
@ -158,7 +158,7 @@ public:
|
||||
page.mark_object(ZAddress::marked(object), dummy, dummy);
|
||||
|
||||
const uint32_t live_objects = size;
|
||||
const uint32_t live_bytes = live_objects * object_size;
|
||||
const size_t live_bytes = live_objects * object_size;
|
||||
page.inc_live_atomic(live_objects, live_bytes);
|
||||
|
||||
// Setup forwarding
|
||||
|
Loading…
Reference in New Issue
Block a user