From 9892e0a821bc76a51bbdaaa430e5f3875aa6465a Mon Sep 17 00:00:00 2001 From: egahlin Date: Wed, 5 Dec 2018 16:40:12 +0100 Subject: [PATCH] 8205516: JFR tool Reviewed-by: mgronlun --- src/share/vm/jfr/leakprofiler/emitEventOperation.cpp | 10 ++++++---- .../vm/jfr/leakprofiler/sampling/objectSampler.cpp | 4 ++++ .../vm/jfr/leakprofiler/sampling/objectSampler.hpp | 1 + src/share/vm/jfr/leakprofiler/sampling/sampleList.cpp | 4 ++++ src/share/vm/jfr/leakprofiler/sampling/sampleList.hpp | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/share/vm/jfr/leakprofiler/emitEventOperation.cpp b/src/share/vm/jfr/leakprofiler/emitEventOperation.cpp index 4995dc641..852f95272 100644 --- a/src/share/vm/jfr/leakprofiler/emitEventOperation.cpp +++ b/src/share/vm/jfr/leakprofiler/emitEventOperation.cpp @@ -157,12 +157,14 @@ int EmitEventOperation::write_events(EdgeStore* edge_store) { const jlong last_sweep = _emit_all ? max_jlong : _object_sampler->last_sweep().value(); int count = 0; - for (int i = 0; i < _object_sampler->item_count(); ++i) { - const ObjectSample* sample = _object_sampler->item_at(i); - if (sample->is_alive_and_older_than(last_sweep)) { - write_event(sample, edge_store); + const ObjectSample* current = _object_sampler->first(); + while (current != NULL) { + ObjectSample* prev = current->prev(); + if (current->is_alive_and_older_than(last_sweep)) { + write_event(current, edge_store); ++count; } + current = prev; } // restore thread local stack trace and thread id diff --git a/src/share/vm/jfr/leakprofiler/sampling/objectSampler.cpp b/src/share/vm/jfr/leakprofiler/sampling/objectSampler.cpp index 07c0e652a..eac1d296e 100644 --- a/src/share/vm/jfr/leakprofiler/sampling/objectSampler.cpp +++ b/src/share/vm/jfr/leakprofiler/sampling/objectSampler.cpp @@ -121,6 +121,10 @@ const ObjectSample* ObjectSampler::last() const { return _list->last(); } +const ObjectSample* ObjectSampler::first() const { + return _list->first(); +} + const ObjectSample* ObjectSampler::last_resolved() const { return _list->last_resolved(); } diff --git a/src/share/vm/jfr/leakprofiler/sampling/objectSampler.hpp b/src/share/vm/jfr/leakprofiler/sampling/objectSampler.hpp index b8cea323e..2bf13031f 100644 --- a/src/share/vm/jfr/leakprofiler/sampling/objectSampler.hpp +++ b/src/share/vm/jfr/leakprofiler/sampling/objectSampler.hpp @@ -69,6 +69,7 @@ class ObjectSampler : public CHeapObj { const ObjectSample* item_at(int index) const; ObjectSample* item_at(int index); int item_count() const; + const ObjectSample* first() const; const ObjectSample* last() const; const ObjectSample* last_resolved() const; void set_last_resolved(const ObjectSample* sample); diff --git a/src/share/vm/jfr/leakprofiler/sampling/sampleList.cpp b/src/share/vm/jfr/leakprofiler/sampling/sampleList.cpp index 04fffa8dc..1ef3f5615 100644 --- a/src/share/vm/jfr/leakprofiler/sampling/sampleList.cpp +++ b/src/share/vm/jfr/leakprofiler/sampling/sampleList.cpp @@ -45,6 +45,10 @@ ObjectSample* SampleList::last() const { return _in_use_list.head(); } +ObjectSample* SampleList::first() const { + return _in_use_list.tail(); +} + const ObjectSample* SampleList::last_resolved() const { return _last_resolved; } diff --git a/src/share/vm/jfr/leakprofiler/sampling/sampleList.hpp b/src/share/vm/jfr/leakprofiler/sampling/sampleList.hpp index 9d7d27fd0..6754ed3ba 100644 --- a/src/share/vm/jfr/leakprofiler/sampling/sampleList.hpp +++ b/src/share/vm/jfr/leakprofiler/sampling/sampleList.hpp @@ -53,6 +53,7 @@ class SampleList : public JfrCHeapObj { void set_last_resolved(const ObjectSample* sample); ObjectSample* get(); ObjectSample* last() const; + ObjectSample* first() const; void release(ObjectSample* sample); const ObjectSample* last_resolved() const; ObjectSample* reuse(ObjectSample* sample); -- GitLab