Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_verbose_old/VerboseManagerOld.cpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2020 IBM Corp. and others
4
*
5
* This program and the accompanying materials are made available under
6
* the terms of the Eclipse Public License 2.0 which accompanies this
7
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
8
* or the Apache License, Version 2.0 which accompanies this distribution and
9
* is available at https://www.apache.org/licenses/LICENSE-2.0.
10
*
11
* This Source Code may also be made available under the following
12
* Secondary Licenses when the conditions for such availability set
13
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
14
* General Public License, version 2 with the GNU Classpath
15
* Exception [1] and GNU General Public License, version 2 with the
16
* OpenJDK Assembly Exception [2].
17
*
18
* [1] https://www.gnu.org/software/classpath/license.html
19
* [2] http://openjdk.java.net/legal/assembly-exception.html
20
*
21
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
22
*******************************************************************************/
23
24
#include "gcutils.h"
25
#include "modronnls.h"
26
27
#include <string.h>
28
29
#include "EnvironmentBase.hpp"
30
#include "VerboseEventAFEnd.hpp"
31
#include "VerboseEventAFStart.hpp"
32
#include "VerboseEventClassUnloadingEnd.hpp"
33
#include "VerboseEventClassUnloadingStart.hpp"
34
#include "VerboseEventCompactEnd.hpp"
35
#include "VerboseEventCompactStart.hpp"
36
#include "VerboseEventCompletedConcurrentSweep.hpp"
37
#include "VerboseEventConcurrentAborted.hpp"
38
#include "VerboseEventConcurrentEnd.hpp"
39
#include "VerboseEventConcurrentFinalCardCleaningEnd.hpp"
40
#include "VerboseEventConcurrentFinalCardCleaningStart.hpp"
41
#include "VerboseEventConcurrentHalted.hpp"
42
#include "VerboseEventConcurrentKickOff.hpp"
43
#include "VerboseEventConcurrentlyCompletedSweepPhase.hpp"
44
#include "VerboseEventConcurrentCompleteTracingEnd.hpp"
45
#include "VerboseEventConcurrentCompleteTracingStart.hpp"
46
#include "VerboseEventConcurrentRSScanEnd.hpp"
47
#include "VerboseEventConcurrentRSScanStart.hpp"
48
#include "VerboseEventConcurrentStart.hpp"
49
#include "VerboseEventCopyForwardAbortRaised.hpp"
50
#include "VerboseEventExcessiveGCRaised.hpp"
51
#include "VerboseEventGCInitialized.hpp"
52
#include "VerboseEventGlobalGCEnd.hpp"
53
#include "VerboseEventGlobalGCStart.hpp"
54
#include "VerboseEventHeapResize.hpp"
55
#include "VerboseEventLocalGCEnd.hpp"
56
#include "VerboseEventLocalGCStart.hpp"
57
#include "VerboseEventMarkEnd.hpp"
58
#include "VerboseEventMarkStart.hpp"
59
#include "VerboseEventMetronomeCycleEnd.hpp"
60
#include "VerboseEventMetronomeCycleStart.hpp"
61
#include "VerboseEventMetronomeGCEnd.hpp"
62
#include "VerboseEventMetronomeGCStart.hpp"
63
#include "VerboseEventMetronomeNonMonotonicTime.hpp"
64
#include "VerboseEventMetronomeSynchronousGCEnd.hpp"
65
#include "VerboseEventMetronomeSynchronousGCStart.hpp"
66
#include "VerboseEventMetronomeTriggerEnd.hpp"
67
#include "VerboseEventMetronomeTriggerStart.hpp"
68
#include "VerboseEventMetronomeOutOfMemory.hpp"
69
#include "VerboseEventMetronomeUtilizationTrackerOverflow.hpp"
70
#include "VerboseEventPercolateCollect.hpp"
71
#include "VerboseEventSweepEnd.hpp"
72
#include "VerboseEventSweepStart.hpp"
73
#include "VerboseEventSystemGCEnd.hpp"
74
#include "VerboseEventSystemGCStart.hpp"
75
#include "VerboseEventTarokIncrementEnd.hpp"
76
#include "VerboseEventTarokIncrementStart.hpp"
77
#include "VerboseFileLoggingOutput.hpp"
78
#include "GCExtensions.hpp"
79
#include "VerboseOutputAgent.hpp"
80
#include "VerboseStandardStreamOutput.hpp"
81
#include "VerboseTraceOutput.hpp"
82
#include "VerboseManagerOld.hpp"
83
#include "VerboseEventStream.hpp"
84
85
86
extern "C" {
87
88
/**
89
* Generate a verbosegc event object
90
* This function is called whenever a hook is received (all hooked events point at this function). A
91
* different userData will be passed for each event type - this function pointer is then dereferenced
92
* to instantiate the correct type.
93
*
94
* @param eventData Pointer to the event-specific structure containing the data for this hook.
95
* @param userData void* function pointer to the newInstance() method of the event type for this hook.
96
*/
97
void
98
generateVerbosegcEvent(J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData)
99
{
100
MM_VerboseEventStream *eventStream;
101
102
/* call the function pointer - this will call the newInstance()
103
* method that corresponds to the event type we have received. */
104
MM_VerboseEvent *event = ((MM_VerboseEvent *(*)(void *, J9HookInterface**))userData)(eventData,hook);
105
MM_EnvironmentBase *env = MM_EnvironmentBase::getEnvironment(event->getThread());
106
107
if (NULL != event) {
108
MM_VerboseManagerOld *verboseManager = (MM_VerboseManagerOld*) MM_GCExtensions::getExtensions(event->getThread()->_vm)->verboseGCManager;
109
eventStream = verboseManager->getEventStreamForEvent(event);
110
111
eventStream->chainEvent(env, event);
112
if (event->endsEventChain()) {
113
eventStream->processStream(env);
114
}
115
}
116
}
117
118
}
119
120
/**
121
* Create a new MM_VerboseManagerOld instance.
122
* @return Pointer to the new MM_VerboseManagerOld.
123
*/
124
MM_VerboseManagerOld *
125
MM_VerboseManagerOld::newInstance(MM_EnvironmentBase *env, OMR_VM* vm)
126
{
127
MM_GCExtensions* extensions = MM_GCExtensions::getExtensions(vm);
128
129
MM_VerboseManagerOld *verboseManager = (MM_VerboseManagerOld *)extensions->getForge()->allocate(sizeof(MM_VerboseManagerOld), MM_AllocationCategory::FIXED, J9_GET_CALLSITE());
130
if (verboseManager) {
131
new(verboseManager) MM_VerboseManagerOld(vm);
132
if(!verboseManager->initialize(env)) {
133
verboseManager->kill(env);
134
verboseManager = NULL;
135
}
136
}
137
return verboseManager;
138
}
139
140
/**
141
* Kill the MM_VerboseManagerOld instance.
142
* Tears down the related structures and frees any storage.
143
*/
144
void
145
MM_VerboseManagerOld::kill(MM_EnvironmentBase *env)
146
{
147
tearDown(env);
148
149
MM_GCExtensions* extensions = MM_GCExtensions::getExtensions(env->getOmrVM());
150
extensions->getForge()->free(this);
151
}
152
153
/**
154
* Initializes the MM_VerboseManagerOld instance.
155
*/
156
bool
157
MM_VerboseManagerOld::initialize(MM_EnvironmentBase *env)
158
{
159
PORT_ACCESS_FROM_ENVIRONMENT(env);
160
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env->getOmrVM());
161
_mmHooks = J9_HOOK_INTERFACE(extensions->hookInterface);
162
_mmPrivateHooks = J9_HOOK_INTERFACE(extensions->privateHookInterface);
163
_omrHooks = J9_HOOK_INTERFACE(extensions->omrHookInterface);
164
165
/* Create the Event Stream */
166
if(NULL == (_eventStream = MM_VerboseEventStream::newInstance(env, this))) {
167
return false;
168
}
169
170
_lastOutputTime = j9time_hires_clock();
171
172
return true;
173
}
174
175
/**
176
* Tear down the structures managed by the MM_VerboseManagerOld.
177
* Tears down the event stream and output agents.
178
*/
179
void
180
MM_VerboseManagerOld::tearDown(MM_EnvironmentBase *env)
181
{
182
disableVerboseGC();
183
184
if(NULL != _eventStream) {
185
_eventStream->kill(env);
186
_eventStream = NULL;
187
}
188
189
MM_VerboseOutputAgent *agent = _agentChain;
190
_agentChain = NULL;
191
192
while(NULL != agent) {
193
MM_VerboseOutputAgent *nextAgent = agent->getNextAgent();
194
agent->kill(env);
195
agent = nextAgent;
196
}
197
}
198
199
/**
200
* Get the event stream which the given event should be added to.
201
*/
202
MM_VerboseEventStream *
203
MM_VerboseManagerOld::getEventStreamForEvent(MM_VerboseEvent *event)
204
{
205
MM_VerboseEventStream *eventStream;
206
207
if(event->isAtomic()) {
208
/* Use a thread-local event-stream */
209
eventStream = MM_VerboseEventStream::newInstance(MM_EnvironmentBase::getEnvironment(event->getThread()), this);
210
if(NULL == eventStream) {
211
/* Error - use the main event stream and hope for the best */
212
eventStream = _eventStream;
213
} else {
214
/* This is a one time event stream for an atomic event - when the event
215
* stream is done being processed, it should be disposed of immediately.
216
*/
217
eventStream->setDisposable(true);
218
}
219
} else {
220
/* Use the main event-stream */
221
eventStream = _eventStream;
222
}
223
224
return eventStream;
225
}
226
227
void
228
MM_VerboseManagerOld::closeStreams(MM_EnvironmentBase *env)
229
{
230
MM_VerboseOutputAgent *agent = _agentChain;
231
while(NULL != agent) {
232
agent->closeStream(env);
233
agent = agent->getNextAgent();
234
}
235
}
236
237
/**
238
* Adds an output agent to the output agent chain.
239
* @param agent Pointer to the agent to be added.
240
*/
241
void
242
MM_VerboseManagerOld::chainOutputAgent(MM_VerboseOutputAgent *agent)
243
{
244
agent->setNextAgent(_agentChain);
245
_agentChain = agent;
246
}
247
248
void
249
MM_VerboseManagerOld::enableVerboseGC()
250
{
251
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(_omrVM);
252
253
if (!_hooksAttached){
254
(*_omrHooks)->J9HookRegisterWithCallSite(_omrHooks, J9HOOK_MM_OMR_INITIALIZED, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventGCInitialized::newInstance);
255
256
if (extensions->isMetronomeGC()) {
257
enableVerboseGCRealtime();
258
} else {
259
enableVerboseGCNonRealtime();
260
}
261
262
if (extensions->isVLHGC()) {
263
enableVerboseGCVLHGC();
264
}
265
266
_hooksAttached = true;
267
}
268
}
269
270
271
void
272
MM_VerboseManagerOld::disableVerboseGC()
273
{
274
if (_hooksAttached){
275
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(_omrVM);
276
(*_omrHooks)->J9HookUnregister(_omrHooks, J9HOOK_MM_OMR_INITIALIZED, generateVerbosegcEvent, NULL);
277
278
if (extensions->isMetronomeGC()) {
279
disableVerboseGCRealtime();
280
} else {
281
disableVerboseGCNonRealtime();
282
}
283
284
if (extensions->isVLHGC()) {
285
disableVerboseGCVLHGC();
286
}
287
288
_hooksAttached = false;
289
_indentationLevel = 0;
290
}
291
}
292
293
void
294
MM_VerboseManagerOld::enableVerboseGCRealtime()
295
{
296
#if defined(J9VM_GC_REALTIME)
297
/* These are the hooks metronome is interested in
298
* TODO: this is a hack - we need a pluggable way to define different verbosegc systems (eg j2se, metronome, gclite)
299
*/
300
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_INCREMENT_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMetronomeGCStart::newInstance);
301
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_INCREMENT_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMetronomeGCEnd::newInstance);
302
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_SYNCHRONOUS_GC_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMetronomeSynchronousGCStart::newInstance);
303
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_SYNCHRONOUS_GC_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMetronomeSynchronousGCEnd::newInstance);
304
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_TRIGGER_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMetronomeTriggerStart::newInstance);
305
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_TRIGGER_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMetronomeTriggerEnd::newInstance);
306
(*_omrHooks)->J9HookRegisterWithCallSite(_omrHooks, J9HOOK_MM_OMR_GC_CYCLE_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMetronomeCycleStart::newInstance);
307
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_GC_POST_CYCLE_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMetronomeCycleEnd::newInstance);
308
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_OUT_OF_MEMORY, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMetronomeOutOfMemory::newInstance);
309
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_UTILIZATION_TRACKER_OVERFLOW, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMetronomeUtilizationTrackerOverflow::newInstance);
310
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_NON_MONOTONIC_TIME, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMetronomeNonMonotonicTime::newInstance);
311
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_TAROK_INCREMENT_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventTarokIncrementStart::newInstance);
312
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_TAROK_INCREMENT_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventTarokIncrementEnd::newInstance);
313
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_COPY_FORWARD_ABORT, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventCopyForwardAbortRaised::newInstance);
314
#endif /* J9VM_GC_REALTIME */
315
}
316
317
void
318
MM_VerboseManagerOld::disableVerboseGCRealtime()
319
{
320
#if defined(J9VM_GC_REALTIME)
321
/* Unregister metronome verbosegc hooks */
322
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_INCREMENT_START, generateVerbosegcEvent, NULL);
323
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_INCREMENT_END, generateVerbosegcEvent, NULL);
324
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_SYNCHRONOUS_GC_START, generateVerbosegcEvent, NULL);
325
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_SYNCHRONOUS_GC_END, generateVerbosegcEvent, NULL);
326
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_TRIGGER_START, generateVerbosegcEvent, NULL);
327
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_METRONOME_TRIGGER_END, generateVerbosegcEvent, NULL);
328
(*_omrHooks)->J9HookUnregister(_omrHooks, J9HOOK_MM_OMR_GC_CYCLE_START, generateVerbosegcEvent, NULL);
329
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_GC_POST_CYCLE_END, generateVerbosegcEvent, NULL);
330
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_OUT_OF_MEMORY, generateVerbosegcEvent, NULL);
331
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_UTILIZATION_TRACKER_OVERFLOW, generateVerbosegcEvent, NULL);
332
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_NON_MONOTONIC_TIME, generateVerbosegcEvent, NULL);
333
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_TAROK_INCREMENT_START, generateVerbosegcEvent, NULL);
334
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_TAROK_INCREMENT_END, generateVerbosegcEvent, NULL);
335
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_COPY_FORWARD_ABORT, generateVerbosegcEvent, NULL);
336
#endif /* J9VM_GC_REALTIME */
337
}
338
339
void
340
MM_VerboseManagerOld::enableVerboseGCNonRealtime()
341
{
342
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_GLOBAL_GC_INCREMENT_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventGlobalGCStart::newInstance);
343
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_GLOBAL_GC_INCREMENT_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventGlobalGCEnd::newInstance);
344
345
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_MARK_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMarkStart::newInstance);
346
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_MARK_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventMarkEnd::newInstance);
347
348
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_SWEEP_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventSweepStart::newInstance);
349
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_SWEEP_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventSweepEnd::newInstance);
350
#if defined(J9VM_GC_MODRON_COMPACTION)
351
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_COMPACT_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventCompactStart::newInstance);
352
(*_omrHooks)->J9HookRegisterWithCallSite(_omrHooks, J9HOOK_MM_OMR_COMPACT_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventCompactEnd::newInstance);
353
#endif /* defined(J9VM_GC_MODRON_COMPACTION) */
354
#if defined(J9VM_GC_MODRON_SCAVENGER)
355
(*_omrHooks)->J9HookRegisterWithCallSite(_omrHooks, J9HOOK_MM_OMR_LOCAL_GC_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventLocalGCStart::newInstance);
356
(*_omrHooks)->J9HookRegisterWithCallSite(_omrHooks, J9HOOK_MM_OMR_LOCAL_GC_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventLocalGCEnd::newInstance);
357
#endif /* defined(J9VM_GC_MODRON_SCAVENGER) */
358
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_SYSTEM_GC_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventSystemGCStart::newInstance);
359
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_SYSTEM_GC_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventSystemGCEnd::newInstance);
360
361
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_ALLOCATION_FAILURE_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventAFStart::newInstance);
362
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_ALLOCATION_FAILURE_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventAFEnd::newInstance);
363
364
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_HEAP_RESIZE, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventHeapResize::newInstance);
365
366
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_KICKOFF, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentKickOff::newInstance);
367
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_ABORTED, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentAborted::newInstance);
368
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_HALTED, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentHalted::newInstance);
369
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COLLECTION_CARD_CLEANING_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentFinalCardCleaningStart::newInstance);
370
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COLLECTION_CARD_CLEANING_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentFinalCardCleaningEnd::newInstance);
371
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COMPLETE_TRACING_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentCompleteTracingStart::newInstance);
372
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COMPLETE_TRACING_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentCompleteTracingEnd::newInstance);
373
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_REMEMBERED_SET_SCAN_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentRSScanStart::newInstance);
374
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_REMEMBERED_SET_SCAN_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentRSScanEnd::newInstance);
375
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COLLECTION_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentStart::newInstance);
376
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COLLECTION_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentEnd::newInstance);
377
378
#if defined(J9VM_GC_CONCURRENT_SWEEP)
379
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENTLY_COMPLETED_SWEEP_PHASE, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventConcurrentlyCompletedSweepPhase::newInstance);
380
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_COMPLETED_CONCURRENT_SWEEP, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventCompletedConcurrentSweep::newInstance);
381
#endif /* J9VM_GC_CONCURRENT_SWEEP */
382
383
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CLASS_UNLOADING_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventClassUnloadingStart::newInstance);
384
(*_mmHooks)->J9HookRegisterWithCallSite(_mmHooks, J9HOOK_MM_CLASS_UNLOADING_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventClassUnloadingEnd::newInstance);
385
386
#if defined(J9VM_GC_MODRON_SCAVENGER)
387
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_PERCOLATE_COLLECT, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventPercolateCollect::newInstance);
388
#endif /* J9VM_GC_MODRON_SCAVENGER */
389
390
(*_omrHooks)->J9HookRegisterWithCallSite(_omrHooks, J9HOOK_MM_OMR_EXCESSIVEGC_RAISED, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventExcessiveGCRaised::newInstance);
391
}
392
393
void
394
MM_VerboseManagerOld::disableVerboseGCNonRealtime()
395
{
396
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_GLOBAL_GC_INCREMENT_START, generateVerbosegcEvent, NULL);
397
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_GLOBAL_GC_INCREMENT_END, generateVerbosegcEvent, NULL);
398
399
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_MARK_START, generateVerbosegcEvent, NULL);
400
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_MARK_END, generateVerbosegcEvent, NULL);
401
402
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_SWEEP_START, generateVerbosegcEvent, NULL);
403
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_SWEEP_END, generateVerbosegcEvent, NULL);
404
#if defined(J9VM_GC_MODRON_COMPACTION)
405
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_COMPACT_START, generateVerbosegcEvent, NULL);
406
(*_omrHooks)->J9HookUnregister(_omrHooks, J9HOOK_MM_OMR_COMPACT_END, generateVerbosegcEvent, NULL);
407
#endif /* defined(J9VM_GC_MODRON_COMPACTION) */
408
#if defined(J9VM_GC_MODRON_SCAVENGER)
409
(*_omrHooks)->J9HookUnregister(_omrHooks, J9HOOK_MM_OMR_LOCAL_GC_START, generateVerbosegcEvent, NULL);
410
(*_omrHooks)->J9HookUnregister(_omrHooks, J9HOOK_MM_OMR_LOCAL_GC_END, generateVerbosegcEvent, NULL);
411
#endif /* defined(J9VM_GC_MODRON_SCAVENGER) */
412
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_SYSTEM_GC_START, generateVerbosegcEvent, NULL);
413
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_SYSTEM_GC_END, generateVerbosegcEvent, NULL);
414
415
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_ALLOCATION_FAILURE_START, generateVerbosegcEvent, NULL);
416
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_ALLOCATION_FAILURE_END, generateVerbosegcEvent, NULL);
417
418
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_HEAP_RESIZE, generateVerbosegcEvent, NULL);
419
420
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_KICKOFF, generateVerbosegcEvent, NULL);
421
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_ABORTED, generateVerbosegcEvent, NULL);
422
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_HALTED, generateVerbosegcEvent, NULL);
423
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COLLECTION_CARD_CLEANING_START, generateVerbosegcEvent, NULL);
424
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COLLECTION_CARD_CLEANING_END, generateVerbosegcEvent, NULL);
425
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COMPLETE_TRACING_START, generateVerbosegcEvent, NULL);
426
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COMPLETE_TRACING_END, generateVerbosegcEvent, NULL);
427
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_REMEMBERED_SET_SCAN_START, generateVerbosegcEvent, NULL);
428
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_REMEMBERED_SET_SCAN_END, generateVerbosegcEvent, NULL);
429
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COLLECTION_START, generateVerbosegcEvent, NULL);
430
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COLLECTION_END, generateVerbosegcEvent, NULL);
431
432
#if defined(J9VM_GC_CONCURRENT_SWEEP)
433
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CONCURRENTLY_COMPLETED_SWEEP_PHASE, generateVerbosegcEvent, NULL);
434
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_COMPLETED_CONCURRENT_SWEEP, generateVerbosegcEvent, NULL);
435
#endif /* J9VM_GC_CONCURRENT_SWEEP */
436
437
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_CLASS_UNLOADING_START, generateVerbosegcEvent, NULL);
438
(*_mmHooks)->J9HookUnregister(_mmHooks, J9HOOK_MM_CLASS_UNLOADING_END, generateVerbosegcEvent, NULL);
439
440
#if defined(J9VM_GC_MODRON_SCAVENGER)
441
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_PERCOLATE_COLLECT, generateVerbosegcEvent, NULL);
442
#endif /* J9VM_GC_MODRON_SCAVENGER */
443
444
(*_omrHooks)->J9HookUnregister(_omrHooks, J9HOOK_MM_OMR_EXCESSIVEGC_RAISED, generateVerbosegcEvent, NULL);
445
}
446
447
void
448
MM_VerboseManagerOld::enableVerboseGCVLHGC()
449
{
450
#if defined(J9VM_GC_VLHGC)
451
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_TAROK_INCREMENT_START, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventTarokIncrementStart::newInstance);
452
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_TAROK_INCREMENT_END, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventTarokIncrementEnd::newInstance);
453
(*_mmPrivateHooks)->J9HookRegisterWithCallSite(_mmPrivateHooks, J9HOOK_MM_PRIVATE_COPY_FORWARD_ABORT, generateVerbosegcEvent, OMR_GET_CALLSITE(), (void *)MM_VerboseEventCopyForwardAbortRaised::newInstance);
454
#endif /* defined(J9VM_GC_VLHGC) */
455
456
}
457
458
void
459
MM_VerboseManagerOld::disableVerboseGCVLHGC()
460
{
461
#if defined(J9VM_GC_VLHGC)
462
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_TAROK_INCREMENT_START, generateVerbosegcEvent, NULL);
463
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_TAROK_INCREMENT_END, generateVerbosegcEvent, NULL);
464
(*_mmPrivateHooks)->J9HookUnregister(_mmPrivateHooks, J9HOOK_MM_PRIVATE_COPY_FORWARD_ABORT, generateVerbosegcEvent, NULL);
465
#endif /* defined(J9VM_GC_VLHGC) */
466
}
467
468
/**
469
* Finds an agent of a given type in the event chain.
470
* @param type Indicates the type of agent to return.
471
* @return Pointer to an agent of the specified type.
472
*/
473
MM_VerboseOutputAgent *
474
MM_VerboseManagerOld::findAgentInChain(AgentType type)
475
{
476
MM_VerboseOutputAgent *agent = _agentChain;
477
478
while (agent){
479
if (type == agent->getType()){
480
return agent;
481
}
482
agent = agent->getNextAgent();
483
}
484
485
return NULL;
486
}
487
488
AgentType
489
MM_VerboseManagerOld::parseAgentType(MM_EnvironmentBase *env, char *filename, UDATA fileCount, UDATA iterations)
490
{
491
if(NULL == filename) {
492
return STANDARD_STREAM;
493
}
494
495
if(!strcmp(filename, "stderr") || !strcmp(filename, "stdout")) {
496
return STANDARD_STREAM;
497
}
498
499
if(!strcmp(filename, "trace")) {
500
return TRACE;
501
}
502
503
if(!strcmp(filename, "hook")) {
504
return HOOK;
505
}
506
507
return FILE_LOGGING;
508
}
509
510
/**
511
* Counts the number of output agents currently enabled.
512
* @return the number of current output agents.
513
*/
514
UDATA
515
MM_VerboseManagerOld::countActiveOutputHandlers()
516
{
517
MM_VerboseOutputAgent *agent = _agentChain;
518
UDATA count = 0;
519
520
while(agent) {
521
if(agent->isActive()) {
522
count += 1;
523
}
524
agent = agent->getNextAgent();
525
}
526
527
return count;
528
}
529
530
/**
531
* Walks the output agent chain disabling the agents.
532
*/
533
void
534
MM_VerboseManagerOld::disableAgents()
535
{
536
MM_VerboseOutputAgent *agent = _agentChain;
537
538
while(agent) {
539
agent->isActive(false);
540
agent = agent->getNextAgent();
541
}
542
}
543
544
/**
545
* Configures verbosegc according to the parameters passed.
546
* @param filename The name of the file or output stream to log to.
547
* @param fileCount The number of files to log to.
548
* @param iterations The number of gc cycles to log to each file.
549
* @return true on success, false on failure
550
*/
551
bool
552
MM_VerboseManagerOld::configureVerboseGC(OMR_VM *omrVM, char *filename, UDATA fileCount, UDATA iterations)
553
{
554
MM_EnvironmentBase env(omrVM);
555
556
MM_VerboseOutputAgent *agent;
557
558
disableAgents();
559
560
AgentType type = parseAgentType(&env, filename, fileCount, iterations);
561
562
agent = findAgentInChain(type);
563
if(NULL != agent) {
564
agent->reconfigure(&env, filename, fileCount, iterations);
565
} else {
566
switch(type) {
567
case STANDARD_STREAM:
568
agent = MM_VerboseStandardStreamOutput::newInstance(&env, filename);
569
break;
570
571
case TRACE:
572
agent = MM_VerboseTraceOutput::newInstance(&env);
573
break;
574
575
case FILE_LOGGING:
576
agent = MM_VerboseFileLoggingOutput::newInstance(&env, filename, fileCount, iterations);
577
if (NULL == agent) {
578
agent = findAgentInChain(STANDARD_STREAM);
579
if (NULL != agent) {
580
agent->isActive(true);
581
return true;
582
}
583
/* if we failed to create a file stream and there is no stderr agenttry to create a stderr agent */
584
agent = MM_VerboseStandardStreamOutput::newInstance(&env, NULL);
585
}
586
break;
587
588
case HOOK:
589
/* The hook method is only available to new verbose */
590
return false;
591
592
default:
593
return false;
594
}
595
596
if(NULL == agent) {
597
return false;
598
}
599
600
chainOutputAgent(agent);
601
}
602
603
agent->isActive(true);
604
605
return true;
606
}
607
608
/**
609
* Passes the event stream to each output agent in the output agent chain.
610
*/
611
void
612
MM_VerboseManagerOld::passStreamToOutputAgents(MM_EnvironmentBase *env, MM_VerboseEventStream *stream)
613
{
614
MM_VerboseOutputAgent *agent = _agentChain;
615
616
while(NULL != agent) {
617
if(agent->isActive()) {
618
agent->processEventStream(env, stream);
619
}
620
agent = agent->getNextAgent();
621
}
622
}
623
624