Path: blob/master/runtime/compiler/infra/J9Cfg.hpp
6000 views
/*******************************************************************************1* Copyright (c) 2000, 2019 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#ifndef J9_CFG_INCL23#define J9_CFG_INCL2425/*26* The following #define and typedef must appear before any #includes in this file27*/28#ifndef J9_CFG_CONNECTOR29#define J9_CFG_CONNECTOR30namespace J9 { class CFG; }31namespace J9 { typedef J9::CFG CFGConnector; }32#endif3334#include "infra/OMRCfg.hpp"3536#include <stddef.h>37#include <stdint.h>38#include "cs2/listof.h"39#include "env/TRMemory.hpp"40#include "il/Node.hpp"41#include "infra/Assert.hpp"42#include "infra/List.hpp"43#include "infra/TRCfgEdge.hpp"44#include "infra/TRCfgNode.hpp"4546class TR_BitVector;47class TR_BlockCloner;48class TR_BlockFrequencyInfo;49class TR_ExternalProfiler;50class TR_RegionStructure;51class TR_Structure;52namespace TR { class Block; }53namespace TR { class CFG; }54namespace TR { class Compilation; }55namespace TR { class ResolvedMethodSymbol; }56namespace TR { class TreeTop; }57template <class T> class TR_Array;5859namespace J960{6162class CFG : public OMR::CFGConnector63{64public:6566CFG(TR::Compilation *c, TR::ResolvedMethodSymbol *m) :67OMR::CFGConnector(c, m),68_externalProfiler(NULL)69{70}7172CFG(TR::Compilation *c, TR::ResolvedMethodSymbol *m, TR::Region &r) :73OMR::CFGConnector(c, m, r),74_externalProfiler(NULL)75{76}7778/**79* Set up profiling frequencies for nodes and edges, normalized to the80* maxBlockCount in TR::Recompilation.81*82* Returns true if profiling information was available and used.83*/84bool setFrequencies();8586void setBlockAndEdgeFrequenciesBasedOnStructure();87TR_BitVector *setBlockAndEdgeFrequenciesBasedOnJITProfiler();88void setBlockFrequenciesBasedOnInterpreterProfiler();89void computeInitialBlockFrequencyBasedOnExternalProfiler(TR::Compilation *comp);90void propagateFrequencyInfoFromExternalProfiler(TR_ExternalProfiler *profiler);91void getInterpreterProfilerBranchCountersOnDoubleton(TR::CFGNode *cfgNode, int32_t *taken, int32_t *nottaken);92void setSwitchEdgeFrequenciesOnNode(TR::CFGNode *node, TR::Compilation *comp);93void setBlockFrequency(TR::CFGNode *node, int32_t frequency, bool addFrequency = false);94int32_t scanForFrequencyOnSimpleMethod(TR::TreeTop *tt, TR::TreeTop *endTT);9596bool hasBranchProfilingData() { return _externalProfiler ? true : false; }97void getBranchCountersFromProfilingData(TR::Node *node, TR::Block *block, int32_t *taken, int32_t *notTaken);9899bool emitVerbosePseudoRandomFrequencies();100101protected:102103TR_ExternalProfiler *_externalProfiler;104};105106}107108#endif109110111