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

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

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

Powered by Google App Engine
This is Rietveld 408576698