Commit Graph

41 Commits

Author SHA1 Message Date
kmillikin@chromium.org
ea910460bd More refactoring of class Compiler's interface.
Change more functions used by the Compiler class to have a uniform
interface: they get passed as argument an input/output pointer to a
CompilationInfo that they mutate if they succeed, and they return a
flag telling whether they succeeded.

Also, remove some unnecessary timers.

Review URL: http://codereview.chromium.org/3561012

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5583 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-10-04 14:30:43 +00:00
erik.corry@gmail.com
d46fb9d454 New attempt to make the allocation routines 64 bit clean.
This one has been approved by the 64 bit compiler in MSVC
2005 so I hope it also passes the 2008 version.

The --max-new-space-size option is now in kBytes.
The --max-old-space-size option is now in MBytes.

Some issues remain with 64 bit heaps and the counters.  See
http://code.google.com/p/v8/issues/detail?id=887
Review URL: http://codereview.chromium.org/3573005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5559 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-09-30 07:22:53 +00:00
erik.corry@gmail.com
2d0c23bc82 Revert attempt to make heap size 32/64 clean. This change needs to
be done from Windows where the compiler is stricter about truncating
changes.
Review URL: http://codereview.chromium.org/3454035

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5545 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-09-28 12:49:25 +00:00
erik.corry@gmail.com
28d7064856 More correctness around PrintF and 32/64 bit values.
Fix test after 64 bit heap size change.
Review URL: http://codereview.chromium.org/3432032

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5543 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-09-28 11:44:30 +00:00
kmillikin@chromium.org
830185b175 Clean up some messiness in Scopes.
For some reason, the scope's arguments and arguments shadow were
variable proxies, which resulted in all references to the arguments
shadow being shared in the AST.  This makes it hard to put per-node
state on the AST nodes.

I took the opportunity to remove Variable::AsVariable which has
confused people in the past, and to rename Variable::slot to the more
accurate Variable::AsSlot.

Review URL: http://codereview.chromium.org/3432022

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5517 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-09-24 07:53:59 +00:00
kasperl@chromium.org
98ac5d813f Introduce a new intermediate AST node for encapsulating the
increment part of a count operation.
Review URL: http://codereview.chromium.org/3150032

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5328 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-08-24 12:56:45 +00:00
kasperl@chromium.org
7b51dc7edb Cleanup the AST code by removing unused parts and get rid of the
flow graph code completely. Add new AST node for null compares
and use it to make the full codegens better at generating code
for null comparisons.
Review URL: http://codereview.chromium.org/3146037

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5323 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-08-24 07:26:49 +00:00
erik.corry@gmail.com
b600905133 ARM: Track Smis on top 4 stack positions and Smi loop variables.
Improve code generation for known smis and suspected Smis.
Review URL: http://codereview.chromium.org/2452002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4783 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-06-02 09:37:02 +00:00
kmillikin@chromium.org
81779f6324 Rework flow graph construction.
The flow graph has been simplified to remove the special branch, join,
and exit nodes.  All nodes are now basic blocks (possibly empty to
preserve edge-split form) with a distinguished entry and exit block.

Most trivial expressions are not added to the flow graph as
instructions.  The assigned variable analyzer has been changed to
sometimes work right-to-left so that right subexpressions can be
marked as trivial.

The reaching definitions analysis has been temporarily removed, and
the analyses that depended on it (primitivity analysis, dead code
marking) as well.

Review URL: http://codereview.chromium.org/1530003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4307 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-29 14:23:55 +00:00
kmillikin@chromium.org
70bbac9c56 Move flow graph and helper classes to their own file.
The FlowGraph, FlowGraphBuilder, and flow graph node classes are moved
to src/flow-graph.cc.

Review URL: http://codereview.chromium.org/1253009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4287 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-25 16:22:48 +00:00
kmillikin@chromium.org
15fd3ea54c Initial support for marking live code.
As part of aggressive dead code elimination, we initially assume all
flow-graph instructions are not live.  We mark those that are critical
and recursively all their children.  The children of variable
references (VariableProxies occurring as rvalues) include all their
reaching definitions.

Review URL: http://codereview.chromium.org/1159005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4246 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-24 10:36:18 +00:00
fschneider@chromium.org
04a5802d80 Add iterative primitive type analysis.
This change adds a data-flow pass to statically determine
if a variable contains a primitive type.

It requires building the flow graph and computing reaching
definitions as pre-requisites. The analysis annotates all
VariableProxy nodes with the result.

Review URL: http://codereview.chromium.org/1132005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4224 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-23 13:01:37 +00:00
iposva@chromium.org
a1ec99c05d - Remove function boilerplate objects and use SharedFunctionInfos in
their place.
- Add one field to the SharedFunctionInfo to remember the number of
  literals used in this function.

Review URL: http://codereview.chromium.org/669240

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4211 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-23 06:04:44 +00:00
kmillikin@chromium.org
82a673b8bf Include initial definitions in reaching definitions analysis.
Include the initial definitions for parameters on input to the
function, and the initial definition of stack-allocated locals as
undefined.

Review URL: http://codereview.chromium.org/1155006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4206 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-22 14:07:18 +00:00
fschneider@chromium.org
43fd945eee Loop peeling for inner loops.
This change adds the option to peel off the first iteration of inner loops.

Loop peeling is off by default and can enabled by a flag. It also requires building a flow graph.

As part of this I added the possibility to clone AST nodes.

Review URL: http://codereview.chromium.org/998001

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4205 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-22 13:21:32 +00:00
fschneider@chromium.org
ebf9e6e8e2 Remove unused LivenessAnalyzer class.
Also remove unused attributes related to it from the ast.
Review URL: http://codereview.chromium.org/1117003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4194 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-19 12:54:35 +00:00
fschneider@chromium.org
9202e05016 Fix bug in the count operation where we statically know the input is a smi.
Even if we know that the input to a count operation is a smi we still need to check if the result overflowed (and becomes a heap number).

Also fix the smi loop analysis to take two border cases correctly into account.

Review URL: http://codereview.chromium.org/1040002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4147 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-16 16:03:40 +00:00
kmillikin@chromium.org
4669473a7b Propagate reaching definitions to the instuctions of a block.
After computing RD_in for all flow graph nodes, push the reaching
definitions through the basic blocks to annotate all variable
references in the AST.

Review URL: http://codereview.chromium.org/889003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4143 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-16 10:54:02 +00:00
fschneider@chromium.org
ff03f6b36f Only invoke reaching definitions if there are >0 variables and >0 definitions.
Review URL: http://codereview.chromium.org/885004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4120 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-12 15:01:05 +00:00
kmillikin@chromium.org
10e5690d32 Simple bugfix in reaching definitions.
We only track definitions of stack-allocated variables.  Trying to
look up other variables in the environment is a bug.

Review URL: http://codereview.chromium.org/843006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4119 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-12 14:06:04 +00:00
fschneider@chromium.org
d0908674fa Fix bug in assigned variables analysis.
Property stores were not visited correctly by the visitor.
I fixed this issue by visiting property stores by visiting 
receiver and key directly (and not calling visit on the lhs property
 ast node)

Review URL: http://codereview.chromium.org/903003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4117 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-12 13:12:08 +00:00
kmillikin@chromium.org
e026813732 Compute reaching definitions.
Use the classical worklist algorithm to compute reaching definitions.
All nodes are initially put on the worklist.  Until the worklist is
empty, nodes are removed, their RD_in is recomputed, and if it changes
their successors are added to the worklist.

Review URL: http://codereview.chromium.org/853004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4113 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-12 10:35:45 +00:00
fschneider@chromium.org
d896e4f6f2 Fix treatment of const variables in assigned variable analysis.
Const variables are not considered as trivial sub-expressions since
we have the check for the hole value as a side-effect.

Review URL: http://codereview.chromium.org/849003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4112 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-12 10:20:31 +00:00
kmillikin@chromium.org
cb1f817f77 Initialize reaching definitions state for all flow graph nodes.
Reaching definitions in (RD_in) is initially empty for all nodes.  Gen
and kill sets are computed.  AST node numbers are used for nodes to
refer to their definition number.

Also: two small changes to flow graph printing.  Children of branch
nodes are visited in right-to-left order when performing depth first
search.  Instructions are numbered locally within blocks so as to not
destroy AST node number before printing (it's useful to print the
definition).

Review URL: http://codereview.chromium.org/876001

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4107 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-11 16:24:05 +00:00
fschneider@chromium.org
463ab046fa Fix a bug in smi loop analysis.
Add a missing null check that can hit when the for-loop index is
not a variable.

Review URL: http://codereview.chromium.org/840002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4101 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-11 10:37:29 +00:00
fschneider@chromium.org
7d933936d3 Fix assigned variables analysis.
This change fixes a bug with the arguments object that occurred with
r4087 and r4088. The fix is not marking the arguments variable as trivial
since it can have side effects.


Review URL: http://codereview.chromium.org/851002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4099 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-11 10:28:40 +00:00
whesse@chromium.org
a77411bc70 Revert changes 4088 and 4087 to fix build.
Review URL: http://codereview.chromium.org/805005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4089 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-10 20:41:11 +00:00
fschneider@chromium.org
0143d707a6 Add an assigned variables analysis.
This change adds a pass over the AST that computes the
set of assigned variables for locals and parameters for each expression.

The result of this analysis is used to for two purposes:
1. Recognize variables that are trivial subexpressions. A left sub-expression
   of a binary operation is trivial if it is a local variable or a parameter
   and it is not assigned in the right sub-expression. In the case of a 
   trivial left sub-expression we evaluate the right first.
   Currently only binary operations and compare operations are considered
   when finding trivial left sub-expressions.

2. Recogize certain simple for-loops with a constant trip count where the loop
   variable is always within smi range. If the loop count variable is not
   assigned in the body of the loop (except in the update expression the
   for-loop). This allows omitting smi checks on operation using the loop
   count variable.

Review URL: http://codereview.chromium.org/669155

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4087 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-10 17:19:22 +00:00
kmillikin@chromium.org
dd8a7e1bc6 Add defensive checks to the flow graph builder.
Visitor stack overflow is used to signal an unsupported construct in
the flow graph.  Check for it in more places.  Make the utility
functions for appending to graphs handle more cases if they can be
handled correctly.

Remove the entry node in favor of a block with a NULL predecessor as
single entry.  Represent the empty flow graph as a single empty block.
Add empty blocks lazily where needed to preserve edge-split form.

Review URL: http://codereview.chromium.org/804003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4086 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-10 17:02:25 +00:00
kmillikin@chromium.org
d64008952a Fix presubmit failure.
TBR=fschneider@chromium.org

Review URL: http://codereview.chromium.org/802003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4085 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-10 14:43:43 +00:00
kmillikin@chromium.org
174466d4da Cut back the syntactic constructs handled by the flow graph builder.
While the flow graph is experimental, it's easier to be able to ignore
some problematic syntactic constructs.  Reduce the ones that can occur
in constructed flow graphs.

Review URL: http://codereview.chromium.org/790004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4084 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-10 14:40:31 +00:00
kmillikin@chromium.org
0c2885f83d Add IsStackAllocated helper for variables.
Add a simple boolean helper function for Variables and Slots.

Review URL: http://codereview.chromium.org/722001

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4065 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-09 10:39:18 +00:00
kmillikin@chromium.org
3c0a0ba1e4 Have the flow graph builder collect definitions.
Before computing reaching definitions, the set of all definitions in a
function must be collected and they must be numbered.  Have the flow
graph builder collect definitions for stack-allocated variables into a
list, and implicitly number them with their list index.

