Skip to content

Commit b575e54

Browse files
author
Thomas Schatzl
committed
8303963: Replace various encodings of UINT/SIZE_MAX in gc code
Reviewed-by: ayang, kbarrett
1 parent c183fce commit b575e54

File tree

13 files changed

+13
-15
lines changed

13 files changed

+13
-15
lines changed

src/hotspot/share/gc/g1/g1FullCollector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ bool G1FullCollector::phase2b_forward_oops() {
363363
}
364364

365365
uint G1FullCollector::truncate_parallel_cps() {
366-
uint lowest_current = (uint)-1;
366+
uint lowest_current = UINT_MAX;
367367
for (uint i = 0; i < workers(); i++) {
368368
G1FullGCCompactionPoint* cp = compaction_point(i);
369369
if (cp->has_regions()) {

src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper {
178178
assert(_region_commit_map.find_first_set_bit(start_idx, region_limit) == region_limit,
179179
"Should be no committed regions in the range [%u, %u)", start_idx, region_limit);
180180

181-
size_t const NoPage = ~(size_t)0;
181+
size_t const NoPage = SIZE_MAX;
182182

183183
size_t first_committed = NoPage;
184184
size_t num_committed = 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
class ClassLoaderData;
6262

63-
size_t CollectedHeap::_lab_alignment_reserve = ~(size_t)0;
63+
size_t CollectedHeap::_lab_alignment_reserve = SIZE_MAX;
6464
Klass* CollectedHeap::_filler_object_klass = nullptr;
6565
size_t CollectedHeap::_filler_array_max_size = 0;
6666
size_t CollectedHeap::_stack_chunk_max_size = 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class CollectedHeap : public CHeapObj<mtGC> {
314314
}
315315

316316
static size_t lab_alignment_reserve() {
317-
assert(_lab_alignment_reserve != ~(size_t)0, "uninitialized");
317+
assert(_lab_alignment_reserve != SIZE_MAX, "uninitialized");
318318
return _lab_alignment_reserve;
319319
}
320320

src/hotspot/share/gc/shared/gcId.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class GCId : public AllStatic {
3232
friend class GCIdMark;
3333

3434
static uint _next_id;
35-
static const uint UNDEFINED = (uint)-1;
35+
static const uint UNDEFINED = UINT_MAX;
3636
static uint create();
3737

3838
public:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
template <>
3030
size_t WorkerDataArray<size_t>::uninitialized() {
31-
return (size_t)-1;
31+
return SIZE_MAX;
3232
}
3333

3434
template <>

src/hotspot/share/memory/metaspace/metachunk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void Metachunk::print_on(outputStream* st) const {
303303
"level " CHKLVL_FORMAT " (" SIZE_FORMAT " words), "
304304
"used " SIZE_FORMAT " words, committed " SIZE_FORMAT " words.",
305305
p2i(this), get_state_char(), p2i(base()), level(),
306-
(chunklevel::is_valid_level(level()) ? chunklevel::word_size_for_level(level()) : (size_t)-1),
306+
(chunklevel::is_valid_level(level()) ? chunklevel::word_size_for_level(level()) : SIZE_MAX),
307307
used_words(), committed_words());
308308
}
309309

src/hotspot/share/prims/whitebox.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@
118118
#include "cgroupSubsystem_linux.hpp"
119119
#endif
120120

121-
#define SIZE_T_MAX_VALUE ((size_t) -1)
122-
123121
#define CHECK_JNI_EXCEPTION_(env, value) \
124122
do { \
125123
JavaThread* THREAD = JavaThread::thread_from_jni_environment(env); \
@@ -347,7 +345,7 @@ WB_ENTRY(jint, WB_StressVirtualSpaceResize(JNIEnv* env, jobject o,
347345
// sizeof(size_t) depends on whether OS is 32bit or 64bit. sizeof(jlong) is
348346
// always 8 byte. That's why we should avoid overflow in case of 32bit platform.
349347
if (sizeof(size_t) < sizeof(jlong)) {
350-
jlong size_t_max_value = (jlong) SIZE_T_MAX_VALUE;
348+
jlong size_t_max_value = (jlong)SIZE_MAX;
351349
if (reserved_space_size > size_t_max_value || magnitude > size_t_max_value
352350
|| iterations > size_t_max_value) {
353351
tty->print_cr("One of variables printed above overflows size_t. Can't proceed.\n");

src/hotspot/share/runtime/globals.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,7 @@ const int ObjectAlignmentInBytes = 8;
18851885
product(bool, WhiteBoxAPI, false, DIAGNOSTIC, \
18861886
"Enable internal testing APIs") \
18871887
\
1888-
product(size_t, ArrayAllocatorMallocLimit, (size_t)-1, EXPERIMENTAL, \
1888+
product(size_t, ArrayAllocatorMallocLimit, SIZE_MAX, EXPERIMENTAL, \
18891889
"Allocation less than this value will be allocated " \
18901890
"using malloc. Larger allocations will use mmap.") \
18911891
\

src/hotspot/share/runtime/os.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,7 @@ bool os::release_memory(char* addr, size_t bytes) {
18181818

18191819
// Prints all mappings
18201820
void os::print_memory_mappings(outputStream* st) {
1821-
os::print_memory_mappings(nullptr, (size_t)-1, st);
1821+
os::print_memory_mappings(nullptr, SIZE_MAX, st);
18221822
}
18231823

18241824
// Pretouching must use a store, not just a load. On many OSes loads from

0 commit comments

Comments
 (0)