OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. |
6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 case 16: return 4; | 191 case 16: return 4; |
192 } | 192 } |
193 UNREACHABLE(); | 193 UNREACHABLE(); |
194 return -1; | 194 return -1; |
195 } | 195 } |
196 | 196 |
197 | 197 |
198 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_shift) \ | 198 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_shift) \ |
199 Label fall_through; \ | 199 Label fall_through; \ |
200 const intptr_t kArrayLengthStackOffset = 0 * kWordSize; \ | 200 const intptr_t kArrayLengthStackOffset = 0 * kWordSize; \ |
201 __ MaybeTraceAllocation(cid, R2, &fall_through); \ | 201 __ MaybeTraceAllocation(cid, R2, &fall_through, \ |
| 202 /* inline_isolate = */ false); \ |
202 __ ldr(R2, Address(SP, kArrayLengthStackOffset)); /* Array length. */ \ | 203 __ ldr(R2, Address(SP, kArrayLengthStackOffset)); /* Array length. */ \ |
203 /* Check that length is a positive Smi. */ \ | 204 /* Check that length is a positive Smi. */ \ |
204 /* R2: requested array length argument. */ \ | 205 /* R2: requested array length argument. */ \ |
205 __ tsti(R2, Immediate(kSmiTagMask)); \ | 206 __ tsti(R2, Immediate(kSmiTagMask)); \ |
206 __ b(&fall_through, NE); \ | 207 __ b(&fall_through, NE); \ |
207 __ CompareRegisters(R2, ZR); \ | 208 __ CompareRegisters(R2, ZR); \ |
208 __ b(&fall_through, LT); \ | 209 __ b(&fall_through, LT); \ |
209 __ SmiUntag(R2); \ | 210 __ SmiUntag(R2); \ |
210 /* Check for maximum allowed length. */ \ | 211 /* Check for maximum allowed length. */ \ |
211 /* R2: untagged array length. */ \ | 212 /* R2: untagged array length. */ \ |
212 __ CompareImmediate(R2, max_len); \ | 213 __ CompareImmediate(R2, max_len); \ |
213 __ b(&fall_through, GT); \ | 214 __ b(&fall_through, GT); \ |
214 __ LslImmediate(R2, R2, scale_shift); \ | 215 __ LslImmediate(R2, R2, scale_shift); \ |
215 const intptr_t fixed_size = sizeof(Raw##type_name) + kObjectAlignment - 1; \ | 216 const intptr_t fixed_size = sizeof(Raw##type_name) + kObjectAlignment - 1; \ |
216 __ AddImmediate(R2, R2, fixed_size); \ | 217 __ AddImmediate(R2, R2, fixed_size); \ |
217 __ andi(R2, R2, Immediate(~(kObjectAlignment - 1))); \ | 218 __ andi(R2, R2, Immediate(~(kObjectAlignment - 1))); \ |
218 Heap* heap = Isolate::Current()->heap(); \ | 219 Heap::Space space = Heap::SpaceForAllocation(cid); \ |
219 Heap::Space space = heap->SpaceForAllocation(cid); \ | 220 __ ldr(R3, Address(THR, Thread::heap_offset())); \ |
220 __ LoadImmediate(R0, heap->TopAddress(space)); \ | 221 __ ldr(R0, Address(R3, Heap::TopOffset(space))); \ |
221 __ ldr(R0, Address(R0, 0)); \ | |
222 \ | 222 \ |
223 /* R2: allocation size. */ \ | 223 /* R2: allocation size. */ \ |
224 __ adds(R1, R0, Operand(R2)); \ | 224 __ adds(R1, R0, Operand(R2)); \ |
225 __ b(&fall_through, CS); /* Fail on unsigned overflow. */ \ | 225 __ b(&fall_through, CS); /* Fail on unsigned overflow. */ \ |
226 \ | 226 \ |
227 /* Check if the allocation fits into the remaining space. */ \ | 227 /* Check if the allocation fits into the remaining space. */ \ |
228 /* R0: potential new object start. */ \ | 228 /* R0: potential new object start. */ \ |
229 /* R1: potential next object start. */ \ | 229 /* R1: potential next object start. */ \ |
230 /* R2: allocation size. */ \ | 230 /* R2: allocation size. */ \ |
231 __ LoadImmediate(R3, heap->EndAddress(space)); \ | 231 /* R3: heap. */ \ |
232 __ ldr(R3, Address(R3, 0)); \ | 232 __ ldr(R4, Address(R3, Heap::EndOffset(space))); \ |
233 __ cmp(R1, Operand(R3)); \ | 233 __ cmp(R1, Operand(R4)); \ |
234 __ b(&fall_through, CS); \ | 234 __ b(&fall_through, CS); \ |
235 \ | 235 \ |
236 /* Successfully allocated the object(s), now update top to point to */ \ | 236 /* Successfully allocated the object(s), now update top to point to */ \ |
237 /* next object start and initialize the object. */ \ | 237 /* next object start and initialize the object. */ \ |
238 __ LoadImmediate(R3, heap->TopAddress(space)); \ | 238 __ str(R1, Address(R3, Heap::TopOffset(space))); \ |
239 __ str(R1, Address(R3, 0)); \ | |
240 __ AddImmediate(R0, R0, kHeapObjectTag); \ | 239 __ AddImmediate(R0, R0, kHeapObjectTag); \ |
241 __ UpdateAllocationStatsWithSize(cid, R2, space); \ | 240 __ UpdateAllocationStatsWithSize(cid, R2, space, \ |
| 241 /* inline_isolate = */ false); \ |
242 /* Initialize the tags. */ \ | 242 /* Initialize the tags. */ \ |
243 /* R0: new object start as a tagged pointer. */ \ | 243 /* R0: new object start as a tagged pointer. */ \ |
244 /* R1: new object end address. */ \ | 244 /* R1: new object end address. */ \ |
245 /* R2: allocation size. */ \ | 245 /* R2: allocation size. */ \ |
246 { \ | 246 { \ |
247 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); \ | 247 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); \ |
248 __ LslImmediate(R2, R2, RawObject::kSizeTagPos - kObjectAlignmentLog2); \ | 248 __ LslImmediate(R2, R2, RawObject::kSizeTagPos - kObjectAlignmentLog2); \ |
249 __ csel(R2, ZR, R2, HI); \ | 249 __ csel(R2, ZR, R2, HI); \ |
250 \ | 250 \ |
251 /* Get the class index and insert it into the tags. */ \ | 251 /* Get the class index and insert it into the tags. */ \ |
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1842 | 1842 |
1843 // Allocates one-byte string of length 'end - start'. The content is not | 1843 // Allocates one-byte string of length 'end - start'. The content is not |
1844 // initialized. | 1844 // initialized. |
1845 // 'length-reg' (R2) contains tagged length. | 1845 // 'length-reg' (R2) contains tagged length. |
1846 // Returns new string as tagged pointer in R0. | 1846 // Returns new string as tagged pointer in R0. |
1847 static void TryAllocateOnebyteString(Assembler* assembler, | 1847 static void TryAllocateOnebyteString(Assembler* assembler, |
1848 Label* ok, | 1848 Label* ok, |
1849 Label* failure) { | 1849 Label* failure) { |
1850 const Register length_reg = R2; | 1850 const Register length_reg = R2; |
1851 Label fail; | 1851 Label fail; |
1852 __ MaybeTraceAllocation(kOneByteStringCid, R0, failure); | 1852 __ MaybeTraceAllocation(kOneByteStringCid, R0, failure, |
| 1853 /* inline_isolate = */ false); |
1853 __ mov(R6, length_reg); // Save the length register. | 1854 __ mov(R6, length_reg); // Save the length register. |
1854 // TODO(koda): Protect against negative length and overflow here. | 1855 // TODO(koda): Protect against negative length and overflow here. |
1855 __ SmiUntag(length_reg); | 1856 __ SmiUntag(length_reg); |
1856 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; | 1857 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; |
1857 __ AddImmediate(length_reg, length_reg, fixed_size); | 1858 __ AddImmediate(length_reg, length_reg, fixed_size); |
1858 __ andi(length_reg, length_reg, Immediate(~(kObjectAlignment - 1))); | 1859 __ andi(length_reg, length_reg, Immediate(~(kObjectAlignment - 1))); |
1859 | 1860 |
1860 Isolate* isolate = Isolate::Current(); | |
1861 Heap* heap = isolate->heap(); | |
1862 const intptr_t cid = kOneByteStringCid; | 1861 const intptr_t cid = kOneByteStringCid; |
1863 Heap::Space space = heap->SpaceForAllocation(cid); | 1862 Heap::Space space = Heap::SpaceForAllocation(cid); |
1864 __ LoadImmediate(R3, heap->TopAddress(space)); | 1863 __ ldr(R3, Address(THR, Thread::heap_offset())); |
1865 __ ldr(R0, Address(R3)); | 1864 __ ldr(R0, Address(R3, Heap::TopOffset(space))); |
1866 | 1865 |
1867 // length_reg: allocation size. | 1866 // length_reg: allocation size. |
1868 __ adds(R1, R0, Operand(length_reg)); | 1867 __ adds(R1, R0, Operand(length_reg)); |
1869 __ b(&fail, CS); // Fail on unsigned overflow. | 1868 __ b(&fail, CS); // Fail on unsigned overflow. |
1870 | 1869 |
1871 // Check if the allocation fits into the remaining space. | 1870 // Check if the allocation fits into the remaining space. |
1872 // R0: potential new object start. | 1871 // R0: potential new object start. |
1873 // R1: potential next object start. | 1872 // R1: potential next object start. |
1874 // R2: allocation size. | 1873 // R2: allocation size. |
1875 // R3: heap->TopAddress(space). | 1874 // R3: heap. |
1876 __ LoadImmediate(R7, heap->EndAddress(space)); | 1875 __ ldr(R7, Address(R3, Heap::EndOffset(space))); |
1877 __ ldr(R7, Address(R7)); | |
1878 __ cmp(R1, Operand(R7)); | 1876 __ cmp(R1, Operand(R7)); |
1879 __ b(&fail, CS); | 1877 __ b(&fail, CS); |
1880 | 1878 |
1881 // Successfully allocated the object(s), now update top to point to | 1879 // Successfully allocated the object(s), now update top to point to |
1882 // next object start and initialize the object. | 1880 // next object start and initialize the object. |
1883 __ str(R1, Address(R3)); | 1881 __ str(R1, Address(R3, Heap::TopOffset(space))); |
1884 __ AddImmediate(R0, R0, kHeapObjectTag); | 1882 __ AddImmediate(R0, R0, kHeapObjectTag); |
1885 __ UpdateAllocationStatsWithSize(cid, R2, space); | 1883 __ UpdateAllocationStatsWithSize(cid, R2, space, |
| 1884 /* inline_isolate = */ false); |
1886 | 1885 |
1887 // Initialize the tags. | 1886 // Initialize the tags. |
1888 // R0: new object start as a tagged pointer. | 1887 // R0: new object start as a tagged pointer. |
1889 // R1: new object end address. | 1888 // R1: new object end address. |
1890 // R2: allocation size. | 1889 // R2: allocation size. |
1891 { | 1890 { |
1892 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; | 1891 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; |
1893 | 1892 |
1894 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); | 1893 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); |
1895 __ LslImmediate(R2, R2, shift); | 1894 __ LslImmediate(R2, R2, shift); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2136 | 2135 |
2137 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) { | 2136 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) { |
2138 __ LoadIsolate(R0); | 2137 __ LoadIsolate(R0); |
2139 __ ldr(R0, Address(R0, Isolate::current_tag_offset())); | 2138 __ ldr(R0, Address(R0, Isolate::current_tag_offset())); |
2140 __ ret(); | 2139 __ ret(); |
2141 } | 2140 } |
2142 | 2141 |
2143 } // namespace dart | 2142 } // namespace dart |
2144 | 2143 |
2145 #endif // defined TARGET_ARCH_ARM64 | 2144 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |