PPC: [fullcode] Switch passing of new.target to register.

Port 440a42b741

Original commit message:
    This passes the new.target value in a register instead of through a
    side-channel via the construct stub. Note that this marks the last
    consumer of said side-channel and the special slot in the construct
    stub frame can be removed as a follow-up.

R=mstarzinger@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
TEST=mjsunit/es6/regress/regress-new-target-context
BUG=

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

Cr-Commit-Position: refs/heads/master@{#32585}
This commit is contained in:
mbrandy 2015-12-03 11:37:53 -08:00 committed by Commit bot
parent 6542161302
commit 3950206fc2

View File

@ -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();