author | mgronlun |
Wed, 30 Oct 2019 19:43:52 +0100 | |
changeset 58863 | c16ac7a2eba4 |
parent 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
2 |
* Copyright (c) 2013, 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:
50113
diff
changeset
|
25 |
#ifndef SHARE_JFR_RECORDER_SERVICE_JFRPOSTBOX_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
26 |
#define SHARE_JFR_RECORDER_SERVICE_JFRPOSTBOX_HPP |
50113 | 27 |
|
28 |
#include "jfr/utilities/jfrAllocation.hpp" |
|
29 |
||
30 |
#define MSGBIT(e) (1<<(e)) |
|
31 |
||
32 |
enum JFR_Msg { |
|
33 |
MSG_ALL_MSGS = -1, |
|
34 |
MSG_CLONE_IN_MEMORY = 0, |
|
35 |
MSG_START, |
|
36 |
MSG_STOP, |
|
37 |
MSG_ROTATE, |
|
38 |
MSG_FULLBUFFER, |
|
39 |
MSG_CHECKPOINT, |
|
40 |
MSG_WAKEUP, |
|
41 |
MSG_SHUTDOWN, |
|
42 |
MSG_VM_ERROR, |
|
43 |
MSG_DEADBUFFER, |
|
58863 | 44 |
MSG_FLUSHPOINT, |
50113 | 45 |
MSG_NO_OF_MSGS |
46 |
}; |
|
47 |
||
48 |
/** |
|
49 |
* Jfr messaging. |
|
50 |
* |
|
51 |
* Synchronous messages (posting thread waits for message completion): |
|
52 |
* |
|
53 |
* MSG_CLONE_IN_MEMORY (0) ; MSGBIT(MSG_CLONE_IN_MEMORY) == (1 << 0) == 0x1 |
|
54 |
* MSG_START(1) ; MSGBIT(MSG_START) == (1 << 0x1) == 0x2 |
|
55 |
* MSG_STOP (2) ; MSGBIT(MSG_STOP) == (1 << 0x2) == 0x4 |
|
56 |
* MSG_ROTATE (3) ; MSGBIT(MSG_ROTATE) == (1 << 0x3) == 0x8 |
|
58863 | 57 |
* MSG_VM_ERROR (8) ; MSGBIT(MSG_VM_ERROR) == (1 << 0x8) == 0x100 |
58 |
* MSG_FLUSHPOINT (10) ; MSGBIT(MSG_FLUSHPOINT) == (1 << 0xa) == 0x400 |
|
50113 | 59 |
* |
60 |
* Asynchronous messages (posting thread returns immediately upon deposit): |
|
61 |
* |
|
62 |
* MSG_FULLBUFFER (4) ; MSGBIT(MSG_FULLBUFFER) == (1 << 0x4) == 0x10 |
|
58863 | 63 |
* MSG_CHECKPOINT (5) ; MSGBIT(CHECKPOINT) == (1 << 0x5) == 0x20 |
64 |
* MSG_WAKEUP (6) ; MSGBIT(WAKEUP) == (1 << 0x6) == 0x40 |
|
65 |
* MSG_SHUTDOWN (7) ; MSGBIT(MSG_SHUTDOWN) == (1 << 0x7) == 0x80 |
|
66 |
* MSG_DEADBUFFER (9) ; MSGBIT(MSG_DEADBUFFER) == (1 << 0x9) == 0x200 |
|
50113 | 67 |
*/ |
68 |
||
69 |
class JfrPostBox : public JfrCHeapObj { |
|
70 |
friend class JfrRecorder; |
|
71 |
public: |
|
72 |
void post(JFR_Msg msg); |
|
73 |
||
74 |
private: |
|
75 |
uintptr_t _msg_read_serial; |
|
76 |
uintptr_t _msg_handled_serial; |
|
77 |
volatile int _messages; |
|
78 |
bool _has_waiters; |
|
79 |
||
80 |
JfrPostBox(); |
|
81 |
static JfrPostBox& instance(); |
|
82 |
static JfrPostBox* create(); |
|
83 |
static void destroy(); |
|
84 |
||
85 |
void asynchronous_post(int msg); |
|
86 |
void synchronous_post(int msg); |
|
87 |
void deposit(int new_messages); |
|
88 |
bool is_message_processed(uintptr_t serial_id) const; |
|
89 |
||
90 |
friend void recorderthread_entry(JavaThread*, Thread*); |
|
91 |
// for the friend declaration above |
|
92 |
bool is_empty() const; |
|
93 |
int collect(); |
|
94 |
bool check_waiters(int messages) const; |
|
95 |
void notify_waiters(); |
|
96 |
void notify_collection_stop(); |
|
97 |
}; |
|
98 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50113
diff
changeset
|
99 |
#endif // SHARE_JFR_RECORDER_SERVICE_JFRPOSTBOX_HPP |