| Index: src/arm/builtins-arm.cc
|
| diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc
|
| index efa8d20e388d8266254cbc6dd765b5ca449e0048..138dfc12daf93192e93403d811efa23068760806 100644
|
| --- a/src/arm/builtins-arm.cc
|
| +++ b/src/arm/builtins-arm.cc
|
| @@ -213,39 +213,42 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
|
| // ----------- S t a t e -------------
|
| // -- r0 : number of arguments
|
| // -- r1 : constructor function
|
| + // -- r3 : original constructor
|
| // -- lr : return address
|
| // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
|
| // -- sp[argc * 4] : receiver
|
| // -----------------------------------
|
|
|
| - // 1. Load the first argument into r0 and get rid of the rest (including the
|
| + // 1. Load the first argument into r2 and get rid of the rest (including the
|
| // receiver).
|
| {
|
| Label no_arguments, done;
|
| __ sub(r0, r0, Operand(1), SetCC);
|
| __ b(lo, &no_arguments);
|
| - __ ldr(r0, MemOperand(sp, r0, LSL, kPointerSizeLog2, PreIndex));
|
| + __ ldr(r2, MemOperand(sp, r0, LSL, kPointerSizeLog2, PreIndex));
|
| __ Drop(2);
|
| __ b(&done);
|
| __ bind(&no_arguments);
|
| - __ LoadRoot(r0, Heap::kempty_stringRootIndex);
|
| + __ LoadRoot(r2, Heap::kempty_stringRootIndex);
|
| __ Drop(1);
|
| __ bind(&done);
|
| }
|
|
|
| - // 2. Make sure r0 is a string.
|
| + // 2. Make sure r2 is a string.
|
| {
|
| Label convert, done_convert;
|
| - __ JumpIfSmi(r0, &convert);
|
| - __ CompareObjectType(r0, r2, r2, FIRST_NONSTRING_TYPE);
|
| + __ JumpIfSmi(r2, &convert);
|
| + __ CompareObjectType(r2, r4, r4, FIRST_NONSTRING_TYPE);
|
| __ b(lo, &done_convert);
|
| __ bind(&convert);
|
| {
|
| FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
|
| ToStringStub stub(masm->isolate());
|
| - __ Push(r1);
|
| + __ Push(r1, r3);
|
| + __ Move(r0, r2);
|
| __ CallStub(&stub);
|
| - __ Pop(r1);
|
| + __ Move(r2, r0);
|
| + __ Pop(r1, r3);
|
| }
|
| __ bind(&done_convert);
|
| }
|
| @@ -253,13 +256,18 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
|
| // 3. Allocate a JSValue wrapper for the string.
|
| {
|
| // ----------- S t a t e -------------
|
| - // -- r0 : the first argument
|
| + // -- r2 : the first argument
|
| // -- r1 : constructor function
|
| + // -- r3 : original constructor
|
| // -- lr : return address
|
| // -----------------------------------
|
|
|
| - Label allocate, done_allocate;
|
| - __ Move(r2, r0);
|
| + Label allocate, done_allocate, rt_call;
|
| +
|
| + // Fall back to runtime if the original constructor and function differ.
|
| + __ cmp(r1, r3);
|
| + __ b(ne, &rt_call);
|
| +
|
| __ Allocate(JSValue::kSize, r0, r3, r4, &allocate, TAG_OBJECT);
|
| __ bind(&done_allocate);
|
|
|
| @@ -283,6 +291,18 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
|
| __ Pop(r1, r2);
|
| }
|
| __ b(&done_allocate);
|
| +
|
| + // Fallback to the runtime to create new object.
|
| + __ bind(&rt_call);
|
| + {
|
| + FrameScope scope(masm, StackFrame::INTERNAL);
|
| + __ Push(r1, r2);
|
| + __ Push(r1, r3); // constructor function, original constructor
|
| + __ CallRuntime(Runtime::kNewObject, 2);
|
| + __ Pop(r1, r2);
|
| + }
|
| + __ str(r2, FieldMemOperand(r0, JSValue::kValueOffset));
|
| + __ Ret();
|
| }
|
| }
|
|
|
| @@ -500,8 +520,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| // r3: original constructor
|
| __ bind(&rt_call);
|
|
|
| - __ push(r1); // argument 2/1: constructor function
|
| - __ push(r3); // argument 3/2: original constructor
|
| + __ push(r1); // constructor function
|
| + __ push(r3); // original constructor
|
| __ CallRuntime(Runtime::kNewObject, 2);
|
| __ mov(r4, r0);
|
|
|
|
|