Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_trace/TgcConcurrentcardcleaning.cpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2018 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
/**
24
* @file
25
* @ingroup GC_Trace
26
*/
27
28
29
#include "j9.h"
30
#include "j9cfg.h"
31
#include "mmhook.h"
32
#include "j9port.h"
33
#include "modronopt.h"
34
35
#if defined(OMR_GC_MODRON_CONCURRENT_MARK)
36
#include "ConcurrentCardTableStats.hpp"
37
#include "ConcurrentGCStats.hpp"
38
#include "GCExtensions.hpp"
39
#include "EnvironmentBase.hpp"
40
#include "TgcExtensions.hpp"
41
42
/**
43
* Final card cleaning has finished.
44
* Function called by a hook when the final card cleaning has completed.
45
*
46
* @param concurrentGCStats The address of the concurrent statistics structure
47
* @param cardTableStats The address of the card table statistics structure
48
*/
49
static void
50
tgcHookCardCleaningComplete(J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData)
51
{
52
MM_ConcurrentCollectionCardCleaningEndEvent* event = (MM_ConcurrentCollectionCardCleaningEndEvent*)eventData;
53
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(event->currentThread);
54
MM_TgcExtensions *tgcExtensions = MM_TgcExtensions::getExtensions(extensions);
55
56
tgcExtensions->printf("Card cleaning for GC(%zu)\n",
57
#if defined(J9VM_GC_MODRON_SCAVENGER)
58
extensions->scavengerStats._gcCount +
59
#endif /* J9VM_GC_MODRON_SCAVENGER */
60
extensions->globalGCStats.gcCount +
61
1
62
);
63
64
/* All card clean thresholds initialized to HIGH_VALUES so cast to IDATA so they are printed as -1
65
* if we never got as far asKO of a particular phase of card cleaning
66
*/
67
tgcExtensions->printf(" concurrent card cleaning KO: Threshold=\"%zu\" Phase1= \"%zi\" Phase2= \"%zi\" Phase3= \"%zi\" \n",
68
event->cardCleaningThreshold,
69
(IDATA)event->cardCleaningPhase1KickOff,
70
(IDATA)event->cardCleaningPhase2KickOff,
71
(IDATA)event->cardCleaningPhase3KickOff
72
);
73
74
tgcExtensions->printf(" concurrent cards cleaned: Phase1= \"%zu\" Phase2= \"%zu\" Phase3= \"%zu\" Total= \"%zu\" \n",
75
event->concleanedCardsPhase1,
76
event->concleanedCardsPhase2,
77
event->concleanedCardsPhase3,
78
event->concleanedCards
79
);
80
81
tgcExtensions->printf(" final cards cleaned: Phase1= \"%zu\" Phase2= \"%zu\" Total= \"%zu\" \n",
82
event->finalcleanedCardsPhase1,
83
event->finalcleanedCardsPhase2,
84
event->finalcleanedCards
85
);
86
}
87
88
/**
89
* Initialize cardcleaning tgc tracing.
90
* Initializes the TgcConcurrentExtensions object associated with concurrent tgc tracing.
91
* Attaches hooks to the appropriate functions handling events used by card cleaning tgc tracing.
92
*/
93
bool
94
tgcConcurrentCardCleaningInitialize(J9JavaVM *javaVM)
95
{
96
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(javaVM);
97
bool result = true;
98
99
J9HookInterface** privateHooks = J9_HOOK_INTERFACE(extensions->privateHookInterface);
100
(*privateHooks)->J9HookRegisterWithCallSite(privateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COLLECTION_CARD_CLEANING_END, tgcHookCardCleaningComplete, OMR_GET_CALLSITE(), NULL);
101
102
return result;
103
}
104
105
#endif /* OMR_GC_MODRON_CONCURRENT_MARK */
106
107