Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/codegen/MonitorState.hpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2017 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 <map>
24
#include <functional>
25
#include <utility>
26
#include "compile/Compilation.hpp"
27
#include "env/Region.hpp"
28
#include "il/Node.hpp"
29
#include "il/SymbolReference.hpp"
30
#include "infra/Stack.hpp"
31
32
namespace TR { class Block; }
33
namespace TR { class CFGNode; }
34
namespace TR { class SymbolReference; }
35
36
namespace J9
37
{
38
39
enum MonitorInBlock
40
{
41
NoMonitor = 0,
42
MonitorEnter,
43
MonitorExit
44
};
45
46
47
class SetMonitorStateOnBlockEntry
48
{
49
public:
50
typedef TR::typed_allocator<std::pair<int32_t const, TR_Stack<TR::SymbolReference *>*>, TR::Region&> LiveMonitorStacksAllocator;
51
typedef std::less<int32_t> LiveMonitorStacksComparator;
52
typedef std::map<int32_t, TR_Stack<TR::SymbolReference *>*, LiveMonitorStacksComparator, LiveMonitorStacksAllocator> LiveMonitorStacks;
53
54
SetMonitorStateOnBlockEntry(TR::Compilation * c, LiveMonitorStacks *liveMonitorStacks)
55
: _blocksToVisit(c->trMemory(), 8, false, stackAlloc)
56
{
57
_comp = c;
58
_visitCount = c->incVisitCount();
59
_liveMonitorStacks = liveMonitorStacks;
60
}
61
62
void set(bool& lmmdFailed, bool traceIt = false);
63
64
private:
65
int32_t addSuccessors(TR::CFGNode * cfgNode, TR_Stack<TR::SymbolReference *> *, bool traceIt, bool dontPropagateMonitor = false, MonitorInBlock monitorType = NoMonitor, int32_t callerIndex = -1, bool walkOnlyExceptionSuccs = false);
66
bool isMonitorStateConsistentForBlock(TR::Block *block, TR_Stack<TR::SymbolReference *> *newMonitorStack, bool popMonitor);
67
68
TR_Memory *trMemory() { return comp()->trMemory(); }
69
TR_HeapMemory trHeapMemory() { return trMemory(); }
70
71
TR::Compilation *comp() { return _comp; }
72
73
TR::Compilation *_comp;
74
vcount_t _visitCount;
75
TR_Stack<TR::Block *> _blocksToVisit;
76
LiveMonitorStacks *_liveMonitorStacks;
77
};
78
79
}
80
81