Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/jfr/leakprofiler/sampling/objectSampler.hpp
38922 views
/*1* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_LEAKPROFILER_SAMPLING_OBJECTSAMPLER_HPP25#define SHARE_VM_LEAKPROFILER_SAMPLING_OBJECTSAMPLER_HPP2627#include "memory/allocation.hpp"28#include "jfr/utilities/jfrTime.hpp"2930typedef u8 traceid;3132class BoolObjectClosure;33class JfrStackTrace;34class OopClosure;35class ObjectSample;36class ObjectSampler;37class SampleList;38class SamplePriorityQueue;39class Thread;4041// Class reponsible for holding samples and42// making sure the samples are evenly distributed as43// new entries are added and removed.44class ObjectSampler : public CHeapObj<mtTracing> {45friend class EventEmitter;46friend class JfrRecorderService;47friend class LeakProfiler;48friend class StartOperation;49friend class StopOperation;50friend class ObjectSampleCheckpoint;51friend class WriteObjectSampleStacktrace;52private:53SamplePriorityQueue* _priority_queue;54SampleList* _list;55JfrTicks _last_sweep;56size_t _total_allocated;57size_t _threshold;58size_t _size;59bool _dead_samples;6061// Lifecycle62explicit ObjectSampler(size_t size);63~ObjectSampler();64static bool create(size_t size);65static bool is_created();66static ObjectSampler* sampler();67static void destroy();6869// For operations that require exclusive access (non-safepoint)70static ObjectSampler* acquire();71static void release();7273// Stacktrace74static void fill_stacktrace(JfrStackTrace* stacktrace, JavaThread* thread);75traceid stacktrace_id(const JfrStackTrace* stacktrace, JavaThread* thread);7677// Sampling78static void sample(HeapWord* object, size_t size, JavaThread* thread);79void add(HeapWord* object, size_t size, traceid thread_id, JfrStackTrace* stacktrace, JavaThread* thread);80void scavenge();81void remove_dead(ObjectSample* sample);8283// Called by GC84static void oops_do(BoolObjectClosure* is_alive, OopClosure* f);8586const ObjectSample* item_at(int index) const;87ObjectSample* item_at(int index);88int item_count() const;89const ObjectSample* first() const;90const ObjectSample* last() const;91const ObjectSample* last_resolved() const;92void set_last_resolved(const ObjectSample* sample);93const JfrTicks& last_sweep() const;94};9596#endif // SHARE_VM_LEAKPROFILER_SAMPLING_OBJECTSAMPLER_HPP979899