Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_verbose_old_events/VerboseEventAFStart.cpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2021 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* 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
21
*******************************************************************************/
22
23
#include "VerboseEventAFStart.hpp"
24
#include "GCExtensions.hpp"
25
#include "VerboseEventStream.hpp"
26
#include "VerboseManagerOld.hpp"
27
28
/**
29
* Create an new instance of a MM_VerboseEventAFStart event.
30
* @param event Pointer to a structure containing the data passed over the hookInterface
31
*/
32
MM_VerboseEvent *
33
MM_VerboseEventAFStart::newInstance(MM_AllocationFailureStartEvent *event, J9HookInterface** hookInterface)
34
{
35
MM_VerboseEventAFStart *eventObject;
36
37
eventObject = (MM_VerboseEventAFStart *)MM_VerboseEvent::create(event->currentThread, sizeof(MM_VerboseEventAFStart));
38
if(NULL != eventObject) {
39
new(eventObject) MM_VerboseEventAFStart(event, hookInterface);
40
eventObject->initialize();
41
}
42
return eventObject;
43
}
44
45
/**
46
* Populate events data fields.
47
* The event calls the event stream requesting the address of events it is interested in.
48
* When an address is returned it populates itself with the data.
49
*/
50
void
51
MM_VerboseEventAFStart::consumeEvents(void)
52
{
53
/* Increment collection count */
54
(MEMORY_TYPE_NEW == _subSpaceType) ? (_manager->incrementNurseryAFCount()) : (_manager->incrementTenureAFCount());
55
56
/* Consume global data */
57
_lastAFTime = (MEMORY_TYPE_NEW == _subSpaceType) ? (_manager->getLastNurseryAFTime()) : (_manager->getLastTenureAFTime());
58
_AFCount = (MEMORY_TYPE_NEW == _subSpaceType) ? (_manager->getNurseryAFCount()) : (_manager->getTenureAFCount());
59
}
60
61
/**
62
* Passes a format string and data to the output routine defined in the passed output agent.
63
* @param agent Pointer to an output agent.
64
*/
65
void
66
MM_VerboseEventAFStart::formattedOutput(MM_VerboseOutputAgent *agent)
67
{
68
PORT_ACCESS_FROM_JAVAVM(((J9VMThread*)_omrThread->_language_vmthread)->javaVM);
69
OMRPORT_ACCESS_FROM_J9PORT(PORTLIB);
70
char timestamp[32];
71
UDATA indentLevel = _manager->getIndentLevel();
72
U_64 timeInMicroSeconds = 0;
73
U_64 prevTime = 0;
74
75
omrstr_ftime_ex(timestamp, sizeof(timestamp), VERBOSEGC_DATE_FORMAT, _timeInMilliSeconds, OMRSTR_FTIME_FLAG_LOCAL);
76
switch(_subSpaceType) {
77
case 0:
78
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<af type=\"UNKNOWN!!\" />");
79
return;
80
break;
81
82
case MEMORY_TYPE_NEW:
83
84
if (1 == _manager->getNurseryAFCount()) {
85
prevTime = _manager->getInitializedTime();
86
} else {
87
prevTime = _lastAFTime;
88
}
89
timeInMicroSeconds = j9time_hires_delta(prevTime, _time, J9PORT_TIME_DELTA_IN_MICROSECONDS);
90
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<af type=\"nursery\" id=\"%zu\" timestamp=\"%s\" intervalms=\"%llu.%03.3llu\">",
91
_manager->getNurseryAFCount(),
92
timestamp,
93
timeInMicroSeconds / 1000,
94
timeInMicroSeconds % 1000
95
);
96
break;
97
98
case MEMORY_TYPE_OLD:
99
100
if (1 == _manager->getTenureAFCount()) {
101
prevTime = _manager->getInitializedTime();
102
} else {
103
prevTime = _lastAFTime;
104
}
105
timeInMicroSeconds = j9time_hires_delta(prevTime, _time, J9PORT_TIME_DELTA_IN_MICROSECONDS);
106
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<af type=\"tenured\" id=\"%zu\" timestamp=\"%s\" intervalms=\"%llu.%03.3llu\">",
107
_manager->getTenureAFCount(),
108
timestamp,
109
timeInMicroSeconds / 1000,
110
timeInMicroSeconds % 1000
111
);
112
break;
113
default:
114
break;
115
}
116
117
_manager->incrementIndent();
118
indentLevel = _manager->getIndentLevel();
119
120
agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<minimum requested_bytes=\"%zu\" />", _requestedBytes);
121
122
/* output the common GC start info */
123
gcStartFormattedOutput(agent);
124
125
}
126
127