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

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

Issue 2212383003: Revert of Separate Scope into DeclarationScope and Scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « src/full-codegen/s390/full-codegen-s390.cc ('k') | src/full-codegen/x87/full-codegen-x87.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X64 5 #if V8_TARGET_ARCH_X64
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // o rdi: the JS function object being called (i.e. ourselves) 84 // o rdi: the JS function object being called (i.e. ourselves)
85 // o rdx: the new target value 85 // o rdx: the new target value
86 // o rsi: our context 86 // o rsi: our context
87 // o rbp: our caller's frame pointer 87 // o rbp: our caller's frame pointer
88 // o rsp: stack pointer (pointing to return address) 88 // o rsp: stack pointer (pointing to return address)
89 // 89 //
90 // The function builds a JS frame. Please see JavaScriptFrameConstants in 90 // The function builds a JS frame. Please see JavaScriptFrameConstants in
91 // frames-x64.h for its layout. 91 // frames-x64.h for its layout.
92 void FullCodeGenerator::Generate() { 92 void FullCodeGenerator::Generate() {
93 CompilationInfo* info = info_; 93 CompilationInfo* info = info_;
94 DCHECK_EQ(scope(), info->scope());
95 profiling_counter_ = isolate()->factory()->NewCell( 94 profiling_counter_ = isolate()->factory()->NewCell(
96 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); 95 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate()));
97 SetFunctionPosition(literal()); 96 SetFunctionPosition(literal());
98 Comment cmnt(masm_, "[ function compiled by full code generator"); 97 Comment cmnt(masm_, "[ function compiled by full code generator");
99 98
100 ProfileEntryHookStub::MaybeCallEntryHook(masm_); 99 ProfileEntryHookStub::MaybeCallEntryHook(masm_);
101 100
102 if (FLAG_debug_code && info->ExpectsJSReceiverAsReceiver()) { 101 if (FLAG_debug_code && info->ExpectsJSReceiverAsReceiver()) {
103 StackArgumentsAccessor args(rsp, info->scope()->num_parameters()); 102 StackArgumentsAccessor args(rsp, info->scope()->num_parameters());
104 __ movp(rcx, args.GetReceiverOperand()); 103 __ movp(rcx, args.GetReceiverOperand());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 function_in_register = false; 186 function_in_register = false;
188 // Context is returned in rax. It replaces the context passed to us. 187 // Context is returned in rax. It replaces the context passed to us.
189 // It's saved in the stack and kept live in rsi. 188 // It's saved in the stack and kept live in rsi.
190 __ movp(rsi, rax); 189 __ movp(rsi, rax);
191 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax); 190 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax);
192 191
193 // Copy any necessary parameters into the context. 192 // Copy any necessary parameters into the context.
194 int num_parameters = info->scope()->num_parameters(); 193 int num_parameters = info->scope()->num_parameters();
195 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; 194 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0;
196 for (int i = first_parameter; i < num_parameters; i++) { 195 for (int i = first_parameter; i < num_parameters; i++) {
197 Variable* var = 196 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i);
198 (i == -1) ? info->scope()->receiver() : info->scope()->parameter(i);
199 if (var->IsContextSlot()) { 197 if (var->IsContextSlot()) {
200 int parameter_offset = StandardFrameConstants::kCallerSPOffset + 198 int parameter_offset = StandardFrameConstants::kCallerSPOffset +
201 (num_parameters - 1 - i) * kPointerSize; 199 (num_parameters - 1 - i) * kPointerSize;
202 // Load parameter from stack. 200 // Load parameter from stack.
203 __ movp(rax, Operand(rbp, parameter_offset)); 201 __ movp(rax, Operand(rbp, parameter_offset));
204 // Store it in the context. 202 // Store it in the context.
205 int context_offset = Context::SlotOffset(var->index()); 203 int context_offset = Context::SlotOffset(var->index());
206 __ movp(Operand(rsi, context_offset), rax); 204 __ movp(Operand(rsi, context_offset), rax);
207 // Update the write barrier. This clobbers rax and rbx. 205 // Update the write barrier. This clobbers rax and rbx.
208 if (need_write_barrier) { 206 if (need_write_barrier) {
(...skipping 10 matching lines...) Expand all
219 } 217 }
220 218
221 // Register holding this function and new target are both trashed in case we 219 // Register holding this function and new target are both trashed in case we
222 // bailout here. But since that can happen only when new target is not used 220 // bailout here. But since that can happen only when new target is not used
223 // and we allocate a context, the value of |function_in_register| is correct. 221 // and we allocate a context, the value of |function_in_register| is correct.
224 PrepareForBailoutForId(BailoutId::FunctionContext(), 222 PrepareForBailoutForId(BailoutId::FunctionContext(),
225 BailoutState::NO_REGISTERS); 223 BailoutState::NO_REGISTERS);
226 224
227 // Possibly set up a local binding to the this function which is used in 225 // Possibly set up a local binding to the this function which is used in
228 // derived constructors with super calls. 226 // derived constructors with super calls.
229 Variable* this_function_var = info->scope()->this_function_var(); 227 Variable* this_function_var = scope()->this_function_var();
230 if (this_function_var != nullptr) { 228 if (this_function_var != nullptr) {
231 Comment cmnt(masm_, "[ This function"); 229 Comment cmnt(masm_, "[ This function");
232 if (!function_in_register) { 230 if (!function_in_register) {
233 __ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 231 __ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
234 // The write barrier clobbers register again, keep it marked as such. 232 // The write barrier clobbers register again, keep it marked as such.
235 } 233 }
236 SetVar(this_function_var, rdi, rbx, rcx); 234 SetVar(this_function_var, rdi, rbx, rcx);
237 } 235 }
238 236
239 // Possibly set up a local binding to the new target value. 237 // Possibly set up a local binding to the new target value.
240 Variable* new_target_var = info->scope()->new_target_var(); 238 Variable* new_target_var = scope()->new_target_var();
241 if (new_target_var != nullptr) { 239 if (new_target_var != nullptr) {
242 Comment cmnt(masm_, "[ new.target"); 240 Comment cmnt(masm_, "[ new.target");
243 SetVar(new_target_var, rdx, rbx, rcx); 241 SetVar(new_target_var, rdx, rbx, rcx);
244 } 242 }
245 243
246 // Possibly allocate RestParameters 244 // Possibly allocate RestParameters
247 int rest_index; 245 int rest_index;
248 Variable* rest_param = info->scope()->rest_parameter(&rest_index); 246 Variable* rest_param = scope()->rest_parameter(&rest_index);
249 if (rest_param) { 247 if (rest_param) {
250 Comment cmnt(masm_, "[ Allocate rest parameter array"); 248 Comment cmnt(masm_, "[ Allocate rest parameter array");
251 if (!function_in_register) { 249 if (!function_in_register) {
252 __ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 250 __ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
253 } 251 }
254 FastNewRestParameterStub stub(isolate()); 252 FastNewRestParameterStub stub(isolate());
255 __ CallStub(&stub); 253 __ CallStub(&stub);
256 function_in_register = false; 254 function_in_register = false;
257 SetVar(rest_param, rax, rbx, rdx); 255 SetVar(rest_param, rax, rbx, rdx);
258 } 256 }
259 257
260 // Possibly allocate an arguments object. 258 // Possibly allocate an arguments object.
261 DCHECK_EQ(scope(), info->scope()); 259 Variable* arguments = scope()->arguments();
262 Variable* arguments = info->scope()->arguments();
263 if (arguments != NULL) { 260 if (arguments != NULL) {
264 // Arguments object must be allocated after the context object, in 261 // Arguments object must be allocated after the context object, in
265 // case the "arguments" or ".arguments" variables are in the context. 262 // case the "arguments" or ".arguments" variables are in the context.
266 Comment cmnt(masm_, "[ Allocate arguments object"); 263 Comment cmnt(masm_, "[ Allocate arguments object");
267 if (!function_in_register) { 264 if (!function_in_register) {
268 __ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 265 __ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
269 } 266 }
270 if (is_strict(language_mode()) || !has_simple_parameters()) { 267 if (is_strict(language_mode()) || !has_simple_parameters()) {
271 FastNewStrictArgumentsStub stub(isolate()); 268 FastNewStrictArgumentsStub stub(isolate());
272 __ CallStub(&stub); 269 __ CallStub(&stub);
(...skipping 11 matching lines...) Expand all
284 if (FLAG_trace) { 281 if (FLAG_trace) {
285 __ CallRuntime(Runtime::kTraceEnter); 282 __ CallRuntime(Runtime::kTraceEnter);
286 } 283 }
287 284
288 // Visit the declarations and body unless there is an illegal 285 // Visit the declarations and body unless there is an illegal
289 // redeclaration. 286 // redeclaration.
290 PrepareForBailoutForId(BailoutId::FunctionEntry(), 287 PrepareForBailoutForId(BailoutId::FunctionEntry(),
291 BailoutState::NO_REGISTERS); 288 BailoutState::NO_REGISTERS);
292 { 289 {
293 Comment cmnt(masm_, "[ Declarations"); 290 Comment cmnt(masm_, "[ Declarations");
294 VisitDeclarations(info->scope()->declarations()); 291 VisitDeclarations(scope()->declarations());
295 } 292 }
296 293
297 // Assert that the declarations do not use ICs. Otherwise the debugger 294 // Assert that the declarations do not use ICs. Otherwise the debugger
298 // won't be able to redirect a PC at an IC to the correct IC in newly 295 // won't be able to redirect a PC at an IC to the correct IC in newly
299 // recompiled code. 296 // recompiled code.
300 DCHECK_EQ(0, ic_total_count_); 297 DCHECK_EQ(0, ic_total_count_);
301 298
302 { 299 {
303 Comment cmnt(masm_, "[ Stack check"); 300 Comment cmnt(masm_, "[ Stack check");
304 PrepareForBailoutForId(BailoutId::Declarations(), 301 PrepareForBailoutForId(BailoutId::Declarations(),
(...skipping 3203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3508 __ movp(Operand(rbp, frame_offset), value); 3505 __ movp(Operand(rbp, frame_offset), value);
3509 } 3506 }
3510 3507
3511 3508
3512 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { 3509 void FullCodeGenerator::LoadContextField(Register dst, int context_index) {
3513 __ movp(dst, ContextOperand(rsi, context_index)); 3510 __ movp(dst, ContextOperand(rsi, context_index));
3514 } 3511 }
3515 3512
3516 3513
3517 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { 3514 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() {
3518 DeclarationScope* closure_scope = scope()->GetClosureScope(); 3515 Scope* closure_scope = scope()->ClosureScope();
3519 if (closure_scope->is_script_scope() || 3516 if (closure_scope->is_script_scope() ||
3520 closure_scope->is_module_scope()) { 3517 closure_scope->is_module_scope()) {
3521 // Contexts nested in the native context have a canonical empty function 3518 // Contexts nested in the native context have a canonical empty function
3522 // as their closure, not the anonymous closure containing the global 3519 // as their closure, not the anonymous closure containing the global
3523 // code. 3520 // code.
3524 __ movp(rax, NativeContextOperand()); 3521 __ movp(rax, NativeContextOperand());
3525 PushOperand(ContextOperand(rax, Context::CLOSURE_INDEX)); 3522 PushOperand(ContextOperand(rax, Context::CLOSURE_INDEX));
3526 } else if (closure_scope->is_eval_scope()) { 3523 } else if (closure_scope->is_eval_scope()) {
3527 // Contexts created by a call to eval have the same closure as the 3524 // Contexts created by a call to eval have the same closure as the
3528 // context calling eval, not the anonymous closure containing the eval 3525 // context calling eval, not the anonymous closure containing the eval
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3666 DCHECK_EQ( 3663 DCHECK_EQ(
3667 isolate->builtins()->OnStackReplacement()->entry(), 3664 isolate->builtins()->OnStackReplacement()->entry(),
3668 Assembler::target_address_at(call_target_address, unoptimized_code)); 3665 Assembler::target_address_at(call_target_address, unoptimized_code));
3669 return ON_STACK_REPLACEMENT; 3666 return ON_STACK_REPLACEMENT;
3670 } 3667 }
3671 3668
3672 } // namespace internal 3669 } // namespace internal
3673 } // namespace v8 3670 } // namespace v8
3674 3671
3675 #endif // V8_TARGET_ARCH_X64 3672 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/full-codegen/s390/full-codegen-s390.cc ('k') | src/full-codegen/x87/full-codegen-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698