Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_verbose_java/VerboseHandlerJava.cpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2020 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
/* Temporary file to make compilers happy */
24
25
#include "j9.h"
26
#include "j9cfg.h"
27
#include "mmhook.h"
28
29
#include "VerboseHandlerJava.hpp"
30
#include "EnvironmentBase.hpp"
31
#include "VerboseManager.hpp"
32
#include "VerboseHandlerOutput.hpp"
33
#include "VerboseWriterChain.hpp"
34
#include "GCExtensions.hpp"
35
#include "FinalizeListManager.hpp"
36
#include "VerboseBuffer.hpp"
37
38
void
39
MM_VerboseHandlerJava::outputFinalizableInfo(MM_VerboseManager *manager, MM_EnvironmentBase *env, UDATA indent)
40
{
41
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env);
42
GC_FinalizeListManager *finalizeListManager = extensions->finalizeListManager;
43
44
UDATA systemCount = finalizeListManager->getSystemCount();
45
UDATA defaultCount = finalizeListManager->getDefaultCount();
46
UDATA referenceCount = finalizeListManager->getReferenceCount();
47
UDATA classloaderCount = finalizeListManager->getClassloaderCount();
48
49
if((0 != systemCount) || (0 != defaultCount) || (0 != referenceCount) || (0 != classloaderCount)) {
50
manager->getWriterChain()->formatAndOutput(env, indent, "<pending-finalizers system=\"%zu\" default=\"%zu\" reference=\"%zu\" classloader=\"%zu\" />", systemCount, defaultCount, referenceCount, classloaderCount);
51
}
52
}
53
54
bool
55
MM_VerboseHandlerJava::getThreadName(char *buf, UDATA bufLen, OMR_VMThread *omrThread)
56
{
57
PORT_ACCESS_FROM_JAVAVM(((J9VMThread*)omrThread->_language_vmthread)->javaVM);
58
char* threadName = getOMRVMThreadName(omrThread);
59
UDATA threadNameLength = strlen(threadName);
60
UDATA escapeConsumed = escapeXMLString(OMRPORT_FROM_J9PORT(PORTLIB), buf, bufLen, threadName, strlen(threadName));
61
bool consumedEntireString = (escapeConsumed >= threadNameLength);
62
releaseOMRVMThreadName(omrThread);
63
return consumedEntireString;
64
}
65
66
void
67
MM_VerboseHandlerJava::writeVmArgs(MM_EnvironmentBase* env, MM_VerboseBuffer* buffer, J9JavaVM *vm)
68
{
69
PORT_ACCESS_FROM_JAVAVM(vm);
70
JavaVMInitArgs* vmArgs = vm->vmArgsArray->actualVMArgs;
71
buffer->formatAndOutput(env, 1, "<vmargs>");
72
for (jint i = 0; i < vmArgs->nOptions; ++i) {
73
char escapedXMLString[128];
74
UDATA optLen = strlen(vmArgs->options[i].optionString);
75
UDATA escapeConsumed = escapeXMLString(OMRPORT_FROM_J9PORT(PORTLIB), escapedXMLString, sizeof(escapedXMLString), vmArgs->options[i].optionString, optLen);
76
const char* dots = (escapeConsumed < optLen) ? "..." : "";
77
if (NULL == vmArgs->options[i].extraInfo) {
78
buffer->formatAndOutput(env, 2, "<vmarg name=\"%s%s\" />", escapedXMLString, dots);
79
} else {
80
buffer->formatAndOutput(env, 2, "<vmarg name=\"%s%s\" value=\"%p\" />", escapedXMLString, dots, vmArgs->options[i].extraInfo);
81
}
82
}
83
buffer->formatAndOutput(env, 1, "</vmargs>");
84
}
85
86