Index: src/mips/full-codegen-mips.cc |
diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc |
index 51c0157a438629b94d9687f7043059aeadc44e96..7d2c02ed594f1aa09735e84706f0909070d46646 100644 |
--- a/src/mips/full-codegen-mips.cc |
+++ b/src/mips/full-codegen-mips.cc |
@@ -258,18 +258,36 @@ 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; |
- __ lw(v0, MemOperand(fp, offset)); |
+ |
+ // Get the frame pointer for the calling frame. |
+ __ lw(a2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
+ |
+ // Skip the arguments adaptor frame if it exists. |
+ Label check_frame_marker; |
+ __ lw(a1, MemOperand(a2, StandardFrameConstants::kContextOffset)); |
+ __ Branch(&check_frame_marker, ne, a1, |
+ Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
+ __ lw(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset)); |
+ |
+ // Check the marker in the calling frame. |
+ __ bind(&check_frame_marker); |
+ __ lw(a1, MemOperand(a2, StandardFrameConstants::kMarkerOffset)); |
+ |
+ Label non_construct_frame, done; |
+ __ Branch(&non_construct_frame, ne, a1, |
+ Operand(Smi::FromInt(StackFrame::CONSTRUCT))); |
+ |
+ __ lw(v0, MemOperand(a2, StandardFrameConstants::kExpressionsOffset - |
+ 2 * kPointerSize)); |
+ __ Branch(&done); |
+ |
+ __ bind(&non_construct_frame); |
+ __ LoadRoot(v0, Heap::kUndefinedValueRootIndex); |
+ __ bind(&done); |
+ |
SetVar(new_target_var, v0, a2, a3); |
} |
- 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); |
@@ -278,10 +296,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; |
- } |
__ Addu(a3, fp, |
Operand(StandardFrameConstants::kCallerSPOffset + offset)); |
@@ -326,7 +340,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, v0, a1, a2); |
@@ -487,9 +501,6 @@ void FullCodeGenerator::EmitReturnSequence() { |
// Here we use masm_-> instead of the __ macro to avoid the code coverage |
// tool from instrumenting as we rely on the code size here. |
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(); |
@@ -4280,8 +4291,6 @@ void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { |
__ lw(a1, MemOperand(a2, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
__ SmiUntag(a1, a1); |
- // Subtract 1 from arguments count, for new.target. |
- __ Addu(a1, a1, Operand(-1)); |
__ mov(a0, a1); |
// Get arguments pointer in a2. |