author | rehn |
Fri, 29 Nov 2019 12:09:25 +0100 | |
changeset 59325 | 3636bab5e81e |
parent 58863 | c16ac7a2eba4 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
50113
diff
changeset
|
2 |
* Copyright (c) 2012, 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 |
||
25 |
#include "precompiled.hpp" |
|
26 |
#include "jfr/recorder/jfrRecorder.hpp" |
|
27 |
#include "jfr/recorder/service/jfrPostBox.hpp" |
|
28 |
#include "jfr/recorder/service/jfrRecorderService.hpp" |
|
29 |
#include "jfr/recorder/service/jfrRecorderThread.hpp" |
|
30 |
#include "logging/log.hpp" |
|
31 |
#include "runtime/mutexLocker.hpp" |
|
32 |
#include "runtime/thread.inline.hpp" |
|
33 |
||
34 |
// |
|
35 |
// Entry point for "JFR Recorder Thread" message loop. |
|
36 |
// The recorder thread executes service requests collected from the message system. |
|
37 |
// |
|
38 |
void recorderthread_entry(JavaThread* thread, Thread* unused) { |
|
39 |
assert(thread != NULL, "invariant"); |
|
40 |
#define START (msgs & (MSGBIT(MSG_START))) |
|
41 |
#define SHUTDOWN (msgs & MSGBIT(MSG_SHUTDOWN)) |
|
42 |
#define ROTATE (msgs & (MSGBIT(MSG_ROTATE)|MSGBIT(MSG_STOP))) |
|
58863 | 43 |
#define FLUSHPOINT (msgs & (MSGBIT(MSG_FLUSHPOINT))) |
50113 | 44 |
#define PROCESS_FULL_BUFFERS (msgs & (MSGBIT(MSG_ROTATE)|MSGBIT(MSG_STOP)|MSGBIT(MSG_FULLBUFFER))) |
45 |
#define SCAVENGE (msgs & (MSGBIT(MSG_DEADBUFFER))) |
|
46 |
||
47 |
JfrPostBox& post_box = JfrRecorderThread::post_box(); |
|
48 |
log_debug(jfr, system)("Recorder thread STARTED"); |
|
49 |
||
50 |
{ |
|
51 |
bool done = false; |
|
52 |
int msgs = 0; |
|
53 |
JfrRecorderService service; |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
50113
diff
changeset
|
54 |
MutexLocker msg_lock(JfrMsg_lock); |
50113 | 55 |
|
56 |
// JFR MESSAGE LOOP PROCESSING - BEGIN |
|
57 |
while (!done) { |
|
58 |
if (post_box.is_empty()) { |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
50113
diff
changeset
|
59 |
JfrMsg_lock->wait(); |
50113 | 60 |
} |
61 |
msgs = post_box.collect(); |
|
62 |
JfrMsg_lock->unlock(); |
|
63 |
if (PROCESS_FULL_BUFFERS) { |
|
64 |
service.process_full_buffers(); |
|
65 |
} |
|
66 |
if (SCAVENGE) { |
|
67 |
service.scavenge(); |
|
68 |
} |
|
69 |
// Check amount of data written to chunk already |
|
70 |
// if it warrants asking for a new chunk |
|
71 |
service.evaluate_chunk_size_for_rotation(); |
|
72 |
if (START) { |
|
73 |
service.start(); |
|
74 |
} else if (ROTATE) { |
|
75 |
service.rotate(msgs); |
|
58863 | 76 |
} else if (FLUSHPOINT) { |
77 |
service.flushpoint(); |
|
50113 | 78 |
} |
79 |
JfrMsg_lock->lock(); |
|
80 |
post_box.notify_waiters(); |
|
81 |
if (SHUTDOWN) { |
|
82 |
log_debug(jfr, system)("Request to STOP recorder"); |
|
83 |
done = true; |
|
84 |
} |
|
85 |
} // JFR MESSAGE LOOP PROCESSING - END |
|
86 |
||
87 |
} // JfrMsg_lock scope |
|
88 |
||
89 |
assert(!JfrMsg_lock->owned_by_self(), "invariant"); |
|
90 |
post_box.notify_collection_stop(); |
|
91 |
JfrRecorder::on_recorder_thread_exit(); |
|
92 |
||
93 |
#undef START |
|
94 |
#undef SHUTDOWN |
|
95 |
#undef ROTATE |
|
58863 | 96 |
#undef FLUSHPOINT |
50113 | 97 |
#undef PROCESS_FULL_BUFFERS |
98 |
#undef SCAVENGE |
|
99 |
} |