Commit Graph

41 Commits

Author SHA1 Message Date
sgjesse@chromium.org
3fdc489658 Fix presubmit errors.
TBR=ager@chromium.org
Review URL: http://codereview.chromium.org/570024

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3796 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-02-04 15:21:05 +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
kmillikin@chromium.org
5536273594 Add fast code generator visitor.
It does not yet emit code so there is a flag --print-ir to print the
AST as seen by the code generator.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3748 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-29 15:29:33 +00:00
kmillikin@chromium.org
8588518851 Introduce a stack-allocated structure to encapsulate compile-time information.
Use it to hold the possible shared function info, the possible
receiver, and the compilation loop nesting depth.  Remove loop nesting
from FunctionLiteral AST nodes.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3744 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-29 11:55:40 +00:00
kmillikin@chromium.org
e7528c4ac6 Propagate receiver from initial call site to code generator.
When doing lazy compilation of methods, allow the code generator to know the
(initial) receiver at the (initial) call site.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3739 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-29 09:52:51 +00:00
kmillikin@chromium.org
2b62886dab Refactor the selection of code generator and add the possibility of a
simpler backend for non-toplevel code.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3721 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-27 15:23:48 +00:00
kmillikin@chromium.org
1405258621 Rename the fast-codegen* files to full-codegen*.
Review URL: http://codereview.chromium.org/549109

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3662 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-20 16:28:21 +00:00
kmillikin@chromium.org
6ad58b53f4 Rename the toplevel code generator from "Fast" to "Full". It was
always ambiguous whether it tried to generate fast code, or generate
it quickly.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3660 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-20 15:51:03 +00:00
kmillikin@chromium.org
3e8539d873 First step of refactoring expression contexts in the toplevel code
generator.

Contexts are no longer stored in the AST but in the code generator's
state.  This means that the running the code generator selector is not
required to use the toplevel code generator (for instance, if we
already know that we can and should use it).

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3645 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-19 12:41:02 +00:00
kmillikin@chromium.org
9095abb776 Introduce 'top-of-stack caching' to the toplevel code generator by
allowing the value of the rightmost subexpressions to be evaluated
into an accumulator register (eg, eax, rax, or r0) rather than onto
the stack.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3630 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-18 14:04:55 +00:00
fschneider@chromium.org
1cc579ff4e Fix issue 541 and some refactoring of the top-level compiler.
* Refactor VisitProperty to use the platform-specific methods for emitting the IC calls.
* Refactor recording of source positions in the top-level compiler.
* Correct the recorded source positions for assignments and property loads.
* Fix bug on x64 where source positions were not recorded before a calling a call-IC.
* Correct some inconsistencies between IA-32 and X64 top-level code generator.

We now pass all regression tests with 
--always-fast-compiler.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3612 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-15 12:00:59 +00:00
fschneider@chromium.org
acf74b04a7 Fix a problem when compiling built-ins with the top-level compiler.
Replace runtime call to NumberAdd with call to binary op stub.

Until now the top-level compiler always called a runtime function
for count operations. 

In some places we expected in the JS builtins smis as arguments.
If we perform a count operation before all smis would get converted into
heap numbers by the runtime number add function and result in a runtime 
assert.

Also: Add missing debugger information in the top-level compiler for 
do-while loops.


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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3610 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-14 17:22:59 +00:00
kmillikin@chromium.org
39b9f57f19 Cleanup the handling of control flow in the toplevel code generator.
Do abstract the setting and restoring of 'argument' state into a
function that takes arguments.

Do not set the argument state in the code generator unless it
represents arguments to a recursive call to Visit.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3594 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-13 11:29:08 +00:00
kmillikin@chromium.org
f0b8c2d97a Some cleanup of the toplevel code generator:
* Rename the operation of filling a context with a value.  Formerly it
  was 'Move', now it's 'Apply' so as to avoid confusion with various
  other Moves (eg, in the toplevel codegen, in the macro assemblers).

* Use the abstraction Drop rather than math on the stack pointer.

* Add a predicate on AST expression nodes to abstract a repeated test
  whether we should us a regular (named) IC or a keyed IC.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3580 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-12 08:48:26 +00:00
kmillikin@chromium.org
a1bf879720 More cleanup of slot handling in the nonoptimizing code generator.
Rename CreateSlotOperand so that it's clear it can emit code.  Use it
where possible.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3534 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-05 11:29:27 +00:00
fschneider@chromium.org
637a21952f Added general pre- and postfix count operations to top-level compiler.
Until now we only supported postfix operations on global variables.
This change add generic count operations to the top-level compiler.

I tried to re-use code from the code generator used for assignment expressions
where possible.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3530 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-04 13:56:31 +00:00
lrn@chromium.org
9b0a967cae Fast-codegen: Adding support for try/catch and throw.
Still no support for lookup-variables, so we bailout if using the catch variable.

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


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3498 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-12-18 13:38:28 +00:00
kmillikin@chromium.org
6af6a82ae3 Streamline the calling convention of the call ICs by passing the
property name in a register rather than on the stack below the
receiver and arguments.

