50113
|
1 |
/*
|
|
2 |
* Copyright (c) 2016, 2018, 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_VM_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP
|
|
26 |
#define SHARE_VM_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP
|
|
27 |
|
|
28 |
#include "jfr/recorder/storage/jfrBuffer.hpp"
|
|
29 |
#include "jfr/recorder/storage/jfrMemorySpace.hpp"
|
|
30 |
#include "jfr/recorder/storage/jfrMemorySpaceRetrieval.hpp"
|
|
31 |
#include "jfr/utilities/jfrTypes.hpp"
|
|
32 |
|
|
33 |
class JfrCheckpointManager;
|
|
34 |
class JfrChunkWriter;
|
|
35 |
class JfrSerializer;
|
|
36 |
class JfrTypeManager;
|
|
37 |
class Mutex;
|
|
38 |
class Thread;
|
|
39 |
|
|
40 |
struct JfrCheckpointEntry {
|
|
41 |
jlong size;
|
|
42 |
jlong start_time;
|
|
43 |
jlong duration;
|
|
44 |
juint flushpoint;
|
|
45 |
juint nof_segments;
|
|
46 |
};
|
|
47 |
|
|
48 |
typedef JfrMemorySpace<JfrBuffer, JfrMspaceSequentialRetrieval, JfrCheckpointManager> JfrCheckpointMspace;
|
|
49 |
|
|
50 |
//
|
|
51 |
// Responsible for maintaining checkpoints and by implication types.
|
|
52 |
// A checkpoint is an event that has a payload consisting of constant types.
|
|
53 |
// A constant type is a binary relation, a set of key-value pairs.
|
|
54 |
//
|
|
55 |
class JfrCheckpointManager : public JfrCHeapObj {
|
|
56 |
public:
|
|
57 |
typedef JfrCheckpointMspace::Type Buffer;
|
|
58 |
private:
|
|
59 |
JfrCheckpointMspace* _free_list_mspace;
|
|
60 |
JfrCheckpointMspace* _epoch_transition_mspace;
|
|
61 |
Mutex* _lock;
|
|
62 |
JfrTypeManager* _type_manager;
|
|
63 |
const Thread* _service_thread;
|
|
64 |
JfrChunkWriter& _chunkwriter;
|
|
65 |
bool _checkpoint_epoch_state;
|
|
66 |
|
|
67 |
// mspace callback
|
|
68 |
void register_full(Buffer* t, Thread* thread);
|
|
69 |
void lock();
|
|
70 |
void unlock();
|
|
71 |
DEBUG_ONLY(bool is_locked() const;)
|
|
72 |
|
|
73 |
static Buffer* lease_buffer(Thread* t, size_t size = 0);
|
|
74 |
static Buffer* flush(Buffer* old, size_t used, size_t requested, Thread* t);
|
|
75 |
|
|
76 |
size_t clear();
|
|
77 |
size_t write();
|
|
78 |
size_t write_epoch_transition_mspace();
|
|
79 |
size_t write_types();
|
|
80 |
size_t write_safepoint_types();
|
|
81 |
void write_type_set();
|
|
82 |
void shift_epoch();
|
|
83 |
void synchronize_epoch();
|
|
84 |
bool use_epoch_transition_mspace(const Thread* t) const;
|
|
85 |
|
|
86 |
JfrCheckpointManager(JfrChunkWriter& cw);
|
|
87 |
~JfrCheckpointManager();
|
|
88 |
|
|
89 |
static JfrCheckpointManager& instance();
|
|
90 |
static JfrCheckpointManager* create(JfrChunkWriter& cw);
|
|
91 |
bool initialize();
|
|
92 |
static void destroy();
|
|
93 |
|
|
94 |
static bool register_serializer(JfrTypeId id, bool require_safepoint, bool permit_cache, JfrSerializer* serializer);
|
|
95 |
|
|
96 |
public:
|
|
97 |
void register_service_thread(const Thread* t);
|
|
98 |
static void write_type_set_for_unloaded_classes();
|
|
99 |
static void create_thread_checkpoint(JavaThread* jt);
|
|
100 |
static void write_thread_checkpoint(JavaThread* jt);
|
|
101 |
|
|
102 |
friend class JfrRecorder;
|
|
103 |
friend class JfrRecorderService;
|
|
104 |
friend class JfrCheckpointFlush;
|
|
105 |
friend class JfrCheckpointWriter;
|
|
106 |
friend class JfrSerializer;
|
|
107 |
friend class JfrStackTraceRepository;
|
|
108 |
template <typename, template <typename> class, typename>
|
|
109 |
friend class JfrMemorySpace;
|
|
110 |
};
|
|
111 |
|
|
112 |
#endif //SHARE_VM_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP
|