Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_trace/TgcConcurrent.cpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2018 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 "j9.h"
25
#include "j9cfg.h"
26
#include "mmhook.h"
27
#include "j9port.h"
28
#include "modronopt.h"
29
30
#if defined(OMR_GC_MODRON_CONCURRENT_MARK)
31
#include "GCExtensions.hpp"
32
#include "EnvironmentBase.hpp"
33
#include "TgcExtensions.hpp"
34
35
/**
36
* Concurrent background thread activated.
37
* Function called by a hook when the concurrent background thread is started.
38
*
39
* @param env The environment of the background thread
40
*/
41
static void
42
tgcHookConcurrentBackgroundThreadActivated(J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData)
43
{
44
MM_ConcurrentBackgroundThreadActivatedEvent* event = (MM_ConcurrentBackgroundThreadActivatedEvent*)eventData;
45
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(event->currentThread);
46
MM_TgcExtensions *tgcExtensions = MM_TgcExtensions::getExtensions(extensions);
47
TgcConcurrentExtensions *concurrentExtensions = &tgcExtensions->_concurrent;
48
49
concurrentExtensions->gcCountAtBackgroundThreadActivation =
50
#if defined(J9VM_GC_MODRON_SCAVENGER)
51
extensions->scavengerStats._gcCount +
52
#endif /* J9VM_GC_MODRON_SCAVENGER */
53
extensions->globalGCStats.gcCount;
54
55
tgcExtensions->printf("<CONCURRENT GC BK thread 0x%08.8zx activated after GC(%zu)>\n",
56
event->currentThread->_language_vmthread,
57
concurrentExtensions->gcCountAtBackgroundThreadActivation
58
);
59
}
60
61
/**
62
* Concurrent background thread finished.
63
* Function called by a hook when the concurrent background thread is finished.
64
*
65
* @param env The environment of the background thread
66
* @param traceTotal The number of bytes traced by the background thread during concurrent mark
67
*/
68
static void
69
tgcHookConcurrentBackgroundThreadFinished(J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData)
70
{
71
MM_ConcurrentBackgroundThreadFinishedEvent* event = (MM_ConcurrentBackgroundThreadFinishedEvent*)eventData;
72
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(event->currentThread);
73
MM_TgcExtensions *tgcExtensions = MM_TgcExtensions::getExtensions(extensions);
74
TgcConcurrentExtensions *concurrentExtensions = &tgcExtensions->_concurrent;
75
76
tgcExtensions->printf("<CONCURRENT GC BK thread 0x%08.8zx (started after GC(%zu)) traced %zu>\n",
77
event->currentThread->_language_vmthread,
78
concurrentExtensions->gcCountAtBackgroundThreadActivation,
79
event->traceTotal
80
);
81
}
82
83
/**
84
* Initialize concurrent tgc tracing.
85
* Initializes the TgcConcurrentExtensions object associated with concurrent tgc tracing. Attaches hooks
86
* to the appropriate functions handling events used by concurrent tgc tracing.
87
*/
88
bool
89
tgcConcurrentInitialize(J9JavaVM *javaVM)
90
{
91
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(javaVM);
92
bool result = true;
93
94
J9HookInterface** privateHooks = J9_HOOK_INTERFACE(extensions->privateHookInterface);
95
(*privateHooks)->J9HookRegisterWithCallSite(privateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_BACKGROUND_THREAD_ACTIVATED, tgcHookConcurrentBackgroundThreadActivated, OMR_GET_CALLSITE(), NULL);
96
(*privateHooks)->J9HookRegisterWithCallSite(privateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_BACKGROUND_THREAD_FINISHED, tgcHookConcurrentBackgroundThreadFinished, OMR_GET_CALLSITE(), NULL);
97
98
return result;
99
}
100
101
#endif /* OMR_GC_MODRON_CONCURRENT_MARK */
102
103