| Index: src/ppc/builtins-ppc.cc
|
| diff --git a/src/ppc/builtins-ppc.cc b/src/ppc/builtins-ppc.cc
|
| index 881cffb57513e85aa4e6ca00f1125508a8953363..c630016dd26fb1f9efc6f69b9be1722a04dd09fd 100644
|
| --- a/src/ppc/builtins-ppc.cc
|
| +++ b/src/ppc/builtins-ppc.cc
|
| @@ -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);
|
|
|
|
|