mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8234437: Remove CollectedHeap::safe_object_iterate()
Reviewed-by: kbarrett, sjohanss
This commit is contained in:
parent
097ca3b94f
commit
08822b4e05
18 changed files with 6 additions and 70 deletions
|
@ -290,8 +290,8 @@ void EpsilonHeap::do_full_collection(bool clear_all_soft_refs) {
|
||||||
collect(gc_cause());
|
collect(gc_cause());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EpsilonHeap::safe_object_iterate(ObjectClosure *cl) {
|
void EpsilonHeap::object_iterate(ObjectClosure *cl) {
|
||||||
_space->safe_object_iterate(cl);
|
_space->object_iterate(cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EpsilonHeap::print_on(outputStream *st) const {
|
void EpsilonHeap::print_on(outputStream *st) const {
|
||||||
|
|
|
@ -103,10 +103,7 @@ public:
|
||||||
virtual void do_full_collection(bool clear_all_soft_refs);
|
virtual void do_full_collection(bool clear_all_soft_refs);
|
||||||
|
|
||||||
// Heap walking support
|
// Heap walking support
|
||||||
virtual void safe_object_iterate(ObjectClosure* cl);
|
virtual void object_iterate(ObjectClosure* cl);
|
||||||
virtual void object_iterate(ObjectClosure* cl) {
|
|
||||||
safe_object_iterate(cl);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Object pinning support: every object is implicitly pinned
|
// Object pinning support: every object is implicitly pinned
|
||||||
virtual bool supports_object_pinning() const { return true; }
|
virtual bool supports_object_pinning() const { return true; }
|
||||||
|
|
|
@ -1166,10 +1166,6 @@ public:
|
||||||
// Iterate over all objects, calling "cl.do_object" on each.
|
// Iterate over all objects, calling "cl.do_object" on each.
|
||||||
virtual void object_iterate(ObjectClosure* cl);
|
virtual void object_iterate(ObjectClosure* cl);
|
||||||
|
|
||||||
virtual void safe_object_iterate(ObjectClosure* cl) {
|
|
||||||
object_iterate(cl);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate over heap regions, in address order, terminating the
|
// Iterate over heap regions, in address order, terminating the
|
||||||
// iteration early if the "do_heap_region" method returns "true".
|
// iteration early if the "do_heap_region" method returns "true".
|
||||||
void heap_region_iterate(HeapRegionClosure* blk) const;
|
void heap_region_iterate(HeapRegionClosure* blk) const;
|
||||||
|
|
|
@ -213,7 +213,6 @@ class ParallelScavengeHeap : public CollectedHeap {
|
||||||
size_t unsafe_max_tlab_alloc(Thread* thr) const;
|
size_t unsafe_max_tlab_alloc(Thread* thr) const;
|
||||||
|
|
||||||
void object_iterate(ObjectClosure* cl);
|
void object_iterate(ObjectClosure* cl);
|
||||||
void safe_object_iterate(ObjectClosure* cl) { object_iterate(cl); }
|
|
||||||
|
|
||||||
HeapWord* block_start(const void* addr) const;
|
HeapWord* block_start(const void* addr) const;
|
||||||
bool block_is_obj(const HeapWord* addr) const;
|
bool block_is_obj(const HeapWord* addr) const;
|
||||||
|
|
|
@ -387,10 +387,6 @@ class CollectedHeap : public CHeapObj<mtInternal> {
|
||||||
// Iterate over all objects, calling "cl.do_object" on each.
|
// Iterate over all objects, calling "cl.do_object" on each.
|
||||||
virtual void object_iterate(ObjectClosure* cl) = 0;
|
virtual void object_iterate(ObjectClosure* cl) = 0;
|
||||||
|
|
||||||
// Similar to object_iterate() except iterates only
|
|
||||||
// over live objects.
|
|
||||||
virtual void safe_object_iterate(ObjectClosure* cl) = 0;
|
|
||||||
|
|
||||||
// Returns the longest time (in ms) that has elapsed since the last
|
// Returns the longest time (in ms) that has elapsed since the last
|
||||||
// time that any part of the heap was examined by a garbage collection.
|
// time that any part of the heap was examined by a garbage collection.
|
||||||
virtual jlong millis_since_last_gc() = 0;
|
virtual jlong millis_since_last_gc() = 0;
|
||||||
|
|
|
@ -1034,11 +1034,6 @@ void GenCollectedHeap::object_iterate(ObjectClosure* cl) {
|
||||||
_old_gen->object_iterate(cl);
|
_old_gen->object_iterate(cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenCollectedHeap::safe_object_iterate(ObjectClosure* cl) {
|
|
||||||
_young_gen->safe_object_iterate(cl);
|
|
||||||
_old_gen->safe_object_iterate(cl);
|
|
||||||
}
|
|
||||||
|
|
||||||
Space* GenCollectedHeap::space_containing(const void* addr) const {
|
Space* GenCollectedHeap::space_containing(const void* addr) const {
|
||||||
Space* res = _young_gen->space_containing(addr);
|
Space* res = _young_gen->space_containing(addr);
|
||||||
if (res != NULL) {
|
if (res != NULL) {
|
||||||
|
|
|
@ -248,7 +248,6 @@ public:
|
||||||
// Iteration functions.
|
// Iteration functions.
|
||||||
void oop_iterate(OopIterateClosure* cl);
|
void oop_iterate(OopIterateClosure* cl);
|
||||||
void object_iterate(ObjectClosure* cl);
|
void object_iterate(ObjectClosure* cl);
|
||||||
void safe_object_iterate(ObjectClosure* cl);
|
|
||||||
Space* space_containing(const void* addr) const;
|
Space* space_containing(const void* addr) const;
|
||||||
|
|
||||||
// A CollectedHeap is divided into a dense sequence of "blocks"; that is,
|
// A CollectedHeap is divided into a dense sequence of "blocks"; that is,
|
||||||
|
|
|
@ -289,21 +289,6 @@ void Generation::object_iterate(ObjectClosure* cl) {
|
||||||
space_iterate(&blk);
|
space_iterate(&blk);
|
||||||
}
|
}
|
||||||
|
|
||||||
class GenerationSafeObjIterateClosure : public SpaceClosure {
|
|
||||||
private:
|
|
||||||
ObjectClosure* _cl;
|
|
||||||
public:
|
|
||||||
virtual void do_space(Space* s) {
|
|
||||||
s->safe_object_iterate(_cl);
|
|
||||||
}
|
|
||||||
GenerationSafeObjIterateClosure(ObjectClosure* cl) : _cl(cl) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
void Generation::safe_object_iterate(ObjectClosure* cl) {
|
|
||||||
GenerationSafeObjIterateClosure blk(cl);
|
|
||||||
space_iterate(&blk);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if INCLUDE_SERIALGC
|
#if INCLUDE_SERIALGC
|
||||||
|
|
||||||
void Generation::prepare_for_compaction(CompactPoint* cp) {
|
void Generation::prepare_for_compaction(CompactPoint* cp) {
|
||||||
|
|
|
@ -470,11 +470,6 @@ class Generation: public CHeapObj<mtGC> {
|
||||||
// each.
|
// each.
|
||||||
virtual void object_iterate(ObjectClosure* cl);
|
virtual void object_iterate(ObjectClosure* cl);
|
||||||
|
|
||||||
// Iterate over all safe objects in the generation, calling "cl.do_object" on
|
|
||||||
// each. An object is safe if its references point to other objects in
|
|
||||||
// the heap. This defaults to object_iterate() unless overridden.
|
|
||||||
virtual void safe_object_iterate(ObjectClosure* cl);
|
|
||||||
|
|
||||||
// Apply "cl->do_oop" to (the address of) all and only all the ref fields
|
// Apply "cl->do_oop" to (the address of) all and only all the ref fields
|
||||||
// in the current generation that contain pointers to objects in younger
|
// in the current generation that contain pointers to objects in younger
|
||||||
// generations. Objects allocated since the last "save_marks" call are
|
// generations. Objects allocated since the last "save_marks" call are
|
||||||
|
|
|
@ -498,12 +498,6 @@ void ContiguousSpace::object_iterate(ObjectClosure* blk) {
|
||||||
object_iterate_from(bottom(), blk);
|
object_iterate_from(bottom(), blk);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For a ContiguousSpace object_iterate() and safe_object_iterate()
|
|
||||||
// are the same.
|
|
||||||
void ContiguousSpace::safe_object_iterate(ObjectClosure* blk) {
|
|
||||||
object_iterate(blk);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContiguousSpace::object_iterate_from(HeapWord* mark, ObjectClosure* blk) {
|
void ContiguousSpace::object_iterate_from(HeapWord* mark, ObjectClosure* blk) {
|
||||||
while (mark < top()) {
|
while (mark < top()) {
|
||||||
blk->do_object(oop(mark));
|
blk->do_object(oop(mark));
|
||||||
|
|
|
@ -175,9 +175,6 @@ class Space: public CHeapObj<mtGC> {
|
||||||
// each. Objects allocated by applications of the closure are not
|
// each. Objects allocated by applications of the closure are not
|
||||||
// included in the iteration.
|
// included in the iteration.
|
||||||
virtual void object_iterate(ObjectClosure* blk) = 0;
|
virtual void object_iterate(ObjectClosure* blk) = 0;
|
||||||
// Similar to object_iterate() except only iterates over
|
|
||||||
// objects whose internal references point to objects in the space.
|
|
||||||
virtual void safe_object_iterate(ObjectClosure* blk) = 0;
|
|
||||||
|
|
||||||
// Create and return a new dirty card to oop closure. Can be
|
// Create and return a new dirty card to oop closure. Can be
|
||||||
// overridden to return the appropriate type of closure
|
// overridden to return the appropriate type of closure
|
||||||
|
@ -584,9 +581,6 @@ class ContiguousSpace: public CompactibleSpace {
|
||||||
// Iteration
|
// Iteration
|
||||||
void oop_iterate(OopIterateClosure* cl);
|
void oop_iterate(OopIterateClosure* cl);
|
||||||
void object_iterate(ObjectClosure* blk);
|
void object_iterate(ObjectClosure* blk);
|
||||||
// For contiguous spaces this method will iterate safely over objects
|
|
||||||
// in the space (i.e., between bottom and top) when at a safepoint.
|
|
||||||
void safe_object_iterate(ObjectClosure* blk);
|
|
||||||
|
|
||||||
// Iterate over as many initialized objects in the space as possible,
|
// Iterate over as many initialized objects in the space as possible,
|
||||||
// calling "cl.do_object_careful" on each. Return NULL if all objects
|
// calling "cl.do_object_careful" on each. Return NULL if all objects
|
||||||
|
|
|
@ -1324,11 +1324,6 @@ void ShenandoahHeap::object_iterate(ObjectClosure* cl) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShenandoahHeap::safe_object_iterate(ObjectClosure* cl) {
|
|
||||||
assert(SafepointSynchronize::is_at_safepoint(), "safe iteration is only available during safepoints");
|
|
||||||
object_iterate(cl);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShenandoahHeap::heap_region_iterate(ShenandoahHeapRegionClosure* blk) const {
|
void ShenandoahHeap::heap_region_iterate(ShenandoahHeapRegionClosure* blk) const {
|
||||||
for (size_t i = 0; i < num_regions(); i++) {
|
for (size_t i = 0; i < num_regions(); i++) {
|
||||||
ShenandoahHeapRegion* current = get_region(i);
|
ShenandoahHeapRegion* current = get_region(i);
|
||||||
|
|
|
@ -547,7 +547,6 @@ public:
|
||||||
|
|
||||||
// Used for native heap walkers: heap dumpers, mostly
|
// Used for native heap walkers: heap dumpers, mostly
|
||||||
void object_iterate(ObjectClosure* cl);
|
void object_iterate(ObjectClosure* cl);
|
||||||
void safe_object_iterate(ObjectClosure* cl);
|
|
||||||
|
|
||||||
// Used by RMI
|
// Used by RMI
|
||||||
jlong millis_since_last_gc();
|
jlong millis_since_last_gc();
|
||||||
|
|
|
@ -246,10 +246,6 @@ void ZCollectedHeap::object_iterate(ObjectClosure* cl) {
|
||||||
_heap.object_iterate(cl, true /* visit_weaks */);
|
_heap.object_iterate(cl, true /* visit_weaks */);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZCollectedHeap::safe_object_iterate(ObjectClosure* cl) {
|
|
||||||
_heap.object_iterate(cl, true /* visit_weaks */);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZCollectedHeap::register_nmethod(nmethod* nm) {
|
void ZCollectedHeap::register_nmethod(nmethod* nm) {
|
||||||
ZNMethod::register_nmethod(nm);
|
ZNMethod::register_nmethod(nm);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,6 @@ public:
|
||||||
virtual GrowableArray<MemoryPool*> memory_pools();
|
virtual GrowableArray<MemoryPool*> memory_pools();
|
||||||
|
|
||||||
virtual void object_iterate(ObjectClosure* cl);
|
virtual void object_iterate(ObjectClosure* cl);
|
||||||
virtual void safe_object_iterate(ObjectClosure* cl);
|
|
||||||
|
|
||||||
virtual void register_nmethod(nmethod* nm);
|
virtual void register_nmethod(nmethod* nm);
|
||||||
virtual void unregister_nmethod(nmethod* nm);
|
virtual void unregister_nmethod(nmethod* nm);
|
||||||
|
|
|
@ -719,7 +719,7 @@ size_t HeapInspection::populate_table(KlassInfoTable* cit, BoolObjectClosure *fi
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
|
|
||||||
RecordInstanceClosure ric(cit, filter);
|
RecordInstanceClosure ric(cit, filter);
|
||||||
Universe::heap()->safe_object_iterate(&ric);
|
Universe::heap()->object_iterate(&ric);
|
||||||
return ric.missed_count();
|
return ric.missed_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,5 +792,5 @@ void HeapInspection::find_instances_at_safepoint(Klass* k, GrowableArray<oop>* r
|
||||||
|
|
||||||
// Iterate over objects in the heap
|
// Iterate over objects in the heap
|
||||||
FindInstanceClosure fic(k, result);
|
FindInstanceClosure fic(k, result);
|
||||||
Universe::heap()->safe_object_iterate(&fic);
|
Universe::heap()->object_iterate(&fic);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1271,9 +1271,6 @@ class VM_HeapIterateOperation: public VM_Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the iteration
|
// do the iteration
|
||||||
// If this operation encounters a bad object when using CMS,
|
|
||||||
// consider using safe_object_iterate() which avoids perm gen
|
|
||||||
// objects that may contain bad references.
|
|
||||||
Universe::heap()->object_iterate(_blk);
|
Universe::heap()->object_iterate(_blk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1882,7 +1882,7 @@ void VM_HeapDumper::doit() {
|
||||||
// The HPROF_GC_CLASS_DUMP and HPROF_GC_INSTANCE_DUMP are the vast bulk
|
// The HPROF_GC_CLASS_DUMP and HPROF_GC_INSTANCE_DUMP are the vast bulk
|
||||||
// of the heap dump.
|
// of the heap dump.
|
||||||
HeapObjectDumper obj_dumper(this, writer());
|
HeapObjectDumper obj_dumper(this, writer());
|
||||||
Universe::heap()->safe_object_iterate(&obj_dumper);
|
Universe::heap()->object_iterate(&obj_dumper);
|
||||||
|
|
||||||
// HPROF_GC_ROOT_THREAD_OBJ + frames + jni locals
|
// HPROF_GC_ROOT_THREAD_OBJ + frames + jni locals
|
||||||
do_threads();
|
do_threads();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue