Commit Graph

35 Commits

Author SHA1 Message Date
regis@google.com 75de3a8cc2 Move type check elimination from backend to graph builder in new compiler.
Review URL: https://chromiumcodereview.appspot.com//10021070

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6713 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-18 21:58:46 +00:00
regis@google.com 9c9652be6f Implement condition type checks in new compiler, thereby removing last bailouts.
Remove svn:eol-style property on various files.
Review URL: https://chromiumcodereview.appspot.com//9969192

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6613 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-17 00:17:33 +00:00
srdjan@google.com 36b456b3b4 Simplify code in code code generator, move checks to flow graph builder. We can assume that any type analysis will occur before the code generator gets called.
Review URL: https://chromiumcodereview.appspot.com//10069042

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6532 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-13 16:49:22 +00:00
srdjan@google.com a0a700026f Eliminated last bailout (except for type checked mode) in the new compiler: generate type arguments for instanceof if needed.
Review URL: https://chromiumcodereview.appspot.com//10071016

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6467 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-12 17:20:43 +00:00
srdjan@google.com d154a7ffce Try/catch in new compiler. Added try index to appropriate instructions. If any instruction throws an exception, the try index tells us which catch entry the exception belongs to.
Review URL: https://chromiumcodereview.appspot.com//10014006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6389 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-10 23:22:40 +00:00
srdjan@google.com fdc147509e Fix a crash in graoh builder where a throw node is added in an expression tree by the parser: allow throws in expressions by not closing the fragment, instead return null as value.
Review URL: https://chromiumcodereview.appspot.com//10032009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6340 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-09 21:31:15 +00:00
srdjan@google.com 76df5fac83 Implement object allocation/construction as effect (no result), sequence labels and unchaining from context.
Review URL: https://chromiumcodereview.appspot.com//10005010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6226 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-05 16:23:22 +00:00
srdjan@google.com 87d8bb5039 Implement StringConcatNode in flow graph builder (it is ised on for "+" on strings, will be soon removed).
Review URL: https://chromiumcodereview.appspot.com//9959134

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6179 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-04 17:25:35 +00:00
srdjan@google.com 86472e6dfd Add contexts.
Review URL: https://chromiumcodereview.appspot.com//9726024

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5793 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-23 21:26:34 +00:00
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
srdjan@google.com 1f072a6171 Remove possibility of critical edges.
Review URL: https://chromiumcodereview.appspot.com//9722009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5601 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-16 23:06:39 +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 d4dcb9fee0 Clean-up CodeGenState: remove unused loop_level and move context_level to CodeGenerator (and add it to FlowGraphBuilder).
Review URL: https://chromiumcodereview.appspot.com//9706086

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5571 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-16 15:38:43 +00:00
kmillikin@google.com 6e7fa43e58 Simplify translation of conditionals in the flow graph builder.
Allow the builder to assume that, if control flow reaches a conditional
expresion, there is always control flow to two branches.

R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5546 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-15 21:52:27 +00:00
regis@google.com 9827cdc826 Split the computation of uninstantiated type arguments between the factory case
and the constructor case, as suggested in my review of
https://chromiumcodereview.appspot.com/9700003/

Examples of generated IL (first factory, second non-factory).

 foo() { return new List<T>(); }
 moo() { return new A<T>(); }

==== file:///home/regis/test.dart_A_foo
 0: [target]
    t0 <- LoadLocal(this)
    t0 <- NativeLoadField(t0, 16)
    t0 <- ExtractFactoryTypeArguments(t0)
    t0 <- StaticCall(List., t0)
    return t0
==== file:///home/regis/test.dart_A_moo
 0: [target]
    t0 <- #null
    t1 <- LoadLocal(this)
    t1 <- NativeLoadField(t1, 16)
    t2 <- Pick(t1)
    t2 <- ExtractConstructorTypeArguments(t2)
    t0 := t2
    t1 <- ExtractConstructorInstantiator(t1, t2)
    t0 <- AllocateObject(Library:'file:///home/regis/test.dart' Class: A, t0, t1)
    t1 <- Pick(t0)
    t2 <- #3
    StaticCall(A., t1, t2)
    return t0

This change removes the computation that previously returned two values at the
cost of a some small code duplication. We could address this duplication by
exposing the computation recognizing the identity vector at the IL level and
implement a branch.
Review URL: https://chromiumcodereview.appspot.com//9703080

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5537 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-15 20:16:29 +00:00
srdjan@google.com daa7217127 Implement more of allocation code using type arguments. Type argument extraction for non-factories produces two results, however, instructions can produce only one temporary. Use a stack placeholder so that we have room to push two results. Examples of generated IL (first factory, second non-factory).
foo() { return new List<T>(); }
  moo() { return new A<T>(); }

==== file:///sources/dartall/dart/runtime/Test.dart_A_foo
 0: [target]
    t1 <- LoadLocal(this)
    t1 <- NativeLoadField(t1, 16)
    t1 <- ExtractTypeArguments(t1)
    t0 <- StaticCall(List., t0)
    return t0
==== file:///sources/dartall/dart/runtime/Test.dart_A_moo
 0: [target]
    t0 <- #null
    t1 <- LoadLocal(this)
    t1 <- NativeLoadField(t1, 16)
    t1 <- ExtractTypeArguments(t1)
    t0 <- AllocateObject(Library:'file:///sources/dartall/dart/runtime/Test.dart' Class: A, t0, t1)
    t1 <- Pick(t0)
    t2 <- #3
    StaticCall(A., t1, t2)
    return t0
Review URL: https://chromiumcodereview.appspot.com//9700003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5480 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-14 18:51:47 +00:00
kmillikin@google.com b05d117185 Support allocating and calling closures in the new non-optimizing compiler.
As part of this change, variable allocation is split out from the backend
code generator.

R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5392 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-13 12:31:45 +00:00
srdjan@google.com be77f7a015 Implementing ConstructorCall: part I.
Review URL: https://chromiumcodereview.appspot.com//9646008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5264 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-09 22:40:37 +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 147527a2d0 Implement increment of locals.
R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5228 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-09 11:41:22 +00:00
kmillikin@google.com 33d36027b1 Implement compilation of conditional expressions.
R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5227 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-09 11:22:33 +00:00
kmillikin@google.com 0aa83907a7 Handle instance field and indexed increment operations.
Handle pre- and post-increment (decrement) in effect and non-effect
contexts.

R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5160 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-08 11:06:02 +00:00
srdjan@google.com 28aa93c232 Implement DoWhile.
Review URL: https://chromiumcodereview.appspot.com//9553008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5055 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-06 21:02:56 +00:00
kmillikin@google.com 0a9194319d Implement postfix indexed increment.
Chosen because of its wartiness.  A pair of new computations are introduced
to allow the IL to express duplication of temporaries and storing to
temporaries.  These will be translated away by the optimizing compiler, but
allow the instruction stream to represent exactly the deoptimization state
we are intereseted in (with at most one deopt point per instruction).

Translation of:

test(a, i) {
  return a[i]++;
}

is

 0: [target]
    t0 <-#0
    t1 <-LoadLocal(a)
    t2 <-LoadLocal(i)
    t3 <-CopyTemp(-1)
    t4 <-CopyTemp(-1)
    t3 <-InstanceCall([], t3, t4)
    SetTemp(-3)
    t4 <-#1
    t3 <-InstanceCall(+, t3, t4)
    InstanceCall([]=, t1, t2, t3)
    return t0

R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5012 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-06 09:49:21 +00:00
kmillikin@google.com 9058b2b8f3 Implement StaticCall and InstanceCall in the new code generator.
1. Introduce a value visitor for argument values.

2. Add enough information to StaticCallComp and InstanceCallComp IL
computations so that we can generate code.

3. Enable code generation for them.

R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4859 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-02 09:03:45 +00:00
kmillikin@google.com 6d46c13c8d Remove non-useful duplicated code from the flow graph builder.
For most AST nodes, there is a core of the translation that is shared
for all contexts and only the handling of the final computation
differs.  Make this last part virtual and the visit functions
non-virtual by default.

We can still override visit functions if we want truly different
translations.

R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4786 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-01 09:49:13 +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
kmillikin@google.com 862dc2f03c Add enough compiler support to compile empty functions on x64.
Implement a simple compilation visitor for the intermediate language.  Copy
code from the x64 code generator to support compilation of functions with no
arguments, no locals, and that return a literal.

Compiled code is not used, but it can be disassembled and visually checked
against the code from the old code generator.

R=srdjan@google.com
BUG=
TEST=expected to pass all tests on x64

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4601 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-27 08:28:51 +00:00
kmillikin@google.com 3fb8b5985e Ensure that outgoing constant arguments will be materialized.
This keeps the IL simple for the benefit of the optimizing compiler.
It intentionally relies on a particular temporary allocation strategy
for the non-optimizing compiler.

For the dart function

main() {
  var x = 2;
  hukairs(1, x, 3);
}

The flow graph is:

 0: [target]
    StoreLocal(x, #2)
    t0 <-#1
    t1 <-LoadLocal(x)
    t2 <-#3
    StaticCall(hukairs, t0, t1, t2)
    return #null

R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4600 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-27 08:04:24 +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
srdjan@google.com d89a53417b Added LongJump for bailout. When trying to fix all crashes, CHECK_ALIVE did not scale well as bailing out mechanism.
Implemented UnaryOpNode. Fix crashes.
(this CL also includes the patches from https://chromiumcodereview.appspot.com/9429056/, will remove them once syncing with submitted 9429056)
Review URL: https://chromiumcodereview.appspot.com//9443002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4541 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-23 16:14:01 +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