8325248: Serial: Remove Generation::space_iterate

Reviewed-by: tschatzl
This commit is contained in:
Albert Mingkun Yang 2024-02-07 12:21:30 +00:00
parent 77ee7f0e24
commit c3a632dca7
6 changed files with 13 additions and 44 deletions

View File

@ -673,12 +673,15 @@ void DefNewGeneration::object_iterate(ObjectClosure* blk) {
from()->object_iterate(blk);
}
void DefNewGeneration::space_iterate(SpaceClosure* blk,
bool usedOnly) {
blk->do_space(eden());
blk->do_space(from());
blk->do_space(to());
HeapWord* DefNewGeneration::block_start(const void* p) const {
if (eden()->is_in_reserved(p)) {
return eden()->block_start_const(p);
}
if (from()->is_in_reserved(p)) {
return from()->block_start_const(p);
}
assert(to()->is_in_reserved(p), "inv");
return to()->block_start_const(p);
}
// The last collection bailed out, we are running out of heap space,

View File

@ -208,7 +208,7 @@ class DefNewGeneration: public Generation {
// Iteration
void object_iterate(ObjectClosure* blk);
void space_iterate(SpaceClosure* blk, bool usedOnly = false);
HeapWord* block_start(const void* p) const;
// Allocation support
virtual bool should_allocate(size_t word_size, bool is_tlab) {

View File

@ -122,25 +122,3 @@ oop Generation::promote(oop obj, size_t obj_size) {
return new_obj;
}
// Some of these are mediocre general implementations. Should be
// overridden to get better performance.
class GenerationBlockStartClosure : public SpaceClosure {
public:
const void* _p;
HeapWord* _start;
virtual void do_space(Space* s) {
if (_start == nullptr && s->is_in_reserved(_p)) {
_start = s->block_start(_p);
}
}
GenerationBlockStartClosure(const void* p) { _p = p; _start = nullptr; }
};
HeapWord* Generation::block_start(const void* p) const {
GenerationBlockStartClosure blk(p);
// Cast away const
((Generation*)this)->space_iterate(&blk);
return blk._start;
}

View File

@ -118,9 +118,6 @@ class Generation: public CHeapObj<mtGC> {
return _reserved.contains(p);
}
// Iteration - do not use for time critical operations
virtual void space_iterate(SpaceClosure* blk, bool usedOnly = false) = 0;
// Returns "true" iff this generation should be used to allocate an
// object of the given size. Young generations might
// wish to exclude very large objects, for example, since, if allocated
@ -202,14 +199,6 @@ class Generation: public CHeapObj<mtGC> {
virtual const char* name() const = 0;
virtual const char* short_name() const = 0;
// Block abstraction.
// Returns the address of the start of the "block" that contains the
// address "addr". We say "blocks" instead of "object" since some heaps
// may not pack objects densely; a chunk may either be an object or a
// non-object.
virtual HeapWord* block_start(const void* addr) const;
virtual void print() const;
virtual void print_on(outputStream* st) const;

View File

@ -263,9 +263,8 @@ void TenuredGeneration::compute_new_size_inner() {
}
}
void TenuredGeneration::space_iterate(SpaceClosure* blk,
bool usedOnly) {
blk->do_space(space());
HeapWord* TenuredGeneration::block_start(const void* p) const {
return space()->block_start_const(p);
}
void TenuredGeneration::younger_refs_iterate(OopIterateClosure* blk) {

View File

@ -98,7 +98,7 @@ class TenuredGeneration: public Generation {
MemRegion prev_used_region() const { return _prev_used_region; }
void save_used_region() { _prev_used_region = used_region(); }
void space_iterate(SpaceClosure* blk, bool usedOnly = false);
HeapWord* block_start(const void* p) const;
void younger_refs_iterate(OopIterateClosure* blk);