diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index a0e990ccb0..f053c7942c 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -291,6 +291,17 @@ void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor( } +void NewStringAddStub::InitializeInterfaceDescriptor( + Isolate* isolate, + CodeStubInterfaceDescriptor* descriptor) { + static Register registers[] = { a1, a0 }; + descriptor->register_param_count_ = 2; + descriptor->register_params_ = registers; + descriptor->deoptimization_handler_ = + Runtime::FunctionForId(Runtime::kStringAdd)->entry; +} + + #define __ ACCESS_MASM(masm) diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index 38334d50dd..56c9240dc5 100644 --- a/src/mips/full-codegen-mips.cc +++ b/src/mips/full-codegen-mips.cc @@ -3740,11 +3740,20 @@ void FullCodeGenerator::EmitStringCharAt(CallRuntime* expr) { void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { ZoneList* args = expr->arguments(); ASSERT_EQ(2, args->length()); - VisitForStackValue(args->at(0)); - VisitForStackValue(args->at(1)); + if (FLAG_new_string_add) { + VisitForStackValue(args->at(0)); + VisitForAccumulatorValue(args->at(1)); - StringAddStub stub(STRING_ADD_CHECK_BOTH); - __ CallStub(&stub); + __ pop(a1); + NewStringAddStub stub(STRING_ADD_CHECK_BOTH, NOT_TENURED); + __ CallStub(&stub); + } else { + VisitForStackValue(args->at(0)); + VisitForStackValue(args->at(1)); + + StringAddStub stub(STRING_ADD_CHECK_BOTH); + __ CallStub(&stub); + } context()->Plug(v0); } diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 5c2d636d0d..b1cf42cb31 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -4480,10 +4480,18 @@ void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { void LCodeGen::DoStringAdd(LStringAdd* instr) { ASSERT(ToRegister(instr->context()).is(cp)); - __ push(ToRegister(instr->left())); - __ push(ToRegister(instr->right())); - StringAddStub stub(instr->hydrogen()->flags()); - CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); + if (FLAG_new_string_add) { + ASSERT(ToRegister(instr->left()).is(a1)); + ASSERT(ToRegister(instr->right()).is(a0)); + NewStringAddStub stub(instr->hydrogen()->flags(), + isolate()->heap()->GetPretenureMode()); + CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); + } else { + __ push(ToRegister(instr->left())); + __ push(ToRegister(instr->right())); + StringAddStub stub(instr->hydrogen()->flags()); + CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); + } } diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index edb1206b01..943d9476f4 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -2335,8 +2335,12 @@ LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { LOperand* context = UseFixed(instr->context(), cp); - LOperand* left = UseRegisterAtStart(instr->left()); - LOperand* right = UseRegisterAtStart(instr->right()); + LOperand* left = FLAG_new_string_add + ? UseFixed(instr->left(), a1) + : UseRegisterAtStart(instr->left()); + LOperand* right = FLAG_new_string_add + ? UseFixed(instr->right(), a0) + : UseRegisterAtStart(instr->right()); return MarkAsCall( DefineFixed(new(zone()) LStringAdd(context, left, right), v0), instr);