Commit Graph

88 Commits

Author SHA1 Message Date
fschneider@google.com 855e718f5b Make Value not a subclass of Computation.
Instead I introduce one new computation to materialize constants.

sizeof(UseVal) drops from 64 to 32.
sizeof(ConstantVal) drops from 48 to 16.
Review URL: https://chromiumcodereview.appspot.com//10829451

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11041 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-21 13:36:36 +00:00
zerny@google.com 5cc78d2a33 Refactored FlowGraphBuilder into a separate FlowGraph representation.
R=kmillikin@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10807 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-16 12:06:17 +00:00
fschneider@google.com df23e58a2f Change indexed load and store IL instructions to fit with SSA backend.
Generic indexed operations are implemented as normal instance calls. Specialized
operations are inserted by the flow-graph optimizer. This also avoid a lot of duplicated code
in the code generator.
Review URL: https://chromiumcodereview.appspot.com//10836239

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10727 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-15 13:54:38 +00:00
vegorov@google.com 3a121cc677 Align AllocateObjectComp and AllocateObjectWithBoundsCheckComp with ssa allocator.
AllocateObjectComp becomes a call computation with all arguments pushed via PushArgument.

AllocateObjectWithBoundsCheckComp pushes inputs internally.

R=fschneider@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10453 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-09 19:34:41 +00:00
vegorov@google.com b9aa74f3a2 Eliminate phis that do not reach any non-environment uses.
This takes care of phis for temporary variables like :expr_temp, lia, lix, igr, casc, alloc, sca that currently create unnecessary pressure on the back-edge of loops.

R=srdjan@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10377 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-08 12:38:21 +00:00
kmillikin@google.com 9ffbf2ffce Store variable counts in the flow graph builder.
Store the constant counts of copied parameters, non-copied parameters, and
(non-parameter) stack locals in the flow graph builder.  This saves passing
them around to flow graph member functions.

Change usage of "fixed parameter" to "non-copied parameter" because it is
different than what fixed parameter means in other parts of the system.

R=fschneider@google.com,zerny@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10289 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-06 14:33:23 +00:00
zerny@google.com c1262fbd49 Reapply "Added support for copied parameters to the SSA compiler."
This reapplies svn revision 10172 with a bug fix.

Original Review URL: https://chromiumcodereview.appspot.com//10837076

R=fschneider@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10280 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-06 10:07:26 +00:00
fschneider@google.com 04fa2e3547 Refactor our IL instruction for static setters.
We do not need a separate IL instruction anymore. Instead I generate
a normal static call and save the result in a temporary local if it
is needed.
Review URL: https://chromiumcodereview.appspot.com//10825176

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10222 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-03 11:14:07 +00:00
kmillikin@google.com 0d699e6c15 Revert "Added support for copied parameters to the SSA compiler."
This reverts svn revision 10172.

TBR=zerny@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10173 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-02 15:10:13 +00:00
zerny@google.com 41f9e67324 Added support for copied parameters to the SSA compiler.
R=fschneider@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10172 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-02 14:53:18 +00:00
fschneider@google.com 362c202998 Use explicit push-argument for InstanceSetter instruction.
This allows optimizing functions with InstanceSetter.
Review URL: https://chromiumcodereview.appspot.com//10826097

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10157 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-02 10:23:29 +00:00
fschneider@google.com c87efe45fa Add explicit PushArgument IL instructions to static calls.
This enables compiling static calls with the SSA-based code generator.

Add a helper to the graph builder for adding argument expressions to the graph.
Review URL: https://chromiumcodereview.appspot.com//10824078

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10008 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-30 11:19:42 +00:00
fschneider@google.com e7853aab37 Add an explicit push-argument instruction to the IL.
It is used in ClosureCall and CreateClosure. Refactoring the other call-instruction
will be done in a separate CL.

These instructions do not have their arguments as input operands anymore since they
are really call-arguments passed on the stack.

This allows us to optimize a function with closure calls with SSA. For example:

foo() {
  bar() { return 42; }
  return bar();
}
Review URL: https://chromiumcodereview.appspot.com//10825035

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9935 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-26 14:10:29 +00:00
vegorov@google.com c9e8d9594e Add support for fixed parameters in the register allocator.
This remove bailout for functions with non-zero number of non-fixed parameters and increases our coverage.

SpillSlot location was renamed into StackSlot location and now allows to address spill slots (positive stack index) and incoming parameters (negative stack index).

Environment was reordered to match order of values on the stack (previously it was inversed).

Correctly reserve spill slots in the prologue of the code. Previously register allocator was allocating spill slots, but generated code did not reserve any space for them on the stack so they might have been overwritten by calls.

Fix off by one in DeoptimizationStub::GenerateCode - we were reserving one slot too many.

Change --optimization-filter flag to use substring search instead of prefix comparison, this is much more useful when VM prefixes function name with a path to the file.

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9934 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-26 13:21:39 +00:00
srdjan@google.com 26e3afe496 Apply Kevin's suggestions, make branch-compare generation more robust
- remove setting previous link during graph building
- do not replace already inserted nodes
Review URL: https://chromiumcodereview.appspot.com//10808035

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9778 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-20 15:20:11 +00:00
kmillikin@google.com e440d86cb5 Revert "Revert "Introduce Goto instructions to the flow graph.""
Reapply svn revision 9731 with a bug fix.  The original review is at
http://chromiumcodereview.appspot.com/10735071/

R=vegorov@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9738 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-18 13:44:12 +00:00
kmillikin@google.com a368233743 Revert "Introduce Goto instructions to the flow graph."
This reverts svn revision 9731 due to test failures.

TBR=vegorov@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9733 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-18 10:44:54 +00:00
kmillikin@google.com 87d743a3c5 Introduce Goto instructions to the flow graph.
Goto is a control instruction with a single successor.

Before: basic blocks ended with an exit (return, throw, or rethrow), a
branch to a pair of target entries, or else they fell through to the
next block entry.

Now: basic blocks end with an exit, a branch, or an explicit goto to a
join entry.

R=vegorov@google.com,srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9731 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-18 10:28:37 +00:00
srdjan@google.com f680c68a55 Cleanup usage of GrowableArrays in class Environment.
Review URL: https://chromiumcodereview.appspot.com//10692140

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9525 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-10 21:06:52 +00:00
srdjan@google.com e801021a27 Cleanups.
Review URL: https://chromiumcodereview.appspot.com//10765007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9482 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-09 20:31:25 +00:00
regis@google.com 32c8564b0a Add --trace_type_check_elimination flag for debugging purposes.
Review URL: https://chromiumcodereview.appspot.com//10689099

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9471 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-09 16:59:15 +00:00
kmillikin@google.com ca7e5a9972 Fix broken build.
TBR=fschneider@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9408 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-04 13:48:26 +00:00
kmillikin@google.com 595aafa18e Simplify adding of computations to the flow graph.
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
2012-07-04 13:43:28 +00:00
fschneider@google.com 7de785eaf4 Remove unused code for StringConcatNode from the AST and the graph builder.
Review URL: https://chromiumcodereview.appspot.com//10693092

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9405 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-04 13:07:22 +00:00
fschneider@google.com da315f478e Revert r9253 because of dartium test failures
TBR=vegorov
Review URL: https://chromiumcodereview.appspot.com//10693048

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9256 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-29 17:27:12 +00:00
fschneider@google.com 6e4bc9fb91 Add a goto instruction to the IL use it to terminate basic blocks.
Having an explicit control instruction at the end of each
basic block allows to easily remove instructions inside
a block because the last_instruction pointer can not change.
Review URL: https://chromiumcodereview.appspot.com//10700034

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9253 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-29 16:31:37 +00:00
regis@google.com 8997078334 Remove old code generator.
Review URL: https://chromiumcodereview.appspot.com//10665038

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9122 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-26 17:43:44 +00:00
regis@google.com 0532a90a2f Implement type cast in the VM.
Review URL: https://chromiumcodereview.appspot.com//10659005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9070 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-25 17:23:11 +00:00
vegorov@google.com 2f23dc4b60 Simple iterative liveness analysis over SSA.
R=fschneider@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9069 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-25 17:07:16 +00:00
asiva@google.com 5cbd276939 Make the parser agnostic to the TokenStream implementation. This is the first step towards compacting the token stream.
Pull the data stream writer/reader code out of snapshot into a generic file so that it can be reused into the token stream compaction implementation.
Review URL: https://chromiumcodereview.appspot.com//10632009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9043 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-22 20:37:01 +00:00
fschneider@google.com 123bfe4e08 Second step for computing SSA: renaming.
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
2012-06-19 11:39:02 +00:00
fschneider@google.com ee4a0fd042 First step to SSA construction: Phi insertion.
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
2012-06-13 13:36:04 +00:00
srdjan@google.com bd0bda32f0 Inline setters, getters, various cleanups & restructuring.
TODO: cid, token_index and try_index are often passsed around. We should pack them in a data structure.
Review URL: https://chromiumcodereview.appspot.com//10540040

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8406 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-07 19:49:50 +00:00
srdjan@google.com d8f4aa2fd0 Use temporary variable for StoreIndexed that returns a value.
Review URL: https://chromiumcodereview.appspot.com//10448059

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8109 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-30 15:55:46 +00:00
srdjan@google.com 1a2bb17304 - Port AssertBool and AssertAssigneable to new location template.
- Change AssertAssigneable to always have instantiator and instantiator-type-arguments (if only as a null literal).
Review URL: https://chromiumcodereview.appspot.com//10446019

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7962 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-24 20:25:37 +00:00
srdjan@google.com eeda4b5810 First step toward an optimizing compiler:
- Fix ic-data instrumentation
- Optimize '+' for Smi-s only, by replacing the instance call with inlined operations.
- Add deoptimization stub
- Add deoptimzation support.
Review URL: https://chromiumcodereview.appspot.com//10431006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7952 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-24 16:50:57 +00:00
fschneider@google.com 13c3beec30 Make saving and restoring of the context around closure calls explicit.
This is a first step to refactor the codegen-templates to be reused
between optimizing and non-optimizing backend.

The context is now explicitly saved in a temporary local variable and
not passed as an argument to the ClosureCall instruction anymore.
Review URL: https://chromiumcodereview.appspot.com//10409043

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7811 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-21 17:59:02 +00:00
srdjan@google.com d016f51e9c Start porting fast typechecks to x64.
Review URL: https://chromiumcodereview.appspot.com//10407018

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7760 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-18 20:10:29 +00:00
kmillikin@google.com e4030da968 Compute assigned variables and dominance frontiers.
During basic block discovery, compute assigned variables in each
block.  After computing immediate dominators, compute dominance
frontiers.  Both of these will be used for SSA construction.

R=fschneider@google.com,srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7685 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-16 13:28:02 +00:00
kmillikin@google.com 75e43da991 Add a global graph entry.
Ensure all blocks including exception handlers are reachable from the
entry.

R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7681 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-16 12:10:02 +00:00
srdjan@google.com f1587852f7 Move code for accessing captured variables into the IL.
Review URL: https://chromiumcodereview.appspot.com//10398046

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7674 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-16 00:35:33 +00:00
srdjan@google.com 48f28eebdb Fix bugs in expression temp allocation, Kevin's CL 10302007 (Remove temporaries using explicit names) and merge with other temp.
Review URL: https://chromiumcodereview.appspot.com//10389041

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7472 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-09 21:39:58 +00:00
srdjan@google.com d55a9bc973 First steps toward a two stages new compiler.
Review URL: https://chromiumcodereview.appspot.com//10356051

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7420 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-08 16:03:15 +00:00
regis@google.com 5e99edcea7 Properly set the element type of literal lists.
Add test.
Keep element type consistent between growable array and backing array.
Fix snapshot reader to set the element type in growable array
Remove run time call checking rest argument.
Review URL: https://chromiumcodereview.appspot.com//10368004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7337 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-04 16:36:27 +00:00
srdjan@google.com 2c3cab0603 Removing all incr-op nodes.
Review URL: https://chromiumcodereview.appspot.com//10354019

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7305 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-03 22:17:44 +00:00
srdjan@google.com 259d099c6d Step toward eliminating increment nodes, starting with increment local. Fix a bug in evaluating side effect free nodes.
Review URL: https://chromiumcodereview.appspot.com//10350003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7300 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-03 20:27:37 +00:00
kmillikin@google.com bf52684184 Automatically assign temporary indices to definitions in the IL.
When added to the graph, automatically assign a temporary index (== stack
height) to definitions.

R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7269 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-03 08:46:10 +00:00
srdjan@google.com 137c0167e7 Switch from AST node ids to computation ids (cid). In addition to computations, some instructions need it as well (Return, Throw, ReThrow). Currently added to all Instructions and Computations.
Review URL: https://chromiumcodereview.appspot.com//10264031

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7205 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-01 21:23:00 +00:00
kmillikin@google.com ca0668bbbe Materialize all constant operands on the stack in the non-optimizing compiler.
This eliminates the distinction between 'value' and 'argument value'.

R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7181 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-01 08:59:54 +00:00
kmillikin@google.com a4466eaf81 Remove some more uses of named temporaries.
Remove all uses of TempVal except those used in expressions with
control flow (&&, ||, and ?:).

R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7144 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-30 08:53:39 +00:00