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

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

Issue 1196193014: Do not add extra argument for new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment added Created 5 years, 5 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
« src/arm/full-codegen-arm.cc ('K') | « src/x64/code-stubs-x64.cc ('k') | no next file » | 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // derived constructors with super calls. 234 // derived constructors with super calls.
235 Variable* this_function_var = scope()->this_function_var(); 235 Variable* this_function_var = scope()->this_function_var();
236 if (this_function_var != nullptr) { 236 if (this_function_var != nullptr) {
237 Comment cmnt(masm_, "[ This function"); 237 Comment cmnt(masm_, "[ This function");
238 SetVar(this_function_var, rdi, rbx, rdx); 238 SetVar(this_function_var, rdi, rbx, rdx);
239 } 239 }
240 240
241 Variable* new_target_var = scope()->new_target_var(); 241 Variable* new_target_var = scope()->new_target_var();
242 if (new_target_var != nullptr) { 242 if (new_target_var != nullptr) {
243 Comment cmnt(masm_, "[ new.target"); 243 Comment cmnt(masm_, "[ new.target");
244 // new.target is parameter -2. 244
245 int offset = 2 * kPointerSize + kFPOnStackSize + kPCOnStackSize + 245 __ movp(rax, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
246 (info_->scope()->num_parameters() - 1) * kPointerSize; 246 Label non_adaptor_frame;
247 __ movp(rax, Operand(rbp, offset)); 247 __ Cmp(Operand(rax, StandardFrameConstants::kContextOffset),
248 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
249 __ j(not_equal, &non_adaptor_frame);
250 __ movp(rax, Operand(rax, StandardFrameConstants::kCallerFPOffset));
251
252 __ bind(&non_adaptor_frame);
253 __ Cmp(Operand(rax, StandardFrameConstants::kMarkerOffset),
254 Smi::FromInt(StackFrame::CONSTRUCT));
255
256 Label non_construct_frame, done;
257 __ j(not_equal, &non_construct_frame);
258
259 // Construct frame
260 __ movp(rax, Operand(rax, StandardFrameConstants::kExpressionsOffset -
261 2 * kPointerSize));
262 __ jmp(&done);
263
264 // Non-construct frame
265 __ bind(&non_construct_frame);
266 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
267
268 __ bind(&done);
248 SetVar(new_target_var, rax, rbx, rdx); 269 SetVar(new_target_var, rax, rbx, rdx);
249 } 270 }
250 271
251 ArgumentsAccessStub::HasNewTarget has_new_target =
252 IsSubclassConstructor(info->function()->kind())
253 ? ArgumentsAccessStub::HAS_NEW_TARGET
254 : ArgumentsAccessStub::NO_NEW_TARGET;
255
256 // Possibly allocate RestParameters 272 // Possibly allocate RestParameters
257 int rest_index; 273 int rest_index;
258 Variable* rest_param = scope()->rest_parameter(&rest_index); 274 Variable* rest_param = scope()->rest_parameter(&rest_index);
259 if (rest_param) { 275 if (rest_param) {
260 Comment cmnt(masm_, "[ Allocate rest parameter array"); 276 Comment cmnt(masm_, "[ Allocate rest parameter array");
261 277
262 int num_parameters = info->scope()->num_parameters(); 278 int num_parameters = info->scope()->num_parameters();
263 int offset = num_parameters * kPointerSize; 279 int offset = num_parameters * kPointerSize;
264 if (has_new_target == ArgumentsAccessStub::HAS_NEW_TARGET) {
265 --num_parameters;
266 ++rest_index;
267 }
268 280
269 __ leap(rdx, 281 __ leap(rdx,
270 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset)); 282 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset));
271 __ Push(rdx); 283 __ Push(rdx);
272 __ Push(Smi::FromInt(num_parameters)); 284 __ Push(Smi::FromInt(num_parameters));
273 __ Push(Smi::FromInt(rest_index)); 285 __ Push(Smi::FromInt(rest_index));
274 __ Push(Smi::FromInt(language_mode())); 286 __ Push(Smi::FromInt(language_mode()));
275 287
276 RestParamAccessStub stub(isolate()); 288 RestParamAccessStub stub(isolate());
277 __ CallStub(&stub); 289 __ CallStub(&stub);
(...skipping 25 matching lines...) Expand all
303 // stack frame was an arguments adapter frame. 315 // stack frame was an arguments adapter frame.
304 316
305 ArgumentsAccessStub::Type type; 317 ArgumentsAccessStub::Type type;
306 if (is_strict(language_mode()) || !is_simple_parameter_list()) { 318 if (is_strict(language_mode()) || !is_simple_parameter_list()) {
307 type = ArgumentsAccessStub::NEW_STRICT; 319 type = ArgumentsAccessStub::NEW_STRICT;
308 } else if (function()->has_duplicate_parameters()) { 320 } else if (function()->has_duplicate_parameters()) {
309 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; 321 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
310 } else { 322 } else {
311 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 323 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
312 } 324 }
313 ArgumentsAccessStub stub(isolate(), type, has_new_target); 325 ArgumentsAccessStub stub(isolate(), type);
314 __ CallStub(&stub); 326 __ CallStub(&stub);
315 327
316 SetVar(arguments, rax, rbx, rdx); 328 SetVar(arguments, rax, rbx, rdx);
317 } 329 }
318 330
319 if (FLAG_trace) { 331 if (FLAG_trace) {
320 __ CallRuntime(Runtime::kTraceEnter, 0); 332 __ CallRuntime(Runtime::kTraceEnter, 0);
321 } 333 }
322 334
323 // Visit the declarations and body unless there is an illegal 335 // Visit the declarations and body unless there is an illegal
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 #endif 470 #endif
459 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); 471 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1);
460 __ RecordJSReturn(); 472 __ RecordJSReturn();
461 // Do not use the leave instruction here because it is too short to 473 // Do not use the leave instruction here because it is too short to
462 // patch with the code required by the debugger. 474 // patch with the code required by the debugger.
463 __ movp(rsp, rbp); 475 __ movp(rsp, rbp);
464 __ popq(rbp); 476 __ popq(rbp);
465 int no_frame_start = masm_->pc_offset(); 477 int no_frame_start = masm_->pc_offset();
466 478
467 int arg_count = info_->scope()->num_parameters() + 1; 479 int arg_count = info_->scope()->num_parameters() + 1;
468 if (IsSubclassConstructor(info_->function()->kind())) {
469 arg_count++;
470 }
471 int arguments_bytes = arg_count * kPointerSize; 480 int arguments_bytes = arg_count * kPointerSize;
472 __ Ret(arguments_bytes, rcx); 481 __ Ret(arguments_bytes, rcx);
473 482
474 // Add padding that will be overwritten by a debugger breakpoint. We 483 // Add padding that will be overwritten by a debugger breakpoint. We
475 // have just generated at least 7 bytes: "movp rsp, rbp; pop rbp; ret k" 484 // have just generated at least 7 bytes: "movp rsp, rbp; pop rbp; ret k"
476 // (3 + 1 + 3) for x64 and at least 6 (2 + 1 + 3) bytes for x32. 485 // (3 + 1 + 3) for x64 and at least 6 (2 + 1 + 3) bytes for x32.
477 const int kPadding = Assembler::kJSReturnSequenceLength - 486 const int kPadding = Assembler::kJSReturnSequenceLength -
478 kPointerSize == kInt64Size ? 7 : 6; 487 kPointerSize == kInt64Size ? 7 : 6;
479 for (int i = 0; i < kPadding; ++i) { 488 for (int i = 0; i < kPadding; ++i) {
480 masm_->int3(); 489 masm_->int3();
(...skipping 3686 matching lines...) Expand 10 before | Expand all | Expand 10 after
4167 // default constructor has no arguments, so no adaptor frame means no args. 4176 // default constructor has no arguments, so no adaptor frame means no args.
4168 __ movp(rax, Immediate(0)); 4177 __ movp(rax, Immediate(0));
4169 __ jmp(&args_set_up); 4178 __ jmp(&args_set_up);
4170 4179
4171 // Copy arguments from adaptor frame. 4180 // Copy arguments from adaptor frame.
4172 { 4181 {
4173 __ bind(&adaptor_frame); 4182 __ bind(&adaptor_frame);
4174 __ movp(rcx, Operand(rdx, ArgumentsAdaptorFrameConstants::kLengthOffset)); 4183 __ movp(rcx, Operand(rdx, ArgumentsAdaptorFrameConstants::kLengthOffset));
4175 __ SmiToInteger64(rcx, rcx); 4184 __ SmiToInteger64(rcx, rcx);
4176 4185
4177 // Subtract 1 from arguments count, for new.target.
4178 __ subp(rcx, Immediate(1));
4179 __ movp(rax, rcx); 4186 __ movp(rax, rcx);
4180 __ leap(rdx, Operand(rdx, rcx, times_pointer_size, 4187 __ leap(rdx, Operand(rdx, rcx, times_pointer_size,
4181 StandardFrameConstants::kCallerSPOffset)); 4188 StandardFrameConstants::kCallerSPOffset));
4182 Label loop; 4189 Label loop;
4183 __ bind(&loop); 4190 __ bind(&loop);
4184 __ Push(Operand(rdx, -1 * kPointerSize)); 4191 __ Push(Operand(rdx, -1 * kPointerSize));
4185 __ subp(rdx, Immediate(kPointerSize)); 4192 __ subp(rdx, Immediate(kPointerSize));
4186 __ decp(rcx); 4193 __ decp(rcx);
4187 __ j(not_zero, &loop); 4194 __ j(not_zero, &loop);
4188 } 4195 }
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
5496 Assembler::target_address_at(call_target_address, 5503 Assembler::target_address_at(call_target_address,
5497 unoptimized_code)); 5504 unoptimized_code));
5498 return OSR_AFTER_STACK_CHECK; 5505 return OSR_AFTER_STACK_CHECK;
5499 } 5506 }
5500 5507
5501 5508
5502 } // namespace internal 5509 } // namespace internal
5503 } // namespace v8 5510 } // namespace v8
5504 5511
5505 #endif // V8_TARGET_ARCH_X64 5512 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/arm/full-codegen-arm.cc ('K') | « src/x64/code-stubs-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698