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
8276670: G1: Move and rename G1CardSetFreePool and related classes #6289
Closed
Hamlin-Li
wants to merge
11
commits into
openjdk:master
from
Hamlin-Li:rename-move-G1CardSetFreePool-out
+410
−324
Closed
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5be485f
Initial commit
Hamlin-Li d9d699c
move g1CardSetFreeMemoryTask.*
Hamlin-Li 28d509c
Fix missing files
Hamlin-Li bee8f1e
Fix missing in test
Hamlin-Li 7669e04
Fix gtest tests
Hamlin-Li 4eb0361
Fix typos
Hamlin-Li 02c2b94
Merge branch 'master' into rename-move-G1CardSetFreePool-out
Hamlin-Li c15129e
Fix typo
Hamlin-Li d7fb55c
Rename from G1BufferListXxx to G1SegmentedArrayXxx
Hamlin-Li a51ebcd
Rename card set to segmented array
Hamlin-Li 7cfe01f
Merge with master
Hamlin-Li File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -25,9 +25,9 @@ | ||
#ifndef SHARE_GC_G1_G1CARDSETMEMORY_HPP | ||
#define SHARE_GC_G1_G1CARDSETMEMORY_HPP | ||
|
||
#include "gc/g1/g1SegmentedArrayFreePool.hpp" | ||
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. Include order, must be sorted alphabetically |
||
#include "gc/g1/g1CardSet.hpp" | ||
#include "gc/g1/g1CardSetContainers.hpp" | ||
#include "gc/g1/g1CardSetContainers.inline.hpp" | ||
#include "gc/g1/g1SegmentedArray.hpp" | ||
#include "memory/allocation.hpp" | ||
#include "utilities/growableArray.hpp" | ||
@@ -136,99 +136,6 @@ class G1CardSetAllocator { | ||
void print(outputStream* os); | ||
}; | ||
|
||
// Statistics for a fixed set of buffer lists. Contains the number of buffers and memory | ||
// used for each. Note that statistics are typically not taken atomically so there | ||
// can be inconsistencies. The user must be prepared for them. | ||
class G1CardSetMemoryStats { | ||
public: | ||
|
||
size_t _num_mem_sizes[G1CardSetConfiguration::num_mem_object_types()]; | ||
size_t _num_buffers[G1CardSetConfiguration::num_mem_object_types()]; | ||
|
||
// Returns all-zero statistics. | ||
G1CardSetMemoryStats(); | ||
|
||
void add(G1CardSetMemoryStats const other) { | ||
STATIC_ASSERT(ARRAY_SIZE(_num_buffers) == ARRAY_SIZE(_num_mem_sizes)); | ||
for (uint i = 0; i < ARRAY_SIZE(_num_mem_sizes); i++) { | ||
_num_mem_sizes[i] += other._num_mem_sizes[i]; | ||
_num_buffers[i] += other._num_buffers[i]; | ||
} | ||
} | ||
|
||
void clear(); | ||
|
||
uint num_pools() const { return G1CardSetConfiguration::num_mem_object_types(); } | ||
}; | ||
|
||
// A set of free lists holding memory buffers for use by G1CardSetAllocators. | ||
class G1CardSetFreePool { | ||
// The global free pool. | ||
static G1CardSetFreePool _freelist_pool; | ||
|
||
const uint _num_free_lists; | ||
G1CardSetBufferList* _free_lists; | ||
|
||
public: | ||
static G1CardSetFreePool* free_list_pool() { return &_freelist_pool; } | ||
static G1CardSetMemoryStats free_list_sizes() { return _freelist_pool.memory_sizes(); } | ||
|
||
class G1ReturnMemoryProcessor; | ||
typedef GrowableArrayCHeap<G1ReturnMemoryProcessor*, mtGC> G1ReturnMemoryProcessorSet; | ||
|
||
static void update_unlink_processors(G1ReturnMemoryProcessorSet* unlink_processors); | ||
|
||
explicit G1CardSetFreePool(uint num_free_lists); | ||
~G1CardSetFreePool(); | ||
|
||
G1CardSetBufferList* free_list(uint i) { | ||
assert(i < _num_free_lists, "must be"); | ||
return &_free_lists[i]; | ||
} | ||
|
||
uint num_free_lists() const { return _num_free_lists; } | ||
|
||
G1CardSetMemoryStats memory_sizes() const; | ||
size_t mem_size() const; | ||
|
||
void print_on(outputStream* out); | ||
}; | ||
|
||
// Data structure containing current in-progress state for returning memory to the | ||
// operating system for a single G1CardSetBufferList. | ||
class G1CardSetFreePool::G1ReturnMemoryProcessor : public CHeapObj<mtGC> { | ||
G1CardSetBufferList* _source; | ||
size_t _return_to_vm_size; | ||
|
||
G1CardSetBuffer* _first; | ||
size_t _unlinked_bytes; | ||
size_t _num_unlinked; | ||
|
||
public: | ||
explicit G1ReturnMemoryProcessor(size_t return_to_vm) : | ||
_source(nullptr), _return_to_vm_size(return_to_vm), _first(nullptr), _unlinked_bytes(0), _num_unlinked(0) { | ||
} | ||
|
||
// Updates the instance members about the given card set buffer list for the purpose | ||
// of giving back memory. Only necessary members are updated, e.g. if there is | ||
// nothing to return to the VM, do not set the source list. | ||
void visit_free_list(G1CardSetBufferList* source); | ||
|
||
bool finished_return_to_vm() const { return _return_to_vm_size == 0; } | ||
bool finished_return_to_os() const { return _first == nullptr; } | ||
|
||
// Returns memory to the VM until the given deadline expires. Returns true if | ||
// there is no more work. Guarantees forward progress, i.e. at least one buffer | ||
// has been processed after returning. | ||
// return_to_vm() re-adds buffers to the respective free list. | ||
bool return_to_vm(jlong deadline); | ||
// Returns memory to the VM until the given deadline expires. Returns true if | ||
// there is no more work. Guarantees forward progress, i.e. at least one buffer | ||
// has been processed after returning. | ||
// return_to_os() gives back buffers to the OS. | ||
bool return_to_os(jlong deadline); | ||
}; | ||
|
||
class G1CardSetMemoryManager : public CHeapObj<mtGCCardSet> { | ||
G1CardSetConfiguration* _config; | ||
|
||
@@ -237,7 +144,7 @@ class G1CardSetMemoryManager : public CHeapObj<mtGCCardSet> { | ||
uint num_mem_object_types() const; | ||
public: | ||
G1CardSetMemoryManager(G1CardSetConfiguration* config, | ||
G1CardSetFreePool* free_list_pool); | ||
G1SegmentedArrayFreePool<mtGCCardSet>* free_list_pool); | ||
|
||
virtual ~G1CardSetMemoryManager(); | ||
|
||
@@ -256,7 +163,7 @@ class G1CardSetMemoryManager : public CHeapObj<mtGCCardSet> { | ||
size_t mem_size() const; | ||
size_t wasted_mem_size() const; | ||
|
||
G1CardSetMemoryStats memory_stats() const; | ||
G1SegmentedArrayMemoryStats memory_stats() const; | ||
}; | ||
|
||
#endif // SHARE_GC_G1_G1CARDSETMEMORY_HPP |
This file contains 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 |
---|---|---|
@@ -33,7 +33,7 @@ | ||
#include "gc/g1/g1Arguments.hpp" | ||
#include "gc/g1/g1BarrierSet.hpp" | ||
#include "gc/g1/g1BatchedTask.hpp" | ||
#include "gc/g1/g1CardSetFreeMemoryTask.hpp" | ||
#include "gc/g1/g1SegmentedArrayFreeMemoryTask.hpp" | ||
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. Include order, must be sorted alphabetically |
||
#include "gc/g1/g1CollectedHeap.inline.hpp" | ||
#include "gc/g1/g1CollectionSet.hpp" | ||
#include "gc/g1/g1CollectionSetCandidates.hpp" | ||
@@ -1723,7 +1723,7 @@ jint G1CollectedHeap::initialize() { | ||
_periodic_gc_task = new G1PeriodicGCTask("Periodic GC Task"); | ||
_service_thread->register_task(_periodic_gc_task); | ||
|
||
_free_card_set_memory_task = new G1CardSetFreeMemoryTask("Card Set Free Memory Task"); | ||
_free_card_set_memory_task = new G1SegmentedArrayFreeMemoryTask("Card Set Free Memory Task"); | ||
_service_thread->register_task(_free_card_set_memory_task); | ||
|
||
{ | ||
@@ -2943,11 +2943,11 @@ bool G1CollectedHeap::should_sample_collection_set_candidates() const { | ||
return candidates != NULL && candidates->num_remaining() > 0; | ||
} | ||
|
||
void G1CollectedHeap::set_collection_set_candidates_stats(G1CardSetMemoryStats& stats) { | ||
void G1CollectedHeap::set_collection_set_candidates_stats(G1SegmentedArrayMemoryStats& stats) { | ||
_collection_set_candidates_card_set_stats = stats; | ||
} | ||
|
||
void G1CollectedHeap::set_young_gen_card_set_stats(const G1CardSetMemoryStats& stats) { | ||
void G1CollectedHeap::set_young_gen_card_set_stats(const G1SegmentedArrayMemoryStats& stats) { | ||
_young_gen_card_set_stats = stats; | ||
} | ||
|
||
Oops, something went wrong.
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.
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.
Include order, must be sorted alphabetically