Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java @ 2842:7596ae867a7b
basic inlining passes all tests, including optimistic inlining
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 01 Jun 2011 16:26:17 +0200 |
parents | 75e0d39833a0 |
children | 14708c03abba |
comparison
equal
deleted
inserted
replaced
2841:633e66de40fe | 2842:7596ae867a7b |
---|---|
29 import com.oracle.graal.graph.*; | 29 import com.oracle.graal.graph.*; |
30 import com.sun.c1x.*; | 30 import com.sun.c1x.*; |
31 import com.sun.c1x.debug.*; | 31 import com.sun.c1x.debug.*; |
32 import com.sun.c1x.ir.*; | 32 import com.sun.c1x.ir.*; |
33 import com.sun.cri.ci.*; | 33 import com.sun.cri.ci.*; |
34 import com.sun.cri.ri.*; | |
34 | 35 |
35 /** | 36 /** |
36 * The {@code FrameState} class encapsulates the frame state (i.e. local variables and | 37 * The {@code FrameState} class encapsulates the frame state (i.e. local variables and |
37 * operand stack) at a particular point in the abstract interpretation. | 38 * operand stack) at a particular point in the abstract interpretation. |
38 */ | 39 */ |
58 @Override | 59 @Override |
59 protected int successorCount() { | 60 protected int successorCount() { |
60 return super.successorCount() + SUCCESSOR_COUNT; | 61 return super.successorCount() + SUCCESSOR_COUNT; |
61 } | 62 } |
62 | 63 |
63 public Value outerFrameState() { | 64 public FrameState outerFrameState() { |
64 return (Value) inputs().get(super.inputCount() + INPUT_OUTER_FRAME_STATE); | 65 return (FrameState) inputs().get(super.inputCount() + INPUT_OUTER_FRAME_STATE); |
65 } | 66 } |
66 | 67 |
67 public Value setOuterFrameState(Value n) { | 68 public FrameState setOuterFrameState(FrameState n) { |
68 assert n == null || n.kind == CiKind.Object; | 69 return (FrameState) inputs().set(super.inputCount() + INPUT_OUTER_FRAME_STATE, n); |
69 return (Value) inputs().set(super.inputCount() + INPUT_OUTER_FRAME_STATE, n); | |
70 } | 70 } |
71 | 71 |
72 @Override | 72 @Override |
73 public void setValueAt(int i, Value x) { | 73 public void setValueAt(int i, Value x) { |
74 inputs().set(INPUT_COUNT + i, x); | 74 inputs().set(INPUT_COUNT + i, x); |
77 /** | 77 /** |
78 * The bytecode index to which this frame state applies. This will be {@code -1} | 78 * The bytecode index to which this frame state applies. This will be {@code -1} |
79 * iff this state is mutable. | 79 * iff this state is mutable. |
80 */ | 80 */ |
81 public final int bci; | 81 public final int bci; |
82 | |
83 public final RiMethod method; | |
82 | 84 |
83 /** | 85 /** |
84 * Creates a {@code FrameState} for the given scope and maximum number of stack and local variables. | 86 * Creates a {@code FrameState} for the given scope and maximum number of stack and local variables. |
85 * | 87 * |
86 * @param bci the bytecode index of the frame state | 88 * @param bci the bytecode index of the frame state |
87 * @param localsSize number of locals | 89 * @param localsSize number of locals |
88 * @param stackSize size of the stack | 90 * @param stackSize size of the stack |
89 * @param lockSize number of locks | 91 * @param lockSize number of locks |
90 */ | 92 */ |
91 public FrameState(int bci, int localsSize, int stackSize, int locksSize, Graph graph) { | 93 public FrameState(RiMethod method, int bci, int localsSize, int stackSize, int locksSize, Graph graph) { |
92 super(CiKind.Illegal, localsSize + stackSize + locksSize + INPUT_COUNT, SUCCESSOR_COUNT, graph); | 94 super(CiKind.Illegal, localsSize + stackSize + locksSize + INPUT_COUNT, SUCCESSOR_COUNT, graph); |
95 this.method = method; | |
93 this.bci = bci; | 96 this.bci = bci; |
94 this.localsSize = localsSize; | 97 this.localsSize = localsSize; |
95 this.stackSize = stackSize; | 98 this.stackSize = stackSize; |
96 this.locksSize = locksSize; | 99 this.locksSize = locksSize; |
97 C1XMetrics.FrameStatesCreated++; | 100 C1XMetrics.FrameStatesCreated++; |
98 C1XMetrics.FrameStateValuesCreated += localsSize + stackSize + locksSize; | 101 C1XMetrics.FrameStateValuesCreated += localsSize + stackSize + locksSize; |
99 } | 102 } |
100 | 103 |
101 FrameState(int bci, Value[] locals, Value[] stack, int stackSize, ArrayList<Value> locks, Graph graph) { | 104 FrameState(RiMethod method, int bci, Value[] locals, Value[] stack, int stackSize, ArrayList<Value> locks, Graph graph) { |
102 this(bci, locals.length, stackSize, locks.size(), graph); | 105 this(method, bci, locals.length, stackSize, locks.size(), graph); |
103 for (int i = 0; i < locals.length; i++) { | 106 for (int i = 0; i < locals.length; i++) { |
104 setValueAt(i, locals[i]); | 107 setValueAt(i, locals[i]); |
105 } | 108 } |
106 for (int i = 0; i < stackSize; i++) { | 109 for (int i = 0; i < stackSize; i++) { |
107 setValueAt(localsSize + i, stack[i]); | 110 setValueAt(localsSize + i, stack[i]); |
123 /** | 126 /** |
124 * Gets a copy of this frame state without the stack. | 127 * Gets a copy of this frame state without the stack. |
125 */ | 128 */ |
126 @Override | 129 @Override |
127 public FrameState duplicateWithEmptyStack(int bci) { | 130 public FrameState duplicateWithEmptyStack(int bci) { |
128 FrameState other = new FrameState(bci, localsSize, 0, locksSize(), graph()); | 131 FrameState other = new FrameState(method, bci, localsSize, 0, locksSize(), graph()); |
129 for (int i = 0; i < localsSize; i++) { | 132 for (int i = 0; i < localsSize; i++) { |
130 other.setValueAt(i, localAt(i)); | 133 other.setValueAt(i, localAt(i)); |
131 } | 134 } |
132 for (int i = 0; i < locksSize; i++) { | 135 for (int i = 0; i < locksSize; i++) { |
133 other.setValueAt(localsSize + i, lockAt(i)); | 136 other.setValueAt(localsSize + i, lockAt(i)); |
142 * or double is followed by a null slot. | 145 * or double is followed by a null slot. |
143 */ | 146 */ |
144 public FrameState duplicateModified(int bci, CiKind popKind, Value... pushedValues) { | 147 public FrameState duplicateModified(int bci, CiKind popKind, Value... pushedValues) { |
145 int popSlots = popKind.sizeInSlots(); | 148 int popSlots = popKind.sizeInSlots(); |
146 int pushSlots = pushedValues.length; | 149 int pushSlots = pushedValues.length; |
147 FrameState other = new FrameState(bci, localsSize, stackSize - popSlots + pushSlots, locksSize(), graph()); | 150 FrameState other = new FrameState(method, bci, localsSize, stackSize - popSlots + pushSlots, locksSize(), graph()); |
148 for (int i = 0; i < localsSize; i++) { | 151 for (int i = 0; i < localsSize; i++) { |
149 other.setValueAt(i, localAt(i)); | 152 other.setValueAt(i, localAt(i)); |
150 } | 153 } |
151 for (int i = 0; i < stackSize - popSlots; i++) { | 154 for (int i = 0; i < stackSize - popSlots; i++) { |
152 other.setValueAt(localsSize + i, stackAt(i)); | 155 other.setValueAt(localsSize + i, stackAt(i)); |
401 } | 404 } |
402 } | 405 } |
403 } | 406 } |
404 | 407 |
405 public Merge block() { | 408 public Merge block() { |
406 if (usages().size() > 0) { | 409 for (Node usage : usages()) { |
407 assert usages().size() == 1; | 410 if (usage instanceof Merge) { |
408 Node node = usages().get(0); | 411 return (Merge) usage; |
409 if (node instanceof Merge) { | |
410 return (Merge) node; | |
411 } | 412 } |
412 } | 413 } |
413 return null; | 414 return null; |
414 } | 415 } |
415 | 416 |
450 for (int i = 0; i < valuesSize(); i++) { | 451 for (int i = 0; i < valuesSize(); i++) { |
451 Value value = valueAt(i); | 452 Value value = valueAt(i); |
452 if (value != null) { | 453 if (value != null) { |
453 proc.doValue(value); | 454 proc.doValue(value); |
454 } | 455 } |
456 } | |
457 if (outerFrameState() != null) { | |
458 outerFrameState().forEachLiveStateValue(proc); | |
455 } | 459 } |
456 } | 460 } |
457 | 461 |
458 @Override | 462 @Override |
459 public String toString() { | 463 public String toString() { |
485 out.print("FrameState"); | 489 out.print("FrameState"); |
486 } | 490 } |
487 | 491 |
488 @Override | 492 @Override |
489 public FrameState copy() { | 493 public FrameState copy() { |
490 return new FrameState(bci, localsSize, stackSize, locksSize, graph()); | 494 return new FrameState(method, bci, localsSize, stackSize, locksSize, graph()); |
491 } | 495 } |
492 | 496 |
493 | 497 |
494 private FrameState copy(int newBci) { | 498 private FrameState copy(int newBci) { |
495 return new FrameState(newBci, localsSize, stackSize, locksSize, graph()); | 499 return new FrameState(method, newBci, localsSize, stackSize, locksSize, graph()); |
496 } | 500 } |
497 | 501 |
498 @Override | 502 @Override |
499 public String shortName() { | 503 public String shortName() { |
500 return "FrameState@" + bci; | 504 return "FrameState@" + bci; |
504 // nothing to do for now | 508 // nothing to do for now |
505 } | 509 } |
506 | 510 |
507 @Override | 511 @Override |
508 public Node copy(Graph into) { | 512 public Node copy(Graph into) { |
509 FrameState x = new FrameState(bci, localsSize, stackSize, locksSize, into); | 513 FrameState x = new FrameState(method, bci, localsSize, stackSize, locksSize, into); |
510 x.setNonNull(isNonNull()); | 514 x.setNonNull(isNonNull()); |
511 return x; | 515 return x; |
512 } | 516 } |
513 } | 517 } |