| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
| 9 | 9 |
| 10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 RAX); | 134 RAX); |
| 135 __ LoadObject(RAX, Object::null_object()); | 135 __ LoadObject(RAX, Object::null_object()); |
| 136 __ ret(); | 136 __ ret(); |
| 137 __ Bind(&fall_through); | 137 __ Bind(&fall_through); |
| 138 } | 138 } |
| 139 | 139 |
| 140 | 140 |
| 141 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_factor) \ | 141 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_factor) \ |
| 142 Label fall_through; \ | 142 Label fall_through; \ |
| 143 const intptr_t kArrayLengthStackOffset = 1 * kWordSize; \ | 143 const intptr_t kArrayLengthStackOffset = 1 * kWordSize; \ |
| 144 __ MaybeTraceAllocation(cid, &fall_through, false, \ | 144 __ MaybeTraceAllocation(cid, &fall_through, false); \ |
| 145 /* inline_isolate = */ false); \ | |
| 146 __ movq(RDI, Address(RSP, kArrayLengthStackOffset)); /* Array length. */ \ | 145 __ movq(RDI, Address(RSP, kArrayLengthStackOffset)); /* Array length. */ \ |
| 147 /* Check that length is a positive Smi. */ \ | 146 /* Check that length is a positive Smi. */ \ |
| 148 /* RDI: requested array length argument. */ \ | 147 /* RDI: requested array length argument. */ \ |
| 149 __ testq(RDI, Immediate(kSmiTagMask)); \ | 148 __ testq(RDI, Immediate(kSmiTagMask)); \ |
| 150 __ j(NOT_ZERO, &fall_through); \ | 149 __ j(NOT_ZERO, &fall_through); \ |
| 151 __ cmpq(RDI, Immediate(0)); \ | 150 __ cmpq(RDI, Immediate(0)); \ |
| 152 __ j(LESS, &fall_through); \ | 151 __ j(LESS, &fall_through); \ |
| 153 __ SmiUntag(RDI); \ | 152 __ SmiUntag(RDI); \ |
| 154 /* Check for maximum allowed length. */ \ | 153 /* Check for maximum allowed length. */ \ |
| 155 /* RDI: untagged array length. */ \ | 154 /* RDI: untagged array length. */ \ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 179 /* RCX: potential next object start. */ \ | 178 /* RCX: potential next object start. */ \ |
| 180 /* RDI: allocation size. */ \ | 179 /* RDI: allocation size. */ \ |
| 181 /* R13: heap. */ \ | 180 /* R13: heap. */ \ |
| 182 __ cmpq(RCX, Address(R13, Heap::EndOffset(space))); \ | 181 __ cmpq(RCX, Address(R13, Heap::EndOffset(space))); \ |
| 183 __ j(ABOVE_EQUAL, &fall_through); \ | 182 __ j(ABOVE_EQUAL, &fall_through); \ |
| 184 \ | 183 \ |
| 185 /* Successfully allocated the object(s), now update top to point to */ \ | 184 /* Successfully allocated the object(s), now update top to point to */ \ |
| 186 /* next object start and initialize the object. */ \ | 185 /* next object start and initialize the object. */ \ |
| 187 __ movq(Address(R13, Heap::TopOffset(space)), RCX); \ | 186 __ movq(Address(R13, Heap::TopOffset(space)), RCX); \ |
| 188 __ addq(RAX, Immediate(kHeapObjectTag)); \ | 187 __ addq(RAX, Immediate(kHeapObjectTag)); \ |
| 189 __ UpdateAllocationStatsWithSize(cid, RDI, space, \ | 188 __ UpdateAllocationStatsWithSize(cid, RDI, space); \ |
| 190 /* inline_isolate = */ false); \ | |
| 191 /* Initialize the tags. */ \ | 189 /* Initialize the tags. */ \ |
| 192 /* RAX: new object start as a tagged pointer. */ \ | 190 /* RAX: new object start as a tagged pointer. */ \ |
| 193 /* RCX: new object end address. */ \ | 191 /* RCX: new object end address. */ \ |
| 194 /* RDI: allocation size. */ \ | 192 /* RDI: allocation size. */ \ |
| 195 /* R13: scratch register. */ \ | 193 /* R13: scratch register. */ \ |
| 196 { \ | 194 { \ |
| 197 Label size_tag_overflow, done; \ | 195 Label size_tag_overflow, done; \ |
| 198 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); \ | 196 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); \ |
| 199 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); \ | 197 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); \ |
| 200 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); \ | 198 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); \ |
| (...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 } | 1836 } |
| 1839 | 1837 |
| 1840 | 1838 |
| 1841 // Allocates one-byte string of length 'end - start'. The content is not | 1839 // Allocates one-byte string of length 'end - start'. The content is not |
| 1842 // initialized. 'length-reg' contains tagged length. | 1840 // initialized. 'length-reg' contains tagged length. |
| 1843 // Returns new string as tagged pointer in RAX. | 1841 // Returns new string as tagged pointer in RAX. |
| 1844 static void TryAllocateOnebyteString(Assembler* assembler, | 1842 static void TryAllocateOnebyteString(Assembler* assembler, |
| 1845 Label* ok, | 1843 Label* ok, |
| 1846 Label* failure, | 1844 Label* failure, |
| 1847 Register length_reg) { | 1845 Register length_reg) { |
| 1848 __ MaybeTraceAllocation(kOneByteStringCid, failure, false, | 1846 __ MaybeTraceAllocation(kOneByteStringCid, failure, false); |
| 1849 /* inline_isolate = */ false); | |
| 1850 if (length_reg != RDI) { | 1847 if (length_reg != RDI) { |
| 1851 __ movq(RDI, length_reg); | 1848 __ movq(RDI, length_reg); |
| 1852 } | 1849 } |
| 1853 Label pop_and_fail; | 1850 Label pop_and_fail; |
| 1854 __ pushq(RDI); // Preserve length. | 1851 __ pushq(RDI); // Preserve length. |
| 1855 __ SmiUntag(RDI); | 1852 __ SmiUntag(RDI); |
| 1856 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; | 1853 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; |
| 1857 __ leaq(RDI, Address(RDI, TIMES_1, fixed_size)); // RDI is a Smi. | 1854 __ leaq(RDI, Address(RDI, TIMES_1, fixed_size)); // RDI is a Smi. |
| 1858 __ andq(RDI, Immediate(-kObjectAlignment)); | 1855 __ andq(RDI, Immediate(-kObjectAlignment)); |
| 1859 | 1856 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1872 // RCX: potential next object start. | 1869 // RCX: potential next object start. |
| 1873 // RDI: allocation size. | 1870 // RDI: allocation size. |
| 1874 // R13: heap. | 1871 // R13: heap. |
| 1875 __ cmpq(RCX, Address(R13, Heap::EndOffset(space))); | 1872 __ cmpq(RCX, Address(R13, Heap::EndOffset(space))); |
| 1876 __ j(ABOVE_EQUAL, &pop_and_fail); | 1873 __ j(ABOVE_EQUAL, &pop_and_fail); |
| 1877 | 1874 |
| 1878 // Successfully allocated the object(s), now update top to point to | 1875 // Successfully allocated the object(s), now update top to point to |
| 1879 // next object start and initialize the object. | 1876 // next object start and initialize the object. |
| 1880 __ movq(Address(R13, Heap::TopOffset(space)), RCX); | 1877 __ movq(Address(R13, Heap::TopOffset(space)), RCX); |
| 1881 __ addq(RAX, Immediate(kHeapObjectTag)); | 1878 __ addq(RAX, Immediate(kHeapObjectTag)); |
| 1882 __ UpdateAllocationStatsWithSize(cid, RDI, space, | 1879 __ UpdateAllocationStatsWithSize(cid, RDI, space); |
| 1883 /* inline_isolate = */ false); | |
| 1884 | 1880 |
| 1885 // Initialize the tags. | 1881 // Initialize the tags. |
| 1886 // RAX: new object start as a tagged pointer. | 1882 // RAX: new object start as a tagged pointer. |
| 1887 // RDI: allocation size. | 1883 // RDI: allocation size. |
| 1888 { | 1884 { |
| 1889 Label size_tag_overflow, done; | 1885 Label size_tag_overflow, done; |
| 1890 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 1886 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| 1891 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 1887 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
| 1892 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); | 1888 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); |
| 1893 __ jmp(&done, Assembler::kNearJump); | 1889 __ jmp(&done, Assembler::kNearJump); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2117 __ LoadIsolate(RAX); | 2113 __ LoadIsolate(RAX); |
| 2118 __ movq(RAX, Address(RAX, Isolate::current_tag_offset())); | 2114 __ movq(RAX, Address(RAX, Isolate::current_tag_offset())); |
| 2119 __ ret(); | 2115 __ ret(); |
| 2120 } | 2116 } |
| 2121 | 2117 |
| 2122 #undef __ | 2118 #undef __ |
| 2123 | 2119 |
| 2124 } // namespace dart | 2120 } // namespace dart |
| 2125 | 2121 |
| 2126 #endif // defined TARGET_ARCH_X64 | 2122 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |