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

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

Issue 876603003: VM: Refactor more intrinsics of GrowableList to use IR builder. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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_ia32.cc ('k') | runtime/vm/intrinsifier_x64.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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 T1); 127 T1);
128 // Set the length field in the growable array object to 0. 128 // Set the length field in the growable array object to 0.
129 __ Ret(); // Returns the newly allocated object in V0. 129 __ Ret(); // Returns the newly allocated object in V0.
130 __ delay_slot()->sw(ZR, 130 __ delay_slot()->sw(ZR,
131 FieldAddress(V0, GrowableObjectArray::length_offset())); 131 FieldAddress(V0, GrowableObjectArray::length_offset()));
132 132
133 __ Bind(&fall_through); 133 __ Bind(&fall_through);
134 } 134 }
135 135
136 136
137 void Intrinsifier::GrowableArrayGetIndexed(Assembler* assembler) {
138 Label fall_through;
139
140 __ lw(T0, Address(SP, 0 * kWordSize)); // Index
141
142 __ andi(CMPRES1, T0, Immediate(kSmiTagMask));
143 __ bne(CMPRES1, ZR, &fall_through); // Index is not an smi, fall through
144 __ delay_slot()->lw(T1, Address(SP, 1 * kWordSize)); // Array
145
146 // Range check.
147 __ lw(T2, FieldAddress(T1, GrowableObjectArray::length_offset()));
148 __ BranchUnsignedGreaterEqual(T0, T2, &fall_through);
149
150 __ lw(T2, FieldAddress(T1, GrowableObjectArray::data_offset())); // data
151
152 ASSERT(kSmiTagShift == 1);
153 // array element at T2 + T0 * 2 + Array::data_offset - 1
154 __ sll(T3, T0, 1);
155 __ addu(T2, T2, T3);
156 __ Ret();
157 __ delay_slot()->lw(V0, FieldAddress(T2, Array::data_offset()));
158 __ Bind(&fall_through);
159 }
160
161
162 // Set value into growable object array at specified index.
163 // On stack: growable array (+2), index (+1), value (+0).
164 void Intrinsifier::GrowableArraySetIndexed(Assembler* assembler) {
165 if (FLAG_enable_type_checks) {
166 return;
167 }
168 Label fall_through;
169 __ lw(T1, Address(SP, 1 * kWordSize)); // Index.
170 __ andi(CMPRES1, T1, Immediate(kSmiTagMask));
171 __ bne(CMPRES1, ZR, &fall_through); // Non-smi index.
172 __ delay_slot()->lw(T0, Address(SP, 2 * kWordSize)); // GrowableArray.
173 // Range check using _length field.
174 __ lw(T2, FieldAddress(T0, GrowableObjectArray::length_offset()));
175 // Runtime throws exception.
176 __ BranchUnsignedGreaterEqual(T1, T2, &fall_through);
177 __ lw(T0, FieldAddress(T0, GrowableObjectArray::data_offset())); // data.
178 __ lw(T2, Address(SP, 0 * kWordSize)); // Value.
179 // Note that T1 is Smi, i.e, times 2.
180 ASSERT(kSmiTagShift == 1);
181 __ sll(T1, T1, 1);
182 __ addu(T1, T0, T1);
183 __ StoreIntoObject(T0,
184 FieldAddress(T1, Array::data_offset()),
185 T2);
186 __ Ret();
187 __ Bind(&fall_through);
188 }
189
190
191 // Set length of growable object array. The length cannot
192 // be greater than the length of the data container.
193 // On stack: growable array (+1), length (+0).
194 void Intrinsifier::GrowableArraySetLength(Assembler* assembler) {
195 Label fall_through;
196 __ lw(T1, Address(SP, 0 * kWordSize)); // Length value.
197 __ andi(CMPRES1, T1, Immediate(kSmiTagMask));
198 __ bne(CMPRES1, ZR, &fall_through); // Non-smi length.
199 __ delay_slot()->lw(T0, Address(SP, 1 * kWordSize)); // Growable array.
200 __ Ret();
201 __ delay_slot()->sw(T1,
202 FieldAddress(T0, GrowableObjectArray::length_offset()));
203 __ Bind(&fall_through);
204 }
205
206
207 // Set data of growable object array.
208 // On stack: growable array (+1), data (+0).
209 void Intrinsifier::GrowableArraySetData(Assembler* assembler) {
210 if (FLAG_enable_type_checks) {
211 return;
212 }
213 Label fall_through;
214 __ lw(T1, Address(SP, 0 * kWordSize)); // Data.
215 // Check that data is an ObjectArray.
216 __ andi(CMPRES1, T1, Immediate(kSmiTagMask));
217 __ beq(CMPRES1, ZR, &fall_through); // Data is Smi.
218 __ LoadClassId(CMPRES1, T1);
219 __ BranchNotEqual(CMPRES1, Immediate(kArrayCid), &fall_through);
220 __ lw(T0, Address(SP, 1 * kWordSize)); // Growable array.
221 __ StoreIntoObject(T0,
222 FieldAddress(T0, GrowableObjectArray::data_offset()),
223 T1);
224 __ Ret();
225 __ Bind(&fall_through);
226 }
227
228
229 // Add an element to growable array if it doesn't need to grow, otherwise 137 // Add an element to growable array if it doesn't need to grow, otherwise
230 // call into regular code. 138 // call into regular code.
231 // On stack: growable array (+1), value (+0). 139 // On stack: growable array (+1), value (+0).
232 void Intrinsifier::GrowableArray_add(Assembler* assembler) { 140 void Intrinsifier::GrowableArray_add(Assembler* assembler) {
233 // In checked mode we need to type-check the incoming argument. 141 // In checked mode we need to type-check the incoming argument.
234 if (FLAG_enable_type_checks) return; 142 if (FLAG_enable_type_checks) return;
235 Label fall_through; 143 Label fall_through;
236 __ lw(T0, Address(SP, 1 * kWordSize)); // Array. 144 __ lw(T0, Address(SP, 1 * kWordSize)); // Array.
237 __ lw(T1, FieldAddress(T0, GrowableObjectArray::length_offset())); 145 __ lw(T1, FieldAddress(T0, GrowableObjectArray::length_offset()));
238 // T1: length. 146 // T1: length.
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 Isolate* isolate = Isolate::Current(); 2051 Isolate* isolate = Isolate::Current();
2144 __ LoadImmediate(V0, reinterpret_cast<uword>(isolate)); 2052 __ LoadImmediate(V0, reinterpret_cast<uword>(isolate));
2145 // Set return value. 2053 // Set return value.
2146 __ Ret(); 2054 __ Ret();
2147 __ delay_slot()->lw(V0, Address(V0, Isolate::current_tag_offset())); 2055 __ delay_slot()->lw(V0, Address(V0, Isolate::current_tag_offset()));
2148 } 2056 }
2149 2057
2150 } // namespace dart 2058 } // namespace dart
2151 2059
2152 #endif // defined TARGET_ARCH_MIPS 2060 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_ia32.cc ('k') | runtime/vm/intrinsifier_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698