Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.hpp
41155 views
1
/*
2
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLER_HPP
26
#define SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLER_HPP
27
28
#include "memory/allocation.hpp"
29
30
typedef u8 traceid;
31
32
class JavaThread;
33
class OopStorage;
34
class ObjectSample;
35
class SampleList;
36
class SamplePriorityQueue;
37
38
// Class reponsible for holding samples and
39
// making sure the samples are evenly distributed as
40
// new entries are added and removed.
41
class ObjectSampler : public CHeapObj<mtTracing> {
42
friend class JfrRecorder;
43
friend class LeakProfiler;
44
friend class ObjectSample;
45
friend class StartOperation;
46
friend class StopOperation;
47
private:
48
SamplePriorityQueue* _priority_queue;
49
SampleList* _list;
50
size_t _total_allocated;
51
size_t _threshold;
52
size_t _size;
53
54
// Lifecycle
55
explicit ObjectSampler(size_t size);
56
~ObjectSampler();
57
static bool create(size_t size);
58
static bool is_created();
59
static void destroy();
60
61
// Sampling
62
static void sample(HeapWord* object, size_t size, JavaThread* thread);
63
void add(HeapWord* object, size_t size, traceid thread_id, JavaThread* thread);
64
void scavenge();
65
void remove_dead(ObjectSample* sample);
66
67
const ObjectSample* item_at(int index) const;
68
ObjectSample* item_at(int index);
69
int item_count() const;
70
71
// OopStorage
72
static bool create_oop_storage();
73
static OopStorage* oop_storage();
74
// Invoked by the GC post oop storage processing.
75
static void oop_storage_gc_notification(size_t num_dead);
76
77
public:
78
static ObjectSampler* sampler();
79
// For operations that require exclusive access (non-safepoint)
80
static ObjectSampler* acquire();
81
static void release();
82
static int64_t last_sweep();
83
const ObjectSample* first() const;
84
ObjectSample* last() const;
85
const ObjectSample* last_resolved() const;
86
void set_last_resolved(const ObjectSample* sample);
87
};
88
89
#endif // SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLER_HPP
90
91