Commit Graph

139 Commits

Author SHA1 Message Date
vegorov@google.com 1ae72fbd8b Change comparison-to-branch fusion to actually remove comparison from the graph.
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9556 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-11 17:41:54 +00:00
regis@google.com e6e70d7bb2 Allocate types in proper heap space.
Allow type finalization without canonicalization.
Review URL: https://chromiumcodereview.appspot.com//10696155

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9529 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-10 21:54:13 +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 ac0025ebd3 Use the instruction iterator rather than an explicit loop in more places.
R=vegorov@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9467 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-09 12:58:36 +00:00
kmillikin@google.com 6bd463ee85 Rename the successor field of instruction to next.
Renaming only change to use a name parallel to 'previous'.

R=vegorov@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9464 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-09 11:38:29 +00:00
fschneider@google.com a411bf5045 Add forward iterator to iterate instructions inside a basic block.
It is currently only used in SSA renaming.
Review URL: https://chromiumcodereview.appspot.com//10692107

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9438 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-06 12:31:37 +00:00
kmillikin@google.com 5f541253ad Eliminate the type distinction between BindInstr and DoInstr.
Represent the distinction between computations whose value is used and
computations whose value is unused with a data member (instead of a
separate type).

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9416 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-05 10:06:28 +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 767b5d4439 Add support for fixed parameters in SSA builder and fix a bug in the pre-order graph traversal.
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
2012-07-04 10:24:19 +00:00
fschneider@google.com 3dcdc79ffe Add deoptimization environments to instructions.
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
2012-07-03 12:54:03 +00:00
fschneider@google.com bece5d05c8 Fix a bug in SSA renaming introduced when using the RemoveFromGraph helper for removing instructions.
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
2012-07-03 08:35:00 +00:00
fschneider@google.com eba7136e7b Make IL instructions a doubly-linked list within basic blocks.
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
2012-07-02 16:08:58 +00:00
fschneider@google.com 31dfb3d8da Fix bailing out of SSA compilation and enable --use-ssa on x64 by default.
We need to re-parse the function when retrying compilation after bailing out
because of the side-effects to the AST (break-, continue-labels).

To improve test coverage I'm enbabling building of SSA on x64 now.
Review URL: https://chromiumcodereview.appspot.com//10694053

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9291 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-02 15:41:37 +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
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 63d4ad7d5f Add new files and data structures for the new register allocator.
This CL adds new files to hold the new register allocator and
adds a parallel-move instructions that will be used to insert
moves for register constraints, spills and phi-resolution.

No new functionality added yet.
Review URL: https://chromiumcodereview.appspot.com//10635020

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9027 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-22 10:59:06 +00:00
fschneider@google.com b42a49f107 Fix a bug in SSA renaming.
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
2012-06-20 10:08:01 +00:00
srdjan@google.com 60fa0b27ca More ICData cleanups: try to use ICData instead of converting it to another intermediate representation. This sets the stage for more & simpler optimizations based on collected type feedback.
Review URL: https://chromiumcodereview.appspot.com//10594002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8877 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-19 21:49:11 +00:00
regis@google.com 9f47fe603b Fix type test elimination using static type propagation in new compiler.
Review URL: https://chromiumcodereview.appspot.com//10578018

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8868 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-19 20:32:44 +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
srdjan@google.com 718554fde4 Temporary fix for static type check elimination in new compiler. Enable tests.
Review URL: https://chromiumcodereview.appspot.com//10580003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8823 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-18 21:04:28 +00:00
fschneider@google.com e1640d96ca Fix bailout from the optimizing-mode compiler and put SSA construction under a flag.
For now the flag is off by default.
Review URL: https://chromiumcodereview.appspot.com//10568007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8783 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-18 12:04:30 +00:00
srdjan@google.com 8ffba8989b Chek stack overflow in while an do-while node (in order to be able to interrupt loops).
Review URL: https://chromiumcodereview.appspot.com//10562010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8730 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-15 18:12:42 +00:00
srdjan@google.com 70bc9aa213 Add token kind into InstanceCallComp so that we do not need to extract it from name (addresses vego…
Review URL: https://chromiumcodereview.appspot.com//10536162

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8675 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-14 17:41:54 +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 5ad91ae250 Add stack check in loops so that loops can be stopped. Optimize relational operations.
Use class-ids to describe type of operation. Should we adapt BinaryOp to use class ids as well?
Review URL: https://chromiumcodereview.appspot.com//10536086

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8507 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-11 17:02:39 +00:00
vegorov@google.com 20549ee20d Implement inlined LoadIndexed operation for arrays on x64.
R=srdjan@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8462 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-08 19:36:26 +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
fschneider@google.com 84027c4457 Add flow graph printing into a .cfg file with flag --print-flow-graph-file.
This CL adds a flag --print-flow-graph-file which produces one
.cfg-file per isolate when enabled. Currently it prints the final
flow graph before code generation.

I also added SuccessorAt and SuccessorCount to allow easy iteration
over the successors of a basic block.
Review URL: https://chromiumcodereview.appspot.com//10446116

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8322 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-06 11:09:02 +00:00
regis@google.com e0d223b30b Address review comments in commited cl (issue 10460002).
Review URL: https://chromiumcodereview.appspot.com//10448079

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8144 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-31 08:31:30 +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
iposva@google.com e41c09b616 Address review comments:
- Remove unnecessary store to local variable.
Review URL: https://chromiumcodereview.appspot.com//10446062

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8073 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-29 18:03:21 +00:00
srdjan@google.com f624ef7821 Moved InstantiateTypeArgumentsComp and InstanceOfComp.
Review URL: https://chromiumcodereview.appspot.com//10440053

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8010 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-25 18:54:12 +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
iposva@google.com 63941a8d3a - Rename NativeLoadField/NativeStoreField to LoadVMField/StoreVMField.
- Implement code patterns for LoadVMField/StoreVMField.
- Fix order of inputs in StoreVMField.
Review URL: https://chromiumcodereview.appspot.com//10451006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7936 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-24 01:13:04 +00:00
regis@google.com 8f45ccddc1 Add flag to measure impact of type check elimination.
Review URL: https://chromiumcodereview.appspot.com//10407074

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7826 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-21 22:21:12 +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
fschneider@google.com 055ba590a4 Add IR printing into a supplied buffer and formatted comments on x64.
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
2012-05-18 01:04:56 +00:00
regis@google.com 1f233e677e Address a few TODOs related to type propagation.
Review URL: https://chromiumcodereview.appspot.com//10407026

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7716 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-17 18:47:45 +00:00
regis@google.com f3aca487fe First shot at static type propagation and type test elimination.
Review URL: https://chromiumcodereview.appspot.com//10399051

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7708 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-16 23:21:24 +00:00
fschneider@google.com 81e36bbb1c Remove an unused input operand from ExtractConstructorInstantiator.
The second input is discarded, so we don't need to pass it as input to
the computation. The explicit pop in the code generator is replaced by 
LoadValue.  This is a small step in refactoring the flowgraph-based code 
generator to be shared between multiple backends.
Review URL: https://chromiumcodereview.appspot.com//10391171

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7705 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-16 22:48:49 +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