1 salcianu 1.1.2.1  // LightBasicBlock.java, created Thu Mar 23 17:44:52 2000 by salcianu
  2 salcianu 1.1.2.9  // Copyright (C) 2000 Alexandru SALCIANU <salcianu@mit.edu>
  3 salcianu 1.1.2.1  // Licensed under the terms of the GNU GPL; see COPYING for details.
  4 salcianu 1.1.2.1  package harpoon.Util.LightBasicBlocks;
  5 salcianu 1.1.2.1  
  6 salcianu 1.1.2.1  import java.util.Iterator;
  7 salcianu 1.1.2.1  import java.util.Enumeration;
  8 salcianu 1.1.2.1  import java.util.Set;
  9 salcianu 1.1.2.9  import java.util.HashSet;
 10 salcianu 1.1.2.1  import java.util.Map;
 11 salcianu 1.1.2.1  import java.util.HashMap;
 12 salcianu 1.1.2.2  import java.util.Arrays;
 13 salcianu 1.1.2.2  import java.util.List;
 14 salcianu 1.1.2.1  
 15 salcianu 1.1.2.1  import harpoon.ClassFile.HCode;
 16 salcianu 1.1.2.1  import harpoon.ClassFile.HCodeElement;
 17 salcianu 1.1.2.1  import harpoon.Analysis.BasicBlock;
 18 salcianu 1.1.2.9  import harpoon.Analysis.BasicBlockInterf;
 19 salcianu 1.1.2.9  import harpoon.Analysis.BasicBlockInterfVisitor;
 20 salcianu 1.1.2.9  import harpoon.Analysis.BasicBlockFactoryInterf;
 21 salcianu 1.1.2.9  import harpoon.Analysis.FCFGBasicBlock;
 22 salcianu 1.1.2.2  import harpoon.Util.UComp;
 23 salcianu 1.1.2.1  
 24 salcianu 1.1.2.9  import harpoon.IR.Quads.Quad;
 25 salcianu 1.1.2.9  import harpoon.IR.Quads.HEADER;
 26 salcianu 1.1.2.9  import harpoon.IR.Quads.FOOTER;
 27 salcianu 1.1.2.9  import harpoon.IR.Quads.HANDLER;
 28 salcianu 1.1.2.9  import harpoon.IR.Quads.METHOD;
 29 salcianu 1.1.2.9  
 30 salcianu 1.1.2.9  import harpoon.Util.Util;
 31 salcianu 1.1.2.9  
 32 salcianu 1.1.2.1  /**
 33 salcianu 1.1.2.1   * <code>LightBasicBlock</code> is designed as a compact version of a
 34 salcianu 1.1.2.1   <code>BasicBlock</code>. The next and the previous basic blocks, as well
 35 salcianu 1.1.2.1   as the composing instructions are stored in arrays, instead of expensive
 36 salcianu 1.1.2.1   <code>Set</code>s. The traversal of these structures is far cheaper that
 37 salcianu 1.1.2.1   the equaivalent operation on <code>BasicBlock</code>s: no
 38 salcianu 1.1.2.1   <code>Iterator</code> object need to be dynamically created, it's juat an
 39 salcianu 1.1.2.9   integer index.
 40 salcianu 1.1.2.9  
 41 salcianu 1.1.2.9   <p>
 42 salcianu 1.1.2.9   <b>Use:</b> To obtain the <code>LightBasicBlock</code>s of a
 43 salcianu 1.1.2.9   given method, you have to obtain a
 44 salcianu 1.1.2.9   <code>BasicBlock.Factory</code> for that method and pass it to
 45 salcianu 1.1.2.9   <code>LightBasicBlock.Factory</code>.
 46 salcianu 1.1.2.9  
 47 salcianu 1.1.2.9   <p>
 48 salcianu 1.1.2.9   If the &quot;quad-with-try&quot; IR is used, the light basic
 49 salcianu 1.1.2.9   blocks contain info about the handlers that handle the exceptions
 50 salcianu 1.1.2.9   that could be thrown by the instructions from each light basic block.
 51 salcianu 1.1.2.9  
 52 salcianu 1.1.2.9   <p>
 53 salcianu 1.1.2.9   <b>Note:</b> The interface might seem minimal but I <b>recommend</b> that
 54 salcianu 1.1.2.1   you use it instead of adding some other methods. For example, one might
 55 salcianu 1.1.2.1   complain that there are no methods to return the number of predecessors,
 56 salcianu 1.1.2.9   nor the <code>i</code>-th predecessor. Here is why: you are expected to
 57 salcianu 1.1.2.1   traverse the list of predecessors in the cheapest way: extract the array
 58 salcianu 1.1.2.1   of predecessors and then do a for whose condition looks something like
 59 salcianu 1.1.2.7   <code>i&lt;pred.length</code> instead of <code>i&lt;lbb.predLength()</code>
 60 salcianu 1.1.2.9   (one method call per iteration!).<br>
 61 salcianu 1.1.2.9  
 62 salcianu 1.1.2.1   * 
 63 salcianu 1.1.2.9   * @author  Alexandru SALCIANU <salcianu@mit.edu>
 64 salcianu 1.6       * @version $Id: LightBasicBlock.java,v 1.6 2004/03/06 21:52:34 salcianu Exp $ */
 65 salcianu 1.1.2.5  public class LightBasicBlock implements java.io.Serializable {
 66 salcianu 1.1.2.1  
 67 salcianu 1.6          /** The user can place his annotations here.
 68 salcianu 1.5              @deprecated */   
 69 salcianu 1.1.2.2      public Object user_info = null;
 70 salcianu 1.1.2.2  
 71 salcianu 1.1.2.2      /** Personal numeric ID */
 72 salcianu 1.1.2.2      private int id;
 73 salcianu 1.1.2.2  
 74 salcianu 1.1.2.2      // See the TODO notice about Arrays.sort(...)
 75 salcianu 1.1.2.2      public String str;
 76 salcianu 1.1.2.2  
 77 salcianu 1.1.2.1      /** The only way to produce <code>LightBasicBlock</code> is via 
 78 salcianu 1.1.2.1          a <code>LightBasicBlock.Factory</code>. Outside this package, you
 79 salcianu 1.1.2.1          cannot manufacture them. */
 80 salcianu 1.1.2.9      LightBasicBlock(BasicBlockInterf bb) {
 81 salcianu 1.1.2.2          // See the TODO notice about Arrays.sort(...)
 82 salcianu 1.1.2.2          this.str = bb.toString();
 83 salcianu 1.1.2.2          //LightBasicBlock(int id) {
 84 salcianu 1.1.2.2          //this.id = id;
 85 salcianu 1.1.2.2      }
 86 salcianu 1.1.2.1  
 87 salcianu 1.1.2.1      /** The successor basic blocks. */
 88 salcianu 1.1.2.1      LightBasicBlock[] next = null;
 89 salcianu 1.1.2.1      /** The predecessor basic blocks. */
 90 salcianu 1.1.2.1      LightBasicBlock[] prev = null;
 91 salcianu 1.1.2.1      /** The instructions in <code>this</code> basic block. */
 92 salcianu 1.1.2.1      HCodeElement[] elements = null;
 93 salcianu 1.1.2.1  
 94 salcianu 1.1.2.9      /** The index in the next array where the exception handlers start. **/
 95 salcianu 1.1.2.9      int handlerStartIndex;
 96 salcianu 1.1.2.9      /** The index in the prev array where the protected lbbs start. */
 97 salcianu 1.1.2.9      int protectedStartIndex;
 98 salcianu 1.1.2.9  
 99 salcianu 1.1.2.9      /** Returns the array of successor light basic blocks. Starting
100 salcianu 1.1.2.9          from position <code>getHandlerStartIndex()</code> on (including
101 salcianu 1.1.2.9          that position), the entries of the returned array point to
102 salcianu 1.1.2.9          light basic blocks corresponding to the handlers for the
103 salcianu 1.1.2.9          instructions of this (light) basic block. The handlers appear
104 salcianu 1.1.2.9          in the order in which they catch exceptions. The exit point of
105 salcianu 1.1.2.9          the method is considered to be the default handler (any
106 salcianu 1.1.2.9          uncaught exception is sent to the caller). */
107 salcianu 1.1.2.6      public final LightBasicBlock[] getNextLBBs() { return next; }
108 salcianu 1.1.2.1  
109 salcianu 1.1.2.9      /** Returns the index of the first handler into the array of next
110 salcianu 1.1.2.9          (light) basic blocks.
111 salcianu 1.1.2.9          @see getNextLBBs */
112 salcianu 1.1.2.9      public final int getHandlerStartIndex() { return handlerStartIndex; }
113 salcianu 1.1.2.9  
114 salcianu 1.1.2.9  
115 salcianu 1.1.2.9      /** Returns the array of predecessor light basic blocks. For basic
116 salcianu 1.1.2.9          blocks that start with a <code>HANDLER</code> instruction, the
117 salcianu 1.1.2.9          entries of the returned array starting from position
118 salcianu 1.1.2.9          <code>getProtectedStartIndex()</code> on (including that
119 salcianu 1.1.2.9          position) point to the light basic block composed of
120 salcianu 1.1.2.9          instructions which are protected by this <code>this</code>
121 salcianu 1.1.2.9          basic block. The end of the method is the only basic block
122 salcianu 1.1.2.9          that has both normal flow predecessors and protected basic
123 salcianu 1.1.2.9          blocks (any uncaught exception is passed down to the
124 salcianu 1.1.2.9          caller). */
125 salcianu 1.1.2.6      public final LightBasicBlock[] getPrevLBBs() { return prev; }
126 salcianu 1.1.2.1  
127 salcianu 1.1.2.9      /** Returns the index of the first protected basic block in the
128 salcianu 1.1.2.9          array of (light) basic blocks. 
129 salcianu 1.1.2.9          @see getPrevLBBs */
130 salcianu 1.1.2.9      public final int getProtectedStartIndex() { return protectedStartIndex; }
131 salcianu 1.1.2.9  
132 salcianu 1.1.2.1      /** Returns the inctructions in <code>this</code> basic block. */
133 salcianu 1.1.2.6      public final HCodeElement[] getElements() { return elements; }
134 salcianu 1.1.2.3  
135 salcianu 1.1.2.3      /** Returns the first instruction from <code>this</code> basic block. */
136 salcianu 1.1.2.6      public final HCodeElement getFirstElement() {
137 salcianu 1.1.2.3          if(elements.length > 0)
138 salcianu 1.1.2.3              return elements[0];
139 salcianu 1.1.2.3          return null;
140 salcianu 1.1.2.3      }
141 salcianu 1.1.2.3  
142 salcianu 1.1.2.3      /** Returns the last instruction from <code>this</code> basic block. */
143 salcianu 1.1.2.3      public final HCodeElement getLastElement(){
144 salcianu 1.1.2.3          int len = elements.length;
145 salcianu 1.1.2.3          if(len > 0)
146 salcianu 1.1.2.3              return elements[len - 1];
147 salcianu 1.1.2.3          return null;
148 salcianu 1.1.2.1      }
149 salcianu 1.1.2.1  
150 salcianu 1.1.2.2      /** String representation. */
151 salcianu 1.1.2.2      public final String toString(){
152 salcianu 1.1.2.2          // See the TODO notice about Arrays.sort(...)
153 salcianu 1.1.2.2          //return "LBB" + id;
154 salcianu 1.1.2.2          return str;
155 salcianu 1.1.2.2      }
156 salcianu 1.1.2.2  
157 salcianu 1.1.2.1      /** Converts the large, set based, basic blocks produced
158 salcianu 1.1.2.1          by a <code>BasicBlock.Factory</code> into smaller, array based,
159 salcianu 1.1.2.1          light basic blocks. */
160 salcianu 1.1.2.5      public static class Factory implements java.io.Serializable {
161 salcianu 1.1.2.1          
162 salcianu 1.1.2.2          private int count = 0;
163 salcianu 1.1.2.2  
164 salcianu 1.1.2.1          /** Creates a <code>LighBasicBlock.Factory</code> object.
165 salcianu 1.1.2.1              It simply converts the large, set based, basic blocks produced
166 salcianu 1.1.2.1              by <code>bbfact</code> into smaller, array based, light basic
167 salcianu 1.1.2.1              blocks. */
168 salcianu 1.1.2.9          public Factory(BasicBlockFactoryInterf bbfact) {
169 salcianu 1.1.2.10             // special case: method with inaccessible code (e.g. natives)
170 salcianu 1.1.2.10             if(bbfact == null) return;
171 salcianu 1.1.2.9              hcode = bbfact.getHCode();
172 salcianu 1.1.2.10             // special case: method with inaccessible code (e.g. natives)
173 salcianu 1.1.2.10             if(hcode == null) return;
174 salcianu 1.1.2.10 
175 salcianu 1.1.2.9              Set bbs = bbfact.blockSet();
176 salcianu 1.1.2.9              int nb_bbs = bbs.size();
177 salcianu 1.1.2.9              lbbs = new LightBasicBlock[nb_bbs];
178 salcianu 1.1.2.9              BasicBlockInterf[] l2b = new BasicBlockInterf[nb_bbs];
179 salcianu 1.1.2.9              Map b2l = new HashMap();
180 salcianu 1.1.2.9  
181 salcianu 1.1.2.9              create_lbbs(bbs, b2l, l2b);
182 salcianu 1.1.2.9  
183 salcianu 1.1.2.9              // record the root basic block
184 salcianu 1.1.2.9              root_lbb = (LightBasicBlock) b2l.get(bbfact.getRootBBInterf());
185 salcianu 1.1.2.9  
186 salcianu 1.1.2.9              // set the links between the LightBasicBlocks:
187 salcianu 1.1.2.9              // 1. succesors
188 salcianu 1.1.2.9              set_next(b2l, l2b);
189 salcianu 1.1.2.9              // 2. predecessors
190 salcianu 1.1.2.9              set_prev(b2l, l2b);
191 salcianu 1.1.2.1          }
192 salcianu 1.1.2.9  
193 salcianu 1.1.2.1          // the underlying hcode
194 salcianu 1.1.2.10         HCode hcode = null;
195 salcianu 1.1.2.1          // all the light basic blocks 
196 salcianu 1.1.2.1          LightBasicBlock[] lbbs = null;
197 salcianu 1.1.2.1          // the root LightBasicBlock
198 salcianu 1.1.2.10         LightBasicBlock root_lbb = null;
199 salcianu 1.1.2.1  
200 salcianu 1.1.2.1          /** Returns the underlying <code>HCode</code>. This factory returns
201 salcianu 1.1.2.1              <code>LightBasicBlock</code>s of the code returned by this
202 salcianu 1.1.2.1              method. */
203 salcianu 1.1.2.6          public HCode getHCode() { return hcode; }
204 salcianu 1.1.2.1  
205 salcianu 1.1.2.1          /** Returns all the <code>LightBasicBlock</code>s of the underlying
206 salcianu 1.1.2.1              <code>HCode</code>. */
207 salcianu 1.1.2.6          public LightBasicBlock[] getAllBBs() { return lbbs; }
208 salcianu 1.1.2.1  
209 salcianu 1.1.2.1          /** Returns the root <code>LightBasicBlock</code>. */
210 salcianu 1.1.2.6          public LightBasicBlock getRoot() { return root_lbb; }
211 salcianu 1.1.2.1  
212 salcianu 1.1.2.1          // map HCodeElement -> LightBasicBlock; computed "on demand"
213 salcianu 1.1.2.1          private Map hce2lbb = null;
214 salcianu 1.1.2.1  
215 salcianu 1.1.2.1          /** Returns the <code>LightBasicBlock</code> the instruction
216 salcianu 1.1.2.1              <code>hce</code> belongs to. */
217 salcianu 1.1.2.6          public LightBasicBlock getBlock(HCodeElement hce) {
218 salcianu 1.1.2.1              if(hce2lbb == null){
219 salcianu 1.1.2.1                  // we need to compute hce2lbb (first time)
220 salcianu 1.1.2.1                  hce2lbb = new HashMap();
221 salcianu 1.1.2.1                  for(int i = 0; i< lbbs.length; i++){
222 salcianu 1.1.2.1                      LightBasicBlock lbb = lbbs[i];
223 salcianu 1.1.2.1                      HCodeElement[] hces = lbb.getElements();
224 salcianu 1.1.2.1                      for(int k = 0; k < hces.length; k++)
225 salcianu 1.1.2.1                          hce2lbb.put(hces[k], lbb);
226 salcianu 1.1.2.1                  }
227 salcianu 1.1.2.1              }
228 salcianu 1.1.2.1  
229 salcianu 1.1.2.1              return (LightBasicBlock) hce2lbb.get(hce);
230 salcianu 1.1.2.1          }
231 salcianu 1.1.2.1  
232 salcianu 1.1.2.9          private void create_lbbs(Set bbs, Map b2l, BasicBlockInterf[] l2b) {
233 salcianu 1.1.2.1              // create the LightBasicBlocks
234 salcianu 1.1.2.1              Iterator it = bbs.iterator();
235 salcianu 1.1.2.9              for(int i = 0; i < lbbs.length; i++) {
236 salcianu 1.1.2.9                  BasicBlockInterf bb = (BasicBlockInterf) it.next();
237 salcianu 1.1.2.2                  LightBasicBlock lbb = new LightBasicBlock(bb);
238 salcianu 1.1.2.1  
239 salcianu 1.1.2.9                  // store the basic block instructions
240 salcianu 1.1.2.2                  List instrs = bb.statements();
241 salcianu 1.1.2.9  
242 salcianu 1.1.2.2                  lbb.elements = (HCodeElement[])
243 salcianu 1.1.2.2                      instrs.toArray(new HCodeElement[instrs.size()]);
244 salcianu 1.1.2.1  
245 salcianu 1.1.2.2                  lbbs[i] = lbb;
246 salcianu 1.1.2.1                  // record the mapping Light Basic Block <-> Basic Block
247 salcianu 1.1.2.1                  l2b[i]  = bb;
248 salcianu 1.1.2.1                  b2l.put(bb, lbb);
249 salcianu 1.1.2.1              }
250 salcianu 1.1.2.9          }
251 salcianu 1.1.2.1  
252 salcianu 1.1.2.9          // set the successors for the code views with explicit
253 salcianu 1.1.2.9          // treatment of exception; straightforward
254 salcianu 1.1.2.9          private void set_next
255 salcianu 1.1.2.9              (final Map b2l, final BasicBlockInterf[] l2b) {
256 salcianu 1.1.2.9  
257 salcianu 1.1.2.9              class BBInterfVisitorNext extends BasicBlockInterfVisitor {
258 salcianu 1.1.2.9  
259 salcianu 1.1.2.9                  LightBasicBlock lbb = null;
260 salcianu 1.1.2.9                  
261 salcianu 1.1.2.9                  public void visit(BasicBlock bb) {
262 salcianu 1.1.2.9                      LightBasicBlock[] lnext = 
263 salcianu 1.1.2.9                          new LightBasicBlock[bb.nextLength()];
264 salcianu 1.1.2.9                      
265 salcianu 1.1.2.9                      int k = 0;
266 salcianu 1.1.2.9                      for(Iterator it = bb.nextSet().iterator();
267 salcianu 1.1.2.9                          it.hasNext(); k++)
268 salcianu 1.1.2.9                          lnext[k] = (LightBasicBlock) b2l.get(it.next());
269 salcianu 1.1.2.9                      
270 salcianu 1.1.2.9                      // Because there is no explicit loop view for the
271 salcianu 1.1.2.9                      // moment, it helps the dataflow analysis to have
272 salcianu 1.1.2.9                      // "next" sorted (the basic blocks closer to the
273 salcianu 1.1.2.9                      // header of the method (loop header) will be in
274 salcianu 1.1.2.9                      // the first positions.  TODO: this should be
275 salcianu 1.1.2.9                      // eliminated once a decent loop view of the code
276 salcianu 1.1.2.9                      // is implemented.
277 salcianu 1.1.2.9                      Arrays.sort(lnext, UComp.uc);
278 salcianu 1.1.2.9                      
279 salcianu 1.1.2.9                      lbb.handlerStartIndex = k;
280 salcianu 1.1.2.9                      // no handlers
281 salcianu 1.1.2.9                      lbb.next = lnext;
282 salcianu 1.1.2.9                  }
283 salcianu 1.1.2.9                  
284 salcianu 1.1.2.9                  public void visit(FCFGBasicBlock bb) {
285 salcianu 1.1.2.9                      LightBasicBlock[] lnext = 
286 salcianu 1.1.2.9                          new LightBasicBlock[bb.normalNextSet().size() + 
287 salcianu 1.1.2.9                                             bb.handlerList().size()];
288 salcianu 1.1.2.9                      int k = 0;
289 salcianu 1.1.2.9                      for(Iterator it = bb.normalNextSet().iterator();
290 salcianu 1.1.2.9                          it.hasNext(); k++)
291 salcianu 1.1.2.9                          lnext[k] = (LightBasicBlock) b2l.get(it.next());
292 salcianu 1.1.2.9                      
293 salcianu 1.1.2.9                      lbb.handlerStartIndex = k;
294 salcianu 1.1.2.9                      for(Iterator it = bb.handlerList().iterator();
295 salcianu 1.1.2.9                          it.hasNext(); k++)
296 salcianu 1.1.2.9                          lnext[k] = (LightBasicBlock) b2l.get(it.next());
297 salcianu 1.1.2.9                      
298 salcianu 1.1.2.9                      lbb.next = lnext;
299 salcianu 1.1.2.9                  }
300 salcianu 1.1.2.9                  
301 salcianu 1.1.2.9                  public void visit(BasicBlockInterf bb) {
302 cananian 1.3.2.1                      assert false : "Unknown BasicBlockInterf!";
303 salcianu 1.1.2.9                  }
304 salcianu 1.1.2.9              };
305 salcianu 1.1.2.9              
306 salcianu 1.1.2.9              BBInterfVisitorNext visitor = new BBInterfVisitorNext();
307 salcianu 1.1.2.9  
308 salcianu 1.1.2.9              for(int i = 0; i < lbbs.length; i++) {
309 salcianu 1.1.2.9                  // lbbs[i] is the ith basic block,
310 salcianu 1.1.2.9                  // l2b[i] is the corresponding light basic block
311 salcianu 1.1.2.9                  visitor.lbb = lbbs[i];
312 salcianu 1.1.2.9                  // visit l2b[i] and set lbbs[i].next
313 salcianu 1.1.2.9                  l2b[i].accept(visitor);
314 salcianu 1.1.2.1              }
315 salcianu 1.1.2.9          }
316 salcianu 1.1.2.1  
317 salcianu 1.1.2.9          // set the successors for the code views with explicit
318 salcianu 1.1.2.9          // treatment of exception; straightforward
319 salcianu 1.1.2.9          private void set_prev(final Map b2l, final BasicBlockInterf[] l2b) {
320 salcianu 1.1.2.9  
321 salcianu 1.1.2.9              class BBInterfVisitorPrev extends BasicBlockInterfVisitor {
322 salcianu 1.1.2.9  
323 salcianu 1.1.2.9                  LightBasicBlock lbb = null;
324 salcianu 1.1.2.9                  
325 salcianu 1.1.2.9                  public void visit(BasicBlock bb) {
326 salcianu 1.1.2.9                      LightBasicBlock[] lprev = 
327 salcianu 1.1.2.9                          new LightBasicBlock[bb.prevLength()];
328 salcianu 1.1.2.9                      
329 salcianu 1.1.2.9                      int k = 0;
330 salcianu 1.1.2.9                      for(Iterator it = bb.prevSet().iterator();
331 salcianu 1.1.2.9                          it.hasNext(); k++)
332 salcianu 1.1.2.9                          lprev[k] = (LightBasicBlock) b2l.get(it.next());
333 salcianu 1.1.2.9                      
334 salcianu 1.1.2.9                      lbb.protectedStartIndex = k;
335 salcianu 1.1.2.9                      // no protected set
336 salcianu 1.1.2.9                      lbb.prev = lprev;
337 salcianu 1.1.2.9                  }
338 salcianu 1.1.2.9                  
339 salcianu 1.1.2.9                  public void visit(FCFGBasicBlock bb) {
340 salcianu 1.1.2.9                      LightBasicBlock[] lprev = 
341 salcianu 1.1.2.9                          new LightBasicBlock[bb.normalPrevSet().size() + 
342 salcianu 1.1.2.9                                             bb.protectedSet().size()];
343 salcianu 1.1.2.9                      int k = 0;
344 salcianu 1.1.2.9                      for(Iterator it = bb.normalPrevSet().iterator();
345 salcianu 1.1.2.9                          it.hasNext(); k++)
346 salcianu 1.1.2.9                          lprev[k] = (LightBasicBlock) b2l.get(it.next());
347 salcianu 1.1.2.9                      
348 salcianu 1.1.2.9                      lbb.protectedStartIndex = k;
349 salcianu 1.1.2.9                      for(Iterator it = bb.protectedSet().iterator();
350 salcianu 1.1.2.9                          it.hasNext(); k++)
351 salcianu 1.1.2.9                          lprev[k] = (LightBasicBlock) b2l.get(it.next());
352 salcianu 1.1.2.9                      
353 salcianu 1.1.2.9                      lbb.prev = lprev;
354 salcianu 1.1.2.9                  }
355 salcianu 1.1.2.9                  
356 salcianu 1.1.2.9                  public void visit(BasicBlockInterf bb) {
357 cananian 1.3.2.1                      assert false : "Unknown BasicBlockInterf!";
358 salcianu 1.1.2.9                  }
359 salcianu 1.1.2.9              };
360 salcianu 1.1.2.9              
361 salcianu 1.1.2.9              BBInterfVisitorPrev visitor = new BBInterfVisitorPrev();
362 salcianu 1.1.2.9  
363 salcianu 1.1.2.9              for(int i = 0; i < lbbs.length; i++) {
364 salcianu 1.1.2.9                  // lbbs[i] is the ith basic block,
365 salcianu 1.1.2.9                  // l2b[i] is the corresponding light basic block
366 salcianu 1.1.2.9                  visitor.lbb = lbbs[i];
367 salcianu 1.1.2.9                  // visit l2b[i] and set lbbs[i].prev
368 salcianu 1.1.2.9                  l2b[i].accept(visitor);
369 salcianu 1.1.2.9              }
370 salcianu 1.1.2.1          }
371 salcianu 1.1.2.1  
372 salcianu 1.1.2.1      }
373 salcianu 1.1.2.1  
374 cananian 1.2      }