Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/codert_vm/runtimeInstrumentation.c
5986 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2014 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 "runtimeInstrumentation.h"
24
25
/**
26
* Handler for the async message to update the RI fields in a thread.
27
*
28
* @param[in] currentThread The current J9VMThread
29
* @param[in] handlerKey Handler key of the current async event
30
* @param[in] userData The J9JavaVM pointer
31
*/
32
static void
33
riAsyncHandler(J9VMThread *currentThread, IDATA handlerKey, void *userData)
34
{
35
/**
36
* Update the current flag values. There is no need to take action based on the new flags.
37
* The RI state will be updated on the next transition back to compiled code.
38
*/
39
currentThread->jitCurrentRIFlags = currentThread->jitPendingRIFlags;
40
}
41
42
UDATA
43
initializeJITRuntimeInstrumentation(J9JavaVM *vm)
44
{
45
J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions;
46
IDATA handlerKey = vmFuncs->J9RegisterAsyncEvent(vm, riAsyncHandler, vm);
47
UDATA rc = 1;
48
49
if (handlerKey >= 0) {
50
vm->jitRIHandlerKey = handlerKey;
51
rc = 0;
52
}
53
54
return rc;
55
}
56
57
void
58
shutdownJITRuntimeInstrumentation(J9JavaVM *vm)
59
{
60
J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions;
61
62
vmFuncs->J9UnregisterAsyncEvent(vm, vm->jitRIHandlerKey);
63
vm->jitRIHandlerKey = -1;
64
}
65
66
UDATA
67
updateJITRuntimeInstrumentationFlags(J9VMThread *targetThread, UDATA newFlags)
68
{
69
J9JavaVM *vm = targetThread->javaVM;
70
J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions;
71
UDATA rc = 1;
72
73
if (targetThread->privateFlags & J9_PRIVATE_FLAGS_RI_INITIALIZED) {
74
targetThread->jitPendingRIFlags = newFlags;
75
vmFuncs->J9SignalAsyncEvent(vm, targetThread, vm->jitRIHandlerKey);
76
rc = 0;
77
}
78
79
return rc;
80
}
81
82