| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 case 16: return 4; | 161 case 16: return 4; |
| 162 } | 162 } |
| 163 UNREACHABLE(); | 163 UNREACHABLE(); |
| 164 return -1; | 164 return -1; |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_shift) \ | 168 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_shift) \ |
| 169 Label fall_through; \ | 169 Label fall_through; \ |
| 170 const intptr_t kArrayLengthStackOffset = 0 * kWordSize; \ | 170 const intptr_t kArrayLengthStackOffset = 0 * kWordSize; \ |
| 171 __ MaybeTraceAllocation(cid, R2, &fall_through, \ | 171 __ MaybeTraceAllocation(cid, R2, &fall_through); \ |
| 172 /* inline_isolate = */ false); \ | |
| 173 __ ldr(R2, Address(SP, kArrayLengthStackOffset)); /* Array length. */ \ | 172 __ ldr(R2, Address(SP, kArrayLengthStackOffset)); /* Array length. */ \ |
| 174 /* Check that length is a positive Smi. */ \ | 173 /* Check that length is a positive Smi. */ \ |
| 175 /* R2: requested array length argument. */ \ | 174 /* R2: requested array length argument. */ \ |
| 176 __ tsti(R2, Immediate(kSmiTagMask)); \ | 175 __ tsti(R2, Immediate(kSmiTagMask)); \ |
| 177 __ b(&fall_through, NE); \ | 176 __ b(&fall_through, NE); \ |
| 178 __ CompareRegisters(R2, ZR); \ | 177 __ CompareRegisters(R2, ZR); \ |
| 179 __ b(&fall_through, LT); \ | 178 __ b(&fall_through, LT); \ |
| 180 __ SmiUntag(R2); \ | 179 __ SmiUntag(R2); \ |
| 181 /* Check for maximum allowed length. */ \ | 180 /* Check for maximum allowed length. */ \ |
| 182 /* R2: untagged array length. */ \ | 181 /* R2: untagged array length. */ \ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 200 /* R2: allocation size. */ \ | 199 /* R2: allocation size. */ \ |
| 201 /* R3: heap. */ \ | 200 /* R3: heap. */ \ |
| 202 __ ldr(R6, Address(R3, Heap::EndOffset(space))); \ | 201 __ ldr(R6, Address(R3, Heap::EndOffset(space))); \ |
| 203 __ cmp(R1, Operand(R6)); \ | 202 __ cmp(R1, Operand(R6)); \ |
| 204 __ b(&fall_through, CS); \ | 203 __ b(&fall_through, CS); \ |
| 205 \ | 204 \ |
| 206 /* Successfully allocated the object(s), now update top to point to */ \ | 205 /* Successfully allocated the object(s), now update top to point to */ \ |
| 207 /* next object start and initialize the object. */ \ | 206 /* next object start and initialize the object. */ \ |
| 208 __ str(R1, Address(R3, Heap::TopOffset(space))); \ | 207 __ str(R1, Address(R3, Heap::TopOffset(space))); \ |
| 209 __ AddImmediate(R0, R0, kHeapObjectTag); \ | 208 __ AddImmediate(R0, R0, kHeapObjectTag); \ |
| 210 __ UpdateAllocationStatsWithSize(cid, R2, space, \ | 209 __ UpdateAllocationStatsWithSize(cid, R2, space); \ |
| 211 /* inline_isolate = */ false); \ | |
| 212 /* Initialize the tags. */ \ | 210 /* Initialize the tags. */ \ |
| 213 /* R0: new object start as a tagged pointer. */ \ | 211 /* R0: new object start as a tagged pointer. */ \ |
| 214 /* R1: new object end address. */ \ | 212 /* R1: new object end address. */ \ |
| 215 /* R2: allocation size. */ \ | 213 /* R2: allocation size. */ \ |
| 216 { \ | 214 { \ |
| 217 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); \ | 215 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); \ |
| 218 __ LslImmediate(R2, R2, RawObject::kSizeTagPos - kObjectAlignmentLog2); \ | 216 __ LslImmediate(R2, R2, RawObject::kSizeTagPos - kObjectAlignmentLog2); \ |
| 219 __ csel(R2, ZR, R2, HI); \ | 217 __ csel(R2, ZR, R2, HI); \ |
| 220 \ | 218 \ |
| 221 /* Get the class index and insert it into the tags. */ \ | 219 /* Get the class index and insert it into the tags. */ \ |
| (...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1919 | 1917 |
| 1920 // Allocates one-byte string of length 'end - start'. The content is not | 1918 // Allocates one-byte string of length 'end - start'. The content is not |
| 1921 // initialized. | 1919 // initialized. |
| 1922 // 'length-reg' (R2) contains tagged length. | 1920 // 'length-reg' (R2) contains tagged length. |
| 1923 // Returns new string as tagged pointer in R0. | 1921 // Returns new string as tagged pointer in R0. |
| 1924 static void TryAllocateOnebyteString(Assembler* assembler, | 1922 static void TryAllocateOnebyteString(Assembler* assembler, |
| 1925 Label* ok, | 1923 Label* ok, |
| 1926 Label* failure) { | 1924 Label* failure) { |
| 1927 const Register length_reg = R2; | 1925 const Register length_reg = R2; |
| 1928 Label fail; | 1926 Label fail; |
| 1929 __ MaybeTraceAllocation(kOneByteStringCid, R0, failure, | 1927 __ MaybeTraceAllocation(kOneByteStringCid, R0, failure); |
| 1930 /* inline_isolate = */ false); | |
| 1931 __ mov(R6, length_reg); // Save the length register. | 1928 __ mov(R6, length_reg); // Save the length register. |
| 1932 // TODO(koda): Protect against negative length and overflow here. | 1929 // TODO(koda): Protect against negative length and overflow here. |
| 1933 __ SmiUntag(length_reg); | 1930 __ SmiUntag(length_reg); |
| 1934 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; | 1931 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; |
| 1935 __ AddImmediate(length_reg, length_reg, fixed_size); | 1932 __ AddImmediate(length_reg, length_reg, fixed_size); |
| 1936 __ andi(length_reg, length_reg, Immediate(~(kObjectAlignment - 1))); | 1933 __ andi(length_reg, length_reg, Immediate(~(kObjectAlignment - 1))); |
| 1937 | 1934 |
| 1938 const intptr_t cid = kOneByteStringCid; | 1935 const intptr_t cid = kOneByteStringCid; |
| 1939 Heap::Space space = Heap::SpaceForAllocation(cid); | 1936 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 1940 __ ldr(R3, Address(THR, Thread::heap_offset())); | 1937 __ ldr(R3, Address(THR, Thread::heap_offset())); |
| 1941 __ ldr(R0, Address(R3, Heap::TopOffset(space))); | 1938 __ ldr(R0, Address(R3, Heap::TopOffset(space))); |
| 1942 | 1939 |
| 1943 // length_reg: allocation size. | 1940 // length_reg: allocation size. |
| 1944 __ adds(R1, R0, Operand(length_reg)); | 1941 __ adds(R1, R0, Operand(length_reg)); |
| 1945 __ b(&fail, CS); // Fail on unsigned overflow. | 1942 __ b(&fail, CS); // Fail on unsigned overflow. |
| 1946 | 1943 |
| 1947 // Check if the allocation fits into the remaining space. | 1944 // Check if the allocation fits into the remaining space. |
| 1948 // R0: potential new object start. | 1945 // R0: potential new object start. |
| 1949 // R1: potential next object start. | 1946 // R1: potential next object start. |
| 1950 // R2: allocation size. | 1947 // R2: allocation size. |
| 1951 // R3: heap. | 1948 // R3: heap. |
| 1952 __ ldr(R7, Address(R3, Heap::EndOffset(space))); | 1949 __ ldr(R7, Address(R3, Heap::EndOffset(space))); |
| 1953 __ cmp(R1, Operand(R7)); | 1950 __ cmp(R1, Operand(R7)); |
| 1954 __ b(&fail, CS); | 1951 __ b(&fail, CS); |
| 1955 | 1952 |
| 1956 // Successfully allocated the object(s), now update top to point to | 1953 // Successfully allocated the object(s), now update top to point to |
| 1957 // next object start and initialize the object. | 1954 // next object start and initialize the object. |
| 1958 __ str(R1, Address(R3, Heap::TopOffset(space))); | 1955 __ str(R1, Address(R3, Heap::TopOffset(space))); |
| 1959 __ AddImmediate(R0, R0, kHeapObjectTag); | 1956 __ AddImmediate(R0, R0, kHeapObjectTag); |
| 1960 __ UpdateAllocationStatsWithSize(cid, R2, space, | 1957 __ UpdateAllocationStatsWithSize(cid, R2, space); |
| 1961 /* inline_isolate = */ false); | |
| 1962 | 1958 |
| 1963 // Initialize the tags. | 1959 // Initialize the tags. |
| 1964 // R0: new object start as a tagged pointer. | 1960 // R0: new object start as a tagged pointer. |
| 1965 // R1: new object end address. | 1961 // R1: new object end address. |
| 1966 // R2: allocation size. | 1962 // R2: allocation size. |
| 1967 { | 1963 { |
| 1968 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; | 1964 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; |
| 1969 | 1965 |
| 1970 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); | 1966 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); |
| 1971 __ LslImmediate(R2, R2, shift); | 1967 __ LslImmediate(R2, R2, shift); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2210 | 2206 |
| 2211 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) { | 2207 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) { |
| 2212 __ LoadIsolate(R0); | 2208 __ LoadIsolate(R0); |
| 2213 __ ldr(R0, Address(R0, Isolate::current_tag_offset())); | 2209 __ ldr(R0, Address(R0, Isolate::current_tag_offset())); |
| 2214 __ ret(); | 2210 __ ret(); |
| 2215 } | 2211 } |
| 2216 | 2212 |
| 2217 } // namespace dart | 2213 } // namespace dart |
| 2218 | 2214 |
| 2219 #endif // defined TARGET_ARCH_ARM64 | 2215 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |