Path: blob/master/runtime/compiler/codegen/MonitorState.hpp
6000 views
/*******************************************************************************1* Copyright (c) 2000, 2017 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 <map>23#include <functional>24#include <utility>25#include "compile/Compilation.hpp"26#include "env/Region.hpp"27#include "il/Node.hpp"28#include "il/SymbolReference.hpp"29#include "infra/Stack.hpp"3031namespace TR { class Block; }32namespace TR { class CFGNode; }33namespace TR { class SymbolReference; }3435namespace J936{3738enum MonitorInBlock39{40NoMonitor = 0,41MonitorEnter,42MonitorExit43};444546class SetMonitorStateOnBlockEntry47{48public:49typedef TR::typed_allocator<std::pair<int32_t const, TR_Stack<TR::SymbolReference *>*>, TR::Region&> LiveMonitorStacksAllocator;50typedef std::less<int32_t> LiveMonitorStacksComparator;51typedef std::map<int32_t, TR_Stack<TR::SymbolReference *>*, LiveMonitorStacksComparator, LiveMonitorStacksAllocator> LiveMonitorStacks;5253SetMonitorStateOnBlockEntry(TR::Compilation * c, LiveMonitorStacks *liveMonitorStacks)54: _blocksToVisit(c->trMemory(), 8, false, stackAlloc)55{56_comp = c;57_visitCount = c->incVisitCount();58_liveMonitorStacks = liveMonitorStacks;59}6061void set(bool& lmmdFailed, bool traceIt = false);6263private:64int32_t addSuccessors(TR::CFGNode * cfgNode, TR_Stack<TR::SymbolReference *> *, bool traceIt, bool dontPropagateMonitor = false, MonitorInBlock monitorType = NoMonitor, int32_t callerIndex = -1, bool walkOnlyExceptionSuccs = false);65bool isMonitorStateConsistentForBlock(TR::Block *block, TR_Stack<TR::SymbolReference *> *newMonitorStack, bool popMonitor);6667TR_Memory *trMemory() { return comp()->trMemory(); }68TR_HeapMemory trHeapMemory() { return trMemory(); }6970TR::Compilation *comp() { return _comp; }7172TR::Compilation *_comp;73vcount_t _visitCount;74TR_Stack<TR::Block *> _blocksToVisit;75LiveMonitorStacks *_liveMonitorStacks;76};7778}798081