diff options
Diffstat (limited to 'deps/v8/src/x64/code-stubs-x64.cc')
-rw-r--r-- | deps/v8/src/x64/code-stubs-x64.cc | 104 |
1 files changed, 83 insertions, 21 deletions
diff --git a/deps/v8/src/x64/code-stubs-x64.cc b/deps/v8/src/x64/code-stubs-x64.cc index f7ded184ec..f87d952568 100644 --- a/deps/v8/src/x64/code-stubs-x64.cc +++ b/deps/v8/src/x64/code-stubs-x64.cc @@ -287,8 +287,8 @@ void FastNewClosureStub::Generate(MacroAssembler* masm) { // The optimized code map must never be empty, so check the first elements. Label install_optimized; // Speculatively move code object into edx. - __ movq(rdx, FieldOperand(rbx, FixedArray::kHeaderSize + kPointerSize)); - __ cmpq(rcx, FieldOperand(rbx, FixedArray::kHeaderSize)); + __ movq(rdx, FieldOperand(rbx, SharedFunctionInfo::kFirstCodeSlot)); + __ cmpq(rcx, FieldOperand(rbx, SharedFunctionInfo::kFirstContextSlot)); __ j(equal, &install_optimized); // Iterate through the rest of map backwards. rdx holds an index. @@ -298,9 +298,9 @@ void FastNewClosureStub::Generate(MacroAssembler* masm) { __ SmiToInteger32(rdx, rdx); __ bind(&loop); // Do not double check first entry. - __ cmpq(rdx, Immediate(SharedFunctionInfo::kEntryLength)); + __ cmpq(rdx, Immediate(SharedFunctionInfo::kSecondEntryIndex)); __ j(equal, &restore); - __ subq(rdx, Immediate(SharedFunctionInfo::kEntryLength)); // Skip an entry. + __ subq(rdx, Immediate(SharedFunctionInfo::kEntryLength)); __ cmpq(rcx, FieldOperand(rbx, rdx, times_pointer_size, @@ -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, |