Skip to content

Commit d195033

Browse files
committed
8261842: Shenandoah: cleanup ShenandoahHeapRegionSet
Reviewed-by: rkennke
1 parent fc1d032 commit d195033

File tree

3 files changed

+6
-88
lines changed

3 files changed

+6
-88
lines changed

src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,10 @@
3333
ShenandoahHeapRegionSetIterator::ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSet* const set) :
3434
_set(set), _heap(ShenandoahHeap::heap()), _current_index(0) {}
3535

36-
void ShenandoahHeapRegionSetIterator::reset(const ShenandoahHeapRegionSet* const set) {
37-
_set = set;
38-
_current_index = 0;
39-
}
40-
4136
ShenandoahHeapRegionSet::ShenandoahHeapRegionSet() :
4237
_heap(ShenandoahHeap::heap()),
4338
_map_size(_heap->num_regions()),
44-
_region_size_bytes_shift(ShenandoahHeapRegion::region_size_bytes_shift()),
4539
_set_map(NEW_C_HEAP_ARRAY(jbyte, _map_size, mtGC)),
46-
_biased_set_map(_set_map - ((uintx)_heap->base() >> _region_size_bytes_shift)),
4740
_region_count(0)
4841
{
4942
// Use 1-byte data type
@@ -58,83 +51,40 @@ ShenandoahHeapRegionSet::~ShenandoahHeapRegionSet() {
5851
}
5952

6053
void ShenandoahHeapRegionSet::add_region(ShenandoahHeapRegion* r) {
61-
assert(!is_in(r), "Already in collection set");
54+
assert(!is_in(r), "Already in region set");
6255
_set_map[r->index()] = 1;
6356
_region_count++;
6457
}
6558

66-
bool ShenandoahHeapRegionSet::add_region_check_for_duplicates(ShenandoahHeapRegion* r) {
67-
if (!is_in(r)) {
68-
add_region(r);
69-
return true;
70-
} else {
71-
return false;
72-
}
73-
}
74-
7559
void ShenandoahHeapRegionSet::remove_region(ShenandoahHeapRegion* r) {
7660
assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
7761
assert(Thread::current()->is_VM_thread(), "Must be VMThread");
7862
assert(is_in(r), "Not in region set");
7963
_set_map[r->index()] = 0;
80-
_region_count --;
64+
_region_count--;
8165
}
8266

8367
void ShenandoahHeapRegionSet::clear() {
8468
assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
8569
Copy::zero_to_bytes(_set_map, _map_size);
86-
8770
_region_count = 0;
8871
}
8972

90-
ShenandoahHeapRegion* ShenandoahHeapRegionSetIterator::claim_next() {
91-
size_t num_regions = _heap->num_regions();
92-
if (_current_index >= (jint)num_regions) {
93-
return NULL;
94-
}
95-
96-
jint saved_current = _current_index;
97-
size_t index = (size_t)saved_current;
98-
99-
while(index < num_regions) {
100-
if (_set->is_in(index)) {
101-
jint cur = Atomic::cmpxchg(&_current_index, saved_current, (jint)(index + 1));
102-
assert(cur >= (jint)saved_current, "Must move forward");
103-
if (cur == saved_current) {
104-
assert(_set->is_in(index), "Invariant");
105-
return _heap->get_region(index);
106-
} else {
107-
index = (size_t)cur;
108-
saved_current = cur;
109-
}
110-
} else {
111-
index ++;
112-
}
113-
}
114-
return NULL;
115-
}
116-
11773
ShenandoahHeapRegion* ShenandoahHeapRegionSetIterator::next() {
118-
size_t num_regions = _heap->num_regions();
119-
for (size_t index = (size_t)_current_index; index < num_regions; index ++) {
74+
for (size_t index = _current_index; index < _heap->num_regions(); index++) {
12075
if (_set->is_in(index)) {
121-
_current_index = (jint)(index + 1);
76+
_current_index = index + 1;
12277
return _heap->get_region(index);
12378
}
12479
}
125-
12680
return NULL;
12781
}
12882

12983
void ShenandoahHeapRegionSet::print_on(outputStream* out) const {
13084
out->print_cr("Region Set : " SIZE_FORMAT "", count());
131-
132-
debug_only(size_t regions = 0;)
133-
for (size_t index = 0; index < _heap->num_regions(); index ++) {
85+
for (size_t index = 0; index < _heap->num_regions(); index++) {
13486
if (is_in(index)) {
13587
_heap->get_region(index)->print_on(out);
136-
debug_only(regions ++;)
13788
}
13889
}
139-
assert(regions == count(), "Must match");
14090
}

src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.hpp

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,14 @@ class ShenandoahHeapRegionSetIterator : public StackObj {
3737
private:
3838
const ShenandoahHeapRegionSet* _set;
3939
ShenandoahHeap* const _heap;
40-
41-
shenandoah_padding(0);
42-
volatile jint _current_index;
43-
shenandoah_padding(1);
40+
size_t _current_index;
4441

4542
// No implicit copying: iterators should be passed by reference to capture the state
4643
NONCOPYABLE(ShenandoahHeapRegionSetIterator);
4744

4845
public:
4946
ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSet* const set);
5047

51-
// Reset existing iterator to new set
52-
void reset(const ShenandoahHeapRegionSet* const set);
53-
54-
// MT version
55-
ShenandoahHeapRegion* claim_next();
56-
5748
// Single-thread version
5849
ShenandoahHeapRegion* next();
5950
};
@@ -63,38 +54,25 @@ class ShenandoahHeapRegionSet : public CHeapObj<mtGC> {
6354
private:
6455
ShenandoahHeap* const _heap;
6556
size_t const _map_size;
66-
size_t const _region_size_bytes_shift;
6757
jbyte* const _set_map;
68-
// Bias set map's base address for fast test if an oop is in set
69-
jbyte* const _biased_set_map;
7058
size_t _region_count;
7159

7260
public:
7361
ShenandoahHeapRegionSet();
7462
~ShenandoahHeapRegionSet();
7563

76-
// Add region to set
7764
void add_region(ShenandoahHeapRegion* r);
78-
bool add_region_check_for_duplicates(ShenandoahHeapRegion* r);
79-
80-
// Remove region from set
8165
void remove_region(ShenandoahHeapRegion* r);
8266

8367
size_t count() const { return _region_count; }
8468
bool is_empty() const { return _region_count == 0; }
8569

8670
inline bool is_in(ShenandoahHeapRegion* r) const;
8771
inline bool is_in(size_t region_idx) const;
88-
inline bool is_in(oop p) const;
8972

9073
void print_on(outputStream* out) const;
9174

9275
void clear();
93-
94-
private:
95-
jbyte* biased_map_address() const {
96-
return _biased_set_map;
97-
}
9876
};
9977

10078
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_HPP

src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.inline.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@
2525
#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_INLINE_HPP
2626
#define SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_INLINE_HPP
2727

28-
#include "gc/shenandoah/shenandoahAsserts.hpp"
2928
#include "gc/shenandoah/shenandoahHeapRegionSet.hpp"
3029
#include "gc/shenandoah/shenandoahHeap.hpp"
31-
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
3230
#include "gc/shenandoah/shenandoahHeapRegion.hpp"
3331

3432
bool ShenandoahHeapRegionSet::is_in(size_t region_idx) const {
@@ -40,12 +38,4 @@ bool ShenandoahHeapRegionSet::is_in(ShenandoahHeapRegion* r) const {
4038
return is_in(r->index());
4139
}
4240

43-
bool ShenandoahHeapRegionSet::is_in(oop p) const {
44-
shenandoah_assert_in_heap(NULL, p);
45-
uintx index = (cast_from_oop<uintx>(p)) >> _region_size_bytes_shift;
46-
// no need to subtract the bottom of the heap from p,
47-
// _biased_set_map is biased
48-
return _biased_set_map[index] == 1;
49-
}
50-
5141
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_INLINE_HPP

0 commit comments

Comments
 (0)