Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java @ 2603:01c5c0443158
new node layout: Phi
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 06 May 2011 11:18:15 +0200 |
parents | 768d77a1c7af |
children | 39aa89baa165 |
comparison
equal
deleted
inserted
replaced
2602:0c6564c254af | 2603:01c5c0443158 |
---|---|
22 */ | 22 */ |
23 package com.sun.c1x.value; | 23 package com.sun.c1x.value; |
24 | 24 |
25 import java.util.*; | 25 import java.util.*; |
26 | 26 |
27 import com.oracle.graal.graph.*; | |
27 import com.sun.c1x.*; | 28 import com.sun.c1x.*; |
28 import com.sun.c1x.graph.*; | 29 import com.sun.c1x.graph.*; |
29 import com.sun.c1x.ir.*; | 30 import com.sun.c1x.ir.*; |
30 import com.sun.cri.ci.*; | 31 import com.sun.cri.ci.*; |
31 | 32 |
32 /** | 33 /** |
33 * The {@code FrameState} class encapsulates the frame state (i.e. local variables and | 34 * The {@code FrameState} class encapsulates the frame state (i.e. local variables and |
34 * operand stack) at a particular point in the abstract interpretation. | 35 * operand stack) at a particular point in the abstract interpretation. |
35 * | |
36 * @author Ben L. Titzer | |
37 */ | 36 */ |
38 public abstract class FrameState { | 37 public abstract class FrameState { |
39 | 38 |
40 /** | 39 /** |
41 * The operand stack and local variables. | 40 * The operand stack and local variables. |
295 | 294 |
296 /** | 295 /** |
297 * Inserts a phi statement into the stack at the specified stack index. | 296 * Inserts a phi statement into the stack at the specified stack index. |
298 * @param block the block begin for which we are creating the phi | 297 * @param block the block begin for which we are creating the phi |
299 * @param i the index into the stack for which to create a phi | 298 * @param i the index into the stack for which to create a phi |
300 */ | 299 * @param graph |
301 public void setupPhiForStack(BlockBegin block, int i) { | 300 */ |
301 public void setupPhiForStack(BlockBegin block, int i, Graph graph) { | |
302 Value p = stackAt(i); | 302 Value p = stackAt(i); |
303 if (p != null) { | 303 if (p != null) { |
304 if (p instanceof Phi) { | 304 if (p instanceof Phi) { |
305 Phi phi = (Phi) p; | 305 Phi phi = (Phi) p; |
306 if (phi.block() == block && phi.isOnStack() && phi.stackIndex() == i) { | 306 if (phi.block() == block && phi.isOnStack() && phi.stackIndex() == i) { |
307 return; | 307 return; |
308 } | 308 } |
309 } | 309 } |
310 values[maxLocals + i] = new Phi(p.kind, block, -i - 1); | 310 values[maxLocals + i] = new Phi(p.kind, block, -i - 1, graph); |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 /** | 314 /** |
315 * Inserts a phi statement for the local at the specified index. | 315 * Inserts a phi statement for the local at the specified index. |
316 * @param block the block begin for which we are creating the phi | 316 * @param block the block begin for which we are creating the phi |
317 * @param i the index of the local variable for which to create the phi | 317 * @param i the index of the local variable for which to create the phi |
318 */ | 318 * @param graph |
319 public void setupPhiForLocal(BlockBegin block, int i) { | 319 */ |
320 public void setupPhiForLocal(BlockBegin block, int i, Graph graph) { | |
320 Value p = values[i]; | 321 Value p = values[i]; |
321 if (p instanceof Phi) { | 322 if (p instanceof Phi) { |
322 Phi phi = (Phi) p; | 323 Phi phi = (Phi) p; |
323 if (phi.block() == block && phi.isLocal() && phi.localIndex() == i) { | 324 if (phi.block() == block && phi.isLocal() && phi.localIndex() == i) { |
324 return; | 325 return; |
325 } | 326 } |
326 } | 327 } |
327 storeLocal(i, new Phi(p.kind, block, i)); | 328 storeLocal(i, new Phi(p.kind, block, i, graph)); |
328 } | 329 } |
329 | 330 |
330 /** | 331 /** |
331 * Gets the value at a specified index in the set of operand stack and local values represented by this frame. | 332 * Gets the value at a specified index in the set of operand stack and local values represented by this frame. |
332 * This method should only be used to iterate over all the values in this frame, irrespective of whether | 333 * This method should only be used to iterate over all the values in this frame, irrespective of whether |
382 } else if (other.maxLocals != maxLocals) { | 383 } else if (other.maxLocals != maxLocals) { |
383 throw new CiBailout("local sizes do not match"); | 384 throw new CiBailout("local sizes do not match"); |
384 } | 385 } |
385 } | 386 } |
386 | 387 |
387 public void merge(BlockBegin block, FrameState other) { | 388 public void merge(BlockBegin block, FrameState other, Graph graph) { |
388 checkSize(other); | 389 checkSize(other); |
389 for (int i = 0; i < valuesSize(); i++) { | 390 for (int i = 0; i < valuesSize(); i++) { |
390 Value x = values[i]; | 391 Value x = values[i]; |
391 if (x != null) { | 392 if (x != null) { |
392 Value y = other.values[i]; | 393 Value y = other.values[i]; |
401 values[i] = null; | 402 values[i] = null; |
402 continue; | 403 continue; |
403 } | 404 } |
404 if (i < maxLocals) { | 405 if (i < maxLocals) { |
405 // this a local | 406 // this a local |
406 setupPhiForLocal(block, i); | 407 setupPhiForLocal(block, i, graph); |
407 } else { | 408 } else { |
408 // this is a stack slot | 409 // this is a stack slot |
409 setupPhiForStack(block, i - maxLocals); | 410 setupPhiForStack(block, i - maxLocals, graph); |
410 } | 411 } |
411 } | 412 } |
412 } | 413 } |
413 } | 414 } |
414 } | 415 } |