Skip to content
Closed
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion test/hotspot/gtest/gc/g1/test_freeRegionList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ TEST_OTHER_VM(G1FreeRegionList, length) {

// Create a fake heap. It does not need to be valid, as the G1HeapRegion constructor
// does not access it.
MemRegion heap(nullptr, num_regions_in_test * G1HeapRegion::GrainWords);
int val = 1;
HeapWord* ptr = reinterpret_cast<HeapWord*>(&val);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial value for val doesn't matter, since we're using its address rather than value.
And the cast could be removed by changing the type of val, leading to something like this:

HeapWord val{};
HeapWord* ptr = align_up(&val, os::vm_page_size());

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I adjusted the coding .

ptr = align_up(ptr, os::vm_page_size());

MemRegion heap(ptr, num_regions_in_test * G1HeapRegion::GrainWords);

// Allocate a fake BOT because the G1HeapRegion constructor initializes
// the BOT.
Expand Down