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

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

Issue 9020030: Optimize indexed store for growable array (intrinsification and inlined optimized). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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 | « no previous file | runtime/vm/opt_code_generator_ia32.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // The intrinsic code below is executed before a method has built its frame. 5 // The intrinsic code below is executed before a method has built its frame.
6 // The return address is on the stack and the arguments below it. 6 // The return address is on the stack and the arguments below it.
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved.
8 // Each intrinsification method returns true if the corresponding 8 // Each intrinsification method returns true if the corresponding
9 // Dart method was intrinsified. 9 // Dart method was intrinsified.
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 V(Double, /, Double_div) \ 63 V(Double, /, Double_div) \
64 V(Double, toDouble, Double_toDouble) \ 64 V(Double, toDouble, Double_toDouble) \
65 V(Double, mulFromInteger, Double_mulFromInteger) \ 65 V(Double, mulFromInteger, Double_mulFromInteger) \
66 V(Double, Double.fromInteger, Double_fromInteger) \ 66 V(Double, Double.fromInteger, Double_fromInteger) \
67 V(ObjectArray, ObjectArray., ObjectArray_Allocate) \ 67 V(ObjectArray, ObjectArray., ObjectArray_Allocate) \
68 V(ObjectArray, get:length, Array_getLength) \ 68 V(ObjectArray, get:length, Array_getLength) \
69 V(ObjectArray, [], Array_getIndexed) \ 69 V(ObjectArray, [], Array_getIndexed) \
70 V(ObjectArray, []=, Array_setIndexed) \ 70 V(ObjectArray, []=, Array_setIndexed) \
71 V(GrowableObjectArray, get:length, GrowableArray_getLength) \ 71 V(GrowableObjectArray, get:length, GrowableArray_getLength) \
72 V(GrowableObjectArray, [], GrowableArray_getIndexed) \ 72 V(GrowableObjectArray, [], GrowableArray_getIndexed) \
73 V(GrowableObjectArray, []=, GrowableArray_setIndexed) \
73 V(ImmutableArray, [], Array_getIndexed) \ 74 V(ImmutableArray, [], Array_getIndexed) \
74 V(ImmutableArray, get:length, Array_getLength) \ 75 V(ImmutableArray, get:length, Array_getLength) \
75 V(Math, sqrt, Math_sqrt) \ 76 V(Math, sqrt, Math_sqrt) \
76 V(Object, ==, Object_equal) \ 77 V(Object, ==, Object_equal) \
77 V(FixedSizeArrayIterator, next, FixedSizeArrayIterator_next) \ 78 V(FixedSizeArrayIterator, next, FixedSizeArrayIterator_next) \
78 V(FixedSizeArrayIterator, hasNext, FixedSizeArrayIterator_hasNext) \ 79 V(FixedSizeArrayIterator, hasNext, FixedSizeArrayIterator_hasNext) \
79 V(StringBase, get:length, String_getLength) \ 80 V(StringBase, get:length, String_getLength) \
80 V(StringBase, charCodeAt, String_charCodeAt) \ 81 V(StringBase, charCodeAt, String_charCodeAt) \
81 V(StringBase, hashCode, String_hashCode) \ 82 V(StringBase, hashCode, String_hashCode) \
82 V(StringBase, isEmpty, String_isEmpty) \ 83 V(StringBase, isEmpty, String_isEmpty) \
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 192
192 // Intrinsify only for Smi value and index. Non-smi values need a store buffer 193 // Intrinsify only for Smi value and index. Non-smi values need a store buffer
193 // update. Array length is always a Smi. 194 // update. Array length is always a Smi.
194 static bool Array_setIndexed(Assembler* assembler) { 195 static bool Array_setIndexed(Assembler* assembler) {
195 if (FLAG_enable_type_checks) { 196 if (FLAG_enable_type_checks) {
196 return false; 197 return false;
197 } 198 }
198 const Immediate raw_null = 199 const Immediate raw_null =
199 Immediate(reinterpret_cast<intptr_t>(Object::null())); 200 Immediate(reinterpret_cast<intptr_t>(Object::null()));
200 Label fall_through; 201 Label fall_through;
201 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Value.
202 __ movl(EBX, Address(ESP, + 2 * kWordSize)); // Index. 202 __ movl(EBX, Address(ESP, + 2 * kWordSize)); // Index.
203 __ orl(EAX, EBX); 203 __ testl(EBX, Immediate(kSmiTagMask));
204 __ testl(EAX, Immediate(kSmiTagMask)); 204 // Index not Smi.
205 // Value or index not Smi.
206 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); 205 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump);
207 __ movl(EAX, Address(ESP, + 3 * kWordSize)); // Array. 206 __ movl(EAX, Address(ESP, + 3 * kWordSize)); // Array.
208 // Range check. 207 // Range check.
209 __ cmpl(EBX, FieldAddress(EAX, Array::length_offset())); 208 __ cmpl(EBX, FieldAddress(EAX, Array::length_offset()));
210 // Runtime throws exception. 209 // Runtime throws exception.
211 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); 210 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump);
212 // Note that EBX is Smi, i.e, times 2. 211 // Note that EBX is Smi, i.e, times 2.
213 ASSERT(kSmiTagShift == 1); 212 ASSERT(kSmiTagShift == 1);
214 // Destroy ECX as we will not continue in the function. 213 // Destroy ECX as we will not continue in the function.
215 __ movl(ECX, Address(ESP, + 1 * kWordSize)); 214 __ movl(ECX, Address(ESP, + 1 * kWordSize)); // Value.
216 __ StoreIntoObject(EAX, 215 __ StoreIntoObject(EAX,
217 FieldAddress(EAX, EBX, TIMES_2, sizeof(RawArray)), 216 FieldAddress(EAX, EBX, TIMES_2, sizeof(RawArray)),
218 ECX); 217 ECX);
219 // Caller is responsible of preserving the value if necessary. 218 // Caller is responsible of preserving the value if necessary.
220 __ ret(); 219 __ ret();
221 __ Bind(&fall_through); 220 __ Bind(&fall_through);
222 return false; 221 return false;
223 } 222 }
224 223
225 224
(...skipping 28 matching lines...) Expand all
254 static bool GrowableArray_getIndexed(Assembler* assembler) { 253 static bool GrowableArray_getIndexed(Assembler* assembler) {
255 intptr_t length_offset = GetOffsetForField(kGrowableArrayClassName, 254 intptr_t length_offset = GetOffsetForField(kGrowableArrayClassName,
256 kGrowableArrayLengthFieldName); 255 kGrowableArrayLengthFieldName);
257 intptr_t array_offset = GetOffsetForField(kGrowableArrayClassName, 256 intptr_t array_offset = GetOffsetForField(kGrowableArrayClassName,
258 kGrowableArrayArrayFieldName); 257 kGrowableArrayArrayFieldName);
259 Label fall_through; 258 Label fall_through;
260 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index. 259 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index.
261 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // GrowableArray. 260 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // GrowableArray.
262 __ testl(EBX, Immediate(kSmiTagMask)); 261 __ testl(EBX, Immediate(kSmiTagMask));
263 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. 262 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index.
264 // Range check. 263 // Range check using _length field.
265 __ cmpl(EBX, FieldAddress(EAX, length_offset)); 264 __ cmpl(EBX, FieldAddress(EAX, length_offset));
266 // Runtime throws exception. 265 // Runtime throws exception.
267 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); 266 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump);
268 __ movl(EAX, FieldAddress(EAX, array_offset)); // backingArray. 267 __ movl(EAX, FieldAddress(EAX, array_offset)); // backingArray.
269 268
270 // Note that EBX is Smi, i.e, times 2. 269 // Note that EBX is Smi, i.e, times 2.
271 ASSERT(kSmiTagShift == 1); 270 ASSERT(kSmiTagShift == 1);
272 __ movl(EAX, FieldAddress(EAX, EBX, TIMES_2, sizeof(RawArray))); 271 __ movl(EAX, FieldAddress(EAX, EBX, TIMES_2, sizeof(RawArray)));
273 __ ret(); 272 __ ret();
274 __ Bind(&fall_through); 273 __ Bind(&fall_through);
275 return false; 274 return false;
276 } 275 }
277 276
278 277
278 // On stack: array (+3), index (+2), value (+1), return-address (+0).
279 static bool GrowableArray_setIndexed(Assembler* assembler) {
280 if (FLAG_enable_type_checks) {
281 return false;
282 }
283 Label fall_through;
284 intptr_t length_offset = GetOffsetForField(kGrowableArrayClassName,
285 kGrowableArrayLengthFieldName);
286 intptr_t array_offset = GetOffsetForField(kGrowableArrayClassName,
287 kGrowableArrayArrayFieldName);
288 __ movl(EBX, Address(ESP, + 2 * kWordSize)); // Index.
289 __ movl(EAX, Address(ESP, + 3 * kWordSize)); // GrowableArray.
290 __ testl(EBX, Immediate(kSmiTagMask));
291 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index.
292 // Range check using _length field.
293 __ cmpl(EBX, FieldAddress(EAX, length_offset));
294 // Runtime throws exception.
295 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump);
296 __ movl(EAX, FieldAddress(EAX, array_offset)); // backingArray.
297 __ movl(EDI, Address(ESP, + 1 * kWordSize)); // Value.
298 // Note that EBX is Smi, i.e, times 2.
299 ASSERT(kSmiTagShift == 1);
300 __ StoreIntoObject(EAX,
301 FieldAddress(EAX, EBX, TIMES_2, sizeof(RawArray)),
302 EDI);
303 __ ret();
304 __ Bind(&fall_through);
305 return false;
306 }
307
308
279 // Tests if two top most arguments are smis, jumps to label not_smi if not. 309 // Tests if two top most arguments are smis, jumps to label not_smi if not.
280 // Topmost argument is in EAX. 310 // Topmost argument is in EAX.
281 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) { 311 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) {
282 __ movl(EAX, Address(ESP, + 1 * kWordSize)); 312 __ movl(EAX, Address(ESP, + 1 * kWordSize));
283 __ movl(EBX, Address(ESP, + 2 * kWordSize)); 313 __ movl(EBX, Address(ESP, + 2 * kWordSize));
284 __ orl(EBX, EAX); 314 __ orl(EBX, EAX);
285 __ testl(EBX, Immediate(kSmiTagMask)); 315 __ testl(EBX, Immediate(kSmiTagMask));
286 __ j(NOT_ZERO, not_smi, Assembler::kNearJump); 316 __ j(NOT_ZERO, not_smi, Assembler::kNearJump);
287 } 317 }
288 318
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 } \ 1042 } \
1013 1043
1014 INTRINSIC_LIST(FIND_INTRINSICS); 1044 INTRINSIC_LIST(FIND_INTRINSICS);
1015 #undef FIND_INTRINSICS 1045 #undef FIND_INTRINSICS
1016 return false; 1046 return false;
1017 } 1047 }
1018 1048
1019 } // namespace dart 1049 } // namespace dart
1020 1050
1021 #endif // defined TARGET_ARCH_IA32 1051 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/opt_code_generator_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698