CACAO
loop.hpp
Go to the documentation of this file.
1 /* src/vm/jit/loop/loop.hpp
2 
3  Copyright (C) 1996-2012
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 #ifndef _LOOP_HPP
26 #define _LOOP_HPP
27 
28 
32 typedef struct Edge Edge;
33 
34 
35 #if defined(__cplusplus)
36 
37 
38 #include <vector>
39 
40 #include "vm/jit/jit.hpp"
41 #include "LoopContainer.hpp"
42 #include "VariableSet.hpp"
43 #include "IntervalMap.hpp"
44 #include "LoopList.hpp"
45 
46 /**
47  * Per-method data used in jitdata.
48  */
49 struct MethodLoopData
50 {
51  std::vector<basicblock*> vertex;
52  s4 n;
54 
55  // During the depth first traversal in dominator.cpp an edge is added to this vector
56  // if it points from the current node to a node which has already been visited.
57  // Not every edge in this vector is also a loopBackEdge!
58  std::vector<Edge> depthBackEdges;
59 
60  // Contains all edges (a,b) from depthBackEdges where b dominates a.
61  std::vector<Edge> loopBackEdges;
62 
63  // Contains pointers to all loops in this method.
64  std::vector<LoopContainer*> loops;
65 
66  // Every method has exactly one (pseudo) root loop that is executed exactly once.
67  LoopContainer* rootLoop;
68 
69  // An index to a free integer variable in the jd->var array.
70  s4 freeVariable;
71 
73  : n(0)
74  , root(0)
75  , rootLoop(0)
76  , freeVariable(0)
77  {}
78 };
79 
80 /**
81  * Per-basicblock data used in basicblock.
82  * Contains information about the dominator tree.
83  */
84 struct BasicblockLoopData
85 {
87  std::vector<basicblock*> pred;
88  s4 semi;
89  std::vector<basicblock*> bucket;
90  basicblock* ancestor;
91  basicblock* label;
92 
93  basicblock* dom; // after calculateDominators: the immediate dominator
94  basicblock* nextSibling; // pointer to the next sibling in the dominator tree or 0.
95  std::vector<basicblock*> children; // the children of a node in the dominator tree
96 
97  // Used to prevent this basicblock from being visited again during a traversal in loop.cpp.
98  // This is NOT a pointer to the loop this basicblock belongs to because such a loop is not unique.
99  LoopContainer* visited;
100 
101  LoopContainer* loop; // The loop which this basicblock is the header of. Can be 0.
102  LoopList loops; // All loops this basicblock is a part of.
103 
104  // The number of loop back edges that leave this basicblock.
105  s4 outgoingBackEdgeCount;
106 
107  bool leaf;
108 
109  // true if analyze has been called for this node, false otherwise.
110  bool analyzed;
111 
112  basicblock* jumpTarget;
113  IntervalMap targetIntervals;
114  IntervalMap intervals;
115 
116  LoopContainer* belongingTo; // used during loop duplication: a marker for blocks to be duplicated.
117  basicblock* copiedTo; // used during loop duplication: points to the same block in the duplicated loop.
118 
119  // Used during grouping: This variable points to the first check after cloning this block.
120  basicblock* arrayIndexCheck;
121 
123  : parent(0)
124  , semi(0)
125  , ancestor(0)
126  , label(0)
127  , dom(0)
128  , nextSibling(0)
129  , visited(0)
130  , loop(0)
131  , outgoingBackEdgeCount(0)
132  , leaf(false)
133  , analyzed(false)
134  , jumpTarget(0)
135 // , targetIntervals(0)
136 // , intervals(0)
137  , belongingTo(0)
138  , copiedTo(0)
139  , arrayIndexCheck(0)
140  {}
141 };
142 
143 /**
144  * An edge in the control flow graph.
145  */
146 struct Edge
147 {
148  basicblock* from;
149  basicblock* to;
150 
151  Edge()
152  : from(0)
153  , to(0)
154  {}
155 
157  : from(from)
158  , to(to)
159  {}
160 };
161 
162 
164 
165 
166 #endif // __cplusplus
167 #endif // _LOOP_HPP
168 
169 /*
170  * These are local overrides for various environment variables in Emacs.
171  * Please do not remove this and leave it at the end of the file, where
172  * Emacs will automagically detect them.
173  * ---------------------------------------------------------------------
174  * Local variables:
175  * mode: c++
176  * indent-tabs-mode: t
177  * c-basic-offset: 4
178  * tab-width: 4
179  * End:
180  * vim:noexpandtab:sw=4:ts=4:
181  */
182 
Maps variable names to intervals.
Definition: IntervalMap.hpp:38
Represents a single loop.
Definition: jit.hpp:126
argument_type from
MachineLoop * loop
struct MethodLoopData MethodLoopData
Definition: loop.hpp:29
OptionPrefix & root()
Definition: Option.cpp:34
struct Edge Edge
Definition: loop.hpp:32
int32_t s4
Definition: types.hpp:45
struct BasicblockLoopData BasicblockLoopData
Definition: loop.hpp:30
void removeArrayBoundChecks(jitdata *jd)
Definition: loop.cpp:404
LoopTreeGraph * parent