| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 case 16: return 4; | 176 case 16: return 4; |
| 177 } | 177 } |
| 178 UNREACHABLE(); | 178 UNREACHABLE(); |
| 179 return -1; | 179 return -1; |
| 180 } | 180 } |
| 181 | 181 |
| 182 | 182 |
| 183 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_shift) \ | 183 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_shift) \ |
| 184 Label fall_through; \ | 184 Label fall_through; \ |
| 185 const intptr_t kArrayLengthStackOffset = 0 * kWordSize; \ | 185 const intptr_t kArrayLengthStackOffset = 0 * kWordSize; \ |
| 186 __ MaybeTraceAllocation(cid, R2, &fall_through); \ | 186 NOT_IN_PRODUCT(__ MaybeTraceAllocation(cid, R2, &fall_through)); \ |
| 187 __ ldr(R2, Address(SP, kArrayLengthStackOffset)); /* Array length. */ \ | 187 __ ldr(R2, Address(SP, kArrayLengthStackOffset)); /* Array length. */ \ |
| 188 /* Check that length is a positive Smi. */ \ | 188 /* Check that length is a positive Smi. */ \ |
| 189 /* R2: requested array length argument. */ \ | 189 /* R2: requested array length argument. */ \ |
| 190 __ tsti(R2, Immediate(kSmiTagMask)); \ | 190 __ tsti(R2, Immediate(kSmiTagMask)); \ |
| 191 __ b(&fall_through, NE); \ | 191 __ b(&fall_through, NE); \ |
| 192 __ CompareRegisters(R2, ZR); \ | 192 __ CompareRegisters(R2, ZR); \ |
| 193 __ b(&fall_through, LT); \ | 193 __ b(&fall_through, LT); \ |
| 194 __ SmiUntag(R2); \ | 194 __ SmiUntag(R2); \ |
| 195 /* Check for maximum allowed length. */ \ | 195 /* Check for maximum allowed length. */ \ |
| 196 /* R2: untagged array length. */ \ | 196 /* R2: untagged array length. */ \ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 214 /* R2: allocation size. */ \ | 214 /* R2: allocation size. */ \ |
| 215 /* R3: heap. */ \ | 215 /* R3: heap. */ \ |
| 216 __ ldr(R6, Address(R3, Heap::EndOffset(space))); \ | 216 __ ldr(R6, Address(R3, Heap::EndOffset(space))); \ |
| 217 __ cmp(R1, Operand(R6)); \ | 217 __ cmp(R1, Operand(R6)); \ |
| 218 __ b(&fall_through, CS); \ | 218 __ b(&fall_through, CS); \ |
| 219 \ | 219 \ |
| 220 /* Successfully allocated the object(s), now update top to point to */ \ | 220 /* Successfully allocated the object(s), now update top to point to */ \ |
| 221 /* next object start and initialize the object. */ \ | 221 /* next object start and initialize the object. */ \ |
| 222 __ str(R1, Address(R3, Heap::TopOffset(space))); \ | 222 __ str(R1, Address(R3, Heap::TopOffset(space))); \ |
| 223 __ AddImmediate(R0, R0, kHeapObjectTag); \ | 223 __ AddImmediate(R0, R0, kHeapObjectTag); \ |
| 224 __ UpdateAllocationStatsWithSize(cid, R2, space); \ | 224 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, R2, space)); \ |
| 225 /* Initialize the tags. */ \ | 225 /* Initialize the tags. */ \ |
| 226 /* R0: new object start as a tagged pointer. */ \ | 226 /* R0: new object start as a tagged pointer. */ \ |
| 227 /* R1: new object end address. */ \ | 227 /* R1: new object end address. */ \ |
| 228 /* R2: allocation size. */ \ | 228 /* R2: allocation size. */ \ |
| 229 { \ | 229 { \ |
| 230 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); \ | 230 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); \ |
| 231 __ LslImmediate(R2, R2, RawObject::kSizeTagPos - kObjectAlignmentLog2); \ | 231 __ LslImmediate(R2, R2, RawObject::kSizeTagPos - kObjectAlignmentLog2); \ |
| 232 __ csel(R2, ZR, R2, HI); \ | 232 __ csel(R2, ZR, R2, HI); \ |
| 233 \ | 233 \ |
| 234 /* Get the class index and insert it into the tags. */ \ | 234 /* Get the class index and insert it into the tags. */ \ |
| (...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 | 1900 |
| 1901 // Allocates one-byte string of length 'end - start'. The content is not | 1901 // Allocates one-byte string of length 'end - start'. The content is not |
| 1902 // initialized. | 1902 // initialized. |
| 1903 // 'length-reg' (R2) contains tagged length. | 1903 // 'length-reg' (R2) contains tagged length. |
| 1904 // Returns new string as tagged pointer in R0. | 1904 // Returns new string as tagged pointer in R0. |
| 1905 static void TryAllocateOnebyteString(Assembler* assembler, | 1905 static void TryAllocateOnebyteString(Assembler* assembler, |
| 1906 Label* ok, | 1906 Label* ok, |
| 1907 Label* failure) { | 1907 Label* failure) { |
| 1908 const Register length_reg = R2; | 1908 const Register length_reg = R2; |
| 1909 Label fail; | 1909 Label fail; |
| 1910 __ MaybeTraceAllocation(kOneByteStringCid, R0, failure); | 1910 NOT_IN_PRODUCT(__ MaybeTraceAllocation(kOneByteStringCid, R0, failure)); |
| 1911 __ mov(R6, length_reg); // Save the length register. | 1911 __ mov(R6, length_reg); // Save the length register. |
| 1912 // TODO(koda): Protect against negative length and overflow here. | 1912 // TODO(koda): Protect against negative length and overflow here. |
| 1913 __ SmiUntag(length_reg); | 1913 __ SmiUntag(length_reg); |
| 1914 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; | 1914 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; |
| 1915 __ AddImmediate(length_reg, length_reg, fixed_size); | 1915 __ AddImmediate(length_reg, length_reg, fixed_size); |
| 1916 __ andi(length_reg, length_reg, Immediate(~(kObjectAlignment - 1))); | 1916 __ andi(length_reg, length_reg, Immediate(~(kObjectAlignment - 1))); |
| 1917 | 1917 |
| 1918 const intptr_t cid = kOneByteStringCid; | 1918 const intptr_t cid = kOneByteStringCid; |
| 1919 Heap::Space space = Heap::SpaceForAllocation(cid); | 1919 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 1920 __ ldr(R3, Address(THR, Thread::heap_offset())); | 1920 __ ldr(R3, Address(THR, Thread::heap_offset())); |
| 1921 __ ldr(R0, Address(R3, Heap::TopOffset(space))); | 1921 __ ldr(R0, Address(R3, Heap::TopOffset(space))); |
| 1922 | 1922 |
| 1923 // length_reg: allocation size. | 1923 // length_reg: allocation size. |
| 1924 __ adds(R1, R0, Operand(length_reg)); | 1924 __ adds(R1, R0, Operand(length_reg)); |
| 1925 __ b(&fail, CS); // Fail on unsigned overflow. | 1925 __ b(&fail, CS); // Fail on unsigned overflow. |
| 1926 | 1926 |
| 1927 // Check if the allocation fits into the remaining space. | 1927 // Check if the allocation fits into the remaining space. |
| 1928 // R0: potential new object start. | 1928 // R0: potential new object start. |
| 1929 // R1: potential next object start. | 1929 // R1: potential next object start. |
| 1930 // R2: allocation size. | 1930 // R2: allocation size. |
| 1931 // R3: heap. | 1931 // R3: heap. |
| 1932 __ ldr(R7, Address(R3, Heap::EndOffset(space))); | 1932 __ ldr(R7, Address(R3, Heap::EndOffset(space))); |
| 1933 __ cmp(R1, Operand(R7)); | 1933 __ cmp(R1, Operand(R7)); |
| 1934 __ b(&fail, CS); | 1934 __ b(&fail, CS); |
| 1935 | 1935 |
| 1936 // Successfully allocated the object(s), now update top to point to | 1936 // Successfully allocated the object(s), now update top to point to |
| 1937 // next object start and initialize the object. | 1937 // next object start and initialize the object. |
| 1938 __ str(R1, Address(R3, Heap::TopOffset(space))); | 1938 __ str(R1, Address(R3, Heap::TopOffset(space))); |
| 1939 __ AddImmediate(R0, R0, kHeapObjectTag); | 1939 __ AddImmediate(R0, R0, kHeapObjectTag); |
| 1940 __ UpdateAllocationStatsWithSize(cid, R2, space); | 1940 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, R2, space)); |
| 1941 | 1941 |
| 1942 // Initialize the tags. | 1942 // Initialize the tags. |
| 1943 // R0: new object start as a tagged pointer. | 1943 // R0: new object start as a tagged pointer. |
| 1944 // R1: new object end address. | 1944 // R1: new object end address. |
| 1945 // R2: allocation size. | 1945 // R2: allocation size. |
| 1946 { | 1946 { |
| 1947 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; | 1947 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; |
| 1948 | 1948 |
| 1949 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); | 1949 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); |
| 1950 __ LslImmediate(R2, R2, shift); | 1950 __ LslImmediate(R2, R2, shift); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2207 __ cmp(R0, Operand(0)); | 2207 __ cmp(R0, Operand(0)); |
| 2208 __ LoadObject(R0, Bool::False()); | 2208 __ LoadObject(R0, Bool::False()); |
| 2209 __ LoadObject(TMP, Bool::True()); | 2209 __ LoadObject(TMP, Bool::True()); |
| 2210 __ csel(R0, TMP, R0, NE); | 2210 __ csel(R0, TMP, R0, NE); |
| 2211 __ ret(); | 2211 __ ret(); |
| 2212 } | 2212 } |
| 2213 | 2213 |
| 2214 } // namespace dart | 2214 } // namespace dart |
| 2215 | 2215 |
| 2216 #endif // defined TARGET_ARCH_ARM64 | 2216 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |