-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8357621: G1: Clean up G1BiasedArray #25406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
tschatzl
wants to merge
5
commits into
openjdk:master
from
tschatzl:submit/8357621-clean-up-biasedarray
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,19 +38,6 @@ class G1BiasedMappedArrayBase : public CHeapObj<mtGC> { | |
|
||
void* _alloc_base; // the address the unpadded array has been allocated to | ||
|
||
public: | ||
typedef size_t idx_t; | ||
|
||
protected: | ||
address _base; // the real base address | ||
size_t _length; // the length of the array | ||
address _biased_base; // base address biased by "bias" elements | ||
size_t _bias; // the bias, i.e. the offset biased_base is located to the right in elements | ||
uint _shift_by; // the amount of bits to shift right when mapping to an index of the array. | ||
|
||
protected: | ||
G1BiasedMappedArrayBase(); | ||
|
||
// Allocate a new array, generic version. | ||
address create_new_base_array(size_t length, size_t elem_size); | ||
|
||
|
@@ -67,6 +54,18 @@ class G1BiasedMappedArrayBase : public CHeapObj<mtGC> { | |
_shift_by = shift_by; | ||
} | ||
|
||
public: | ||
typedef size_t idx_t; | ||
|
||
protected: | ||
address _base; // the real base address | ||
size_t _length; // the length of the array | ||
address _biased_base; // base address biased by "bias" elements | ||
size_t _bias; // the bias, i.e. the offset biased_base is located to the right in elements | ||
uint _shift_by; // the amount of bits to shift right when mapping to an index of the array. | ||
|
||
G1BiasedMappedArrayBase(); | ||
|
||
// Allocate and initialize this array to cover the heap addresses in the range | ||
// of [bottom, end). | ||
void initialize(HeapWord* bottom, HeapWord* end, size_t target_elem_size_in_bytes, size_t mapping_granularity_in_bytes) { | ||
|
@@ -90,7 +89,6 @@ class G1BiasedMappedArrayBase : public CHeapObj<mtGC> { | |
|
||
void verify_index(idx_t index) const PRODUCT_RETURN; | ||
void verify_biased_index(idx_t biased_index) const PRODUCT_RETURN; | ||
void verify_biased_index_inclusive_end(idx_t biased_index) const PRODUCT_RETURN; | ||
|
||
public: | ||
virtual ~G1BiasedMappedArrayBase(); | ||
|
@@ -103,10 +101,15 @@ class G1BiasedMappedArrayBase : public CHeapObj<mtGC> { | |
// heap into this array. | ||
template<class T> | ||
class G1BiasedMappedArray : public G1BiasedMappedArrayBase { | ||
protected: | ||
T* base() const { return (T*)G1BiasedMappedArrayBase::_base; } | ||
|
||
// The raw biased base pointer. | ||
T* biased_base() const { return (T*)G1BiasedMappedArrayBase::_biased_base; } | ||
|
||
public: | ||
typedef G1BiasedMappedArrayBase::idx_t idx_t; | ||
|
||
T* base() const { return (T*)G1BiasedMappedArrayBase::_base; } | ||
// Return the element of the given array at the given index. Assume | ||
// the index is valid. This is a convenience method that does sanity | ||
// checking on the index. | ||
|
@@ -123,9 +126,6 @@ class G1BiasedMappedArray : public G1BiasedMappedArrayBase { | |
this->base()[index] = value; | ||
} | ||
|
||
// The raw biased base pointer. | ||
T* biased_base() const { return (T*)G1BiasedMappedArrayBase::_biased_base; } | ||
|
||
// Return the element of the given array that covers the given word in the | ||
// heap. Assumes the index is valid. | ||
T get_by_address(HeapWord* value) const { | ||
|
@@ -154,26 +154,6 @@ class G1BiasedMappedArray : public G1BiasedMappedArrayBase { | |
biased_base()[biased_index] = value; | ||
} | ||
|
||
// Set the value of all array entries that correspond to addresses | ||
// in the specified MemRegion. | ||
void set_by_address(MemRegion range, T value) { | ||
idx_t biased_start = ((uintptr_t)range.start()) >> this->shift_by(); | ||
idx_t biased_last = ((uintptr_t)range.last()) >> this->shift_by(); | ||
this->verify_biased_index(biased_start); | ||
this->verify_biased_index(biased_last); | ||
for (idx_t i = biased_start; i <= biased_last; i++) { | ||
biased_base()[i] = value; | ||
} | ||
} | ||
|
||
protected: | ||
// Returns the address of the element the given address maps to | ||
T* address_mapped_to(HeapWord* address) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems to be used by testing. |
||
idx_t biased_index = ((uintptr_t)address) >> this->shift_by(); | ||
this->verify_biased_index_inclusive_end(biased_index); | ||
return biased_base() + biased_index; | ||
} | ||
|
||
public: | ||
// Return the smallest address (inclusive) in the heap that this array covers. | ||
HeapWord* bottom_address_mapped() const { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like
base()
needs to be public for testing as well :(There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for all these issues, I just found out that I did not have gtests configured for my build. Should be fixed now.
I moved the test helper methods into the test.