OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 // Input parameters: | 654 // Input parameters: |
655 // LR: return address. | 655 // LR: return address. |
656 // R2: array length as Smi. | 656 // R2: array length as Smi. |
657 // R1: array element type (either NULL or an instantiated type). | 657 // R1: array element type (either NULL or an instantiated type). |
658 // NOTE: R2 cannot be clobbered here as the caller relies on it being saved. | 658 // NOTE: R2 cannot be clobbered here as the caller relies on it being saved. |
659 // The newly allocated object is returned in R0. | 659 // The newly allocated object is returned in R0. |
660 void StubCode::GeneratePatchableAllocateArrayStub(Assembler* assembler, | 660 void StubCode::GeneratePatchableAllocateArrayStub(Assembler* assembler, |
661 uword* entry_patch_offset, uword* patch_code_pc_offset) { | 661 uword* entry_patch_offset, uword* patch_code_pc_offset) { |
662 *entry_patch_offset = assembler->CodeSize(); | 662 *entry_patch_offset = assembler->CodeSize(); |
663 Label slow_case; | 663 Label slow_case; |
| 664 Isolate* isolate = Isolate::Current(); |
| 665 const Class& cls = Class::Handle(isolate->object_store()->array_class()); |
| 666 ASSERT(!cls.IsNull()); |
664 // Compute the size to be allocated, it is based on the array length | 667 // Compute the size to be allocated, it is based on the array length |
665 // and is computed as: | 668 // and is computed as: |
666 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). | 669 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). |
667 // Assert that length is a Smi. | 670 // Assert that length is a Smi. |
668 __ tsti(R2, Immediate(kSmiTagMask)); | 671 __ tsti(R2, Immediate(kSmiTagMask)); |
669 if (FLAG_use_slow_path) { | 672 if (FLAG_use_slow_path || cls.trace_allocation()) { |
670 __ b(&slow_case); | 673 __ b(&slow_case); |
671 } else { | 674 } else { |
672 __ b(&slow_case, NE); | 675 __ b(&slow_case, NE); |
673 } | 676 } |
674 __ cmp(R2, Operand(0)); | 677 __ cmp(R2, Operand(0)); |
675 __ b(&slow_case, LT); | 678 __ b(&slow_case, LT); |
676 | 679 |
677 Isolate* isolate = Isolate::Current(); | |
678 Heap* heap = isolate->heap(); | 680 Heap* heap = isolate->heap(); |
679 const intptr_t cid = kArrayCid; | 681 const intptr_t cid = kArrayCid; |
680 Heap::Space space = heap->SpaceForAllocation(cid); | 682 Heap::Space space = heap->SpaceForAllocation(cid); |
681 const uword top_address = heap->TopAddress(space); | 683 const uword top_address = heap->TopAddress(space); |
682 __ LoadImmediate(R8, top_address, kNoPP); | 684 __ LoadImmediate(R8, top_address, kNoPP); |
683 const uword end_address = heap->EndAddress(space); | 685 const uword end_address = heap->EndAddress(space); |
684 ASSERT(top_address < end_address); | 686 ASSERT(top_address < end_address); |
685 const uword top_offset = 0; | 687 const uword top_offset = 0; |
686 const uword end_offset = end_address - top_address; | 688 const uword end_offset = end_address - top_address; |
687 | 689 |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 // Result: | 2189 // Result: |
2188 // R1: entry point. | 2190 // R1: entry point. |
2189 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2191 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
2190 EmitMegamorphicLookup(assembler, R0, R1, R1); | 2192 EmitMegamorphicLookup(assembler, R0, R1, R1); |
2191 __ ret(); | 2193 __ ret(); |
2192 } | 2194 } |
2193 | 2195 |
2194 } // namespace dart | 2196 } // namespace dart |
2195 | 2197 |
2196 #endif // defined TARGET_ARCH_ARM64 | 2198 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |