OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
| 30 #if defined(V8_TARGET_ARCH_X64) |
| 31 |
30 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
31 #include "codegen-inl.h" | 33 #include "codegen-inl.h" |
32 #include "assembler-x64.h" | 34 #include "assembler-x64.h" |
33 #include "macro-assembler-x64.h" | 35 #include "macro-assembler-x64.h" |
34 #include "serialize.h" | 36 #include "serialize.h" |
35 #include "debug.h" | 37 #include "debug.h" |
36 | 38 |
37 namespace v8 { | 39 namespace v8 { |
38 namespace internal { | 40 namespace internal { |
39 | 41 |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 } else { | 795 } else { |
794 movq(dst, src1); | 796 movq(dst, src1); |
795 subq(dst, src2); | 797 subq(dst, src2); |
796 j(overflow, on_not_smi_result); | 798 j(overflow, on_not_smi_result); |
797 } | 799 } |
798 } | 800 } |
799 | 801 |
800 | 802 |
801 void MacroAssembler::SmiSub(Register dst, | 803 void MacroAssembler::SmiSub(Register dst, |
802 Register src1, | 804 Register src1, |
803 Operand const& src2, | 805 const Operand& src2, |
804 Label* on_not_smi_result) { | 806 Label* on_not_smi_result) { |
805 if (on_not_smi_result == NULL) { | 807 if (on_not_smi_result == NULL) { |
806 // No overflow checking. Use only when it's known that | 808 // No overflow checking. Use only when it's known that |
807 // overflowing is impossible (e.g., subtracting two positive smis). | 809 // overflowing is impossible (e.g., subtracting two positive smis). |
808 if (dst.is(src1)) { | 810 if (dst.is(src1)) { |
809 subq(dst, src2); | 811 subq(dst, src2); |
810 } else { | 812 } else { |
811 movq(dst, src1); | 813 movq(dst, src1); |
812 subq(dst, src2); | 814 subq(dst, src2); |
813 } | 815 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 | 913 |
912 Move(kScratchRegister, constant); | 914 Move(kScratchRegister, constant); |
913 addq(dst, kScratchRegister); | 915 addq(dst, kScratchRegister); |
914 } else { | 916 } else { |
915 Move(dst, constant); | 917 Move(dst, constant); |
916 addq(dst, src); | 918 addq(dst, src); |
917 } | 919 } |
918 } | 920 } |
919 | 921 |
920 | 922 |
| 923 void MacroAssembler::SmiAddConstant(const Operand& dst, Smi* constant) { |
| 924 if (constant->value() != 0) { |
| 925 Move(kScratchRegister, constant); |
| 926 addq(dst, kScratchRegister); |
| 927 } |
| 928 } |
| 929 |
| 930 |
921 void MacroAssembler::SmiAddConstant(Register dst, | 931 void MacroAssembler::SmiAddConstant(Register dst, |
922 Register src, | 932 Register src, |
923 Smi* constant, | 933 Smi* constant, |
924 Label* on_not_smi_result) { | 934 Label* on_not_smi_result) { |
925 if (constant->value() == 0) { | 935 if (constant->value() == 0) { |
926 if (!dst.is(src)) { | 936 if (!dst.is(src)) { |
927 movq(dst, src); | 937 movq(dst, src); |
928 } | 938 } |
929 } else if (dst.is(src)) { | 939 } else if (dst.is(src)) { |
930 ASSERT(!dst.is(kScratchRegister)); | 940 ASSERT(!dst.is(kScratchRegister)); |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 Label* fail, | 1733 Label* fail, |
1724 bool is_heap_object) { | 1734 bool is_heap_object) { |
1725 if (!is_heap_object) { | 1735 if (!is_heap_object) { |
1726 JumpIfSmi(obj, fail); | 1736 JumpIfSmi(obj, fail); |
1727 } | 1737 } |
1728 Cmp(FieldOperand(obj, HeapObject::kMapOffset), map); | 1738 Cmp(FieldOperand(obj, HeapObject::kMapOffset), map); |
1729 j(not_equal, fail); | 1739 j(not_equal, fail); |
1730 } | 1740 } |
1731 | 1741 |
1732 | 1742 |
1733 void MacroAssembler::AbortIfNotNumber(Register object, const char* msg) { | 1743 void MacroAssembler::AbortIfNotNumber(Register object) { |
1734 Label ok; | 1744 Label ok; |
1735 Condition is_smi = CheckSmi(object); | 1745 Condition is_smi = CheckSmi(object); |
1736 j(is_smi, &ok); | 1746 j(is_smi, &ok); |
1737 Cmp(FieldOperand(object, HeapObject::kMapOffset), | 1747 Cmp(FieldOperand(object, HeapObject::kMapOffset), |
1738 Factory::heap_number_map()); | 1748 Factory::heap_number_map()); |
1739 Assert(equal, msg); | 1749 Assert(equal, "Operand not a number"); |
1740 bind(&ok); | 1750 bind(&ok); |
1741 } | 1751 } |
1742 | 1752 |
1743 | 1753 |
1744 void MacroAssembler::AbortIfNotSmi(Register object, const char* msg) { | 1754 void MacroAssembler::AbortIfNotSmi(Register object) { |
1745 Label ok; | 1755 Label ok; |
1746 Condition is_smi = CheckSmi(object); | 1756 Condition is_smi = CheckSmi(object); |
1747 j(is_smi, &ok); | 1757 Assert(is_smi, "Operand not a smi"); |
1748 Assert(equal, msg); | |
1749 bind(&ok); | |
1750 } | 1758 } |
1751 | 1759 |
1752 | 1760 |
1753 Condition MacroAssembler::IsObjectStringType(Register heap_object, | 1761 Condition MacroAssembler::IsObjectStringType(Register heap_object, |
1754 Register map, | 1762 Register map, |
1755 Register instance_type) { | 1763 Register instance_type) { |
1756 movq(map, FieldOperand(heap_object, HeapObject::kMapOffset)); | 1764 movq(map, FieldOperand(heap_object, HeapObject::kMapOffset)); |
1757 movzxbl(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); | 1765 movzxbl(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); |
1758 ASSERT(kNotStringTag != 0); | 1766 ASSERT(kNotStringTag != 0); |
1759 testb(instance_type, Immediate(kIsNotStringMask)); | 1767 testb(instance_type, Immediate(kIsNotStringMask)); |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2759 CodePatcher::~CodePatcher() { | 2767 CodePatcher::~CodePatcher() { |
2760 // Indicate that code has changed. | 2768 // Indicate that code has changed. |
2761 CPU::FlushICache(address_, size_); | 2769 CPU::FlushICache(address_, size_); |
2762 | 2770 |
2763 // Check that the code was patched as expected. | 2771 // Check that the code was patched as expected. |
2764 ASSERT(masm_.pc_ == address_ + size_); | 2772 ASSERT(masm_.pc_ == address_ + size_); |
2765 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2773 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
2766 } | 2774 } |
2767 | 2775 |
2768 } } // namespace v8::internal | 2776 } } // namespace v8::internal |
| 2777 |
| 2778 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |