Mercurial > hg > graal-compiler
annotate graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java @ 2741:a3cd5eb68837
more GraphBuilder cleanup, moved mergeOrClone to GraphBuilder
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 20 May 2011 11:11:33 +0200 |
parents | a2f62de90c76 |
children | 99c84a06bb64 |
rev | line source |
---|---|
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
1 /* |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
4 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
8 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
13 * accompanied this code). |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
14 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
18 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
21 * questions. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
22 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
23 package com.sun.c1x.value; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
24 |
2731
a2f62de90c76
Removed unused optimization settings. Removed unused imports.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2728
diff
changeset
|
25 import static com.sun.c1x.value.ValueUtil.*; |
a2f62de90c76
Removed unused optimization settings. Removed unused imports.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2728
diff
changeset
|
26 |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
27 import java.util.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
28 |
2603 | 29 import com.oracle.graal.graph.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
30 import com.sun.c1x.*; |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
31 import com.sun.c1x.debug.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
32 import com.sun.c1x.ir.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
33 import com.sun.cri.ci.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
34 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
35 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
36 * The {@code FrameState} class encapsulates the frame state (i.e. local variables and |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
37 * operand stack) at a particular point in the abstract interpretation. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
38 */ |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
39 public class FrameState extends Value implements FrameStateAccess { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
40 |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
41 protected final int localsSize; |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
42 |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
43 protected final int stackSize; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
44 |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
45 protected final int locksSize; |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
46 |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
47 private static final int SUCCESSOR_COUNT = 0; |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
48 |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
49 @Override |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
50 protected int inputCount() { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
51 return super.inputCount() + localsSize + stackSize + locksSize; |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
52 } |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
53 |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
54 @Override |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
55 protected int successorCount() { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
56 return super.successorCount() + SUCCESSOR_COUNT; |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
57 } |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
58 |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
59 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
60 * The bytecode index to which this frame state applies. This will be {@code -1} |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
61 * iff this state is mutable. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
62 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
63 public final int bci; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
64 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
65 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
66 * Creates a {@code FrameState} for the given scope and maximum number of stack and local variables. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
67 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
68 * @param bci the bytecode index of the frame state |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
69 * @param localsSize number of locals |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
70 * @param stackSize size of the stack |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
71 * @param lockSize number of locks |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
72 */ |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
73 public FrameState(int bci, int localsSize, int stackSize, int locksSize, Graph graph) { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
74 super(CiKind.Illegal, localsSize + stackSize + locksSize, SUCCESSOR_COUNT, graph); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
75 this.bci = bci; |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
76 this.localsSize = localsSize; |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
77 this.stackSize = stackSize; |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
78 this.locksSize = locksSize; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
79 C1XMetrics.FrameStatesCreated++; |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
80 C1XMetrics.FrameStateValuesCreated += localsSize + stackSize + locksSize; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
81 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
82 |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
83 FrameState(int bci, Value[] locals, Value[] stack, int stackSize, ArrayList<Value> locks, Graph graph) { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
84 this(bci, locals.length, stackSize, locks.size(), graph); |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
85 for (int i = 0; i < locals.length; i++) { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
86 inputs().set(i, locals[i]); |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
87 } |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
88 for (int i = 0; i < stackSize; i++) { |
2666
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
89 inputs().set(localsSize + i, stack[i]); |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
90 } |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
91 for (int i = 0; i < locks.size(); i++) { |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
92 inputs().set(locals.length + stackSize + i, locks.get(i)); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
93 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
94 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
95 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
96 /** |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
97 * Gets a copy of this frame state. |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
98 */ |
2636
8c02ca1e9eb1
Fixed bci for stateBefore in BlockBegin
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2630
diff
changeset
|
99 public FrameState duplicate(int bci) { |
8c02ca1e9eb1
Fixed bci for stateBefore in BlockBegin
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2630
diff
changeset
|
100 FrameState other = copy(bci); |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
101 other.inputs().setAll(inputs()); |
2610
39aa89baa165
cleanup: FrameState copy methods, ImmutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2603
diff
changeset
|
102 return other; |
39aa89baa165
cleanup: FrameState copy methods, ImmutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2603
diff
changeset
|
103 } |
39aa89baa165
cleanup: FrameState copy methods, ImmutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2603
diff
changeset
|
104 |
39aa89baa165
cleanup: FrameState copy methods, ImmutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2603
diff
changeset
|
105 /** |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
106 * Gets a copy of this frame state without the stack. |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
107 */ |
2707
7ed72769d51a
exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2668
diff
changeset
|
108 @Override |
7ed72769d51a
exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2668
diff
changeset
|
109 public FrameState duplicateWithEmptyStack(int bci) { |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
110 FrameState other = new FrameState(bci, localsSize, 0, locksSize(), graph()); |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
111 for (int i = 0; i < localsSize; i++) { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
112 other.inputs().set(i, localAt(i)); |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
113 } |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
114 for (int i = 0; i < locksSize; i++) { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
115 other.inputs().set(localsSize + i, lockAt(i)); |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
116 } |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
117 return other; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
118 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
119 |
2666
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
120 /** |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
121 * Creates a copy of this frame state with one stack element of type popKind popped from the stack and the |
2668
32e8315bb6e4
fixed slot encoding in duplicateModified
Lukas Stadler <lukas.stadler@jku.at>
parents:
2666
diff
changeset
|
122 * values in pushedValues pushed on the stack. The pushedValues are expected to be in slot encoding: a long |
32e8315bb6e4
fixed slot encoding in duplicateModified
Lukas Stadler <lukas.stadler@jku.at>
parents:
2666
diff
changeset
|
123 * or double is followed by a null slot. |
2666
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
124 */ |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
125 public FrameState duplicateModified(int bci, CiKind popKind, Value... pushedValues) { |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
126 int popSlots = popKind.sizeInSlots(); |
2668
32e8315bb6e4
fixed slot encoding in duplicateModified
Lukas Stadler <lukas.stadler@jku.at>
parents:
2666
diff
changeset
|
127 int pushSlots = pushedValues.length; |
2666
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
128 FrameState other = new FrameState(bci, localsSize, stackSize - popSlots + pushSlots, locksSize(), graph()); |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
129 for (int i = 0; i < localsSize; i++) { |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
130 other.inputs().set(i, localAt(i)); |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
131 } |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
132 for (int i = 0; i < stackSize - popSlots; i++) { |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
133 other.inputs().set(localsSize + i, stackAt(i)); |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
134 } |
2668
32e8315bb6e4
fixed slot encoding in duplicateModified
Lukas Stadler <lukas.stadler@jku.at>
parents:
2666
diff
changeset
|
135 int slot = localsSize + stackSize - popSlots; |
32e8315bb6e4
fixed slot encoding in duplicateModified
Lukas Stadler <lukas.stadler@jku.at>
parents:
2666
diff
changeset
|
136 for (int i = 0; i < pushSlots; i++) { |
32e8315bb6e4
fixed slot encoding in duplicateModified
Lukas Stadler <lukas.stadler@jku.at>
parents:
2666
diff
changeset
|
137 other.inputs().set(slot++, pushedValues[i]); |
2666
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
138 } |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
139 for (int i = 0; i < locksSize; i++) { |
2668
32e8315bb6e4
fixed slot encoding in duplicateModified
Lukas Stadler <lukas.stadler@jku.at>
parents:
2666
diff
changeset
|
140 other.inputs().set(localsSize + other.stackSize + i, lockAt(i)); |
2666
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
141 } |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
142 return other; |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
143 } |
6ca76b891d31
duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents:
2636
diff
changeset
|
144 |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
145 public boolean isCompatibleWith(FrameStateAccess other) { |
2581
4a36a0bd6d18
added GraalGraph to classpath, Node as superclass of Value
Lukas Stadler <lukas.stadler@jku.at>
parents:
2570
diff
changeset
|
146 if (stackSize() != other.stackSize() || localsSize() != other.localsSize() || locksSize() != other.locksSize()) { |
4a36a0bd6d18
added GraalGraph to classpath, Node as superclass of Value
Lukas Stadler <lukas.stadler@jku.at>
parents:
2570
diff
changeset
|
147 return false; |
4a36a0bd6d18
added GraalGraph to classpath, Node as superclass of Value
Lukas Stadler <lukas.stadler@jku.at>
parents:
2570
diff
changeset
|
148 } |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
149 for (int i = 0; i < stackSize(); i++) { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
150 Value x = stackAt(i); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
151 Value y = other.stackAt(i); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
152 if (x != y && typeMismatch(x, y)) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
153 return false; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
154 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
155 } |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
156 for (int i = 0; i < locksSize(); i++) { |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
157 if (lockAt(i) != other.lockAt(i)) { |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
158 return false; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
159 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
160 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
161 return true; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
162 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
163 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
164 /** |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
165 * Gets the size of the local variables. |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
166 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
167 public int localsSize() { |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
168 return localsSize; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
169 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
170 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
171 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
172 * Gets the current size (height) of the stack. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
173 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
174 public int stackSize() { |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
175 return stackSize; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
176 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
177 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
178 /** |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
179 * Gets number of locks held by this frame state. |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
180 */ |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
181 public int locksSize() { |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
182 return locksSize; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
183 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
184 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
185 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
186 * Invalidates the local variable at the specified index. If the specified index refers to a doubleword local, then |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
187 * invalidates the high word as well. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
188 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
189 * @param i the index of the local to invalidate |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
190 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
191 public void invalidateLocal(int i) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
192 // note that for double word locals, the high slot should already be null |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
193 // unless the local is actually dead and the high slot is being reused; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
194 // in either case, it is not necessary to null the high slot |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
195 inputs().set(i, null); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
196 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
197 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
198 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
199 * Stores a given local variable at the specified index. If the value is a {@linkplain CiKind#isDoubleWord() double word}, |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
200 * then the next local variable index is also overwritten. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
201 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
202 * @param i the index at which to store |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
203 * @param x the instruction which produces the value for the local |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
204 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
205 public void storeLocal(int i, Value x) { |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
206 assert i < localsSize : "local variable index out of range: " + i; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
207 invalidateLocal(i); |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
208 inputs().set(i, x); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
209 if (isDoubleWord(x)) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
210 // (tw) if this was a double word then kill i+1 |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
211 inputs().set(i + 1, null); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
212 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
213 if (i > 0) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
214 // if there was a double word at i - 1, then kill it |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
215 Value p = localAt(i - 1); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
216 if (isDoubleWord(p)) { |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
217 inputs().set(i - 1, null); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
218 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
219 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
220 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
221 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
222 /** |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
223 * Gets the value in the local variables at the specified index. |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
224 * |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
225 * @param i the index into the locals |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
226 * @return the instruction that produced the value for the specified local |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
227 */ |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
228 public final Value localAt(int i) { |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
229 assert i < localsSize : "local variable index out of range: " + i; |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
230 return (Value) inputs().get(i); |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
231 } |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
232 |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
233 /** |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
234 * Get the value on the stack at the specified stack index. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
235 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
236 * @param i the index into the stack, with {@code 0} being the bottom of the stack |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
237 * @return the instruction at the specified position in the stack |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
238 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
239 public final Value stackAt(int i) { |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
240 assert i >= 0 && i < (localsSize + stackSize); |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
241 return (Value) inputs().get(localsSize + i); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
242 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
243 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
244 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
245 * Retrieves the lock at the specified index in the lock stack. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
246 * @param i the index into the lock stack |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
247 * @return the instruction which produced the object at the specified location in the lock stack |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
248 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
249 public final Value lockAt(int i) { |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
250 assert i >= 0; |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
251 return (Value) inputs().get(localsSize + stackSize + i); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
252 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
253 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
254 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
255 * Inserts a phi statement into the stack at the specified stack index. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
256 * @param block the block begin for which we are creating the phi |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
257 * @param i the index into the stack for which to create a phi |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
258 */ |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
259 public void setupPhiForStack(BlockBegin block, int i) { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
260 Value p = stackAt(i); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
261 if (p != null) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
262 if (p instanceof Phi) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
263 Phi phi = (Phi) p; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
264 if (phi.block() == block && phi.isOnStack() && phi.stackIndex() == i) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
265 return; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
266 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
267 } |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
268 inputs().set(localsSize + i, new Phi(p.kind, block, -i - 1, graph())); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
269 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
270 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
271 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
272 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
273 * Inserts a phi statement for the local at the specified index. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
274 * @param block the block begin for which we are creating the phi |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
275 * @param i the index of the local variable for which to create the phi |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
276 */ |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
277 public void setupPhiForLocal(BlockBegin block, int i) { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
278 Value p = localAt(i); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
279 if (p instanceof Phi) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
280 Phi phi = (Phi) p; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
281 if (phi.block() == block && phi.isLocal() && phi.localIndex() == i) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
282 return; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
283 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
284 } |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
285 storeLocal(i, new Phi(p.kind, block, i, graph())); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
286 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
287 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
288 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
289 * Gets the value at a specified index in the set of operand stack and local values represented by this frame. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
290 * This method should only be used to iterate over all the values in this frame, irrespective of whether |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
291 * they are on the stack or in local variables. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
292 * To iterate the stack slots, the {@link #stackAt(int)} and {@link #stackSize()} methods should be used. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
293 * To iterate the local variables, the {@link #localAt(int)} and {@link #localsSize()} methods should be used. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
294 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
295 * @param i a value in the range {@code [0 .. valuesSize()]} |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
296 * @return the value at index {@code i} which may be {@code null} |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
297 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
298 public final Value valueAt(int i) { |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
299 assert i < (localsSize + stackSize); |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
300 return (Value) inputs().get(i); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
301 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
302 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
303 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
304 * The number of operand stack slots and local variables in this frame. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
305 * This method should typically only be used in conjunction with {@link #valueAt(int)}. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
306 * To iterate the stack slots, the {@link #stackAt(int)} and {@link #stackSize()} methods should be used. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
307 * To iterate the local variables, the {@link #localAt(int)} and {@link #localsSize()} methods should be used. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
308 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
309 * @return the number of local variables in this frame |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
310 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
311 public final int valuesSize() { |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
312 return localsSize + stackSize; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
313 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
314 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
315 public void checkPhis(BlockBegin block, FrameState other) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
316 checkSize(other); |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
317 for (int i = 0; i < valuesSize(); i++) { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
318 Value x = valueAt(i); |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
319 Value y = other.valueAt(i); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
320 if (x != null && x != y) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
321 if (x instanceof Phi) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
322 Phi phi = (Phi) x; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
323 if (phi.block() == block) { |
2582
768d77a1c7af
new node layout: Instruction
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
324 for (int j = 0; j < phi.phiInputCount(); j++) { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
325 if (phi.inputIn(other) == null) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
326 throw new CiBailout("phi " + phi + " has null operand at new predecessor"); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
327 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
328 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
329 continue; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
330 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
331 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
332 throw new CiBailout("instruction is not a phi or null at " + i); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
333 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
334 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
335 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
336 |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
337 private void checkSize(FrameStateAccess other) { |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
338 if (other.stackSize() != stackSize()) { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
339 throw new CiBailout("stack sizes do not match"); |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
340 } else if (other.localsSize() != localsSize) { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
341 throw new CiBailout("local sizes do not match"); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
342 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
343 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
344 |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
345 public void merge(BlockBegin block, FrameStateAccess other) { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
346 checkSize(other); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
347 for (int i = 0; i < valuesSize(); i++) { |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
348 Value x = valueAt(i); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
349 if (x != null) { |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
350 Value y = other.valueAt(i); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
351 if (x != y) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
352 if (typeMismatch(x, y)) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
353 if (x instanceof Phi) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
354 Phi phi = (Phi) x; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
355 if (phi.block() == block) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
356 phi.makeDead(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
357 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
358 } |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
359 inputs().set(i, null); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
360 continue; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
361 } |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
362 if (i < localsSize) { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
363 // this a local |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
364 setupPhiForLocal(block, i); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
365 } else { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
366 // this is a stack slot |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
367 setupPhiForStack(block, i - localsSize); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
368 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
369 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
370 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
371 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
372 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
373 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
374 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
375 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
376 * The interface implemented by a client of {@link FrameState#forEachPhi(BlockBegin, PhiProcedure)} and |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
377 * {@link FrameState#forEachLivePhi(BlockBegin, PhiProcedure)}. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
378 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
379 public static interface PhiProcedure { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
380 boolean doPhi(Phi phi); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
381 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
382 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
383 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
384 * Checks whether this frame state has any {@linkplain Phi phi} statements. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
385 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
386 public boolean hasPhis() { |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
387 for (int i = 0; i < valuesSize(); i++) { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
388 Value value = valueAt(i); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
389 if (value instanceof Phi) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
390 return true; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
391 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
392 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
393 return false; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
394 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
395 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
396 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
397 * The interface implemented by a client of {@link FrameState#forEachLiveStateValue(ValueProcedure)}. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
398 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
399 public static interface ValueProcedure { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
400 void doValue(Value value); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
401 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
402 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
403 /** |
2570
46586c77b129
Cleaned some remaining references to scope/inlining
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2565
diff
changeset
|
404 * Traverses all {@linkplain Value#isLive() live values} of this frame state. |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
405 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
406 * @param proc the call back called to process each live value traversed |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
407 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
408 public final void forEachLiveStateValue(ValueProcedure proc) { |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
409 for (int i = 0; i < valuesSize(); i++) { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
410 Value value = valueAt(i); |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
411 if (value != null) { |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
412 proc.doValue(value); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
413 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
414 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
415 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
416 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
417 @Override |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
418 public String toString() { |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
419 StringBuilder sb = new StringBuilder(); |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
420 String nl = String.format("%n"); |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
421 sb.append("[bci: ").append(bci).append("]").append(nl); |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
422 for (int i = 0; i < localsSize(); ++i) { |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
423 Value value = localAt(i); |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
424 sb.append(String.format(" local[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value)); |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
425 } |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
426 for (int i = 0; i < stackSize(); ++i) { |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
427 Value value = stackAt(i); |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
428 sb.append(String.format(" stack[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value)); |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
429 } |
2611
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
430 for (int i = 0; i < locksSize(); ++i) { |
bd235cb4375a
FrameState cleanup: split into FrameStateBuilder and fixed-size FrameState, removed MutableFrameState
Lukas Stadler <lukas.stadler@jku.at>
parents:
2610
diff
changeset
|
431 Value value = lockAt(i); |
2564
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
432 sb.append(String.format(" lock[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value)); |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
433 } |
274360f98f97
Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2546
diff
changeset
|
434 return sb.toString(); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
435 } |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
436 |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
437 @Override |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
438 public BlockBegin block() { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
439 return null; |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
440 } |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
441 |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
442 @Override |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
443 public void accept(ValueVisitor v) { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
444 v.visitFrameState(this); |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
445 } |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
446 |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
447 @Override |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
448 public void print(LogStream out) { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
449 out.print("FrameState"); |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
450 } |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
451 |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
452 @Override |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
453 public FrameState copy() { |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
454 return new FrameState(bci, localsSize, stackSize, locksSize, graph()); |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
455 } |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2611
diff
changeset
|
456 |
2636
8c02ca1e9eb1
Fixed bci for stateBefore in BlockBegin
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2630
diff
changeset
|
457 |
8c02ca1e9eb1
Fixed bci for stateBefore in BlockBegin
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2630
diff
changeset
|
458 private FrameState copy(int newBci) { |
8c02ca1e9eb1
Fixed bci for stateBefore in BlockBegin
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2630
diff
changeset
|
459 return new FrameState(newBci, localsSize, stackSize, locksSize, graph()); |
8c02ca1e9eb1
Fixed bci for stateBefore in BlockBegin
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2630
diff
changeset
|
460 } |
8c02ca1e9eb1
Fixed bci for stateBefore in BlockBegin
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2630
diff
changeset
|
461 |
2621
dd115f80acf8
changed stateAfter FrameState to successor (instead of input), checkstyle fixes, added fixed root node to graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2616
diff
changeset
|
462 @Override |
dd115f80acf8
changed stateAfter FrameState to successor (instead of input), checkstyle fixes, added fixed root node to graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2616
diff
changeset
|
463 public String shortName() { |
dd115f80acf8
changed stateAfter FrameState to successor (instead of input), checkstyle fixes, added fixed root node to graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2616
diff
changeset
|
464 return "FrameState@" + bci; |
dd115f80acf8
changed stateAfter FrameState to successor (instead of input), checkstyle fixes, added fixed root node to graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2616
diff
changeset
|
465 } |
dd115f80acf8
changed stateAfter FrameState to successor (instead of input), checkstyle fixes, added fixed root node to graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
2616
diff
changeset
|
466 |
2630
c93adece95d2
Small clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2621
diff
changeset
|
467 public void visitFrameState(FrameState i) { |
c93adece95d2
Small clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2621
diff
changeset
|
468 // nothing to do for now |
c93adece95d2
Small clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2621
diff
changeset
|
469 } |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
470 } |