Commit Graph

72 Commits

Author SHA1 Message Date
fschneider@chromium.org
5b753cecb6 Check holder before optimizing calls to global functions.
In the case where the function is not found in the global object,
we have to generate a generic call.

BUG=v8:1106
TEST=mjsunit/regress/regress-1106.js

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6727 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-02-10 12:33:51 +00:00
lrn@chromium.org
2d15eb9a90 Fix bug in object literals with large array indexes as strings.
Review URL: http://codereview.chromium.org/6410028

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6577 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-02-02 14:02:58 +00:00
fschneider@chromium.org
d82332ebb7 Cleanup unused code from the type oracle.
Review URL: http://codereview.chromium.org/6135004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6514 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-27 14:04:07 +00:00
vitalyr@chromium.org
76483f871b Support StringLength in hydrogen (similar to ArrayLength).
To avoid deopts a few extra changes were needed:

o Enable megamorphic state for special property loads on
  primitives. We used to flip between monomorphic stubs.
o Extract pure string (no string wrapper support) version of the
  string length stub.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6472 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-25 15:51:10 +00:00
vitalyr@chromium.org
331b482332 Fix bug 1070: set correct holder for primitive checks.
Code generated for checks starting with primitive receivers skips one step
in the usual prototype checking algorithm, so the holder must always be set.

Not setting the holder did not cause an immediate failure because our
primitives have additional hidden prototypes before the real prototypes.
These extra objects in the chain usually contain no properties and so
allowed the right holders to be selected.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6459 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-25 12:21:03 +00:00
lrn@chromium.org
2e8b8d3ddf Fix bad assumption in object literal interpretation.
We allow symbols that are array indices.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6447 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-25 07:48:19 +00:00
vitalyr@chromium.org
b4ff318e4b Support StringCharCodeAt in hydrogen/lithium.
This patch adds H- and L-variants of StringCharCodeAt and StringLength.

StringCharCodeAt is used to inline a constant function call of
String.prototype.charCodeAt and to implement the corresponding inline
runtime function. It does not yet use the recently introduced extra IC
state. (We can specialize on string encoding and avoid deopts because
of out of bounds accesses.)

StringLength needs more work because the stub version of it also
supports strings wrappers and it matters in some cases. (We have to
separate the string only case.)

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6408 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-19 20:05:22 +00:00
antonm@chromium.org
fae90d4f32 Make closures optimizable by Crankshaft compiler.
Currently only closures which only read from the context are supported.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6340 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-17 08:11:03 +00:00
vitalyr@chromium.org
ac9b035a45 Expose receiver check type in call type feedback.
This a preparatory step to support fast function calls on primitive
values. Not really used yet in hydrogen.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6300 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-13 14:16:08 +00:00
ager@chromium.org
0b9336ac8b Landing for Martin Maly.
Fix CalculateEmitStore HashMap use. 

The hash maps are setup to store strings or smis but instead Literal is being in them. It seems to only work by accident. 


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6279 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-12 09:29:20 +00:00
fschneider@chromium.org
bfecc95694 Revert r6194: Clean up code for type feedback a bit.
This causes a big performance regression. I'll investigate.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6217 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-07 10:36:27 +00:00
fschneider@chromium.org
35533bee36 Clean up code for type feedback a bit.
Remove unused functions and parameters and remove the parts of the
code that mention the old GenericBinaryOpStub. It is not used together
with Crankshaft and replaced with TypeRecordingBinaryOpStub.


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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6194 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-06 10:10:26 +00:00
vitalyr@chromium.org
c5916f552f Support load function prototype in hydrogen/lithium.
Review URL: http://codereview.chromium.org/6009005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6112 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-22 15:43:32 +00:00
vitalyr@chromium.org
57e072298f Merge math function ids and custom call generator ids.
Two old id types are replaced by builtin function ids. We can use
these in the code generators to emit custom code for the selected
functions.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6013 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-14 18:53:48 +00:00
kmillikin@chromium.org
49f4c39d6d Deoptimize to the proper target after assignment side effects.
This fixes V8 issue 989.

Before, assignments used the AST ID of the assignment expression to
mark the side effect of the store, which became a target for
deoptimization bailout for code after the assignment.  In effect
contexts this environment included the value of the assignment, which
was unexpected by the unoptimized code.

Now we introduce a new assignment ID for AST node types that include
an assignment (Assignment, CountOperation, and ForInStatement) and use
it for the side effect of the store.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5990 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-13 16:29:47 +00:00
kasperl@chromium.org
90b3370374 Update V8 to version 3.0 (re-land r5920).
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5922 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-07 11:31:57 +00:00
kasperl@chromium.org
51b494d096 Revert r5920. Will re-land shortly.
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5921 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-07 11:01:02 +00:00
kasperl@chromium.org
e5860bd6a8 Update V8 to version 3.0.
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5920 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-07 09:11:56 +00:00
karlklose@chromium.org
1b0e2597e8 Fix a bug that prevents constants from overwriting function values in object literals.
BUG=http://code.google.com/p/v8/issues/detail?id=907

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5718 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-10-27 11:37:59 +00:00
lrn@chromium.org
484b9df414 Limit end-anchored regexps to testing end of string where possible.
Review URL: http://codereview.chromium.org/3844006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5661 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-10-19 14:00:01 +00:00
lrn@chromium.org
00e23b719d Revert revision 5657.
TBR: erik.corry

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5658 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-10-19 10:37:54 +00:00
lrn@chromium.org
f80da64d36 Use finite-length end-anchored regexps to reduce part of regexp that is searched.
Review URL: http://codereview.chromium.org/3850005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5657 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-10-19 09:42:40 +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
yurys@chromium.org
19d31d3e59 Initialize all VariableProxy fields in its constructor
Review URL: http://codereview.chromium.org/3330002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5390 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-09-01 12:25:46 +00:00
kasperl@chromium.org
3c26a55def Start using the overwrite mode from the full codegens to generate
slightly better code and allow passing arguments to binary op stubs
in registers on the platforms that support it.
Review URL: http://codereview.chromium.org/3203005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5339 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-08-25 11:10:05 +00:00
kasperl@chromium.org
a342aa03d5 Add position information for compares, binary ops, and count
operations.
Review URL: http://codereview.chromium.org/3120027

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5332 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-08-24 13:51:23 +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
fa7c92eaf5 First step towards making JumpTarget work on ARM. Instead
of having a list of virtual frame pointers in the jump
target we have one virtual frame, which is the frame that
all have to merge to to branch to that frame.  The virtual
frame in the JumpTarget is inside the JumpTarget, rather than
being an allocated object that is pointed to.  Unfortunately
this means that the JumpTarget class has to be able to see
the size of a VirtualFrame object to compile, which in turn
lead to a major reorganization of related .h files.  The
actual change of functionality in this change is intended
to be minimal (we now assert that the virtual frames match
when using JumpTarget instead of just assuming that they do).
Review URL: http://codereview.chromium.org/1961004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4631 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-05-10 11:32:25 +00:00
kmillikin@chromium.org
789f832e4a Move the AstVisitor stack check from Accept to Visit.
The stack check has been moved from the Accept function dispatching on
the AST node type, earlier to the Visit function dispatching on the
visitor type.

