 Chromium Code Reviews
 Chromium Code Reviews Issue 1196193014:
  Do not add extra argument for new.target  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 1196193014:
  Do not add extra argument for new.target  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| Index: src/ia32/full-codegen-ia32.cc | 
| diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc | 
| index 1c7b75443f80bef4bd9c8baeb334fdbe7fb5bc85..0a26f40ccbd06c8e55c23f3e4f9f3129960234e3 100644 | 
| --- a/src/ia32/full-codegen-ia32.cc | 
| +++ b/src/ia32/full-codegen-ia32.cc | 
| @@ -246,16 +246,37 @@ void FullCodeGenerator::Generate() { | 
| if (new_target_var != nullptr) { | 
| Comment cmnt(masm_, "[ new.target"); | 
| // new.target is parameter -2. | 
| - int offset = 2 * kPointerSize + kFPOnStackSize + kPCOnStackSize + | 
| - (info_->scope()->num_parameters() - 1) * kPointerSize; | 
| - __ mov(eax, Operand(ebp, offset)); | 
| + // int offset = 2 * kPointerSize + kFPOnStackSize + kPCOnStackSize + | 
| + // (info_->scope()->num_parameters() - 1) * kPointerSize; | 
| + __ mov(eax, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 
| + | 
| + Label non_adaptor_frame; | 
| + __ cmp(Operand(eax, StandardFrameConstants::kContextOffset), | 
| + Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 
| + __ j(not_equal, &non_adaptor_frame); | 
| + __ mov(eax, Operand(eax, StandardFrameConstants::kCallerFPOffset)); | 
| + | 
| + __ bind(&non_adaptor_frame); | 
| + __ cmp(Operand(eax, StandardFrameConstants::kMarkerOffset), | 
| + Immediate(Smi::FromInt(StackFrame::CONSTRUCT))); | 
| + | 
| + Label non_construct_frame, done; | 
| + __ j(not_equal, &non_construct_frame); | 
| + | 
| + // Construct frame | 
| + __ mov(eax, Operand(eax, StandardFrameConstants::kExpressionsOffset - | 
| + 2 * kPointerSize)); | 
| SetVar(new_target_var, eax, ebx, edx); | 
| 
arv (Not doing code reviews)
2015/06/23 14:13:46
This can be shared between the two branches.
 
Dmitry Lomov (no reviews)
2015/06/23 15:06:24
Done.
 | 
| + __ jmp(&done); | 
| + | 
| + // Non-construct frame | 
| + __ bind(&non_construct_frame); | 
| + __ mov(eax, Immediate(isolate()->factory()->undefined_value())); | 
| + SetVar(new_target_var, eax, ebx, edx); | 
| + | 
| + __ bind(&done); | 
| } | 
| - ArgumentsAccessStub::HasNewTarget has_new_target = | 
| - IsSubclassConstructor(info->function()->kind()) | 
| - ? ArgumentsAccessStub::HAS_NEW_TARGET | 
| - : ArgumentsAccessStub::NO_NEW_TARGET; | 
| // Possibly allocate RestParameters | 
| int rest_index; | 
| @@ -265,10 +286,6 @@ void FullCodeGenerator::Generate() { | 
| int num_parameters = info->scope()->num_parameters(); | 
| int offset = num_parameters * kPointerSize; | 
| - if (has_new_target == ArgumentsAccessStub::HAS_NEW_TARGET) { | 
| - --num_parameters; | 
| - ++rest_index; | 
| - } | 
| __ lea(edx, | 
| Operand(ebp, StandardFrameConstants::kCallerSPOffset + offset)); | 
| @@ -312,7 +329,7 @@ void FullCodeGenerator::Generate() { | 
| type = ArgumentsAccessStub::NEW_SLOPPY_FAST; | 
| } | 
| - ArgumentsAccessStub stub(isolate(), type, has_new_target); | 
| + ArgumentsAccessStub stub(isolate(), type); | 
| __ CallStub(&stub); | 
| SetVar(arguments, eax, ebx, edx); | 
| @@ -462,9 +479,6 @@ void FullCodeGenerator::EmitReturnSequence() { | 
| __ pop(ebp); | 
| int arg_count = info_->scope()->num_parameters() + 1; | 
| - if (IsSubclassConstructor(info_->function()->kind())) { | 
| - arg_count++; | 
| - } | 
| int arguments_bytes = arg_count * kPointerSize; | 
| __ Ret(arguments_bytes, ecx); | 
| // Check that the size of the code used for returning is large enough | 
| @@ -3016,6 +3030,7 @@ void FullCodeGenerator::EmitInitializeThisAfterSuper( | 
| Variable* this_var = super_call_ref->this_var()->var(); | 
| GetVar(ecx, this_var); | 
| __ cmp(ecx, isolate()->factory()->the_hole_value()); | 
| + | 
| Label uninitialized_this; | 
| __ j(equal, &uninitialized_this); | 
| __ push(Immediate(this_var->name())); | 
| @@ -4180,8 +4195,6 @@ void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { | 
| __ mov(ecx, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 
| __ SmiUntag(ecx); | 
| - // Subtract 1 from arguments count, for new.target. | 
| - __ sub(ecx, Immediate(1)); | 
| __ mov(eax, ecx); | 
| __ lea(edx, Operand(edx, ecx, times_pointer_size, | 
| StandardFrameConstants::kCallerSPOffset)); |