Implemented only for IA32, passing the name in the ecx register to
match the calling convention of the load ICs.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3484 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-12-17 10:23:20 +00:00
lrn@chromium.org
482d434f4d Fast codegen: Implement with.
Review URL: http://codereview.chromium.org/491077


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3473 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-12-16 09:51:07 +00:00
lrn@chromium.org
9ff5f9daed Fast-codegen: Implementing try/finally on top of nesting context.
Review URL: http://codereview.chromium.org/492002


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3461 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-12-14 11:09:25 +00:00
fschneider@chromium.org
c25151faa6 Adding compound assignments to the top-level compiler.
Review URL: http://codereview.chromium.org/486008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3455 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-12-11 16:09:16 +00:00
lrn@chromium.org
aef02ccccb Fast codegen: Working break and continue.
Started framework for all intra-functional outward control transfers,
including handling of try/finally.

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


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3448 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-12-10 14:06:08 +00:00
lrn@chromium.org
eded148caf Fast-codegen: Arguments object working on all platforms.
This time it's true.

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


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3369 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-11-26 10:28:32 +00:00
kmillikin@chromium.org
0ce4eab1b2 Obey the flag --lazy in the toplevel code generator.
There were two separate implementations of the function
'BuildBoilerplate' that is used to compile function declarations and
function literals.  The implementations did not do exactly the same
thing.  In particular, one ignored the flag --lazy.

Combine the two implementations.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3218 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-11-04 17:59:24 +00:00
fschneider@chromium.org
ff0d885b95 Emitting the common return sequence in the top-level compiler in one function for each platform.
I factored out the code for emitting the return sequence since we had this code duplicated in the top-level compiler.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3213 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-11-04 14:11:39 +00:00
kmillikin@chromium.org
3eb69a34fa Begin using the top-level code generator for code that is inside
directly-applied function literals that are themselves compiled with
the top-level code generator.

The choice is guarded by a test that the function is anonymous (thus
not expected to be recursive) and not in a loop.

A compilation hint is set in the shared function info and used to make
the choice.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3206 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-11-03 14:48:59 +00:00
kmillikin@chromium.org
aa3b00a25a Add support for initialization block assignments in the toplevel code
generator, mimicing the behavior of the optimizing compiler.

Initialization blocks can only contain (thus begin and end) with a
property assignment in toplevel code.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3198 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-11-02 13:30:24 +00:00
kmillikin@chromium.org
b710d66f39 Refactor the somewhat complicated code generation for assignments into
a platform-independent structure and a few platform-specific helpers
to do the heavy lifting.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3195 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-11-02 11:01:47 +00:00
kmillikin@chromium.org
ab3e85eeb4 Initial implementation of top-level compilation of expressions in test
context.  Test contexts are used for the left subexpressions of
short-circuited boolean operators.  The right subexpressions inherit
their expression context from the binary op expression.

Compilation of short-circuited operations in effect and test context
is straightforward:

effect(e0 || e1) =
 test(e0, L0, L1)
 L1: effect(e1)
 L0:

test(e0 || e1, L0, L1) =
 test(e0, L0, L2)
 L2: test(e1, L0, L1)

Because the value of the first subexpression may be needed as the
value of the whole expression in a value context, we introduce a
hybrid value/test contest (the value is needed if true, but not if
false).

value(e0 || e1) =
 value/test(e0, L0, L1)
 L1: value(e1)
 L0:

The compilation of value/test and test/value (introduced by boolean
AND) is:

value/test(e0 || e1, L0, L1) =
 value/test(e0, L0, L2)
 L2: value/test(e1, L0, L1)

test/value(e0 || e1, L0, L1) =
 test(e0, L0, L2)
 L2: test/value(e1, L0, L1)

Boolean AND is the dual.  The AST nodes themselves (not their parents)
are responsible for producing the proper result (effect, value, or
control flow) depending on their context.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3187 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-30 14:06:48 +00:00
fschneider@chromium.org
07cd399b5c Support for calls on named and keyed properties in the fast compiler of the form:
o.x() and o[expr]()

other changes:
- Fix missing relocation info for StoreIC on global object.
- Generate only one common return sequence instead of always appending 
  "return <undefined>" at the end of each function: The first JS 
  return-statement will generate the common return sequence. All
  other return-statements will generate a unconditional branch to the common
  return sequence.


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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3183 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-30 10:22:31 +00:00
kmillikin@chromium.org
d92fa03eca Move the Location class into the AST Expression class as a member.
Since it is (currently) only an enum, change it to an enum (for now).

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3181 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-30 08:36:46 +00:00
kmillikin@chromium.org
b1defd51cb Rename the Location type tags to be consistent with our current naming
scheme for enumerations (eg, EFFECT => kEffect).

Remove the ability to move from one Location to another, which should
never be necessary.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3175 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-29 13:58:04 +00:00
whesse@chromium.org
05d6294e98 Add binary operations to fast compiler.
Review URL: http://codereview.chromium.org/342019

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3172 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-29 11:55:03 +00:00
whesse@chromium.org
0bd21aa0f9 Factor out a commonly used code sequence to DropAndMove(Location, Register)
Review URL: http://codereview.chromium.org/337060

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3156 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-28 09:56:14 +00:00
kmillikin@chromium.org
a73bbe605e Make it more pleasant to work with expression locations in the
top-level code generator backend.  Introduce function to move one
location to another (source cannot be nowhere); to move registers,
slots, and literals into a location; and to move a location to a
register or slot.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3146 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-27 13:38:57 +00:00
fschneider@chromium.org
88371e63f6 Adding declaration of global variables and functions in new compiler.
Adding calls to global functions to the new compiler.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3099 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-21 09:17:39 +00:00
fschneider@chromium.org
1cc731ab0d Record statement positions for the debugger in the fast code generator.
Review URL: http://codereview.chromium.org/271102

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3075 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-15 15:27:37 +00:00
kmillikin@chromium.org
11d9e7ff51 Initial port of top-level code generator to ARM. For the constant
true at the top level we generate:

  0  stmdb sp!, {r1, r8, fp, lr}
  4  add fp, sp, #8
  8  ldr ip, [r10, #+4]
 12  ldr r2, [r10, #+0]
 16  str ip, [sp, #-4]!
 20  add lr, pc, #4
 24  cmp sp, r2
 28  ldrcc pc, [pc, #+68]        ;; code: STUB, StackCheck, minor: 0
 32  ldr ip, [pc, #+68]          ;; object: 0xf5bc4161 <true>
 36  str ip, [sp, #-4]!
 40  ldr ip, [sp, #+0]
 44  str ip, [fp, #-12]
 48  add sp, sp, #4
 52  ldr ip, [fp, #-12]
 56  str ip, [sp, #-4]!
 60  ldr r0, [sp], #+4
 64  mov sp, fp                  ;; js return
 68  ldmia sp!, {fp, lr}
 72  add sp, sp, #4
 76  bx lr
 80  ldr r0, [r10, #+4]
 84  mov sp, fp                  ;; js return
 88  ldmia sp!, {fp, lr}
 92  add sp, sp, #4
 96  bx lr
100  constant pool begin
104  constant
108  constant

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3073 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-15 12:42:16 +00:00
kmillikin@chromium.org
d664dfaf4b Port the initial fast code generator to x64. For the constant true in
top-level code we generate:

 0  push rbp
 1  movq rbp,rsp
 4  push rsi
 5  push rdi
 6  push [r13+0x8]
10  cmpq rsp,[r13+0x0]
14  jnc 25  (0x7ff2c378ff19)
20  call 0x7ff2c377d260     ;; code: STUB, StackCheck, minor: 0
25  movq r10,0x7ff2e8608199    ;; object: 0x7ff2e8608199 <true>
35  push r10
37  movq rax,[rsp]
41  movq [rbp-0x18],rax
45  pop rax
46  push [rbp-0x18]
50  pop rax
51  movq rsp,rbp      ;; js return
54  pop rbp
55  ret 0x8
58  int3
59  int3
60  int3
61  int3
62  int3
63  int3
64  movq rax,[r13+0x8]
68  movq rsp,rbp      ;; js return
71  pop rbp
72  ret 0x8
75  int3
76  int3
77  int3
78  int3
79  int3
80  int3

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3071 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-15 11:21:26 +00:00
kmillikin@chromium.org
f74e723599 Initial infrastructure for fast compilation of top-level code. The
fast code generator is optimized for compilation time and code size.

Currently it is only implemented on IA32.  It is potentially triggered
for any code in the global scope (including code eval'd in the global
scope).  It performs a syntactic check and chooses to compile in fast
mode if the AST contains only supported constructs and matches some
other constraints.

Initially supported constructs are

* ExpressionStatement,
* ReturnStatement,
* VariableProxy (variable references) to parameters and
    stack-allocated locals,
* Assignment with lhs a parameter or stack-allocated local, and
* Literal

This allows compilation of literals at the top level and not much
else.

All intermediate values are allocated to temporaries and the stack is
used for all temporaries.  The extra memory traffic is a known issue.

The code generated for 'true' is:

 0  push ebp
 1  mov ebp,esp
 3  push esi
 4  push edi
 5  push 0xf5cca135             ;; object: 0xf5cca135 <undefined>
10  cmp esp,[0x8277efc]
16  jnc 27  (0xf5cbbb1b)
22  call 0xf5cac960             ;; code: STUB, StackCheck, minor: 0
27  push 0xf5cca161             ;; object: 0xf5cca161 <true>
32  mov eax,[esp]
35  mov [ebp+0xf4],eax
38  pop eax
39  mov eax,[ebp+0xf4]
42  mov esp,ebp                 ;; js return
44  pop ebp
45  ret 0x4
48  mov eax,0xf5cca135          ;; object: 0xf5cca135 <undefined>
53  mov esp,ebp                 ;; js return
55  pop ebp
56  ret 0x4

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3067 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2009-10-14 19:30:50 +00:00