Review URL: http://codereview.chromium.org/668257

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4064 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-09 09:56:19 +00:00
kmillikin@chromium.org
d2fbf9436e Fix presubmit failure (line longer than 80 characters).
TBR=fschneider@chromium.org

Review URL: http://codereview.chromium.org/669271

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4053 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-08 13:04:09 +00:00
kmillikin@chromium.org
8528d650d8 Initial implementation of an edge-labeled instruction flow graph.
The flow graph is built by walking the AST.  Edges are labeled with
instructions (AST nodes).  Normal nodes have a single predecessor edge and a
single (labeled) successor edge.  Branch nodes are explicit, they have a
single predecessor edge and a pair of (unlabeled) successor edges.  Merge
nodes are explicit, they have a pair of predecessor edges and a single
(unlabeled) successor edge.

There is a distinguished (normal) entry node and a distinguished (special)
exit node with arbitrarily many predecessor edges and no successor edges.

The graph is intended to support graph-based analysis and transformation.

Review URL: http://codereview.chromium.org/660449

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4051 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-08 12:53:11 +00:00
fschneider@chromium.org
4a2c81d3b0 Add last use data flow information to the fast code generator.
This change add simple local live variable information to 
the fast code generator.  It supports only AST nodes that 
are accepted by the syntax checker.

Each variable use points to a variable definition structure
which contains the last use of the definition.

To determine whether a variable is live after a certain point
we can check whether its last use occurs later in the evaluation
order defined by the AST labeling number.

The new information is currently only printed out together with
the IR and not yet used for code generation.

Review URL: http://codereview.chromium.org/603004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3839 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-02-12 10:16:30 +00:00
kmillikin@chromium.org
9b5c312bfc Initial implementation of fast path operation for bitwise OR.
Support a binary operation (bitwise OR) so long as it's not nested in
the left subexpression.  This ensures that the expression stack never
has height greater than two and so can be kept fully in registers.

The bounded expression stack height and the absence of any side
effects on the fast path allows us to still bailout out to the very
beginning of the function if any of our fast-path checks fail.

Review URL: http://codereview.chromium.org/594008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3822 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-02-09 13:44:43 +00:00
fschneider@chromium.org
2f0f6face1 Fast compiler: Load globals variables directly from property cells.
This is a first step towards loading globals directly from property cells instead
of going through a load IC.

This change supports only properties with the DontDelete attribute since
we are only able to bailout into the generic code generated by the secondary 
code generator the beginning of a function. The resulting fast-case code is 
specialized for a specific context. When invoked with a different global object, 
it will always bailout to the secondary code.

When loading a property that does not exist at compile-time or a property
that is deleteable we still generate the generic load IC.

Review URL: http://codereview.chromium.org/565034

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3808 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-02-05 13:57:18 +00:00
kmillikin@chromium.org
c174657e9e Incorporate the arguments to the code generator constructors and their
MakeCode functions in the CompilationInfo structure.  This makes it
easier to add new arguments and makes all arguments uniformly
available to the various backends.
Review URL: http://codereview.chromium.org/566008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3789 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-02-03 16:12:55 +00:00
kmillikin@chromium.org
41865cd677 Implement simple fast-path code for functions containing this property stores and global variables.
Code is specialized to the initial receiver.

Review URL: http://codereview.chromium.org/553149

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3760 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-02-01 17:01:58 +00:00
fschneider@chromium.org
88f6734ddb Add a pass for the fast compiler to label expression nodes.
This change adds a post-order numbering to AST nodes that
are relevant for the fast code generator. It is only invoked
together with the fast compiler. 

Also changed the ast printer to print the  numbering for 
testing purposes if it is present.

Review URL: http://codereview.chromium.org/553134

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3738 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-29 09:42:13 +00:00