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

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

Issue 284013002: Improve performance of stubcode based array allocation moving stub to isolate specific area. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | runtime/vm/intrinsifier_arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "vm/cpu.h" 11 #include "vm/cpu.h"
12 #include "vm/flow_graph_compiler.h" 12 #include "vm/flow_graph_compiler.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/symbols.h" 15 #include "vm/symbols.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 DECLARE_FLAG(bool, enable_type_checks); 19 DECLARE_FLAG(bool, enable_type_checks);
20 20
21 21
22 #define __ assembler-> 22 #define __ assembler->
23 23
24 void Intrinsifier::List_Allocate(Assembler* assembler) {
25 const intptr_t kTypeArgumentsOffset = 1 * kWordSize;
26 const intptr_t kArrayLengthOffset = 0 * kWordSize;
27 Label fall_through;
28
29 // Compute the size to be allocated, it is based on the array length
30 // and is computed as:
31 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
32 __ ldr(R3, Address(SP, kArrayLengthOffset)); // Array length.
33
34 // Check that length is a positive Smi.
35 __ tst(R3, ShifterOperand(kSmiTagMask));
36 __ b(&fall_through, NE);
37 __ cmp(R3, ShifterOperand(0));
38 __ b(&fall_through, LT);
39
40 // Check for maximum allowed length.
41 const intptr_t max_len =
42 reinterpret_cast<int32_t>(Smi::New(Array::kMaxElements));
43 __ CompareImmediate(R3, max_len);
44 __ b(&fall_through, GT);
45
46 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
47 __ LoadImmediate(R2, fixed_size);
48 __ add(R2, R2, ShifterOperand(R3, LSL, 1)); // R3 is a Smi.
49 ASSERT(kSmiTagShift == 1);
50 __ bic(R2, R2, ShifterOperand(kObjectAlignment - 1));
51
52 // R2: Allocation size.
53
54 Isolate* isolate = Isolate::Current();
55 Heap* heap = isolate->heap();
56
57 __ LoadImmediate(R6, heap->TopAddress());
58 __ ldr(R0, Address(R6, 0)); // Potential new object start.
59 __ adds(R1, R0, ShifterOperand(R2)); // Potential next object start.
60 __ b(&fall_through, VS);
61
62 // Check if the allocation fits into the remaining space.
63 // R0: potential new object start.
64 // R1: potential next object start.
65 // R2: allocation size.
66 __ LoadImmediate(R3, heap->EndAddress());
67 __ ldr(R3, Address(R3, 0));
68 __ cmp(R1, ShifterOperand(R3));
69 __ b(&fall_through, CS);
70
71 // Successfully allocated the object(s), now update top to point to
72 // next object start and initialize the object.
73 __ str(R1, Address(R6, 0));
74 __ add(R0, R0, ShifterOperand(kHeapObjectTag));
75 __ UpdateAllocationStatsWithSize(kArrayCid, R2, R4);
76
77 // Initialize the tags.
78 // R0: new object start as a tagged pointer.
79 // R1: new object end address.
80 // R2: allocation size.
81 {
82 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
83 const Class& cls = Class::Handle(isolate->object_store()->array_class());
84
85 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag);
86 __ mov(R2, ShifterOperand(R2, LSL, shift), LS);
87 __ mov(R2, ShifterOperand(0), HI);
88
89 // Get the class index and insert it into the tags.
90 // R2: size and bit tags.
91 __ LoadImmediate(TMP, RawObject::ClassIdTag::encode(cls.id()));
92 __ orr(R2, R2, ShifterOperand(TMP));
93 __ str(R2, FieldAddress(R0, Array::tags_offset())); // Store tags.
94 }
95
96 // R0: new object start as a tagged pointer.
97 // R1: new object end address.
98 // Store the type argument field.
99 __ ldr(R2, Address(SP, kTypeArgumentsOffset)); // Type argument.
100 __ StoreIntoObjectNoBarrier(R0,
101 FieldAddress(R0, Array::type_arguments_offset()),
102 R2);
103
104 // Set the length field.
105 __ ldr(R2, Address(SP, kArrayLengthOffset)); // Array Length.
106 __ StoreIntoObjectNoBarrier(R0,
107 FieldAddress(R0, Array::length_offset()),
108 R2);
109
110 // Initialize all array elements to raw_null.
111 // R0: new object start as a tagged pointer.
112 // R1: new object end address.
113 // R2: iterator which initially points to the start of the variable
114 // data area to be initialized.
115 // R3: null
116 __ LoadImmediate(R3, reinterpret_cast<intptr_t>(Object::null()));
117 __ AddImmediate(R2, R0, sizeof(RawArray) - kHeapObjectTag);
118
119 Label init_loop;
120 __ Bind(&init_loop);
121 __ cmp(R2, ShifterOperand(R1));
122 __ str(R3, Address(R2, 0), CC);
123 __ AddImmediate(R2, kWordSize, CC);
124 __ b(&init_loop, CC);
125
126 __ Ret(); // Returns the newly allocated object in R0.
127 __ Bind(&fall_through);
128 }
129
130 24
131 void Intrinsifier::Array_getLength(Assembler* assembler) { 25 void Intrinsifier::Array_getLength(Assembler* assembler) {
132 __ ldr(R0, Address(SP, 0 * kWordSize)); 26 __ ldr(R0, Address(SP, 0 * kWordSize));
133 __ ldr(R0, FieldAddress(R0, Array::length_offset())); 27 __ ldr(R0, FieldAddress(R0, Array::length_offset()));
134 __ Ret(); 28 __ Ret();
135 } 29 }
136 30
137 31
138 void Intrinsifier::ImmutableList_getLength(Assembler* assembler) { 32 void Intrinsifier::ImmutableList_getLength(Assembler* assembler) {
139 return Array_getLength(assembler); 33 return Array_getLength(assembler);
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 static int GetScaleFactor(intptr_t size) { 438 static int GetScaleFactor(intptr_t size) {
545 switch (size) { 439 switch (size) {
546 case 1: return 0; 440 case 1: return 0;
547 case 2: return 1; 441 case 2: return 1;
548 case 4: return 2; 442 case 4: return 2;
549 case 8: return 3; 443 case 8: return 3;
550 case 16: return 4; 444 case 16: return 4;
551 } 445 }
552 UNREACHABLE(); 446 UNREACHABLE();
553 return -1; 447 return -1;
554 }; 448 }
555 449
556 450
557 #define TYPED_DATA_ALLOCATOR(clazz) \ 451 #define TYPED_DATA_ALLOCATOR(clazz) \
558 void Intrinsifier::TypedData_##clazz##_new(Assembler* assembler) { \ 452 void Intrinsifier::TypedData_##clazz##_new(Assembler* assembler) { \
559 intptr_t size = TypedData::ElementSizeInBytes(kTypedData##clazz##Cid); \ 453 intptr_t size = TypedData::ElementSizeInBytes(kTypedData##clazz##Cid); \
560 intptr_t max_len = TypedData::MaxElements(kTypedData##clazz##Cid); \ 454 intptr_t max_len = TypedData::MaxElements(kTypedData##clazz##Cid); \
561 int shift = GetScaleFactor(size); \ 455 int shift = GetScaleFactor(size); \
562 TYPED_ARRAY_ALLOCATION(TypedData, kTypedData##clazz##Cid, max_len, shift); \ 456 TYPED_ARRAY_ALLOCATION(TypedData, kTypedData##clazz##Cid, max_len, shift); \
563 } \ 457 } \
564 void Intrinsifier::TypedData_##clazz##_factory(Assembler* assembler) { \ 458 void Intrinsifier::TypedData_##clazz##_factory(Assembler* assembler) { \
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 Isolate* isolate = Isolate::Current(); 1647 Isolate* isolate = Isolate::Current();
1754 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate)); 1648 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate));
1755 // Set return value to Isolate::current_tag_. 1649 // Set return value to Isolate::current_tag_.
1756 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); 1650 __ ldr(R0, Address(R1, Isolate::current_tag_offset()));
1757 __ Ret(); 1651 __ Ret();
1758 } 1652 }
1759 1653
1760 } // namespace dart 1654 } // namespace dart
1761 1655
1762 #endif // defined TARGET_ARCH_ARM 1656 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | runtime/vm/intrinsifier_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698