Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: runtime/vm/intrinsifier_arm.cc

Issue 1263513002: VM: Load allocation-top and -end via Thread. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fixed cc tests Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_ARM. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 const int32_t raw_null = reinterpret_cast<int32_t>(Object::null()); 182 const int32_t raw_null = reinterpret_cast<int32_t>(Object::null());
183 __ LoadImmediate(R0, raw_null); 183 __ LoadImmediate(R0, raw_null);
184 __ Ret(); 184 __ Ret();
185 __ Bind(&fall_through); 185 __ Bind(&fall_through);
186 } 186 }
187 187
188 188
189 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_shift) \ 189 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_shift) \
190 Label fall_through; \ 190 Label fall_through; \
191 const intptr_t kArrayLengthStackOffset = 0 * kWordSize; \ 191 const intptr_t kArrayLengthStackOffset = 0 * kWordSize; \
192 __ MaybeTraceAllocation(cid, R2, &fall_through); \ 192 __ MaybeTraceAllocation(cid, R2, &fall_through, \
193 /* inline_isolate = */ false); \
193 __ ldr(R2, Address(SP, kArrayLengthStackOffset)); /* Array length. */ \ 194 __ ldr(R2, Address(SP, kArrayLengthStackOffset)); /* Array length. */ \
194 /* Check that length is a positive Smi. */ \ 195 /* Check that length is a positive Smi. */ \
195 /* R2: requested array length argument. */ \ 196 /* R2: requested array length argument. */ \
196 __ tst(R2, Operand(kSmiTagMask)); \ 197 __ tst(R2, Operand(kSmiTagMask)); \
197 __ b(&fall_through, NE); \ 198 __ b(&fall_through, NE); \
198 __ CompareImmediate(R2, 0); \ 199 __ CompareImmediate(R2, 0); \
199 __ b(&fall_through, LT); \ 200 __ b(&fall_through, LT); \
200 __ SmiUntag(R2); \ 201 __ SmiUntag(R2); \
201 /* Check for maximum allowed length. */ \ 202 /* Check for maximum allowed length. */ \
202 /* R2: untagged array length. */ \ 203 /* R2: untagged array length. */ \
203 __ CompareImmediate(R2, max_len); \ 204 __ CompareImmediate(R2, max_len); \
204 __ b(&fall_through, GT); \ 205 __ b(&fall_through, GT); \
205 __ mov(R2, Operand(R2, LSL, scale_shift)); \ 206 __ mov(R2, Operand(R2, LSL, scale_shift)); \
206 const intptr_t fixed_size = sizeof(Raw##type_name) + kObjectAlignment - 1; \ 207 const intptr_t fixed_size = sizeof(Raw##type_name) + kObjectAlignment - 1; \
207 __ AddImmediate(R2, fixed_size); \ 208 __ AddImmediate(R2, fixed_size); \
208 __ bic(R2, R2, Operand(kObjectAlignment - 1)); \ 209 __ bic(R2, R2, Operand(kObjectAlignment - 1)); \
209 Heap* heap = Isolate::Current()->heap(); \ 210 Heap::Space space = Heap::SpaceForAllocation(cid); \
210 Heap::Space space = heap->SpaceForAllocation(cid); \ 211 __ ldr(R3, Address(THR, Thread::heap_offset())); \
211 __ LoadImmediate(R0, heap->TopAddress(space)); \ 212 __ ldr(R0, Address(R3, Heap::TopOffset(space))); \
212 __ ldr(R0, Address(R0, 0)); \
213 \ 213 \
214 /* R2: allocation size. */ \ 214 /* R2: allocation size. */ \
215 __ adds(R1, R0, Operand(R2)); \ 215 __ adds(R1, R0, Operand(R2)); \
216 __ b(&fall_through, CS); /* Fail on unsigned overflow. */ \ 216 __ b(&fall_through, CS); /* Fail on unsigned overflow. */ \
217 \ 217 \
218 /* Check if the allocation fits into the remaining space. */ \ 218 /* Check if the allocation fits into the remaining space. */ \
219 /* R0: potential new object start. */ \ 219 /* R0: potential new object start. */ \
220 /* R1: potential next object start. */ \ 220 /* R1: potential next object start. */ \
221 /* R2: allocation size. */ \ 221 /* R2: allocation size. */ \
222 __ LoadImmediate(R3, heap->EndAddress(space)); \ 222 /* R3: heap. */ \
223 __ ldr(R3, Address(R3, 0)); \ 223 __ ldr(IP, Address(R3, Heap::EndOffset(space))); \
224 __ cmp(R1, Operand(R3)); \ 224 __ cmp(R1, Operand(IP)); \
225 __ b(&fall_through, CS); \ 225 __ b(&fall_through, CS); \
226 \ 226 \
227 /* Successfully allocated the object(s), now update top to point to */ \ 227 /* Successfully allocated the object(s), now update top to point to */ \
228 /* next object start and initialize the object. */ \ 228 /* next object start and initialize the object. */ \
229 __ LoadAllocationStatsAddress(R4, cid); \ 229 __ LoadAllocationStatsAddress(R4, cid, /* inline_isolate = */ false); \
230 __ LoadImmediate(R3, heap->TopAddress(space)); \ 230 __ str(R1, Address(R3, Heap::TopOffset(space))); \
231 __ str(R1, Address(R3, 0)); \
232 __ AddImmediate(R0, kHeapObjectTag); \ 231 __ AddImmediate(R0, kHeapObjectTag); \
233 /* Initialize the tags. */ \ 232 /* Initialize the tags. */ \
234 /* R0: new object start as a tagged pointer. */ \ 233 /* R0: new object start as a tagged pointer. */ \
235 /* R1: new object end address. */ \ 234 /* R1: new object end address. */ \
236 /* R2: allocation size. */ \ 235 /* R2: allocation size. */ \
237 /* R4: allocation stats address */ \ 236 /* R4: allocation stats address */ \
238 { \ 237 { \
239 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); \ 238 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); \
240 __ mov(R3, Operand(R2, LSL, \ 239 __ mov(R3, Operand(R2, LSL, \
241 RawObject::kSizeTagPos - kObjectAlignmentLog2), LS); \ 240 RawObject::kSizeTagPos - kObjectAlignmentLog2), LS); \
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 const Register length_reg = R2; 1773 const Register length_reg = R2;
1775 Label fail; 1774 Label fail;
1776 __ MaybeTraceAllocation(kOneByteStringCid, R0, failure); 1775 __ MaybeTraceAllocation(kOneByteStringCid, R0, failure);
1777 __ mov(R6, Operand(length_reg)); // Save the length register. 1776 __ mov(R6, Operand(length_reg)); // Save the length register.
1778 // TODO(koda): Protect against negative length and overflow here. 1777 // TODO(koda): Protect against negative length and overflow here.
1779 __ SmiUntag(length_reg); 1778 __ SmiUntag(length_reg);
1780 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; 1779 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1;
1781 __ AddImmediate(length_reg, fixed_size); 1780 __ AddImmediate(length_reg, fixed_size);
1782 __ bic(length_reg, length_reg, Operand(kObjectAlignment - 1)); 1781 __ bic(length_reg, length_reg, Operand(kObjectAlignment - 1));
1783 1782
1784 Isolate* isolate = Isolate::Current();
1785 Heap* heap = isolate->heap();
1786 const intptr_t cid = kOneByteStringCid; 1783 const intptr_t cid = kOneByteStringCid;
1787 Heap::Space space = heap->SpaceForAllocation(cid); 1784 Heap::Space space = Heap::SpaceForAllocation(cid);
1788 __ LoadImmediate(R3, heap->TopAddress(space)); 1785 __ ldr(R3, Address(THR, Thread::heap_offset()));
1789 __ ldr(R0, Address(R3, 0)); 1786 __ ldr(R0, Address(R3, Heap::TopOffset(space)));
1790 1787
1791 // length_reg: allocation size. 1788 // length_reg: allocation size.
1792 __ adds(R1, R0, Operand(length_reg)); 1789 __ adds(R1, R0, Operand(length_reg));
1793 __ b(&fail, CS); // Fail on unsigned overflow. 1790 __ b(&fail, CS); // Fail on unsigned overflow.
1794 1791
1795 // Check if the allocation fits into the remaining space. 1792 // Check if the allocation fits into the remaining space.
1796 // R0: potential new object start. 1793 // R0: potential new object start.
1797 // R1: potential next object start. 1794 // R1: potential next object start.
1798 // R2: allocation size. 1795 // R2: allocation size.
1799 // R3: heap->TopAddress(space). 1796 // R3: heap.
1800 __ LoadImmediate(R7, heap->EndAddress(space)); 1797 __ ldr(R7, Address(R3, Heap::EndOffset(space)));
1801 __ ldr(R7, Address(R7, 0));
1802 __ cmp(R1, Operand(R7)); 1798 __ cmp(R1, Operand(R7));
1803 __ b(&fail, CS); 1799 __ b(&fail, CS);
1804 1800
1805 // Successfully allocated the object(s), now update top to point to 1801 // Successfully allocated the object(s), now update top to point to
1806 // next object start and initialize the object. 1802 // next object start and initialize the object.
1807 __ LoadAllocationStatsAddress(R4, cid); 1803 __ LoadAllocationStatsAddress(R4, cid, /* inline_isolate = */ false);
1808 __ str(R1, Address(R3, 0)); 1804 __ str(R1, Address(R3, Heap::TopOffset(space)));
1809 __ AddImmediate(R0, kHeapObjectTag); 1805 __ AddImmediate(R0, kHeapObjectTag);
1810 1806
1811 // Initialize the tags. 1807 // Initialize the tags.
1812 // R0: new object start as a tagged pointer. 1808 // R0: new object start as a tagged pointer.
1813 // R1: new object end address. 1809 // R1: new object end address.
1814 // R2: allocation size. 1810 // R2: allocation size.
1815 // R4: allocation stats address. 1811 // R4: allocation stats address.
1816 { 1812 {
1817 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; 1813 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
1818 1814
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 2060
2065 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) { 2061 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) {
2066 __ LoadIsolate(R0); 2062 __ LoadIsolate(R0);
2067 __ ldr(R0, Address(R0, Isolate::current_tag_offset())); 2063 __ ldr(R0, Address(R0, Isolate::current_tag_offset()));
2068 __ Ret(); 2064 __ Ret();
2069 } 2065 }
2070 2066
2071 } // namespace dart 2067 } // namespace dart
2072 2068
2073 #endif // defined TARGET_ARCH_ARM 2069 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698