OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); | 1630 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); |
1631 ArrayConstructorStub stub(masm->isolate()); | 1631 ArrayConstructorStub stub(masm->isolate()); |
1632 __ TailCallStub(&stub); | 1632 __ TailCallStub(&stub); |
1633 } | 1633 } |
1634 | 1634 |
1635 | 1635 |
1636 // static | 1636 // static |
1637 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { | 1637 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
1638 // ----------- S t a t e ------------- | 1638 // ----------- S t a t e ------------- |
1639 // -- rax : number of arguments | 1639 // -- rax : number of arguments |
| 1640 // -- rdi : function |
| 1641 // -- rsi : context |
1640 // -- rsp[0] : return address | 1642 // -- rsp[0] : return address |
1641 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) | 1643 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) |
1642 // -- rsp[(argc + 1) * 8] : receiver | 1644 // -- rsp[(argc + 1) * 8] : receiver |
1643 // ----------------------------------- | 1645 // ----------------------------------- |
1644 Condition const cc = (kind == MathMaxMinKind::kMin) ? below : above; | 1646 Condition const cc = (kind == MathMaxMinKind::kMin) ? below : above; |
1645 Heap::RootListIndex const root_index = | 1647 Heap::RootListIndex const root_index = |
1646 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex | 1648 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex |
1647 : Heap::kMinusInfinityValueRootIndex; | 1649 : Heap::kMinusInfinityValueRootIndex; |
1648 XMMRegister const reg = (kind == MathMaxMinKind::kMin) ? xmm1 : xmm0; | 1650 XMMRegister const reg = (kind == MathMaxMinKind::kMin) ? xmm1 : xmm0; |
1649 | 1651 |
(...skipping 15 matching lines...) Expand all Loading... |
1665 | 1667 |
1666 // Load the double value of the parameter into xmm1, maybe converting the | 1668 // Load the double value of the parameter into xmm1, maybe converting the |
1667 // parameter to a number first using the ToNumber builtin if necessary. | 1669 // parameter to a number first using the ToNumber builtin if necessary. |
1668 Label convert, convert_smi, convert_number, done_convert; | 1670 Label convert, convert_smi, convert_number, done_convert; |
1669 __ bind(&convert); | 1671 __ bind(&convert); |
1670 __ JumpIfSmi(rbx, &convert_smi); | 1672 __ JumpIfSmi(rbx, &convert_smi); |
1671 __ JumpIfRoot(FieldOperand(rbx, HeapObject::kMapOffset), | 1673 __ JumpIfRoot(FieldOperand(rbx, HeapObject::kMapOffset), |
1672 Heap::kHeapNumberMapRootIndex, &convert_number); | 1674 Heap::kHeapNumberMapRootIndex, &convert_number); |
1673 { | 1675 { |
1674 // Parameter is not a Number, use the ToNumber builtin to convert it. | 1676 // Parameter is not a Number, use the ToNumber builtin to convert it. |
1675 FrameScope scope(masm, StackFrame::INTERNAL); | 1677 FrameScope scope(masm, StackFrame::MANUAL); |
| 1678 __ Push(rbp); |
| 1679 __ Move(rbp, rsp); |
| 1680 __ Push(rsi); |
| 1681 __ Push(rdi); |
1676 __ Integer32ToSmi(rax, rax); | 1682 __ Integer32ToSmi(rax, rax); |
1677 __ Integer32ToSmi(rcx, rcx); | 1683 __ Integer32ToSmi(rcx, rcx); |
1678 __ Push(rax); | 1684 __ Push(rax); |
1679 __ Push(rcx); | 1685 __ Push(rcx); |
1680 __ Push(rdx); | 1686 __ Push(rdx); |
1681 __ movp(rax, rbx); | 1687 __ movp(rax, rbx); |
1682 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); | 1688 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
1683 __ movp(rbx, rax); | 1689 __ movp(rbx, rax); |
1684 __ Pop(rdx); | 1690 __ Pop(rdx); |
1685 __ Pop(rcx); | 1691 __ Pop(rcx); |
1686 __ Pop(rax); | 1692 __ Pop(rax); |
| 1693 __ Pop(rdi); |
| 1694 __ Pop(rsi); |
1687 { | 1695 { |
1688 // Restore the double accumulator value (xmm0). | 1696 // Restore the double accumulator value (xmm0). |
1689 Label restore_smi, done_restore; | 1697 Label restore_smi, done_restore; |
1690 __ JumpIfSmi(rdx, &restore_smi, Label::kNear); | 1698 __ JumpIfSmi(rdx, &restore_smi, Label::kNear); |
1691 __ Movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); | 1699 __ Movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); |
1692 __ jmp(&done_restore, Label::kNear); | 1700 __ jmp(&done_restore, Label::kNear); |
1693 __ bind(&restore_smi); | 1701 __ bind(&restore_smi); |
1694 __ SmiToDouble(xmm0, rdx); | 1702 __ SmiToDouble(xmm0, rdx); |
1695 __ bind(&done_restore); | 1703 __ bind(&done_restore); |
1696 } | 1704 } |
1697 __ SmiToInteger32(rcx, rcx); | 1705 __ SmiToInteger32(rcx, rcx); |
1698 __ SmiToInteger32(rax, rax); | 1706 __ SmiToInteger32(rax, rax); |
| 1707 __ leave(); |
1699 } | 1708 } |
1700 __ jmp(&convert); | 1709 __ jmp(&convert); |
1701 __ bind(&convert_number); | 1710 __ bind(&convert_number); |
1702 __ Movsd(xmm1, FieldOperand(rbx, HeapNumber::kValueOffset)); | 1711 __ Movsd(xmm1, FieldOperand(rbx, HeapNumber::kValueOffset)); |
1703 __ jmp(&done_convert, Label::kNear); | 1712 __ jmp(&done_convert, Label::kNear); |
1704 __ bind(&convert_smi); | 1713 __ bind(&convert_smi); |
1705 __ SmiToDouble(xmm1, rbx); | 1714 __ SmiToDouble(xmm1, rbx); |
1706 __ bind(&done_convert); | 1715 __ bind(&done_convert); |
1707 | 1716 |
1708 // Perform the actual comparison with the accumulator value on the left hand | 1717 // Perform the actual comparison with the accumulator value on the left hand |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3025 __ ret(0); | 3034 __ ret(0); |
3026 } | 3035 } |
3027 | 3036 |
3028 | 3037 |
3029 #undef __ | 3038 #undef __ |
3030 | 3039 |
3031 } // namespace internal | 3040 } // namespace internal |
3032 } // namespace v8 | 3041 } // namespace v8 |
3033 | 3042 |
3034 #endif // V8_TARGET_ARCH_X64 | 3043 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |