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

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

Issue 502953002: Implement native _List. constructor in the flow-graph builder. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('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 24
25 void Intrinsifier::ObjectArrayAllocate(Assembler* assembler) {
26 Label fall_through;
27 const intptr_t kTypeArgumentsOffset = 1 * kWordSize;
28 const intptr_t kLengthOffset = 0 * kWordSize;
29
30 __ ldr(R1, Address(SP, kTypeArgumentsOffset));
31 __ ldr(R2, Address(SP, kLengthOffset));
32
33 // Compute the size to be allocated, it is based on the array length
34 // and is computed as:
35 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
36 __ MoveRegister(R3, R2); // Array length.
37
38 // Check that length is a positive Smi.
39 __ tst(R3, Operand(kSmiTagMask));
40 __ b(&fall_through, NE);
41 __ cmp(R3, Operand(0));
42 __ b(&fall_through, LT);
43
44 // Check for maximum allowed length.
45 const intptr_t max_len =
46 reinterpret_cast<int32_t>(Smi::New(Array::kMaxElements));
47 __ CompareImmediate(R3, max_len);
48 __ b(&fall_through, GT);
49
50 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
51 __ LoadImmediate(R8, fixed_size);
52 __ add(R8, R8, Operand(R3, LSL, 1)); // R3 is a Smi.
53 ASSERT(kSmiTagShift == 1);
54 __ bic(R8, R8, Operand(kObjectAlignment - 1));
55
56 // R8: Allocation size.
57
58 Isolate* isolate = Isolate::Current();
59 Heap* heap = isolate->heap();
60
61 __ LoadImmediate(R6, heap->TopAddress());
62 __ ldr(R0, Address(R6, 0)); // Potential new object start.
63 __ adds(R7, R0, Operand(R8)); // Potential next object start.
64 __ b(&fall_through, VS);
65
66 // Check if the allocation fits into the remaining space.
67 // R0: potential new object start.
68 // R7: potential next object start.
69 // R8: allocation size.
70 __ LoadImmediate(R3, heap->EndAddress());
71 __ ldr(R3, Address(R3, 0));
72 __ cmp(R7, Operand(R3));
73 __ b(&fall_through, CS);
74
75 // Successfully allocated the object(s), now update top to point to
76 // next object start and initialize the object.
77 __ str(R7, Address(R6, 0));
78 __ add(R0, R0, Operand(kHeapObjectTag));
79 __ UpdateAllocationStatsWithSize(kArrayCid, R8, R4);
80
81 // Initialize the tags.
82 // R0: new object start as a tagged pointer.
83 // R7: new object end address.
84 // R8: allocation size.
85 {
86 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
87 const Class& cls = Class::Handle(isolate->object_store()->array_class());
88
89 __ CompareImmediate(R8, RawObject::SizeTag::kMaxSizeTag);
90 __ mov(R8, Operand(R8, LSL, shift), LS);
91 __ mov(R8, Operand(0), HI);
92
93 // Get the class index and insert it into the tags.
94 // R8: size and bit tags.
95 __ LoadImmediate(TMP, RawObject::ClassIdTag::encode(cls.id()));
96 __ orr(R8, R8, Operand(TMP));
97 __ str(R8, FieldAddress(R0, Array::tags_offset())); // Store tags.
98 }
99
100 // R0: new object start as a tagged pointer.
101 // R7: new object end address.
102 // Store the type argument field.
103 __ StoreIntoObjectNoBarrier(R0,
104 FieldAddress(R0, Array::type_arguments_offset()),
105 R1);
106
107 // Set the length field.
108 __ StoreIntoObjectNoBarrier(R0,
109 FieldAddress(R0, Array::length_offset()),
110 R2);
111
112 // Initialize all array elements to raw_null.
113 // R0: new object start as a tagged pointer.
114 // R7: new object end address.
115 // R8: iterator which initially points to the start of the variable
116 // data area to be initialized.
117 // R3: null
118 __ LoadImmediate(R3, reinterpret_cast<intptr_t>(Object::null()));
119 __ AddImmediate(R8, R0, sizeof(RawArray) - kHeapObjectTag);
120
121 Label init_loop;
122 __ Bind(&init_loop);
123 __ cmp(R8, Operand(R7));
124 __ str(R3, Address(R8, 0), CC);
125 __ AddImmediate(R8, kWordSize, CC);
126 __ b(&init_loop, CC);
127
128 __ Ret(); // Returns the newly allocated object in R0.
129 // Unable to allocate the array using the fast inline code, just call
130 // into the runtime.
131 __ Bind(&fall_through);
132 }
133
134
135 void Intrinsifier::ObjectArrayLength(Assembler* assembler) { 25 void Intrinsifier::ObjectArrayLength(Assembler* assembler) {
136 __ ldr(R0, Address(SP, 0 * kWordSize)); 26 __ ldr(R0, Address(SP, 0 * kWordSize));
137 __ ldr(R0, FieldAddress(R0, Array::length_offset())); 27 __ ldr(R0, FieldAddress(R0, Array::length_offset()));
138 __ Ret(); 28 __ Ret();
139 } 29 }
140 30
141 31
142 void Intrinsifier::ImmutableArrayLength(Assembler* assembler) { 32 void Intrinsifier::ImmutableArrayLength(Assembler* assembler) {
143 ObjectArrayLength(assembler); 33 ObjectArrayLength(assembler);
144 } 34 }
(...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 Isolate* isolate = Isolate::Current(); 1792 Isolate* isolate = Isolate::Current();
1903 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate)); 1793 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate));
1904 // Set return value to Isolate::current_tag_. 1794 // Set return value to Isolate::current_tag_.
1905 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); 1795 __ ldr(R0, Address(R1, Isolate::current_tag_offset()));
1906 __ Ret(); 1796 __ Ret();
1907 } 1797 }
1908 1798
1909 } // namespace dart 1799 } // namespace dart
1910 1800
1911 #endif // defined TARGET_ARCH_ARM 1801 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/intrinsifier_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698