Commit 18d27f19 authored by chunyang.dai's avatar chunyang.dai Committed by Commit bot

X87: Do not add extra argument for new.target.

port 8196c28a (r29238).

original commit message:

  JSConstructStub for subclass constructors instead locates new.target in
  a known location on the stack.

BUG=

Review URL: https://codereview.chromium.org/1207613003

Cr-Commit-Position: refs/heads/master@{#29398}
parent 32f32bdf
......@@ -530,9 +530,6 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) {
__ dec(ecx);
__ j(greater_equal, &loop);
__ inc(eax); // Pushed new.target.
// Handle step in.
Label skip_step_in;
ExternalReference debug_step_in_fp =
......@@ -556,7 +553,8 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) {
// Restore context from the frame.
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
__ mov(ebx, Operand(esp, 0));
// Get arguments count, skipping over new.target.
__ mov(ebx, Operand(esp, kPointerSize));
}
__ pop(ecx); // Return address.
......
......@@ -414,7 +414,6 @@ void LoadIndexedStringStub::Generate(MacroAssembler* masm) {
void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) {
CHECK(!has_new_target());
// The key is in edx and the parameter count is in eax.
DCHECK(edx.is(ArgumentsAccessReadDescriptor::index()));
DCHECK(eax.is(ArgumentsAccessReadDescriptor::parameter_count()));
......@@ -481,8 +480,6 @@ void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) {
// esp[8] : receiver displacement
// esp[12] : function
CHECK(!has_new_target());
// Check if the calling frame is an arguments adaptor frame.
Label runtime;
__ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
......@@ -511,8 +508,6 @@ void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) {
// ebx = parameter count (tagged)
__ mov(ebx, Operand(esp, 1 * kPointerSize));
CHECK(!has_new_target());
// Check if the calling frame is an arguments adaptor frame.
// TODO(rossberg): Factor out some of the bits that are shared with the other
// Generate* functions.
......@@ -753,18 +748,6 @@ void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) {
__ bind(&adaptor_frame);
__ mov(ecx, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset));
if (has_new_target()) {
// If the constructor was [[Call]]ed, the call will not push a new.target
// onto the stack. In that case the arguments array we construct is bogus,
// bu we do not care as the constructor throws immediately.
__ cmp(ecx, Immediate(Smi::FromInt(0)));
Label skip_decrement;
__ j(equal, &skip_decrement);
// Subtract 1 from smi-tagged arguments count.
__ sub(ecx, Immediate(2));
__ bind(&skip_decrement);
}
__ lea(edx, Operand(edx, ecx, times_2,
StandardFrameConstants::kCallerSPOffset));
__ mov(Operand(esp, 1 * kPointerSize), ecx);
......
......@@ -246,17 +246,33 @@ void FullCodeGenerator::Generate() {
Variable* new_target_var = scope()->new_target_var();
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));
__ 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));
__ jmp(&done);
// Non-construct frame
__ bind(&non_construct_frame);
__ mov(eax, Immediate(isolate()->factory()->undefined_value()));
__ bind(&done);
SetVar(new_target_var, eax, ebx, edx);
}
ArgumentsAccessStub::HasNewTarget has_new_target =
IsSubclassConstructor(info->function()->kind())
? ArgumentsAccessStub::HAS_NEW_TARGET
: ArgumentsAccessStub::NO_NEW_TARGET;
// Possibly allocate RestParameters
int rest_index;
......@@ -266,10 +282,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));
......@@ -313,7 +325,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);
......@@ -463,9 +475,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
......@@ -3017,6 +3026,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()));
......@@ -4189,8 +4199,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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment