Path: blob/master/runtime/codert_vm/runtimeInstrumentation.c
5986 views
/*******************************************************************************1* Copyright (c) 1991, 2014 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122#include "runtimeInstrumentation.h"2324/**25* Handler for the async message to update the RI fields in a thread.26*27* @param[in] currentThread The current J9VMThread28* @param[in] handlerKey Handler key of the current async event29* @param[in] userData The J9JavaVM pointer30*/31static void32riAsyncHandler(J9VMThread *currentThread, IDATA handlerKey, void *userData)33{34/**35* Update the current flag values. There is no need to take action based on the new flags.36* The RI state will be updated on the next transition back to compiled code.37*/38currentThread->jitCurrentRIFlags = currentThread->jitPendingRIFlags;39}4041UDATA42initializeJITRuntimeInstrumentation(J9JavaVM *vm)43{44J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions;45IDATA handlerKey = vmFuncs->J9RegisterAsyncEvent(vm, riAsyncHandler, vm);46UDATA rc = 1;4748if (handlerKey >= 0) {49vm->jitRIHandlerKey = handlerKey;50rc = 0;51}5253return rc;54}5556void57shutdownJITRuntimeInstrumentation(J9JavaVM *vm)58{59J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions;6061vmFuncs->J9UnregisterAsyncEvent(vm, vm->jitRIHandlerKey);62vm->jitRIHandlerKey = -1;63}6465UDATA66updateJITRuntimeInstrumentationFlags(J9VMThread *targetThread, UDATA newFlags)67{68J9JavaVM *vm = targetThread->javaVM;69J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions;70UDATA rc = 1;7172if (targetThread->privateFlags & J9_PRIVATE_FLAGS_RI_INITIALIZED) {73targetThread->jitPendingRIFlags = newFlags;74vmFuncs->J9SignalAsyncEvent(vm, targetThread, vm->jitRIHandlerKey);75rc = 0;76}7778return rc;79}808182