mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-14 21:19:00 +00:00
8387764: G1: Let G1CollectedHeap::_summary_bytes_used use the Atomic API
Reviewed-by: aboldtch, shade
This commit is contained in:
parent
f264341bac
commit
6e5bfcc645
@ -1761,12 +1761,11 @@ size_t G1CollectedHeap::unused_committed_regions_in_bytes() const {
|
||||
|
||||
// Computes the sum of the storage used by the various regions.
|
||||
size_t G1CollectedHeap::used() const {
|
||||
size_t result = _summary_bytes_used + _allocator->used_in_alloc_regions();
|
||||
return result;
|
||||
return used_unlocked() + _allocator->used_in_alloc_regions();
|
||||
}
|
||||
|
||||
size_t G1CollectedHeap::used_unlocked() const {
|
||||
return _summary_bytes_used;
|
||||
return _summary_bytes_used.load_relaxed();
|
||||
}
|
||||
|
||||
class SumUsedClosure: public G1HeapRegionClosure {
|
||||
@ -3034,18 +3033,18 @@ void G1CollectedHeap::prepare_region_for_full_compaction(G1HeapRegion* hr) {
|
||||
}
|
||||
|
||||
void G1CollectedHeap::increase_used(size_t bytes) {
|
||||
_summary_bytes_used += bytes;
|
||||
_summary_bytes_used.add_then_fetch(bytes, memory_order_relaxed);
|
||||
}
|
||||
|
||||
void G1CollectedHeap::decrease_used(size_t bytes) {
|
||||
assert(_summary_bytes_used >= bytes,
|
||||
assert(used_unlocked() >= bytes,
|
||||
"invariant: _summary_bytes_used: %zu should be >= bytes: %zu",
|
||||
_summary_bytes_used, bytes);
|
||||
_summary_bytes_used -= bytes;
|
||||
used_unlocked(), bytes);
|
||||
_summary_bytes_used.sub_then_fetch(bytes, memory_order_relaxed);
|
||||
}
|
||||
|
||||
void G1CollectedHeap::set_used(size_t bytes) {
|
||||
_summary_bytes_used = bytes;
|
||||
_summary_bytes_used.store_relaxed(bytes);
|
||||
}
|
||||
|
||||
class RebuildRegionSetsClosure : public G1HeapRegionClosure {
|
||||
|
||||
@ -243,7 +243,7 @@ private:
|
||||
|
||||
// Outside of GC pauses, the number of bytes used in all regions other
|
||||
// than the current allocation region(s).
|
||||
volatile size_t _summary_bytes_used;
|
||||
Atomic<size_t> _summary_bytes_used;
|
||||
|
||||
void increase_used(size_t bytes);
|
||||
void decrease_used(size_t bytes);
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
nonstatic_field(G1HeapRegion, _bottom, HeapWord* const) \
|
||||
nonstatic_field(G1HeapRegion, _top, Atomic<HeapWord*>) \
|
||||
nonstatic_field(G1HeapRegion, _end, HeapWord* const) \
|
||||
volatile_nonstatic_field(G1HeapRegion, _pinned_object_count, Atomic<size_t>)\
|
||||
nonstatic_field(G1HeapRegion, _pinned_object_count, Atomic<size_t>) \
|
||||
\
|
||||
nonstatic_field(G1HeapRegionType, _tag, G1HeapRegionType::Tag volatile) \
|
||||
\
|
||||
@ -55,7 +55,7 @@
|
||||
\
|
||||
nonstatic_field(G1HeapRegionManager, _regions, G1HeapRegionTable) \
|
||||
\
|
||||
volatile_nonstatic_field(G1CollectedHeap, _summary_bytes_used, size_t) \
|
||||
nonstatic_field(G1CollectedHeap, _summary_bytes_used, Atomic<size_t>) \
|
||||
nonstatic_field(G1CollectedHeap, _hrm, G1HeapRegionManager) \
|
||||
nonstatic_field(G1CollectedHeap, _monitoring_support, G1MonitoringSupport*) \
|
||||
nonstatic_field(G1CollectedHeap, _old_set, G1HeapRegionSetBase) \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user