Skip to content

Commit

Permalink
Use size_t insread of uint64_t, use pointer_delta instead of pointer …
Browse files Browse the repository at this point in the history
…subtraction
  • Loading branch information
sendaoYan committed Jan 8, 2025
1 parent 97a2cab commit 5052dcf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/hotspot/share/memory/memoryReserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,13 @@ ReservedSpace HeapReserver::Instance::try_reserve_range(char *highest_start,
assert(is_aligned(highest_start, attach_point_alignment), "precondition");
assert(is_aligned(lowest_start, attach_point_alignment), "precondition");

const size_t attach_range = highest_start - lowest_start;
const uint64_t num_attempts_possible = (attach_range / attach_point_alignment) + 1;
const uint64_t num_attempts_to_try = MIN2((uint64_t)HeapSearchSteps, num_attempts_possible);
const uint64_t num_intervals = num_attempts_to_try - 1;
const size_t attach_range = pointer_delta(highest_start, lowest_start, sizeof(char*));
const size_t num_attempts_possible = (attach_range / attach_point_alignment) + 1;
const size_t num_attempts_to_try = MIN2((size_t)HeapSearchSteps, num_attempts_possible);
const size_t num_intervals = num_attempts_to_try - 1;
const size_t stepsize = num_intervals == 0 ? 0 : align_down(attach_range / num_intervals, attach_point_alignment);

for (uint64_t i = 0; i < num_attempts_to_try; ++i) {
for (size_t i = 0; i < num_attempts_to_try; ++i) {
char* const attach_point = highest_start - stepsize * i;
ReservedSpace reserved = try_reserve_memory(size, alignment, page_size, attach_point);

Expand Down

0 comments on commit 5052dcf

Please sign in to comment.