Commit 5a8da494 authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: [es6] Better support for built-ins subclassing.

Port 4490ce85

Original commit message:
    Create proper initial map for original constructor (new.target) instead of doing prototype
    transition on the base constructor's initial map. This approach fixes in-object slack tracking
    for subclass instances.
    This CL also fixes subclassing from String.

    It also fixes typed array map smashing done during typed array initialization.

R=ishell@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, dstence@us.ibm.com
BUG=v8:3101, v8:3330, v8:4419
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#31720}
parent 16ca5c61
......@@ -222,41 +222,44 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r3 : number of arguments
// -- r4 : constructor function
// -- r6 : original constructor
// -- lr : return address
// -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
// -- sp[argc * 4] : receiver
// -----------------------------------
// 1. Load the first argument into r3 and get rid of the rest (including the
// 1. Load the first argument into r5 and get rid of the rest (including the
// receiver).
{
Label no_arguments, done;
__ cmpi(r3, Operand::Zero());
__ beq(&no_arguments);
__ subi(r3, r3, Operand(1));
__ ShiftLeftImm(r3, r3, Operand(kPointerSizeLog2));
__ LoadPUX(r3, MemOperand(sp, r3));
__ ShiftLeftImm(r5, r3, Operand(kPointerSizeLog2));
__ LoadPUX(r5, MemOperand(sp, r5));
__ Drop(2);
__ b(&done);
__ bind(&no_arguments);
__ LoadRoot(r3, Heap::kempty_stringRootIndex);
__ LoadRoot(r5, Heap::kempty_stringRootIndex);
__ Drop(1);
__ bind(&done);
}
// 2. Make sure r3 is a string.
// 2. Make sure r5 is a string.
{
Label convert, done_convert;
__ JumpIfSmi(r3, &convert);
__ CompareObjectType(r3, r5, r5, FIRST_NONSTRING_TYPE);
__ JumpIfSmi(r5, &convert);
__ CompareObjectType(r5, r7, r7, FIRST_NONSTRING_TYPE);
__ blt(&done_convert);
__ bind(&convert);
{
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
ToStringStub stub(masm->isolate());
__ push(r4);
__ Push(r4, r6);
__ mr(r3, r5);
__ CallStub(&stub);
__ pop(r4);
__ mr(r5, r3);
__ Pop(r4, r6);
}
__ bind(&done_convert);
}
......@@ -264,13 +267,18 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
// 3. Allocate a JSValue wrapper for the string.
{
// ----------- S t a t e -------------
// -- r3 : the first argument
// -- r5 : the first argument
// -- r4 : constructor function
// -- r6 : original constructor
// -- lr : return address
// -----------------------------------
Label allocate, done_allocate;
__ mr(r5, r3);
Label allocate, done_allocate, rt_call;
// Fall back to runtime if the original constructor and function differ.
__ cmp(r4, r6);
__ bne(&rt_call);
__ Allocate(JSValue::kSize, r3, r6, r7, &allocate, TAG_OBJECT);
__ bind(&done_allocate);
......@@ -294,6 +302,17 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
__ Pop(r4, r5);
}
__ b(&done_allocate);
// Fallback to the runtime to create new object.
__ bind(&rt_call);
{
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
__ Push(r4, r5, r4, r6); // constructor function, original constructor
__ CallRuntime(Runtime::kNewObject, 2);
__ Pop(r4, r5);
}
__ StoreP(r5, FieldMemOperand(r3, JSValue::kValueOffset), r0);
__ Ret();
}
}
......@@ -509,7 +528,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// r4: constructor function
// r6: original constructor
__ bind(&rt_call);
__ Push(r4, r6);
__ Push(r4, r6); // constructor function, original constructor
__ CallRuntime(Runtime::kNewObject, 2);
__ mr(r7, r3);
......
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