Skip to content

8365122: G1: Minor clean up of G1SurvivorRegions #26692

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
Show file tree
Hide file tree
Changes from all 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
16 changes: 5 additions & 11 deletions src/hotspot/share/gc/g1/g1Policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,9 @@ uint G1Policy::calculate_desired_eden_length_before_mixed(double base_time_ms,
}

double G1Policy::predict_survivor_regions_evac_time() const {
const GrowableArray<G1HeapRegion*>* survivor_regions = _g1h->survivor()->regions();
double survivor_regions_evac_time = predict_young_region_other_time_ms(_g1h->survivor()->length());
for (GrowableArrayIterator<G1HeapRegion*> it = survivor_regions->begin();
it != survivor_regions->end();
++it) {
survivor_regions_evac_time += predict_region_copy_time_ms(*it, _g1h->collector_state()->in_young_only_phase());
for (G1HeapRegion* r : _g1h->survivor()->regions()) {
survivor_regions_evac_time += predict_region_copy_time_ms(r, _g1h->collector_state()->in_young_only_phase());
}

return survivor_regions_evac_time;
Expand Down Expand Up @@ -1461,16 +1458,13 @@ uint G1Policy::calc_max_old_cset_length() const {
void G1Policy::transfer_survivors_to_cset(const G1SurvivorRegions* survivors) {
start_adding_survivor_regions();

for (GrowableArrayIterator<G1HeapRegion*> it = survivors->regions()->begin();
it != survivors->regions()->end();
++it) {
G1HeapRegion* curr = *it;
set_region_survivor(curr);
for (G1HeapRegion* r : survivors->regions()) {
set_region_survivor(r);

// The region is a non-empty survivor so let's add it to
// the incremental collection set for the next evacuation
// pause.
_collection_set->add_survivor_regions(curr);
_collection_set->add_survivor_regions(r);
}
stop_adding_survivor_regions();

Expand Down
15 changes: 6 additions & 9 deletions src/hotspot/share/gc/g1/g1SurvivorRegions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,33 @@
#include "utilities/growableArray.hpp"

G1SurvivorRegions::G1SurvivorRegions() :
_regions(new (mtGC) GrowableArray<G1HeapRegion*>(8, mtGC)),
_regions(8, mtGC),
_used_bytes(0),
_regions_on_node() {}

uint G1SurvivorRegions::add(G1HeapRegion* hr) {
assert(hr->is_survivor(), "should be flagged as survivor region");
_regions->append(hr);
_regions.append(hr);
return _regions_on_node.add(hr);
}

uint G1SurvivorRegions::length() const {
return (uint)_regions->length();
return (uint)_regions.length();
}

uint G1SurvivorRegions::regions_on_node(uint node_index) const {
return _regions_on_node.count(node_index);
}

void G1SurvivorRegions::convert_to_eden() {
for (GrowableArrayIterator<G1HeapRegion*> it = _regions->begin();
it != _regions->end();
++it) {
G1HeapRegion* hr = *it;
hr->set_eden_pre_gc();
for (G1HeapRegion* r : _regions) {
r->set_eden_pre_gc();
}
clear();
}

void G1SurvivorRegions::clear() {
_regions->clear();
_regions.clear();
_used_bytes = 0;
_regions_on_node.clear();
}
Expand Down
11 changes: 6 additions & 5 deletions src/hotspot/share/gc/g1/g1SurvivorRegions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@

#include "gc/g1/g1RegionsOnNodes.hpp"
#include "runtime/globals.hpp"
#include "utilities/growableArray.hpp"

template <typename T>
class GrowableArray;
class G1HeapRegion;

// Set of current survivor regions.
class G1SurvivorRegions {
private:
GrowableArray<G1HeapRegion*>* _regions;
volatile size_t _used_bytes;
G1RegionsOnNodes _regions_on_node;
GrowableArray<G1HeapRegion*> _regions;
volatile size_t _used_bytes;
G1RegionsOnNodes _regions_on_node;

public:
G1SurvivorRegions();
Expand All @@ -50,7 +51,7 @@ class G1SurvivorRegions {
uint length() const;
uint regions_on_node(uint node_index) const;

const GrowableArray<G1HeapRegion*>* regions() const {
const GrowableArray<G1HeapRegion*>& regions() const {
return _regions;
}

Expand Down