author | mgronlun |
Wed, 30 Oct 2019 19:43:52 +0100 | |
changeset 58863 | c16ac7a2eba4 |
parent 58132 | caa25ab47aca |
child 58157 | 9dca61a7df19 |
child 58679 | 9c3209ff7550 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52850
diff
changeset
|
2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
50113 | 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 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52850
diff
changeset
|
25 |
#ifndef SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLER_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52850
diff
changeset
|
26 |
#define SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLER_HPP |
50113 | 27 |
|
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "jfr/utilities/jfrTime.hpp" |
|
30 |
||
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
53244
diff
changeset
|
31 |
typedef u8 traceid; |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
53244
diff
changeset
|
32 |
|
50113 | 33 |
class BoolObjectClosure; |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
55571
diff
changeset
|
34 |
class JavaThread; |
50113 | 35 |
class OopClosure; |
36 |
class ObjectSample; |
|
37 |
class SampleList; |
|
38 |
class SamplePriorityQueue; |
|
39 |
||
40 |
// Class reponsible for holding samples and |
|
41 |
// making sure the samples are evenly distributed as |
|
42 |
// new entries are added and removed. |
|
43 |
class ObjectSampler : public CHeapObj<mtTracing> { |
|
44 |
friend class LeakProfiler; |
|
45 |
friend class StartOperation; |
|
46 |
friend class StopOperation; |
|
47 |
private: |
|
48 |
SamplePriorityQueue* _priority_queue; |
|
49 |
SampleList* _list; |
|
50 |
JfrTicks _last_sweep; |
|
51 |
size_t _total_allocated; |
|
52 |
size_t _threshold; |
|
53 |
size_t _size; |
|
54 |
bool _dead_samples; |
|
55 |
||
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
53244
diff
changeset
|
56 |
// Lifecycle |
50113 | 57 |
explicit ObjectSampler(size_t size); |
58 |
~ObjectSampler(); |
|
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
53244
diff
changeset
|
59 |
static bool create(size_t size); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
53244
diff
changeset
|
60 |
static bool is_created(); |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
53244
diff
changeset
|
61 |
static void destroy(); |
50113 | 62 |
|
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
53244
diff
changeset
|
63 |
// Sampling |
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
53244
diff
changeset
|
64 |
static void sample(HeapWord* object, size_t size, JavaThread* thread); |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
55571
diff
changeset
|
65 |
void add(HeapWord* object, size_t size, traceid thread_id, JavaThread* thread); |
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
53244
diff
changeset
|
66 |
void scavenge(); |
50113 | 67 |
void remove_dead(ObjectSample* sample); |
68 |
||
69 |
// Called by GC |
|
55571
49102ba8cf14
8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
mgronlun
parents:
53244
diff
changeset
|
70 |
static void oops_do(BoolObjectClosure* is_alive, OopClosure* f); |
50113 | 71 |
|
72 |
const ObjectSample* item_at(int index) const; |
|
73 |
ObjectSample* item_at(int index); |
|
74 |
int item_count() const; |
|
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
55571
diff
changeset
|
75 |
|
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
55571
diff
changeset
|
76 |
public: |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
55571
diff
changeset
|
77 |
static ObjectSampler* sampler(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
55571
diff
changeset
|
78 |
// For operations that require exclusive access (non-safepoint) |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
55571
diff
changeset
|
79 |
static ObjectSampler* acquire(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
55571
diff
changeset
|
80 |
static void release(); |
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
55571
diff
changeset
|
81 |
|
52850 | 82 |
const ObjectSample* first() const; |
58132
caa25ab47aca
8225797: OldObjectSample event creates unexpected amount of checkpoint data
mgronlun
parents:
55571
diff
changeset
|
83 |
ObjectSample* last() const; |
50113 | 84 |
const ObjectSample* last_resolved() const; |
85 |
void set_last_resolved(const ObjectSample* sample); |
|
86 |
const JfrTicks& last_sweep() const; |
|
87 |
}; |
|
88 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52850
diff
changeset
|
89 |
#endif // SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLER_HPP |