Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/infra/J9Cfg.hpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2019 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 J9_CFG_INCL
24
#define J9_CFG_INCL
25
26
/*
27
* The following #define and typedef must appear before any #includes in this file
28
*/
29
#ifndef J9_CFG_CONNECTOR
30
#define J9_CFG_CONNECTOR
31
namespace J9 { class CFG; }
32
namespace J9 { typedef J9::CFG CFGConnector; }
33
#endif
34
35
#include "infra/OMRCfg.hpp"
36
37
#include <stddef.h>
38
#include <stdint.h>
39
#include "cs2/listof.h"
40
#include "env/TRMemory.hpp"
41
#include "il/Node.hpp"
42
#include "infra/Assert.hpp"
43
#include "infra/List.hpp"
44
#include "infra/TRCfgEdge.hpp"
45
#include "infra/TRCfgNode.hpp"
46
47
class TR_BitVector;
48
class TR_BlockCloner;
49
class TR_BlockFrequencyInfo;
50
class TR_ExternalProfiler;
51
class TR_RegionStructure;
52
class TR_Structure;
53
namespace TR { class Block; }
54
namespace TR { class CFG; }
55
namespace TR { class Compilation; }
56
namespace TR { class ResolvedMethodSymbol; }
57
namespace TR { class TreeTop; }
58
template <class T> class TR_Array;
59
60
namespace J9
61
{
62
63
class CFG : public OMR::CFGConnector
64
{
65
public:
66
67
CFG(TR::Compilation *c, TR::ResolvedMethodSymbol *m) :
68
OMR::CFGConnector(c, m),
69
_externalProfiler(NULL)
70
{
71
}
72
73
CFG(TR::Compilation *c, TR::ResolvedMethodSymbol *m, TR::Region &r) :
74
OMR::CFGConnector(c, m, r),
75
_externalProfiler(NULL)
76
{
77
}
78
79
/**
80
* Set up profiling frequencies for nodes and edges, normalized to the
81
* maxBlockCount in TR::Recompilation.
82
*
83
* Returns true if profiling information was available and used.
84
*/
85
bool setFrequencies();
86
87
void setBlockAndEdgeFrequenciesBasedOnStructure();
88
TR_BitVector *setBlockAndEdgeFrequenciesBasedOnJITProfiler();
89
void setBlockFrequenciesBasedOnInterpreterProfiler();
90
void computeInitialBlockFrequencyBasedOnExternalProfiler(TR::Compilation *comp);
91
void propagateFrequencyInfoFromExternalProfiler(TR_ExternalProfiler *profiler);
92
void getInterpreterProfilerBranchCountersOnDoubleton(TR::CFGNode *cfgNode, int32_t *taken, int32_t *nottaken);
93
void setSwitchEdgeFrequenciesOnNode(TR::CFGNode *node, TR::Compilation *comp);
94
void setBlockFrequency(TR::CFGNode *node, int32_t frequency, bool addFrequency = false);
95
int32_t scanForFrequencyOnSimpleMethod(TR::TreeTop *tt, TR::TreeTop *endTT);
96
97
bool hasBranchProfilingData() { return _externalProfiler ? true : false; }
98
void getBranchCountersFromProfilingData(TR::Node *node, TR::Block *block, int32_t *taken, int32_t *notTaken);
99
100
bool emitVerbosePseudoRandomFrequencies();
101
102
protected:
103
104
TR_ExternalProfiler *_externalProfiler;
105
};
106
107
}
108
109
#endif
110
111