Path: blob/master/runtime/gc_base/IdleGCManager.hpp
5986 views
1/*******************************************************************************2* Copyright (c) 1991, 2020 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* 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 and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*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-exception21*******************************************************************************/2223/**24* @file25* @ingroup GC_Base26*/27#if !defined(IDLERESOURCEMANAGERHPP_)28#define IDLERESOURCEMANAGERHPP_29#include "j9.h"30#include "j9cfg.h"31#if defined(OMR_GC_IDLE_HEAP_MANAGER)32#include "BaseNonVirtual.hpp"33#include "EnvironmentBase.hpp"34#include "GCExtensions.hpp"3536extern "C" {37/**38* Hook "J9HOOK_VM_RUNTIME_STATE_CHANGED" callback function39* Manages Heap Free Pages If Current Runtime State is IDLE40*/41void idleGCManagerVMStateHook(J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData);42}4344/**45* Manages free java heap memory whenever JVM becomes idle. Registers for VM Runtime State Notification Hook46*/47class MM_IdleGCManager : public MM_BaseNonVirtual48{49private:50/*51* reference to the language runtime52*/53J9JavaVM* _javaVM;5455protected:56public:5758private:59protected:60/**61* Initialize the object of this class and registers for Runtime State hook62*/63bool initialize(MM_EnvironmentBase* env);64/**65* cleanup the object & unregisters registered hook66*/67void tearDown(MM_EnvironmentBase* env);68public:69/**70* creates the object71*/72static MM_IdleGCManager* newInstance(MM_EnvironmentBase* env);73/**74* deallocates the object75*/76void kill(MM_EnvironmentBase* env);77/**78* Whenever JVM becomes idle, uses the opportunity to free up pages of free java heap79*/80void manageFreeHeap(J9VMThread* currentThread);8182/**83* construct the object84*/85MM_IdleGCManager(MM_EnvironmentBase* env)86: MM_BaseNonVirtual()87, _javaVM((J9JavaVM*)env->getOmrVM()->_language_vm)88{89_typeId = __FUNCTION__;90}91};92#endif /* defined(OMR_GC_IDLE_HEAP_MANAGER) */93#endif /* IDLERESOURCEMANAGERHPP_ */949596