Index: src/full-codegen/ppc/full-codegen-ppc.cc |
diff --git a/src/full-codegen/ppc/full-codegen-ppc.cc b/src/full-codegen/ppc/full-codegen-ppc.cc |
index 68b843081cba9b6bcbadf1dcb8cd9dbf6958ab56..e8014c0d9f132a1c24791006001221bea9b665be 100644 |
--- a/src/full-codegen/ppc/full-codegen-ppc.cc |
+++ b/src/full-codegen/ppc/full-codegen-ppc.cc |
@@ -89,6 +89,7 @@ class JumpPatchSite BASE_EMBEDDED { |
// |
// The live registers are: |
// o r4: the JS function object being called (i.e., ourselves) |
+// o r6: the new target value |
// o cp: our context |
// o fp: our caller's frame pointer (aka r31) |
// o sp: stack pointer |
@@ -187,14 +188,24 @@ void FullCodeGenerator::Generate() { |
__ Push(info->scope()->GetScopeInfo(info->isolate())); |
__ CallRuntime(Runtime::kNewScriptContext, 2); |
PrepareForBailoutForId(BailoutId::ScriptContext(), TOS_REG); |
- } else if (slots <= FastNewContextStub::kMaximumSlots) { |
- FastNewContextStub stub(isolate(), slots); |
- __ CallStub(&stub); |
- // Result of FastNewContextStub is always in new space. |
- need_write_barrier = false; |
+ // The new target value is not used, clobbering is safe. |
+ DCHECK_NULL(info->scope()->new_target_var()); |
} else { |
- __ push(r4); |
- __ CallRuntime(Runtime::kNewFunctionContext, 1); |
+ if (info->scope()->new_target_var() != nullptr) { |
+ __ push(r6); // Preserve new target. |
+ } |
+ if (slots <= FastNewContextStub::kMaximumSlots) { |
+ FastNewContextStub stub(isolate(), slots); |
+ __ CallStub(&stub); |
+ // Result of FastNewContextStub is always in new space. |
+ need_write_barrier = false; |
+ } else { |
+ __ push(r4); |
+ __ CallRuntime(Runtime::kNewFunctionContext, 1); |
+ } |
+ if (info->scope()->new_target_var() != nullptr) { |
+ __ pop(r6); // Preserve new target. |
+ } |
} |
function_in_register_r4 = false; |
// Context is returned in r3. It replaces the context passed to us. |
@@ -217,7 +228,7 @@ void FullCodeGenerator::Generate() { |
// Update the write barrier. |
if (need_write_barrier) { |
- __ RecordWriteContextSlot(cp, target.offset(), r3, r6, |
+ __ RecordWriteContextSlot(cp, target.offset(), r3, r5, |
kLRHasBeenSaved, kDontSaveFPRegs); |
} else if (FLAG_debug_code) { |
Label done; |
@@ -228,11 +239,11 @@ void FullCodeGenerator::Generate() { |
} |
} |
} |
- PrepareForBailoutForId(BailoutId::FunctionContext(), NO_REGISTERS); |
- // Function register is trashed in case we bailout here. But since that |
- // could happen only when we allocate a context the value of |
- // |function_in_register_r4| is correct. |
+ // Register holding this function and new target are both trashed in case we |
+ // bailout here. But since that can happen only when new target is not used |
+ // and we allocate a context, the value of |function_in_register| is correct. |
+ PrepareForBailoutForId(BailoutId::FunctionContext(), NO_REGISTERS); |
// Possibly set up a local binding to the this function which is used in |
// derived constructors with super calls. |
@@ -246,36 +257,11 @@ void FullCodeGenerator::Generate() { |
SetVar(this_function_var, r4, r3, r5); |
} |
+ // Possibly set up a local binding to the new target value. |
Variable* new_target_var = scope()->new_target_var(); |
if (new_target_var != nullptr) { |
Comment cmnt(masm_, "[ new.target"); |
- |
- // 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; |
- function_in_register_r4 = false; |
- |
- __ bne(&non_construct_frame); |
- __ LoadP(r3, MemOperand(r5, ConstructFrameConstants::kNewTargetOffset)); |
- __ b(&done); |
- |
- __ bind(&non_construct_frame); |
- __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
- __ bind(&done); |
- |
- SetVar(new_target_var, r3, r5, r6); |
+ SetVar(new_target_var, r6, r3, r5); |
} |
Variable* arguments = scope()->arguments(); |