Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_trace/TgcAllocation.cpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2017 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 "j9.h"
24
#include "j9cfg.h"
25
#include "j9port.h"
26
#include "modronopt.h"
27
#include "mmhook.h"
28
29
#include "EnvironmentBase.hpp"
30
#include "GCExtensions.hpp"
31
#include "VMThreadListIterator.hpp"
32
#include "TLHAllocationInterface.hpp"
33
#include "TgcExtensions.hpp"
34
#include "TgcAllocation.hpp"
35
#include "HeapStats.hpp"
36
37
static void
38
tgcAllocationPrintStats(OMR_VMThread* omrVMThread)
39
{
40
MM_GCExtensions *ext = MM_GCExtensions::getExtensions(omrVMThread);
41
MM_TgcExtensions *tgcExtensions = MM_TgcExtensions::getExtensions(ext);
42
43
MM_AllocationStats *allocStats = &ext->allocationStats;
44
45
tgcExtensions->printf("---------- Allocation Statistics ----------\n");
46
#if defined(J9VM_GC_THREAD_LOCAL_HEAP)
47
UDATA tlhRefreshCountTotal = allocStats->_tlhRefreshCountFresh + allocStats->_tlhRefreshCountReused;
48
UDATA tlhAllocatedTotal = allocStats->tlhBytesAllocated();
49
tgcExtensions->printf("TLH Refresh Count Total: %12zu\n", tlhRefreshCountTotal);
50
tgcExtensions->printf("TLH Refresh Count Fresh: %12zu\n", allocStats->_tlhRefreshCountFresh);
51
tgcExtensions->printf("TLH Refresh Count Reused: %12zu\n", allocStats->_tlhRefreshCountReused);
52
tgcExtensions->printf("TLH Refresh Bytes Total: %12zu\n", tlhAllocatedTotal);
53
tgcExtensions->printf("TLH Refresh Bytes Fresh: %12zu\n", allocStats->_tlhAllocatedFresh);
54
tgcExtensions->printf("TLH Discarded Bytes: %12zu\n", allocStats->_tlhDiscardedBytes);
55
tgcExtensions->printf("TLH Refresh Bytes Reused: %12zu\n", allocStats->_tlhAllocatedReused);
56
tgcExtensions->printf("TLH Requested Bytes: %12zu\n", allocStats->_tlhRequestedBytes);
57
tgcExtensions->printf("TLH Max Abandoned List Length: %12zu\n", allocStats->_tlhMaxAbandonedListSize);
58
#endif /* defined (J9VM_GC_THREAD_LOCAL_HEAP) */
59
tgcExtensions->printf("Normal Allocated Count: %12zu\n", allocStats->_allocationCount);
60
tgcExtensions->printf("Normal Allocated Bytes: %12zu\n", allocStats->_allocationBytes);
61
}
62
63
static void
64
tgcHookAllocationGlobalPrintStats(J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData)
65
{
66
MM_GlobalGCStartEvent* event = (MM_GlobalGCStartEvent*)eventData;
67
tgcAllocationPrintStats(event->currentThread);
68
}
69
70
static void
71
tgcHookAllocationLocalPrintStats(J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData)
72
{
73
MM_LocalGCStartEvent* event = (MM_LocalGCStartEvent*)eventData;
74
tgcAllocationPrintStats(event->currentThread);
75
}
76
77
bool
78
tgcAllocationInitialize(J9JavaVM *javaVM)
79
{
80
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(javaVM);
81
bool result = true;
82
83
J9HookInterface** omrHooks = J9_HOOK_INTERFACE(extensions->omrHookInterface);
84
(*omrHooks)->J9HookRegisterWithCallSite(omrHooks, J9HOOK_MM_OMR_GLOBAL_GC_START, tgcHookAllocationGlobalPrintStats, OMR_GET_CALLSITE(), NULL);
85
(*omrHooks)->J9HookRegisterWithCallSite(omrHooks, J9HOOK_MM_OMR_LOCAL_GC_START, tgcHookAllocationLocalPrintStats, OMR_GET_CALLSITE(), NULL);
86
87
return result;
88
}
89
90