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

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

Issue 282073006: Inline Array allocation for constant lengths (except ARM64). (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/intermediate_language.h ('k') | runtime/vm/intermediate_language_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) 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 2237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 const intptr_t kNumTemps = 0; 2248 const intptr_t kNumTemps = 0;
2249 LocationSummary* locs = 2249 LocationSummary* locs =
2250 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 2250 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
2251 locs->set_in(kElementTypePos, Location::RegisterLocation(R1)); 2251 locs->set_in(kElementTypePos, Location::RegisterLocation(R1));
2252 locs->set_in(kLengthPos, Location::RegisterLocation(R2)); 2252 locs->set_in(kLengthPos, Location::RegisterLocation(R2));
2253 locs->set_out(0, Location::RegisterLocation(R0)); 2253 locs->set_out(0, Location::RegisterLocation(R0));
2254 return locs; 2254 return locs;
2255 } 2255 }
2256 2256
2257 2257
2258 // Inlines array allocation for known constant values.
2259 static void InlineArrayAllocation(FlowGraphCompiler* compiler,
2260 intptr_t num_elements,
2261 Label* slow_path,
2262 Label* done) {
2263 const Register kLengthReg = R2;
2264 const Register kElemTypeReg = R1;
2265 const intptr_t kArraySize = Array::InstanceSize(num_elements);
2266
2267 Isolate* isolate = Isolate::Current();
2268 Heap* heap = isolate->heap();
2269
2270 __ LoadImmediate(R6, heap->TopAddress());
2271 __ ldr(R0, Address(R6, 0)); // Potential new object start.
2272 __ AddImmediate(R7, R0, kArraySize); // Potential next object start.
2273 __ b(slow_path, VS);
2274
2275 // Check if the allocation fits into the remaining space.
2276 // R0: potential new object start.
2277 // R7: potential next object start.
2278 __ LoadImmediate(R3, heap->EndAddress());
2279 __ ldr(R3, Address(R3, 0));
2280 __ cmp(R7, ShifterOperand(R3));
2281 __ b(slow_path, CS);
2282
2283 // Successfully allocated the object(s), now update top to point to
2284 // next object start and initialize the object.
2285 __ str(R7, Address(R6, 0));
2286 __ add(R0, R0, ShifterOperand(kHeapObjectTag));
2287 __ LoadImmediate(R8, heap->TopAddress());
2288 __ UpdateAllocationStatsWithSize(kArrayCid, R8, R4);
2289
2290
2291 // Initialize the tags.
2292 // R0: new object start as a tagged pointer.
2293 {
2294 uword tags = 0;
2295 tags = RawObject::ClassIdTag::update(kArrayCid, tags);
2296 tags = RawObject::SizeTag::update(kArraySize, tags);
2297 __ LoadImmediate(R8, tags);
2298 __ str(R8, FieldAddress(R0, Array::tags_offset())); // Store tags.
2299 }
2300 // R0: new object start as a tagged pointer.
2301 // R7: new object end address.
2302
2303 // Store the type argument field.
2304 __ StoreIntoObjectNoBarrier(R0,
2305 FieldAddress(R0, Array::type_arguments_offset()),
2306 kElemTypeReg);
2307
2308 // Set the length field.
2309 __ StoreIntoObjectNoBarrier(R0,
2310 FieldAddress(R0, Array::length_offset()),
2311 kLengthReg);
2312
2313 // Initialize all array elements to raw_null.
2314 // R0: new object start as a tagged pointer.
2315 // R7: new object end address.
2316 // R8: iterator which initially points to the start of the variable
2317 // data area to be initialized.
2318 // R3: null
2319 __ LoadImmediate(R3, reinterpret_cast<intptr_t>(Object::null()));
2320 __ AddImmediate(R8, R0, sizeof(RawArray) - kHeapObjectTag);
2321
2322 Label init_loop;
2323 __ Bind(&init_loop);
2324 __ cmp(R8, ShifterOperand(R7));
2325 __ str(R3, Address(R8, 0), CC);
2326 __ AddImmediate(R8, kWordSize, CC);
2327 __ b(&init_loop, CC);
2328 __ b(done);
2329 }
2330
2331
2258 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2332 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2259 // Allocate the array. R2 = length, R1 = element type. 2333 const Register kLengthReg = R2;
2260 ASSERT(locs()->in(kElementTypePos).reg() == R1); 2334 const Register kElemTypeReg = R1;
2261 ASSERT(locs()->in(kLengthPos).reg() == R2); 2335 const Register kResultReg = R0;
2336
2337 ASSERT(locs()->in(kElementTypePos).reg() == kElemTypeReg);
2338 ASSERT(locs()->in(kLengthPos).reg() == kLengthReg);
2339
2340 if (num_elements()->BindsToConstant() &&
2341 num_elements()->BoundConstant().IsSmi()) {
2342 const intptr_t length = Smi::Cast(num_elements()->BoundConstant()).Value();
2343 if ((length >= 0) && (length <= Array::kMaxElements)) {
2344 Label slow_path, done;
2345 InlineArrayAllocation(compiler, length, &slow_path, &done);
2346 __ Bind(&slow_path);
2347 __ PushObject(Object::ZoneHandle()); // Make room for the result.
2348 __ Push(kLengthReg); // length.
2349 __ Push(kElemTypeReg);
2350 compiler->GenerateRuntimeCall(token_pos(),
2351 deopt_id(),
2352 kAllocateArrayRuntimeEntry,
2353 2,
2354 locs());
2355 __ Drop(2);
2356 __ Pop(kResultReg);
2357 __ Bind(&done);
2358 return;
2359 }
2360 }
2361
2262 compiler->GenerateCall(token_pos(), 2362 compiler->GenerateCall(token_pos(),
2263 &StubCode::AllocateArrayLabel(), 2363 &StubCode::AllocateArrayLabel(),
2264 PcDescriptors::kOther, 2364 PcDescriptors::kOther,
2265 locs()); 2365 locs());
2266 ASSERT(locs()->out(0).reg() == R0); 2366 ASSERT(locs()->out(0).reg() == kResultReg);
2267 } 2367 }
2268 2368
2269 2369
2270 class BoxDoubleSlowPath : public SlowPathCode { 2370 class BoxDoubleSlowPath : public SlowPathCode {
2271 public: 2371 public:
2272 explicit BoxDoubleSlowPath(Instruction* instruction) 2372 explicit BoxDoubleSlowPath(Instruction* instruction)
2273 : instruction_(instruction) { } 2373 : instruction_(instruction) { }
2274 2374
2275 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 2375 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
2276 __ Comment("BoxDoubleSlowPath"); 2376 __ Comment("BoxDoubleSlowPath");
(...skipping 3905 matching lines...) Expand 10 before | Expand all | Expand 10 after
6182 compiler->GenerateCall(token_pos(), 6282 compiler->GenerateCall(token_pos(),
6183 &label, 6283 &label,
6184 PcDescriptors::kOther, 6284 PcDescriptors::kOther,
6185 locs()); 6285 locs());
6186 __ Drop(ArgumentCount()); // Discard arguments. 6286 __ Drop(ArgumentCount()); // Discard arguments.
6187 } 6287 }
6188 6288
6189 } // namespace dart 6289 } // namespace dart
6190 6290
6191 #endif // defined TARGET_ARCH_ARM 6291 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698