Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/x64/full-codegen-x64.cc

Issue 3152016: Remove experimental fast-codegen. We are no longer working on this (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/fast-codegen-x64.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // formal parameter count expected by the function. 47 // formal parameter count expected by the function.
48 // 48 //
49 // The live registers are: 49 // The live registers are:
50 // o rdi: the JS function object being called (ie, ourselves) 50 // o rdi: the JS function object being called (ie, ourselves)
51 // o rsi: our context 51 // o rsi: our context
52 // o rbp: our caller's frame pointer 52 // o rbp: our caller's frame pointer
53 // o rsp: stack pointer (pointing to return address) 53 // o rsp: stack pointer (pointing to return address)
54 // 54 //
55 // The function builds a JS frame. Please see JavaScriptFrameConstants in 55 // The function builds a JS frame. Please see JavaScriptFrameConstants in
56 // frames-x64.h for its layout. 56 // frames-x64.h for its layout.
57 void FullCodeGenerator::Generate(CompilationInfo* info, Mode mode) { 57 void FullCodeGenerator::Generate(CompilationInfo* info) {
58 ASSERT(info_ == NULL); 58 ASSERT(info_ == NULL);
59 info_ = info; 59 info_ = info;
60 SetFunctionPosition(function()); 60 SetFunctionPosition(function());
61 Comment cmnt(masm_, "[ function compiled by full code generator"); 61 Comment cmnt(masm_, "[ function compiled by full code generator");
62 62
63 if (mode == PRIMARY) { 63 __ push(rbp); // Caller's frame pointer.
64 __ push(rbp); // Caller's frame pointer. 64 __ movq(rbp, rsp);
65 __ movq(rbp, rsp); 65 __ push(rsi); // Callee's context.
66 __ push(rsi); // Callee's context. 66 __ push(rdi); // Callee's JS Function.
67 __ push(rdi); // Callee's JS Function.
68 67
69 { Comment cmnt(masm_, "[ Allocate locals"); 68 { Comment cmnt(masm_, "[ Allocate locals");
70 int locals_count = scope()->num_stack_slots(); 69 int locals_count = scope()->num_stack_slots();
71 if (locals_count == 1) { 70 if (locals_count == 1) {
72 __ PushRoot(Heap::kUndefinedValueRootIndex); 71 __ PushRoot(Heap::kUndefinedValueRootIndex);
73 } else if (locals_count > 1) { 72 } else if (locals_count > 1) {
74 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex); 73 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex);
75 for (int i = 0; i < locals_count; i++) { 74 for (int i = 0; i < locals_count; i++) {
76 __ push(rdx); 75 __ push(rdx);
77 }
78 } 76 }
79 } 77 }
80
81 bool function_in_register = true;
82
83 // Possibly allocate a local context.
84 int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
85 if (heap_slots > 0) {
86 Comment cmnt(masm_, "[ Allocate local context");
87 // Argument to NewContext is the function, which is still in rdi.
88 __ push(rdi);
89 if (heap_slots <= FastNewContextStub::kMaximumSlots) {
90 FastNewContextStub stub(heap_slots);
91 __ CallStub(&stub);
92 } else {
93 __ CallRuntime(Runtime::kNewContext, 1);
94 }
95 function_in_register = false;
96 // Context is returned in both rax and rsi. It replaces the context
97 // passed to us. It's saved in the stack and kept live in rsi.
98 __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi);
99
100 // Copy any necessary parameters into the context.
101 int num_parameters = scope()->num_parameters();
102 for (int i = 0; i < num_parameters; i++) {
103 Slot* slot = scope()->parameter(i)->slot();
104 if (slot != NULL && slot->type() == Slot::CONTEXT) {
105 int parameter_offset = StandardFrameConstants::kCallerSPOffset +
106 (num_parameters - 1 - i) * kPointerSize;
107 // Load parameter from stack.
108 __ movq(rax, Operand(rbp, parameter_offset));
109 // Store it in the context.
110 int context_offset = Context::SlotOffset(slot->index());
111 __ movq(Operand(rsi, context_offset), rax);
112 // Update the write barrier. This clobbers all involved
113 // registers, so we have use a third register to avoid
114 // clobbering rsi.
115 __ movq(rcx, rsi);
116 __ RecordWrite(rcx, context_offset, rax, rbx);
117 }
118 }
119 }
120
121 // Possibly allocate an arguments object.
122 Variable* arguments = scope()->arguments()->AsVariable();
123 if (arguments != NULL) {
124 // Arguments object must be allocated after the context object, in
125 // case the "arguments" or ".arguments" variables are in the context.
126 Comment cmnt(masm_, "[ Allocate arguments object");
127 if (function_in_register) {
128 __ push(rdi);
129 } else {
130 __ push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
131 }
132 // The receiver is just before the parameters on the caller's stack.
133 int offset = scope()->num_parameters() * kPointerSize;
134 __ lea(rdx,
135 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset));
136 __ push(rdx);
137 __ Push(Smi::FromInt(scope()->num_parameters()));
138 // Arguments to ArgumentsAccessStub:
139 // function, receiver address, parameter count.
140 // The stub will rewrite receiver and parameter count if the previous
141 // stack frame was an arguments adapter frame.
142 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT);
143 __ CallStub(&stub);
144 // Store new arguments object in both "arguments" and ".arguments" slots.
145 __ movq(rcx, rax);
146 Move(arguments->slot(), rax, rbx, rdx);
147 Slot* dot_arguments_slot =
148 scope()->arguments_shadow()->AsVariable()->slot();
149 Move(dot_arguments_slot, rcx, rbx, rdx);
150 }
151 } 78 }
152 79
80 bool function_in_register = true;
81
82 // Possibly allocate a local context.
83 int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
84 if (heap_slots > 0) {
85 Comment cmnt(masm_, "[ Allocate local context");
86 // Argument to NewContext is the function, which is still in rdi.
87 __ push(rdi);
88 if (heap_slots <= FastNewContextStub::kMaximumSlots) {
89 FastNewContextStub stub(heap_slots);
90 __ CallStub(&stub);
91 } else {
92 __ CallRuntime(Runtime::kNewContext, 1);
93 }
94 function_in_register = false;
95 // Context is returned in both rax and rsi. It replaces the context
96 // passed to us. It's saved in the stack and kept live in rsi.
97 __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi);
98
99 // Copy any necessary parameters into the context.
100 int num_parameters = scope()->num_parameters();
101 for (int i = 0; i < num_parameters; i++) {
102 Slot* slot = scope()->parameter(i)->slot();
103 if (slot != NULL && slot->type() == Slot::CONTEXT) {
104 int parameter_offset = StandardFrameConstants::kCallerSPOffset +
105 (num_parameters - 1 - i) * kPointerSize;
106 // Load parameter from stack.
107 __ movq(rax, Operand(rbp, parameter_offset));
108 // Store it in the context.
109 int context_offset = Context::SlotOffset(slot->index());
110 __ movq(Operand(rsi, context_offset), rax);
111 // Update the write barrier. This clobbers all involved
112 // registers, so we have use a third register to avoid
113 // clobbering rsi.
114 __ movq(rcx, rsi);
115 __ RecordWrite(rcx, context_offset, rax, rbx);
116 }
117 }
118 }
119
120 // Possibly allocate an arguments object.
121 Variable* arguments = scope()->arguments()->AsVariable();
122 if (arguments != NULL) {
123 // Arguments object must be allocated after the context object, in
124 // case the "arguments" or ".arguments" variables are in the context.
125 Comment cmnt(masm_, "[ Allocate arguments object");
126 if (function_in_register) {
127 __ push(rdi);
128 } else {
129 __ push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
130 }
131 // The receiver is just before the parameters on the caller's stack.
132 int offset = scope()->num_parameters() * kPointerSize;
133 __ lea(rdx,
134 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset));
135 __ push(rdx);
136 __ Push(Smi::FromInt(scope()->num_parameters()));
137 // Arguments to ArgumentsAccessStub:
138 // function, receiver address, parameter count.
139 // The stub will rewrite receiver and parameter count if the previous
140 // stack frame was an arguments adapter frame.
141 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT);
142 __ CallStub(&stub);
143 // Store new arguments object in both "arguments" and ".arguments" slots.
144 __ movq(rcx, rax);
145 Move(arguments->slot(), rax, rbx, rdx);
146 Slot* dot_arguments_slot =
147 scope()->arguments_shadow()->AsVariable()->slot();
148 Move(dot_arguments_slot, rcx, rbx, rdx);
149 }
150
153 { Comment cmnt(masm_, "[ Declarations"); 151 { Comment cmnt(masm_, "[ Declarations");
154 // For named function expressions, declare the function name as a 152 // For named function expressions, declare the function name as a
155 // constant. 153 // constant.
156 if (scope()->is_function_scope() && scope()->function() != NULL) { 154 if (scope()->is_function_scope() && scope()->function() != NULL) {
157 EmitDeclaration(scope()->function(), Variable::CONST, NULL); 155 EmitDeclaration(scope()->function(), Variable::CONST, NULL);
158 } 156 }
159 // Visit all the explicit declarations unless there is an illegal 157 // Visit all the explicit declarations unless there is an illegal
160 // redeclaration. 158 // redeclaration.
161 if (scope()->HasIllegalRedeclaration()) { 159 if (scope()->HasIllegalRedeclaration()) {
162 scope()->VisitIllegalRedeclaration(this); 160 scope()->VisitIllegalRedeclaration(this);
(...skipping 3183 matching lines...) Expand 10 before | Expand all | Expand 10 after
3346 __ ret(0); 3344 __ ret(0);
3347 } 3345 }
3348 3346
3349 3347
3350 #undef __ 3348 #undef __
3351 3349
3352 3350
3353 } } // namespace v8::internal 3351 } } // namespace v8::internal
3354 3352
3355 #endif // V8_TARGET_ARCH_X64 3353 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/fast-codegen-x64.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698