Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2195 } | 2195 } |
| 2196 | 2196 |
| 2197 | 2197 |
| 2198 // Inlines array allocation for known constant values. | 2198 // Inlines array allocation for known constant values. |
| 2199 static void InlineArrayAllocation(FlowGraphCompiler* compiler, | 2199 static void InlineArrayAllocation(FlowGraphCompiler* compiler, |
| 2200 intptr_t num_elements, | 2200 intptr_t num_elements, |
| 2201 Label* slow_path, | 2201 Label* slow_path, |
| 2202 Label* done) { | 2202 Label* done) { |
| 2203 const Register kLengthReg = R2; | 2203 const Register kLengthReg = R2; |
| 2204 const Register kElemTypeReg = R1; | 2204 const Register kElemTypeReg = R1; |
| 2205 const intptr_t kArraySize = Array::InstanceSize(num_elements); | 2205 const intptr_t instance_size = Array::InstanceSize(num_elements); |
| 2206 | 2206 |
| 2207 Isolate* isolate = Isolate::Current(); | 2207 __ TryAllocateArray(kArrayCid, instance_size, slow_path, |
| 2208 Heap* heap = isolate->heap(); | 2208 R0, // instance |
| 2209 | 2209 R7, // end address |
| 2210 __ LoadImmediate(R6, heap->TopAddress()); | 2210 R6, |
| 2211 __ ldr(R0, Address(R6, 0)); // Potential new object start. | 2211 R8); |
| 2212 __ AddImmediate(R7, R0, kArraySize); // Potential next object start. | |
| 2213 __ b(slow_path, VS); | |
| 2214 | |
| 2215 // Check if the allocation fits into the remaining space. | |
| 2216 // R0: potential new object start. | |
| 2217 // R7: potential next object start. | |
| 2218 __ LoadImmediate(R3, heap->EndAddress()); | |
| 2219 __ ldr(R3, Address(R3, 0)); | |
| 2220 __ cmp(R7, Operand(R3)); | |
| 2221 __ b(slow_path, CS); | |
| 2222 | |
| 2223 // Successfully allocated the object(s), now update top to point to | |
| 2224 // next object start and initialize the object. | |
| 2225 __ str(R7, Address(R6, 0)); | |
| 2226 __ add(R0, R0, Operand(kHeapObjectTag)); | |
| 2227 __ LoadImmediate(R8, heap->TopAddress()); | |
|
Florian Schneider
2014/08/06 10:52:42
This is fixed in TryAllocateArray (assembler_arm.c
| |
| 2228 __ UpdateAllocationStatsWithSize(kArrayCid, R8, R4); | |
| 2229 | |
| 2230 | |
| 2231 // Initialize the tags. | |
| 2232 // R0: new object start as a tagged pointer. | |
| 2233 { | |
| 2234 uword tags = 0; | |
| 2235 tags = RawObject::ClassIdTag::update(kArrayCid, tags); | |
| 2236 tags = RawObject::SizeTag::update(kArraySize, tags); | |
| 2237 __ LoadImmediate(R8, tags); | |
| 2238 __ str(R8, FieldAddress(R0, Array::tags_offset())); // Store tags. | |
| 2239 } | |
| 2240 // R0: new object start as a tagged pointer. | 2212 // R0: new object start as a tagged pointer. |
| 2241 // R7: new object end address. | 2213 // R7: new object end address. |
| 2242 | 2214 |
| 2243 // Store the type argument field. | 2215 // Store the type argument field. |
| 2244 __ StoreIntoObjectNoBarrier(R0, | 2216 __ StoreIntoObjectNoBarrier(R0, |
| 2245 FieldAddress(R0, Array::type_arguments_offset()), | 2217 FieldAddress(R0, Array::type_arguments_offset()), |
| 2246 kElemTypeReg); | 2218 kElemTypeReg); |
| 2247 | 2219 |
| 2248 // Set the length field. | 2220 // Set the length field. |
| 2249 __ StoreIntoObjectNoBarrier(R0, | 2221 __ StoreIntoObjectNoBarrier(R0, |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2547 deopt_id(), | 2519 deopt_id(), |
| 2548 kInstantiateTypeArgumentsRuntimeEntry, | 2520 kInstantiateTypeArgumentsRuntimeEntry, |
| 2549 2, | 2521 2, |
| 2550 locs()); | 2522 locs()); |
| 2551 __ Drop(2); // Drop instantiator and uninstantiated type arguments. | 2523 __ Drop(2); // Drop instantiator and uninstantiated type arguments. |
| 2552 __ Pop(result_reg); // Pop instantiated type arguments. | 2524 __ Pop(result_reg); // Pop instantiated type arguments. |
| 2553 __ Bind(&type_arguments_instantiated); | 2525 __ Bind(&type_arguments_instantiated); |
| 2554 } | 2526 } |
| 2555 | 2527 |
| 2556 | 2528 |
| 2529 LocationSummary* AllocateUninitializedContextInstr::MakeLocationSummary( | |
| 2530 Isolate* isolate, | |
| 2531 bool opt) const { | |
| 2532 ASSERT(opt); | |
| 2533 const intptr_t kNumInputs = 0; | |
| 2534 const intptr_t kNumTemps = 3; | |
| 2535 LocationSummary* locs = new(isolate) LocationSummary( | |
| 2536 isolate, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath); | |
| 2537 locs->set_temp(0, Location::RegisterLocation(R1)); | |
| 2538 locs->set_temp(1, Location::RegisterLocation(R2)); | |
| 2539 locs->set_temp(2, Location::RegisterLocation(R3)); | |
| 2540 locs->set_out(0, Location::RegisterLocation(R0)); | |
| 2541 return locs; | |
| 2542 } | |
| 2543 | |
| 2544 | |
| 2545 class AllocateContextSlowPath : public SlowPathCode { | |
| 2546 public: | |
| 2547 explicit AllocateContextSlowPath( | |
| 2548 AllocateUninitializedContextInstr* instruction) | |
| 2549 : instruction_(instruction) { } | |
| 2550 | |
| 2551 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | |
| 2552 __ Comment("AllocateContextSlowPath"); | |
| 2553 __ Bind(entry_label()); | |
| 2554 | |
| 2555 LocationSummary* locs = instruction_->locs(); | |
| 2556 locs->live_registers()->Remove(locs->out(0)); | |
| 2557 | |
| 2558 compiler->SaveLiveRegisters(locs); | |
| 2559 | |
| 2560 __ LoadImmediate(R1, instruction_->num_context_variables()); | |
| 2561 StubCode* stub_code = compiler->isolate()->stub_code(); | |
| 2562 const ExternalLabel label(stub_code->AllocateContextEntryPoint()); | |
| 2563 compiler->GenerateCall(instruction_->token_pos(), | |
| 2564 &label, | |
| 2565 RawPcDescriptors::kOther, | |
| 2566 locs); | |
| 2567 ASSERT(instruction_->locs()->out(0).reg() == R0); | |
| 2568 compiler->RestoreLiveRegisters(instruction_->locs()); | |
| 2569 __ b(exit_label()); | |
| 2570 } | |
| 2571 | |
| 2572 private: | |
| 2573 AllocateUninitializedContextInstr* instruction_; | |
| 2574 }; | |
| 2575 | |
| 2576 | |
| 2577 void AllocateUninitializedContextInstr::EmitNativeCode( | |
| 2578 FlowGraphCompiler* compiler) { | |
| 2579 Register temp0 = locs()->temp(0).reg(); | |
| 2580 Register temp1 = locs()->temp(1).reg(); | |
| 2581 Register temp2 = locs()->temp(2).reg(); | |
| 2582 Register result = locs()->out(0).reg(); | |
| 2583 // Try allocate the object. | |
| 2584 AllocateContextSlowPath* slow_path = new AllocateContextSlowPath(this); | |
| 2585 compiler->AddSlowPathCode(slow_path); | |
| 2586 intptr_t instance_size = Context::InstanceSize(num_context_variables()); | |
| 2587 | |
| 2588 __ TryAllocateArray(kContextCid, instance_size, slow_path->entry_label(), | |
| 2589 result, // instance | |
| 2590 temp0, | |
| 2591 temp1, | |
| 2592 temp2); | |
| 2593 | |
| 2594 // Setup up number of context variables field. | |
| 2595 __ LoadImmediate(temp0, num_context_variables()); | |
| 2596 __ str(temp0, FieldAddress(result, Context::num_variables_offset())); | |
| 2597 | |
| 2598 // Setup isolate field. | |
| 2599 __ ldr(temp0, FieldAddress(CTX, Context::isolate_offset())); | |
| 2600 __ str(temp0, FieldAddress(result, Context::isolate_offset())); | |
| 2601 | |
| 2602 __ Bind(slow_path->exit_label()); | |
| 2603 } | |
| 2604 | |
| 2605 | |
| 2557 LocationSummary* AllocateContextInstr::MakeLocationSummary(Isolate* isolate, | 2606 LocationSummary* AllocateContextInstr::MakeLocationSummary(Isolate* isolate, |
| 2558 bool opt) const { | 2607 bool opt) const { |
| 2559 const intptr_t kNumInputs = 0; | 2608 const intptr_t kNumInputs = 0; |
| 2560 const intptr_t kNumTemps = 1; | 2609 const intptr_t kNumTemps = 1; |
| 2561 LocationSummary* locs = new(isolate) LocationSummary( | 2610 LocationSummary* locs = new(isolate) LocationSummary( |
| 2562 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); | 2611 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); |
| 2563 locs->set_temp(0, Location::RegisterLocation(R1)); | 2612 locs->set_temp(0, Location::RegisterLocation(R1)); |
| 2564 locs->set_out(0, Location::RegisterLocation(R0)); | 2613 locs->set_out(0, Location::RegisterLocation(R0)); |
| 2565 return locs; | 2614 return locs; |
| 2566 } | 2615 } |
| (...skipping 4044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6611 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 6660 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
| 6612 #if defined(DEBUG) | 6661 #if defined(DEBUG) |
| 6613 __ LoadImmediate(R4, kInvalidObjectPointer); | 6662 __ LoadImmediate(R4, kInvalidObjectPointer); |
| 6614 __ LoadImmediate(R5, kInvalidObjectPointer); | 6663 __ LoadImmediate(R5, kInvalidObjectPointer); |
| 6615 #endif | 6664 #endif |
| 6616 } | 6665 } |
| 6617 | 6666 |
| 6618 } // namespace dart | 6667 } // namespace dart |
| 6619 | 6668 |
| 6620 #endif // defined TARGET_ARCH_ARM | 6669 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |