Index: src/mips64/builtins-mips64.cc |
diff --git a/src/mips64/builtins-mips64.cc b/src/mips64/builtins-mips64.cc |
index 389d39be6c824ae1659a696ab04eaa58a13e21cb..24f25e1b60d0d8c5c7cc67c37c4dfcb01a52c40b 100644 |
--- a/src/mips64/builtins-mips64.cc |
+++ b/src/mips64/builtins-mips64.cc |
@@ -224,6 +224,7 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
// ----------- S t a t e ------------- |
// -- a0 : number of arguments |
// -- a1 : constructor function |
+ // -- a3 : original constructor |
// -- ra : return address |
// -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
// -- sp[argc * 8] : receiver |
@@ -257,10 +258,10 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
{ |
FrameScope scope(masm, StackFrame::INTERNAL); |
ToStringStub stub(masm->isolate()); |
- __ Push(a1); |
+ __ Push(a1, a3); |
__ CallStub(&stub); |
__ Move(a0, v0); |
- __ Pop(a1); |
+ __ Pop(a1, a3); |
} |
__ bind(&done_convert); |
} |
@@ -270,10 +271,15 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
// ----------- S t a t e ------------- |
// -- a0 : the first argument |
// -- a1 : constructor function |
+ // -- a3 : original constructor |
// -- ra : return address |
// ----------------------------------- |
- Label allocate, done_allocate; |
+ Label allocate, done_allocate, rt_call; |
+ |
+ // Fall back to runtime if the original constructor and function differ. |
+ __ Branch(&rt_call, ne, a1, Operand(a3)); |
+ |
__ Allocate(JSValue::kSize, v0, a2, a3, &allocate, TAG_OBJECT); |
__ bind(&done_allocate); |
@@ -297,6 +303,17 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
__ Pop(a0, a1); |
} |
__ jmp(&done_allocate); |
+ |
+ // Fallback to the runtime to create new object. |
+ __ bind(&rt_call); |
+ { |
+ FrameScope scope(masm, StackFrame::INTERNAL); |
+ __ Push(a0, a1, a1, a3); // constructor function, original constructor |
+ __ CallRuntime(Runtime::kNewObject, 2); |
+ __ Pop(a0, a1); |
+ } |
+ __ sd(a0, FieldMemOperand(v0, JSValue::kValueOffset)); |
+ __ Ret(); |
} |
} |
@@ -508,7 +525,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
// a3: original constructor |
__ bind(&rt_call); |
- __ Push(a1, a3); // arguments 2-3 / 1-2 |
+ __ Push(a1, a3); // constructor function, original constructor |
__ CallRuntime(Runtime::kNewObject, 2); |
__ mov(t0, v0); |