Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_verbose_old_events/VerboseEventConcurrentKickOff.cpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2014 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 "j9modron.h"
25
26
#include "Debug.hpp"
27
#include "GCExtensions.hpp"
28
#include "ScanClassesMode.hpp"
29
#include "VerboseEventConcurrentKickOff.hpp"
30
#include "VerboseEventStream.hpp"
31
#include "VerboseManagerOld.hpp"
32
33
/**
34
* Create an new instance of a MM_VerboseEventConcurrentKickOff event.
35
* @param event Pointer to a structure containing the data passed over the hookInterface
36
*/
37
MM_VerboseEvent *
38
MM_VerboseEventConcurrentKickOff::newInstance(MM_ConcurrentKickoffEvent *event, J9HookInterface** hookInterface)
39
{
40
MM_VerboseEventConcurrentKickOff *eventObject;
41
42
eventObject = (MM_VerboseEventConcurrentKickOff *)MM_VerboseEvent::create(event->currentThread, sizeof(MM_VerboseEventConcurrentKickOff));
43
if(NULL != eventObject) {
44
new(eventObject) MM_VerboseEventConcurrentKickOff(event, hookInterface);
45
eventObject->initialize();
46
}
47
return eventObject;
48
}
49
50
void
51
MM_VerboseEventConcurrentKickOff::initialize(void)
52
{
53
OMRPORT_ACCESS_FROM_OMRVMTHREAD(_omrThread);
54
_timeInMilliSeconds = omrtime_current_time_millis();
55
}
56
57
/**
58
* Populate events data fields.
59
* The event calls the event stream requesting the address of events it is interested in.
60
* When an address is returned it populates itself with the data.
61
*/
62
void
63
MM_VerboseEventConcurrentKickOff::consumeEvents(void)
64
{
65
}
66
67
/**
68
* Passes a format string and data to the output routine defined in the passed output agent.
69
* @param agent Pointer to an output agent.
70
*/
71
void
72
MM_VerboseEventConcurrentKickOff::formattedOutput(MM_VerboseOutputAgent *agent)
73
{
74
OMRPORT_ACCESS_FROM_OMRVMTHREAD(_omrThread);
75
char timestamp[32];
76
UDATA indentLevel = _manager->getIndentLevel();
77
78
omrstr_ftime(timestamp, sizeof(timestamp), VERBOSEGC_DATE_FORMAT, _timeInMilliSeconds);
79
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<con event=\"kickoff\" timestamp=\"%s\">", timestamp);
80
81
_manager->incrementIndent();
82
indentLevel = _manager->getIndentLevel();
83
84
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<kickoff reason=\"%s\" />", getKickoffReasonAsString(_kickOffReason, _languageKickOffReason));
85
86
if(static_cast<J9JavaVM*>(_omrThread->_vm->_language_vm)->memoryManagerFunctions->j9gc_scavenger_enabled(static_cast<J9JavaVM*>(_omrThread->_vm->_language_vm))) {
87
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<stats tenurefreebytes=\"%zu\" nurseryfreebytes=\"%zu\" tracetarget=\"%zu\" kickoff=\"%zu\" />",
88
_tenureFreeBytes,
89
_nurseryFreeBytes,
90
_traceTarget,
91
_kickOffThreshold);
92
} else {
93
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<stats tenurefreebytes=\"%zu\" tracetarget=\"%zu\" kickoff=\"%zu\" />",
94
_tenureFreeBytes,
95
_traceTarget,
96
_kickOffThreshold);
97
}
98
99
_manager->decrementIndent();
100
indentLevel = _manager->getIndentLevel();
101
102
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "</con>");
103
agent->endOfCycle(static_cast<J9VMThread*>(_omrThread->_language_vmthread));
104
}
105
106
/**
107
* Return the reason for kickoff as a string
108
* @param mode reason code
109
*/
110
const char *
111
MM_VerboseEventConcurrentKickOff::getKickoffReasonAsString(UDATA reason, UDATA languageReason)
112
{
113
if ((ConcurrentKickoffReason) reason == LANGUAGE_DEFINED_REASON) {
114
115
switch (languageReason) {
116
case FORCED_UNLOADING_CLASSES:
117
return "Unloading of classes requested";
118
case NO_LANGUAGE_KICKOFF_REASON:
119
/* Should never be the case */
120
assume(0,"No reason set for kickoff");
121
default:
122
return "unknown";
123
}
124
125
} else {
126
127
switch((ConcurrentKickoffReason)reason) {
128
case KICKOFF_THRESHOLD_REACHED:
129
return "Kickoff threshold reached";
130
case NEXT_SCAVENGE_WILL_PERCOLATE:
131
return "Next scavenge will percolate";
132
case NO_KICKOFF_REASON:
133
/* Should never be the case */
134
assume(0,"No reason set for kickoff");
135
default:
136
return "unknown";
137
}
138
139
}
140
}
141
142
143