Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_base/IdleGCManager.hpp
5986 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2020 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
/**
25
* @file
26
* @ingroup GC_Base
27
*/
28
#if !defined(IDLERESOURCEMANAGERHPP_)
29
#define IDLERESOURCEMANAGERHPP_
30
#include "j9.h"
31
#include "j9cfg.h"
32
#if defined(OMR_GC_IDLE_HEAP_MANAGER)
33
#include "BaseNonVirtual.hpp"
34
#include "EnvironmentBase.hpp"
35
#include "GCExtensions.hpp"
36
37
extern "C" {
38
/**
39
* Hook "J9HOOK_VM_RUNTIME_STATE_CHANGED" callback function
40
* Manages Heap Free Pages If Current Runtime State is IDLE
41
*/
42
void idleGCManagerVMStateHook(J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData);
43
}
44
45
/**
46
* Manages free java heap memory whenever JVM becomes idle. Registers for VM Runtime State Notification Hook
47
*/
48
class MM_IdleGCManager : public MM_BaseNonVirtual
49
{
50
private:
51
/*
52
* reference to the language runtime
53
*/
54
J9JavaVM* _javaVM;
55
56
protected:
57
public:
58
59
private:
60
protected:
61
/**
62
* Initialize the object of this class and registers for Runtime State hook
63
*/
64
bool initialize(MM_EnvironmentBase* env);
65
/**
66
* cleanup the object & unregisters registered hook
67
*/
68
void tearDown(MM_EnvironmentBase* env);
69
public:
70
/**
71
* creates the object
72
*/
73
static MM_IdleGCManager* newInstance(MM_EnvironmentBase* env);
74
/**
75
* deallocates the object
76
*/
77
void kill(MM_EnvironmentBase* env);
78
/**
79
* Whenever JVM becomes idle, uses the opportunity to free up pages of free java heap
80
*/
81
void manageFreeHeap(J9VMThread* currentThread);
82
83
/**
84
* construct the object
85
*/
86
MM_IdleGCManager(MM_EnvironmentBase* env)
87
: MM_BaseNonVirtual()
88
, _javaVM((J9JavaVM*)env->getOmrVM()->_language_vm)
89
{
90
_typeId = __FUNCTION__;
91
}
92
};
93
#endif /* defined(OMR_GC_IDLE_HEAP_MANAGER) */
94
#endif /* IDLERESOURCEMANAGERHPP_ */
95
96