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

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

Issue 627103005: Unrolls array initialization loop for small arrays. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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/intermediate_language_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/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 locs->set_out(0, Location::RegisterLocation(R0)); 2211 locs->set_out(0, Location::RegisterLocation(R0));
2212 return locs; 2212 return locs;
2213 } 2213 }
2214 2214
2215 2215
2216 // Inlines array allocation for known constant values. 2216 // Inlines array allocation for known constant values.
2217 static void InlineArrayAllocation(FlowGraphCompiler* compiler, 2217 static void InlineArrayAllocation(FlowGraphCompiler* compiler,
2218 intptr_t num_elements, 2218 intptr_t num_elements,
2219 Label* slow_path, 2219 Label* slow_path,
2220 Label* done) { 2220 Label* done) {
2221 const int kInlineArraySize = 12; // Same as kInlineInstanceSize.
2221 const Register kLengthReg = R2; 2222 const Register kLengthReg = R2;
2222 const Register kElemTypeReg = R1; 2223 const Register kElemTypeReg = R1;
2223 const intptr_t instance_size = Array::InstanceSize(num_elements); 2224 const intptr_t instance_size = Array::InstanceSize(num_elements);
2224 2225
2225 __ TryAllocateArray(kArrayCid, instance_size, slow_path, 2226 __ TryAllocateArray(kArrayCid, instance_size, slow_path,
2226 R0, // instance 2227 R0, // instance
2227 R7, // end address 2228 R3, // end address
2228 R6, 2229 R6,
2229 R8); 2230 R8);
2230 // R0: new object start as a tagged pointer. 2231 // R0: new object start as a tagged pointer.
2231 // R7: new object end address. 2232 // R3: new object end address.
2232 2233
2233 // Store the type argument field. 2234 // Store the type argument field.
2234 __ StoreIntoObjectNoBarrier(R0, 2235 __ StoreIntoObjectNoBarrier(R0,
2235 FieldAddress(R0, Array::type_arguments_offset()), 2236 FieldAddress(R0, Array::type_arguments_offset()),
2236 kElemTypeReg); 2237 kElemTypeReg);
2237 2238
2238 // Set the length field. 2239 // Set the length field.
2239 __ StoreIntoObjectNoBarrier(R0, 2240 __ StoreIntoObjectNoBarrier(R0,
2240 FieldAddress(R0, Array::length_offset()), 2241 FieldAddress(R0, Array::length_offset()),
2241 kLengthReg); 2242 kLengthReg);
2242 2243
2243 // Initialize all array elements to raw_null. 2244 // Initialize all array elements to raw_null.
2244 // R0: new object start as a tagged pointer. 2245 // R0: new object start as a tagged pointer.
2245 // R7: new object end address. 2246 // R3: new object end address.
2246 // R8: iterator which initially points to the start of the variable 2247 // R8: iterator which initially points to the start of the variable
2247 // data area to be initialized. 2248 // data area to be initialized.
2248 // R3: null 2249 // R6, R7: null
2249 if (num_elements > 0) { 2250 if (num_elements > 0) {
2250 __ LoadImmediate(R3, reinterpret_cast<intptr_t>(Object::null())); 2251 const intptr_t array_size = instance_size - sizeof(RawArray);
2252 __ LoadImmediate(R6, reinterpret_cast<intptr_t>(Object::null()));
2253 __ mov(R7, Operand(R6));
2251 __ AddImmediate(R8, R0, sizeof(RawArray) - kHeapObjectTag); 2254 __ AddImmediate(R8, R0, sizeof(RawArray) - kHeapObjectTag);
2252 2255 if (array_size < (kInlineArraySize * kWordSize)) {
2253 Label init_loop; 2256 intptr_t current_offset = 0;
2254 __ Bind(&init_loop); 2257 while (current_offset + kWordSize < array_size) {
2255 __ cmp(R8, Operand(R7)); 2258 __ strd(R6, Address(R8, current_offset));
2256 __ str(R3, Address(R8, 0), CC); 2259 current_offset += 2*kWordSize;
2257 __ AddImmediate(R8, kWordSize, CC); 2260 }
2258 __ b(&init_loop, CC); 2261 while (current_offset < array_size) {
2262 __ str(R6, Address(R8, current_offset));
2263 current_offset += kWordSize;
2264 }
2265 } else {
2266 Label init_loop;
2267 __ Bind(&init_loop);
2268 __ AddImmediate(R8, 2 * kWordSize);
2269 __ cmp(R8, Operand(R3));
2270 __ strd(R6, Address(R8, -2 * kWordSize), LS);
2271 __ b(&init_loop, CC);
2272 __ str(R6, Address(R8, -2 * kWordSize), HI);
2273 }
2259 } 2274 }
2260 __ b(done); 2275 __ b(done);
2261 } 2276 }
2262 2277
2263 2278
2264 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2279 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2265 const Register kLengthReg = R2; 2280 const Register kLengthReg = R2;
2266 const Register kElemTypeReg = R1; 2281 const Register kElemTypeReg = R1;
2267 const Register kResultReg = R0; 2282 const Register kResultReg = R0;
2268 2283
(...skipping 4736 matching lines...) Expand 10 before | Expand all | Expand 10 after
7005 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 7020 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
7006 #if defined(DEBUG) 7021 #if defined(DEBUG)
7007 __ LoadImmediate(R4, kInvalidObjectPointer); 7022 __ LoadImmediate(R4, kInvalidObjectPointer);
7008 __ LoadImmediate(R5, kInvalidObjectPointer); 7023 __ LoadImmediate(R5, kInvalidObjectPointer);
7009 #endif 7024 #endif
7010 } 7025 }
7011 7026
7012 } // namespace dart 7027 } // namespace dart
7013 7028
7014 #endif // defined TARGET_ARCH_ARM 7029 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/intermediate_language_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698