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

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

Issue 502953002: Implement native _List. constructor in the flow-graph builder. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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/intrinsifier_arm.cc ('k') | runtime/vm/intrinsifier_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) 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" // Needed here to get TARGET_ARCH_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 #include "vm/intrinsifier.h" 8 #include "vm/intrinsifier.h"
9 9
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
11 #include "vm/flow_graph_compiler.h" 11 #include "vm/flow_graph_compiler.h"
12 #include "vm/object.h" 12 #include "vm/object.h"
13 #include "vm/object_store.h" 13 #include "vm/object_store.h"
14 #include "vm/symbols.h" 14 #include "vm/symbols.h"
15 15
16 namespace dart { 16 namespace dart {
17 17
18 DECLARE_FLAG(bool, enable_type_checks); 18 DECLARE_FLAG(bool, enable_type_checks);
19 19
20 20
21 #define __ assembler-> 21 #define __ assembler->
22 22
23 23
24 void Intrinsifier::ObjectArrayAllocate(Assembler* assembler) {
25 Label fall_through;
26 const intptr_t kTypeArgumentsOffset = 1 * kWordSize;
27 const intptr_t kLengthOffset = 0 * kWordSize;
28
29 __ ldr(R1, Address(SP, kTypeArgumentsOffset));
30 __ ldr(R2, Address(SP, kLengthOffset));
31
32 // Compute the size to be allocated, it is based on the array length
33 // and is computed as:
34 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
35 // Assert that length is a Smi.
36 __ tsti(R2, kSmiTagMask);
37 __ b(&fall_through, NE);
38
39 __ cmp(R2, Operand(0));
40 __ b(&fall_through, LT);
41 __ LoadFieldFromOffset(R8, CTX, Context::isolate_offset(), kNoPP);
42 __ LoadFromOffset(R8, R8, Isolate::heap_offset(), kNoPP);
43 __ LoadFromOffset(R8, R8, Heap::new_space_offset(), kNoPP);
44
45 // Calculate and align allocation size.
46 // Load new object start and calculate next object start.
47 // R1: array element type.
48 // R2: array length as Smi.
49 // R8: points to new space object.
50 __ LoadFromOffset(R0, R8, Scavenger::top_offset(), kNoPP);
51 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
52 __ LoadImmediate(R3, fixed_size, kNoPP);
53 __ add(R3, R3, Operand(R2, LSL, 2)); // R2 is Smi.
54 ASSERT(kSmiTagShift == 1);
55 __ andi(R3, R3, ~(kObjectAlignment - 1));
56 __ adds(R7, R3, Operand(R0));
57 __ b(&fall_through, VS);
58
59 // Check if the allocation fits into the remaining space.
60 // R0: potential new object start.
61 // R1: array element type.
62 // R2: array length as Smi.
63 // R3: array size.
64 // R7: potential next object start.
65 // R8: points to new space object.
66 __ LoadFromOffset(TMP, R8, Scavenger::end_offset(), kNoPP);
67 __ CompareRegisters(R7, TMP);
68 __ b(&fall_through, CS); // Branch if unsigned higher or equal.
69
70 // Successfully allocated the object(s), now update top to point to
71 // next object start and initialize the object.
72 // R0: potential new object start.
73 // R3: array size.
74 // R7: potential next object start.
75 // R8: Points to new space object.
76 __ StoreToOffset(R7, R8, Scavenger::top_offset(), kNoPP);
77 __ add(R0, R0, Operand(kHeapObjectTag));
78 __ UpdateAllocationStatsWithSize(kArrayCid, R3, kNoPP);
79
80 // R0: new object start as a tagged pointer.
81 // R1: array element type.
82 // R2: array length as Smi.
83 // R3: array size.
84 // R7: new object end address.
85
86 // Store the type argument field.
87 __ StoreIntoObjectOffsetNoBarrier(
88 R0, Array::type_arguments_offset(), R1, PP);
89
90 // Set the length field.
91 __ StoreIntoObjectOffsetNoBarrier(R0, Array::length_offset(), R2, PP);
92
93 // Calculate the size tag.
94 // R0: new object start as a tagged pointer.
95 // R2: array length as Smi.
96 // R3: array size.
97 // R7: new object end address.
98 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
99 __ CompareImmediate(R3, RawObject::SizeTag::kMaxSizeTag, kNoPP);
100 // If no size tag overflow, shift R1 left, else set R1 to zero.
101 __ Lsl(TMP, R3, shift);
102 __ csel(R1, TMP, R1, LS);
103 __ csel(R1, ZR, R1, HI);
104
105 // Get the class index and insert it into the tags.
106 __ LoadImmediate(TMP, RawObject::ClassIdTag::encode(kArrayCid), kNoPP);
107 __ orr(R1, R1, Operand(TMP));
108 __ StoreFieldToOffset(R1, R0, Array::tags_offset(), kNoPP);
109
110 // Initialize all array elements to raw_null.
111 // R0: new object start as a tagged pointer.
112 // R7: new object end address.
113 // R2: array length as Smi.
114 __ AddImmediate(R1, R0, Array::data_offset() - kHeapObjectTag, kNoPP);
115 // R1: iterator which initially points to the start of the variable
116 // data area to be initialized.
117 __ LoadObject(TMP, Object::null_object(), PP);
118 Label loop, done;
119 __ Bind(&loop);
120 // TODO(cshapiro): StoreIntoObjectNoBarrier
121 __ CompareRegisters(R1, R7);
122 __ b(&done, CS);
123 __ str(TMP, Address(R1)); // Store if unsigned lower.
124 __ AddImmediate(R1, R1, kWordSize, kNoPP);
125 __ b(&loop); // Loop until R1 == R7.
126 __ Bind(&done);
127
128 // Done allocating and initializing the array.
129 // R0: new object.
130 // R2: array length as Smi (preserved for the caller.)
131 __ ret();
132 __ Bind(&fall_through);
133 }
134
135
136 void Intrinsifier::ObjectArrayLength(Assembler* assembler) { 24 void Intrinsifier::ObjectArrayLength(Assembler* assembler) {
137 __ ldr(R0, Address(SP, 0 * kWordSize)); 25 __ ldr(R0, Address(SP, 0 * kWordSize));
138 __ ldr(R0, FieldAddress(R0, Array::length_offset())); 26 __ ldr(R0, FieldAddress(R0, Array::length_offset()));
139 __ ret(); 27 __ ret();
140 } 28 }
141 29
142 30
143 void Intrinsifier::ImmutableArrayLength(Assembler* assembler) { 31 void Intrinsifier::ImmutableArrayLength(Assembler* assembler) {
144 ObjectArrayLength(assembler); 32 ObjectArrayLength(assembler);
145 } 33 }
(...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 Isolate* isolate = Isolate::Current(); 1682 Isolate* isolate = Isolate::Current();
1795 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate), kNoPP); 1683 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate), kNoPP);
1796 // Set return value to Isolate::current_tag_. 1684 // Set return value to Isolate::current_tag_.
1797 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); 1685 __ ldr(R0, Address(R1, Isolate::current_tag_offset()));
1798 __ ret(); 1686 __ ret();
1799 } 1687 }
1800 1688
1801 } // namespace dart 1689 } // namespace dart
1802 1690
1803 #endif // defined TARGET_ARCH_ARM64 1691 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_arm.cc ('k') | runtime/vm/intrinsifier_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698