Commit Graph

14 Commits

Author SHA1 Message Date
kmillikin@google.com be9bc9c068 Compute immediate dominators using SEMI-NCA.
This is a version of the Lengauer-Tarjan algorithm that is both simpler and
faster.

R=srdjan@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9729015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5737 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-21 23:45:20 +00:00
kmillikin@google.com df6881a022 Do not use recursion for depth-first traversal of straight line code.
For straight-line sequences of intermediate instructions, use iteration in
the depth-first search implementation.

R=srdjan@google.com
BUG=
TEST=vm/CodeIndexTable should pass on x64

Review URL: https://chromiumcodereview.appspot.com//9732022

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5660 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-19 21:57:06 +00:00
kmillikin@google.com 7c43fbb9a3 Make the CFG depth-first traversal do more work for us.
Turn the depth-first traversal into a pass to discover the graph's basic
block structure.  Record basic-block predecessors in the block entry
instructions.  Also record the last instruction in a block in the block
entry instruction (giving constant-time access to the block's successors).

Also, record the depth-first spanning tree of the traversal to be used for
dominator computation.

R=srdjan@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9730003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5655 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-19 19:39:14 +00:00
kmillikin@google.com 6653fd66eb Compute preorder as well as postorder basic block orderings.
The Lengauer-Tarjan dominator/dominance frontier algorithm needs to
visit the blocks in reverse preorder (in the first pass) and preorder
(in the second).  Compute that at the same time as postorder (e.g.,
using the same spanning tree).

Take this chance to make the flow graph visitors always operate on a
forward block ordering.

R=srdjan@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9719003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5598 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-16 22:20:04 +00:00
srdjan@google.com b9ba050c9c Make Throw and ReThrow instructions instead of computations. That way they can terminate a basic block.
Review URL: https://chromiumcodereview.appspot.com//9699090

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5539 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-15 20:42:01 +00:00
srdjan@google.com fdb793e189 Add Throw and ReThrow nodes. Rethrow not yet tested (bailout with untested), since it needs the try/catch implementation. Discuss if Throw/ReThrow shoudl be computations or instructions. We have one case in parser where throw is added into the expression tree.
I suggest introducing an EndInstr that has no successor and use it for throw and return. (TODO: Discuss and chnage if necessary). Currently we generate code even after the throw.
Review URL: https://chromiumcodereview.appspot.com//9706032

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5490 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-14 21:47:43 +00:00
srdjan@google.com c333da7111 Implement logical AND/OR.
Review URL: https://chromiumcodereview.appspot.com//9649012

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5253 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-09 21:34:58 +00:00
kmillikin@google.com 01695137f8 Turn CopyTemp and SetTemp into instructions.
These were always used and assumed to be in a stylized form (CopyTemp in
Bind and SetTemp in Do).  Make this required by the IL.  This change allows
eliminating the relative indexing in favor of temporary names, without
restructuring the compiler at all.

R=srdjan@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9616005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5072 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-07 10:24:01 +00:00
kmillikin@google.com b565b15849 Expand the instruction visitor to visit computations and values.
For compilation passes we will want a visitor that can reach computations
and values, rather than virtual functions in the computation/value classes.
Implement the visitor signature and double dispatching.  Use it to remove
the virtual Print functions.

R=srdjan@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9471010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4664 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-28 08:58:49 +00:00
srdjan@google.com 397f15c454 Added LoadLiteralComp, StrictCompareComp; implement InstanceCallNode.
Review URL: https://chromiumcodereview.appspot.com//9456033

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4580 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-24 22:37:57 +00:00
kmillikin@google.com 023b02d54c Implement a simple InstructionVisitor class.
The instruction visitor visits each block and for each block each
instruction.  Rewrite the instruction printing code to use this new
visitor.

R=srdjan@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9453014

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4547 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-23 18:29:58 +00:00
kmillikin@google.com 164832b3a3 Add type testing and casting support.
Introduce a virtual tag() function to Instruction classes, use it to
implement type testing and casting.  Use type testing and casting to
eliminate some virtual functions on the instruction classes.

R=srdjan@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9454012

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4546 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-23 18:15:11 +00:00
kmillikin@google.com 392cdd56ef Recognize basic block entries in the flow graph.
Also, instead of keeping a list of all instructions, keep a list of only
block entries.  The printing implementation is changed (for the better) to
use the new representation.  With --use_new_compiler and --print_flow_graph
the function:

main() {
  var f = 1;
  var n = 5;
  while (n > 0) {
    f = f * n;
    n = n - 1;
  }
  print(f);
}

prints as:

 0: [target]
    StoreLocal(f, #1)
    StoreLocal(n, #5) goto 1
 1: [join]
    t0 <-LoadLocal(n)
    t0 <-InstanceCall(>, t0, #0)
    if t0 goto(2, 3)
 2: [target]
    t0 <-LoadLocal(f)
    t1 <-LoadLocal(n)
    t0 <-InstanceCall(*, t0, t1)
    StoreLocal(f, t0)
    t0 <-LoadLocal(n)
    t0 <-InstanceCall(-, t0, #1)
    StoreLocal(n, t0) goto 1
 3: [target]
    t0 <-LoadLocal(f)
    StaticCall(print, t0)
    return #null

R=srdjan@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9429056

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4515 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-23 09:09:45 +00:00
kmillikin@google.com 41e77a0a9e Initial implementation of a flow-graph builder for Dart's AST.
Visit the AST and generate an instruction (ie, not basic-block) flow
graph.

The flow graph for the simple function:

main() {
  var f = 1;
  var n = 5;
  while (n > 0) {
    f = f * n;
    n = n - 1;
  }
  print(f);
}

is:

       1: StoreLocal(f, #1)
       2: StoreLocal(n, #5)
       3: [join]
       4: t0 <-LoadLocal(n)
       5: t0 <-InstanceCall(>, t0, #0)
       6: if t0 goto(7, 15)
       7: [target]
       8: t0 <-LoadLocal(f)
       9: t1 <-LoadLocal(n)
      10: t0 <-InstanceCall(*, t0, t1)
      11: StoreLocal(f, t0)
      12: t0 <-LoadLocal(n)
      13: t0 <-InstanceCall(-, t0, #1)
      14: StoreLocal(n, t0) goto 3
      15: [target]
      16: t0 <-LoadLocal(f)
      17: StaticCall(print, t0)
      18: return #null

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9414003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4460 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-22 15:20:13 +00:00