Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/infra/J9MonitorTable.hpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2021 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
#ifndef TRJ9_MONITORTABLE_INCL
24
#define TRJ9_MONITORTABLE_INCL
25
26
#ifndef TRJ9_MONITORTABLE_CONNECTOR
27
#define TRJ9_MONITORTABLE_CONNECTOR
28
namespace J9 { class MonitorTable; }
29
namespace J9 { typedef MonitorTable MonitorTableConnector; }
30
#endif
31
32
33
#include "infra/OMRMonitorTable.hpp"
34
#include "infra/Link.hpp"
35
#include "infra/Monitor.hpp"
36
#include "infra/RWMonitor.hpp"
37
38
struct J9PortLibrary;
39
struct J9JavaVM;
40
struct J9VMThread;
41
namespace TR { class MonitorTable; }
42
43
namespace J9
44
{
45
46
class OMR_EXTENSIBLE MonitorTable : public OMR::MonitorTableConnector
47
{
48
public:
49
50
void *operator new(size_t size, void *p) {return p;}
51
52
static TR::MonitorTable *init(J9PortLibrary *portLib, J9JavaVM *javaVM);
53
54
void free();
55
56
J9::RWMonitor *getClassUnloadMonitor() { return &_classUnloadMonitor; }
57
TR::Monitor *getClassTableMutex() { return &_classTableMutex; }
58
TR::Monitor *getIProfilerPersistenceMonitor() { return &_iprofilerPersistenceMonitor; }
59
void removeAndDestroy(TR::Monitor *monitor);
60
61
bool isThreadInSafeMonitorState(J9VMThread *vmThread);
62
TR::Monitor *monitorHeldByCurrentThread();
63
int32_t readAcquireClassUnloadMonitor(int32_t compThreadIndex);
64
int32_t readReleaseClassUnloadMonitor(int32_t compThreadIndex);
65
int32_t getClassUnloadMonitorHoldCount(int32_t i) const { return _classUnloadMonitorHolders[i]; }
66
67
bool allocInitClassUnloadMonitorHolders(uint32_t allowedTotalCompThreads);
68
69
private:
70
71
friend class TR::Monitor;
72
friend class J9::Monitor;
73
friend class J9::RWMonitor;
74
friend class TR::MonitorTable;
75
76
TR::Monitor *create(char *name);
77
void insert(TR::Monitor *monitor);
78
79
J9PortLibrary *_portLib;
80
TR_LinkHead0<TR::Monitor> _monitors;
81
82
TR::Monitor _tableMonitor;
83
TR::Monitor _j9ScratchMemoryPoolMonitor;
84
J9::RWMonitor _classUnloadMonitor;
85
TR::Monitor _classTableMutex; // JavaVM's class table mutex
86
TR::Monitor _iprofilerPersistenceMonitor;
87
88
// To detect which thread has locked the classUnloadMonitor we will keep an array of integers
89
// Each entry corresponds to a determined compilation thread. This way we avoid any
90
// concurrency issues. Each number represents how many times the compilation thread has entered
91
// the classUnloadmonitor. Normally it should not be more than 1
92
//
93
int32_t *_classUnloadMonitorHolders;
94
uint32_t _numCompThreads;
95
};
96
97
}
98
99
#endif
100
101