This allows very simple non-recursive visitors (not taking extra
arguments or returning values) via the convention of calling "Visit"
if one wants the stack check and "Accept" if one does not.  Recursive
calls should all be via "Visit".

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4320 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-30 12:25:58 +00:00
kmillikin@chromium.org
155a9cdd08 Simplify IA32 code generator API.
Cut down on the number of arguments passed to the various binary operation
code generator functions by passing along the expression itself, rather than
a subset of its fields.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4319 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-30 12:12:31 +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
whesse@chromium.org
a255a71181 Speed up conversion of untagged int32 result if we know it must be a smi.
Review URL: http://codereview.chromium.org/1233003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4273 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-25 13:22:37 +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
kmillikin@chromium.org
65115c2857 Mark all loop conditions.
Previously we marked compare operations that occurred as for loop
conditions so as to avoid inlining the floating-point code for them.
Begin marking all expressions that occur as any loop condition
(because they are never dead code).

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4227 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-23 13:36:38 +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
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
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
kmillikin@chromium.org
ac896bb5a0 Add a predicate IsPrimitive to AST Expression nodes.
IsPrimitive reflects that an expression's value is known statically to
be one of the ECMA-262-3 JS types other than Object (e.g., Undefined,
Null, Boolean, String, or Number).

The type conversions ToPrimitive, ToNumber, ToInteger, ToInt32,
ToUInt32, ToUint16, ToString, or ToObject cannot invoke user code for
primitive input values.  ToObject throws a TypeError if its input is
Undefined or Null.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4116 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-12 13:10:42 +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
bce8d2ebae Remove unneeded variable usage analysis.
A variable usage analysis pass was run on toplevel and lazily-compiled
code but never used.  Remove this pass and the data structures it
builds.

The representation of variable usage for Variables has been changed
from a struct containing a (weighted) count of reads and writes to a
simple flag.  VariableProxies are always used, as before.  The unused
"object uses" is removed.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4052 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-03-08 13:01:24 +00:00
lrn@chromium.org
f03e42b133 Added validating JSON parser mode to parser.
Review URL: http://codereview.chromium.org/549207

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3752 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-02-01 10:31:55 +00:00
lrn@chromium.org
46504c1557 Attempt to make \b\w+ faster. Slight performance increase on, e.g., string unpacking.
Review URL: http://codereview.chromium.org/507051


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3563 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-07 19:01:23 +00:00
kmillikin@chromium.org
6a83cb0ced In the toplevel compiler, shift the responsibility of assigning a
location to an Expression AST node from the node's parent to the node
itself.

This allows an inherited code generation context from a parent node to
be passed arbitrarily far down the tree (eg, the subexpression of a
unary not is in the same context as the unary expression itself, the
then and else subexpressions of the ternary operator are in the same
context as the whole expression, and so forth).

We do not yet take advantage of this in the backend (eg, the right
subexpression of short-circuited OR is still compiled by using the
parent's destination location, rather than the subexpression's
itself).

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3163 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-28 13:25:40 +00:00
kmillikin@chromium.org
a563800b4c Initial implementation of printing the AST as a JSON string. This
implementation is not yet complete (it prints only the node name for
some AST constructs) and does not serialize everything needed to
reconstitute the AST.

It is motivated by a desire to prototype source-to-source
transformations in JavaScript itself (or anything else that can grok
JSON), but it should have other uses too.

Feedback is welcome.
Review URL: http://codereview.chromium.org/131101

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3051 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-12 15:06:28 +00:00
kmillikin@chromium.org
586f94f292 Split the AST LoopStatement type into separate types for do/while,
while, and for loops.

Previously they were distinguished by a type field, which required
runtime asserts to avoid invalid nodes (since not all loop types have
the same internal structure).  Now they C++ type system is used to
require well-formed loop ASTs.

Because they do not share compilation code, we had very large
functions in the code generators that merely did a runtime dispatch to
a specific implementation based on the type.
Review URL: http://codereview.chromium.org/269049

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3048 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-12 13:14:06 +00:00
kmillikin@chromium.org
928bfae405 Remove CallEval as a subclass of the Call AST node type. We were not
differentiating between Call and CallEval except in the code
generator, and the difference can be detected from a regular Call AST
node at code generation time.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2984 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-09-29 13:28:30 +00:00
kmillikin@chromium.org
1a39e07003 Another name change for consistency's sake. NODE_LIST -> AST_NODE_LIST.
Review URL: http://codereview.chromium.org/159633

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2587 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-07-30 12:09:05 +00:00