Commit 8636e105 authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: Do not add extra argument for new.target

Port 8196c28a

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

R=dslomov@chromium.org, dstence@us.ibm.com, michael_dawson@ca.ibm.com
BUG=

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

Cr-Commit-Position: refs/heads/master@{#29254}
parent a9558715
......@@ -788,8 +788,6 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) {
__ bdnz(&loop);
__ bind(&no_args);
__ addi(r3, r3, Operand(1));
// Handle step in.
Label skip_step_in;
ExternalReference debug_step_in_fp =
......@@ -815,7 +813,8 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) {
// r3: result
// sp[0]: number of arguments (smi-tagged)
__ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
__ LoadP(r4, MemOperand(sp, 0));
// Get arguments count, skipping over new.target.
__ LoadP(r4, MemOperand(sp, kPointerSize));
// Leave construct frame.
}
......
......@@ -1628,7 +1628,6 @@ void LoadIndexedStringStub::Generate(MacroAssembler* masm) {
void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) {
CHECK(!has_new_target());
// The displacement is the offset of the last parameter (if any)
// relative to the frame pointer.
const int kDisplacement =
......@@ -1689,8 +1688,6 @@ void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) {
// sp[1] : receiver displacement
// sp[2] : function
CHECK(!has_new_target());
// Check if the calling frame is an arguments adaptor frame.
Label runtime;
__ LoadP(r6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
......@@ -1721,8 +1718,6 @@ void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) {
// r9 : allocated object (tagged)
// r11 : mapped parameter count (tagged)
CHECK(!has_new_target());
__ LoadP(r4, MemOperand(sp, 0 * kPointerSize));
// r4 = parameter count (tagged)
......@@ -2005,14 +2000,6 @@ void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) {
// Patch the arguments.length and the parameters pointer.
__ bind(&adaptor_frame);
__ LoadP(r4, MemOperand(r5, ArgumentsAdaptorFrameConstants::kLengthOffset));
if (has_new_target()) {
__ CmpSmiLiteral(r4, Smi::FromInt(0), r0);
Label skip_decrement;
__ beq(&skip_decrement);
// Subtract 1 from smi-tagged arguments count.
__ SubSmiLiteral(r4, r4, Smi::FromInt(1), r0);
__ bind(&skip_decrement);
}
__ StoreP(r4, MemOperand(sp, 0));
__ SmiToPtrArrayOffset(r6, r4);
__ add(r6, r5, r6);
......
......@@ -254,18 +254,35 @@ 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 +
(info_->scope()->num_parameters() + 1) * kPointerSize;
__ LoadP(r3, MemOperand(fp, offset));
// Get the frame pointer for the calling frame.
__ LoadP(r5, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
// Skip the arguments adaptor frame if it exists.
__ LoadP(r4, MemOperand(r5, StandardFrameConstants::kContextOffset));
__ CmpSmiLiteral(r4, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0);
Label skip;
__ bne(&skip);
__ LoadP(r5, MemOperand(r5, StandardFrameConstants::kCallerFPOffset));
__ bind(&skip);
// Check the marker in the calling frame.
__ LoadP(r4, MemOperand(r5, StandardFrameConstants::kMarkerOffset));
__ CmpSmiLiteral(r4, Smi::FromInt(StackFrame::CONSTRUCT), r0);
Label non_construct_frame, done;
__ bne(&non_construct_frame);
__ LoadP(r3, MemOperand(r5, StandardFrameConstants::kExpressionsOffset -
2 * kPointerSize));
__ b(&done);
__ bind(&non_construct_frame);
__ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
__ bind(&done);
SetVar(new_target_var, r3, r5, r6);
}
ArgumentsAccessStub::HasNewTarget has_new_target =
IsSubclassConstructor(info->function()->kind())
? ArgumentsAccessStub::HAS_NEW_TARGET
: ArgumentsAccessStub::NO_NEW_TARGET;
// Possibly allocate RestParameters
int rest_index;
Variable* rest_param = scope()->rest_parameter(&rest_index);
......@@ -274,10 +291,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;
}
__ addi(r6, fp, Operand(StandardFrameConstants::kCallerSPOffset + offset));
__ LoadSmiLiteral(r5, Smi::FromInt(num_parameters));
......@@ -320,7 +333,7 @@ void FullCodeGenerator::Generate() {
} else {
type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
}
ArgumentsAccessStub stub(isolate(), type, has_new_target);
ArgumentsAccessStub stub(isolate(), type);
__ CallStub(&stub);
SetVar(arguments, r3, r4, r5);
......@@ -484,9 +497,6 @@ void FullCodeGenerator::EmitReturnSequence() {
{
Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_);
int32_t arg_count = info_->scope()->num_parameters() + 1;
if (IsSubclassConstructor(info_->function()->kind())) {
arg_count++;
}
int32_t sp_delta = arg_count * kPointerSize;
CodeGenerator::RecordPositions(masm_, function()->end_position() - 1);
__ RecordJSReturn();
......@@ -4286,9 +4296,6 @@ void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) {
__ LoadP(r3, MemOperand(r5, ArgumentsAdaptorFrameConstants::kLengthOffset));
__ SmiUntag(r3);
// Subtract 1 from arguments count, for new.target.
__ subi(r3, r3, Operand(1));
// Get arguments pointer in r5.
__ ShiftLeftImm(r0, r3, Operand(kPointerSizeLog2));
__ add(r5, r5, r0);
......
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