| Index: src/x64/code-stubs-x64.cc
|
| diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
|
| index f7ded184ecc386ee47777caf4bd4e079ffcc7a58..2f4454c150ea342f2c65f020e72bc75a4c292e47 100644
|
| --- a/src/x64/code-stubs-x64.cc
|
| +++ b/src/x64/code-stubs-x64.cc
|
| @@ -1272,6 +1272,17 @@ static void BinaryOpStub_GenerateFloatingPointCode(MacroAssembler* masm,
|
| }
|
|
|
|
|
| +static void BinaryOpStub_GenerateRegisterArgsPushUnderReturn(
|
| + MacroAssembler* masm) {
|
| + // Push arguments, but ensure they are under the return address
|
| + // for a tail call.
|
| + __ pop(rcx);
|
| + __ push(rdx);
|
| + __ push(rax);
|
| + __ push(rcx);
|
| +}
|
| +
|
| +
|
| void BinaryOpStub::GenerateAddStrings(MacroAssembler* masm) {
|
| ASSERT(op_ == Token::ADD);
|
| Label left_not_string, call_runtime;
|
| @@ -1284,8 +1295,9 @@ void BinaryOpStub::GenerateAddStrings(MacroAssembler* masm) {
|
| __ JumpIfSmi(left, &left_not_string, Label::kNear);
|
| __ CmpObjectType(left, FIRST_NONSTRING_TYPE, rcx);
|
| __ j(above_equal, &left_not_string, Label::kNear);
|
| - StringAddStub string_add_left_stub(NO_STRING_CHECK_LEFT_IN_STUB);
|
| - GenerateRegisterArgsPush(masm);
|
| + StringAddStub string_add_left_stub((StringAddFlags)
|
| + (ERECT_FRAME | NO_STRING_CHECK_LEFT_IN_STUB));
|
| + BinaryOpStub_GenerateRegisterArgsPushUnderReturn(masm);
|
| __ TailCallStub(&string_add_left_stub);
|
|
|
| // Left operand is not a string, test right.
|
| @@ -1294,8 +1306,9 @@ void BinaryOpStub::GenerateAddStrings(MacroAssembler* masm) {
|
| __ CmpObjectType(right, FIRST_NONSTRING_TYPE, rcx);
|
| __ j(above_equal, &call_runtime, Label::kNear);
|
|
|
| - StringAddStub string_add_right_stub(NO_STRING_CHECK_RIGHT_IN_STUB);
|
| - GenerateRegisterArgsPush(masm);
|
| + StringAddStub string_add_right_stub((StringAddFlags)
|
| + (ERECT_FRAME | NO_STRING_CHECK_RIGHT_IN_STUB));
|
| + BinaryOpStub_GenerateRegisterArgsPushUnderReturn(masm);
|
| __ TailCallStub(&string_add_right_stub);
|
|
|
| // Neither argument is a string.
|
| @@ -1322,8 +1335,12 @@ void BinaryOpStub::GenerateSmiStub(MacroAssembler* masm) {
|
|
|
| if (call_runtime.is_linked()) {
|
| __ bind(&call_runtime);
|
| - GenerateRegisterArgsPush(masm);
|
| - GenerateCallRuntime(masm);
|
| + {
|
| + FrameScope scope(masm, StackFrame::INTERNAL);
|
| + GenerateRegisterArgsPush(masm);
|
| + GenerateCallRuntime(masm);
|
| + }
|
| + __ Ret();
|
| }
|
| }
|
|
|
| @@ -1356,8 +1373,9 @@ void BinaryOpStub::GenerateBothStringStub(MacroAssembler* masm) {
|
| __ CmpObjectType(right, FIRST_NONSTRING_TYPE, rcx);
|
| __ j(above_equal, &call_runtime);
|
|
|
| - StringAddStub string_add_stub(NO_STRING_CHECK_IN_STUB);
|
| - GenerateRegisterArgsPush(masm);
|
| + StringAddStub string_add_stub((StringAddFlags)
|
| + (ERECT_FRAME | NO_STRING_CHECK_IN_STUB));
|
| + BinaryOpStub_GenerateRegisterArgsPushUnderReturn(masm);
|
| __ TailCallStub(&string_add_stub);
|
|
|
| __ bind(&call_runtime);
|
| @@ -1442,8 +1460,12 @@ void BinaryOpStub::GenerateNumberStub(MacroAssembler* masm) {
|
| GenerateTypeTransition(masm);
|
|
|
| __ bind(&gc_required);
|
| - GenerateRegisterArgsPush(masm);
|
| - GenerateCallRuntime(masm);
|
| + {
|
| + FrameScope scope(masm, StackFrame::INTERNAL);
|
| + GenerateRegisterArgsPush(masm);
|
| + GenerateCallRuntime(masm);
|
| + }
|
| + __ Ret();
|
| }
|
|
|
|
|
| @@ -1462,8 +1484,12 @@ void BinaryOpStub::GenerateGeneric(MacroAssembler* masm) {
|
| }
|
|
|
| __ bind(&call_runtime);
|
| - GenerateRegisterArgsPush(masm);
|
| - GenerateCallRuntime(masm);
|
| + {
|
| + FrameScope scope(masm, StackFrame::INTERNAL);
|
| + GenerateRegisterArgsPush(masm);
|
| + GenerateCallRuntime(masm);
|
| + }
|
| + __ Ret();
|
| }
|
|
|
|
|
| @@ -1507,10 +1533,8 @@ static void BinaryOpStub_GenerateHeapResultAllocation(MacroAssembler* masm,
|
|
|
|
|
| void BinaryOpStub::GenerateRegisterArgsPush(MacroAssembler* masm) {
|
| - __ pop(rcx);
|
| __ push(rdx);
|
| __ push(rax);
|
| - __ push(rcx);
|
| }
|
|
|
|
|
| @@ -4791,7 +4815,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
|
| __ movq(rdx, Operand(rsp, 1 * kPointerSize)); // Second argument (right).
|
|
|
| // Make sure that both arguments are strings if not known in advance.
|
| - if (flags_ == NO_STRING_ADD_FLAGS) {
|
| + if ((flags_ & NO_STRING_ADD_FLAGS) != 0) {
|
| __ JumpIfSmi(rax, &call_runtime);
|
| __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, r8);
|
| __ j(above_equal, &call_runtime);
|
| @@ -5068,15 +5092,53 @@ void StringAddStub::Generate(MacroAssembler* masm) {
|
|
|
| // Just jump to runtime to add the two strings.
|
| __ bind(&call_runtime);
|
| - __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
|
| +
|
| + if ((flags_ & ERECT_FRAME) != 0) {
|
| + GenerateRegisterArgsPop(masm, rcx);
|
| + // Build a frame
|
| + {
|
| + FrameScope scope(masm, StackFrame::INTERNAL);
|
| + GenerateRegisterArgsPush(masm);
|
| + __ CallRuntime(Runtime::kStringAdd, 2);
|
| + }
|
| + __ Ret();
|
| + } else {
|
| + __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
|
| + }
|
|
|
| if (call_builtin.is_linked()) {
|
| __ bind(&call_builtin);
|
| - __ InvokeBuiltin(builtin_id, JUMP_FUNCTION);
|
| + if ((flags_ & ERECT_FRAME) != 0) {
|
| + GenerateRegisterArgsPop(masm, rcx);
|
| + // Build a frame
|
| + {
|
| + FrameScope scope(masm, StackFrame::INTERNAL);
|
| + GenerateRegisterArgsPush(masm);
|
| + __ InvokeBuiltin(builtin_id, CALL_FUNCTION);
|
| + }
|
| + __ Ret();
|
| + } else {
|
| + __ InvokeBuiltin(builtin_id, JUMP_FUNCTION);
|
| + }
|
| }
|
| }
|
|
|
|
|
| +void StringAddStub::GenerateRegisterArgsPush(MacroAssembler* masm) {
|
| + __ push(rax);
|
| + __ push(rdx);
|
| +}
|
| +
|
| +
|
| +void StringAddStub::GenerateRegisterArgsPop(MacroAssembler* masm,
|
| + Register temp) {
|
| + __ pop(temp);
|
| + __ pop(rdx);
|
| + __ pop(rax);
|
| + __ push(temp);
|
| +}
|
| +
|
| +
|
| void StringAddStub::GenerateConvertArgument(MacroAssembler* masm,
|
| int stack_offset,
|
| Register arg,
|
|
|