In preparation for collapsing BindInstr/DoInstr and flattening
Computations into the Instruction hierarchy.
Add a pair of functions EffectGraphVisitor::Bind and
EffectGraphVisitor::Do for adding computations to the flow graph that
have respectively one and zero uses. This creates a single site where
we construct new BindInstr and a single site where we construct new
DoInstr (also, a single site where we construct new UseVal during flow
graph construction).
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com//10702092
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9407 260f80e4-7a28-3924-810f-c04153c831b5
Each fixed parameter is initially defined by a ParameterInstr as definition. This
definition is not in the instruction stream, but just in the initial environment
at the graph entry so that the live range of all parameters start at the same point.
The pre-order spanning tree was computed in the wrong way which caused test failures
when building SSA because renaming relies on the dominator tree which depends on
the preorder spanning tree.
Also change the IL printing functions to be more compatible with the visualizer tool.
Review URL: https://chromiumcodereview.appspot.com//10735002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9391 260f80e4-7a28-3924-810f-c04153c831b5
Each instruction that can deoptimize need to have the values of the
non-optimizing code as uses. The values are stored in an environment
(GrowableArray<Value*>) attached to the instruction when constructing
SSA form.
For now every instructions gets a deoptimization environment. It contains
the values of all locals, parameters and expression stack elements at
the start of the instruction.
The environment is not used yet, but can be printed in the flow graph
with the flag --print-environments.
Review URL: https://chromiumcodereview.appspot.com//10696090
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9345 260f80e4-7a28-3924-810f-c04153c831b5
The helper function RemoveFromGraph resets previous and next instruction pointers to NULL
when deleting an instruction.
I changed it to return the successor of the removed instruction so that the function is
more convenient to use while iterating over the list of instructions.
Review URL: https://chromiumcodereview.appspot.com//10692072
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9332 260f80e4-7a28-3924-810f-c04153c831b5
In order to be able to efficiently iterate backwards over instructions
and removing or replacing instructions in the graph we want them to
be a double-linked list inside basic blocks. The list has the following
1. Block entry instructions do not have a previous instruction.
2. The last instruction in a block may or may not have a next instruction:
- Branches have a NULL-successor.
- Normal block exits have a block entry instructions as successor.
This CL also makes the accessor for previous and next instruction in this
list non-virtual. This avoidis the current code duplication there.
Review URL: https://chromiumcodereview.appspot.com//10665022
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9297 260f80e4-7a28-3924-810f-c04153c831b5
This CL changes the order of step 2a and 2b in the SSA renaming: Uses of
LoadLocal/StoreLocal must be renamed first so that the environment is correctly
updated for StoreLocal instructions.
A simple example showing the bug:
test_xy() {
var x = 1;
var y = 2;
var z = 3;
for (var i = 0; i < 5; i++) {
y = z = x;
x++;
}
return x + y + z;
}
Also in this change:
- changed the printing of SSA operands to v0, v1, .. instead
of t0, t1 to better distinguish them from non-SSA operands.
- make sure that UseVal are always copied when renaming phi
input operands.
Review URL: https://chromiumcodereview.appspot.com//10583014
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8893 260f80e4-7a28-3924-810f-c04153c831b5
This CL adds the renaming step to the SSA construction. The renaming pass
initializes a start environment with the initial values of all locals (#null)
and parameters and removes LoadLocal and StoreLocal instructions from the
graph.
Right now the renaming does not support functions with parameters yet.
I added a TODO for this. The SSA form for a simple function with an if-statement:
function foo() {
var v = 0;
var x;
if (v == 0) {
x = 42;
}
return x;
}
looks as follows:
0: [graph]
#null
#null
1: [target]
t0 <- #0
t1 <- #null
t2 <- #0
t3 <- EqualityCompare(t0 == t2)
Branch if t3 goto (2, 3)
2: [target]
t5 <- #42 goto 4
3: [target] goto 4
4: [join]
t4 <- phi(t1,t5)
Return t4
Review URL: https://chromiumcodereview.appspot.com//10544206
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8839 260f80e4-7a28-3924-810f-c04153c831b5
This CL contains the phi insertion step of the SSA construction algorithmus: The phi instructions inserted are not functional yet. Renaming is not included yet.
I based it on Kevin's CL (http://codereview.chromium.org/10388161/), rebased and fixed a bug (added missing iterator.Advance()) there.
It also reintroduces the Definition IL class because Phi-instructions are also
definitions that are referenced by UseVal.
I also added the set of immediately dominated blocks to each basic block.
This will be needed for pre-order dominator-tree traversal in the renaming pass.
Review URL: https://chromiumcodereview.appspot.com//10539108
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8604 260f80e4-7a28-3924-810f-c04153c831b5
This change refactors printing function for instructions
so that they can be used for different purposes like
printing to stdout (what FlowGraphPrinter currently does),
creating code comments for the disassembler, or in the future
dumping the IR into a file.
I added an abstract interface to iterate over the inputs
of an computation: InputCount and InputAt. This is only
an intermediate step likely to change in the future. For
that I had to bring back the [] operator for zero-operand
instructions.
Review URL: https://chromiumcodereview.appspot.com//10407031
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7731 260f80e4-7a28-3924-810f-c04153c831b5