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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
9 | 9 |
10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 Label fall_through; | 93 Label fall_through; |
94 | 94 |
95 // Try allocating in new space. | 95 // Try allocating in new space. |
96 const Class& cls = Class::Handle( | 96 const Class& cls = Class::Handle( |
97 Isolate::Current()->object_store()->growable_object_array_class()); | 97 Isolate::Current()->object_store()->growable_object_array_class()); |
98 __ TryAllocate(cls, &fall_through, Assembler::kFarJump, RAX, R13); | 98 __ TryAllocate(cls, &fall_through, Assembler::kFarJump, RAX, R13); |
99 | 99 |
100 // Store backing array object in growable array object. | 100 // Store backing array object in growable array object. |
101 __ movq(RCX, Address(RSP, kArrayOffset)); // data argument. | 101 __ movq(RCX, Address(RSP, kArrayOffset)); // data argument. |
102 // RAX is new, no barrier needed. | 102 // RAX is new, no barrier needed. |
103 __ InitializeFieldNoBarrier( | 103 __ StoreIntoObjectNoBarrier( |
104 RAX, | 104 RAX, |
105 FieldAddress(RAX, GrowableObjectArray::data_offset()), | 105 FieldAddress(RAX, GrowableObjectArray::data_offset()), |
106 RCX); | 106 RCX); |
107 | 107 |
108 // RAX: new growable array object start as a tagged pointer. | 108 // RAX: new growable array object start as a tagged pointer. |
109 // Store the type argument field in the growable array object. | 109 // Store the type argument field in the growable array object. |
110 __ movq(RCX, Address(RSP, kTypeArgumentsOffset)); // type argument. | 110 __ movq(RCX, Address(RSP, kTypeArgumentsOffset)); // type argument. |
111 __ InitializeFieldNoBarrier( | 111 __ StoreIntoObjectNoBarrier( |
112 RAX, | 112 RAX, |
113 FieldAddress(RAX, GrowableObjectArray::type_arguments_offset()), | 113 FieldAddress(RAX, GrowableObjectArray::type_arguments_offset()), |
114 RCX); | 114 RCX); |
115 | 115 |
116 // Set the length field in the growable array object to 0. | 116 // Set the length field in the growable array object to 0. |
117 __ ZeroInitSmiField(FieldAddress(RAX, GrowableObjectArray::length_offset())); | 117 __ ZeroInitSmiField(FieldAddress(RAX, GrowableObjectArray::length_offset())); |
118 __ ret(); // returns the newly allocated object in RAX. | 118 __ ret(); // returns the newly allocated object in RAX. |
119 | 119 |
120 __ Bind(&fall_through); | 120 __ Bind(&fall_through); |
121 } | 121 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 __ Bind(&done); \ | 215 __ Bind(&done); \ |
216 \ | 216 \ |
217 /* Get the class index and insert it into the tags. */ \ | 217 /* Get the class index and insert it into the tags. */ \ |
218 __ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cid))); \ | 218 __ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cid))); \ |
219 __ movq(FieldAddress(RAX, type_name::tags_offset()), RDI); /* Tags. */ \ | 219 __ movq(FieldAddress(RAX, type_name::tags_offset()), RDI); /* Tags. */ \ |
220 } \ | 220 } \ |
221 /* Set the length field. */ \ | 221 /* Set the length field. */ \ |
222 /* RAX: new object start as a tagged pointer. */ \ | 222 /* RAX: new object start as a tagged pointer. */ \ |
223 /* RCX: new object end address. */ \ | 223 /* RCX: new object end address. */ \ |
224 __ movq(RDI, Address(RSP, kArrayLengthStackOffset)); /* Array length. */ \ | 224 __ movq(RDI, Address(RSP, kArrayLengthStackOffset)); /* Array length. */ \ |
225 __ InitializeFieldNoBarrier(RAX, \ | 225 __ StoreIntoObjectNoBarrier(RAX, \ |
226 FieldAddress(RAX, type_name::length_offset()), \ | 226 FieldAddress(RAX, type_name::length_offset()), \ |
227 RDI); \ | 227 RDI); \ |
228 /* Initialize all array elements to 0. */ \ | 228 /* Initialize all array elements to 0. */ \ |
229 /* RAX: new object start as a tagged pointer. */ \ | 229 /* RAX: new object start as a tagged pointer. */ \ |
230 /* RCX: new object end address. */ \ | 230 /* RCX: new object end address. */ \ |
231 /* RDI: iterator which initially points to the start of the variable */ \ | 231 /* RDI: iterator which initially points to the start of the variable */ \ |
232 /* RBX: scratch register. */ \ | 232 /* RBX: scratch register. */ \ |
233 /* data area to be initialized. */ \ | 233 /* data area to be initialized. */ \ |
234 __ xorq(RBX, RBX); /* Zero. */ \ | 234 __ xorq(RBX, RBX); /* Zero. */ \ |
235 __ leaq(RDI, FieldAddress(RAX, sizeof(Raw##type_name))); \ | 235 __ leaq(RDI, FieldAddress(RAX, sizeof(Raw##type_name))); \ |
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1875 __ xorq(RDI, RDI); | 1875 __ xorq(RDI, RDI); |
1876 __ Bind(&done); | 1876 __ Bind(&done); |
1877 | 1877 |
1878 // Get the class index and insert it into the tags. | 1878 // Get the class index and insert it into the tags. |
1879 __ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cid))); | 1879 __ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cid))); |
1880 __ movq(FieldAddress(RAX, String::tags_offset()), RDI); // Tags. | 1880 __ movq(FieldAddress(RAX, String::tags_offset()), RDI); // Tags. |
1881 } | 1881 } |
1882 | 1882 |
1883 // Set the length field. | 1883 // Set the length field. |
1884 __ popq(RDI); | 1884 __ popq(RDI); |
1885 __ InitializeFieldNoBarrier(RAX, | 1885 __ StoreIntoObjectNoBarrier(RAX, |
1886 FieldAddress(RAX, String::length_offset()), | 1886 FieldAddress(RAX, String::length_offset()), |
1887 RDI); | 1887 RDI); |
1888 // Clear hash. | 1888 // Clear hash. |
1889 __ ZeroInitSmiField(FieldAddress(RAX, String::hash_offset())); | 1889 __ ZeroInitSmiField(FieldAddress(RAX, String::hash_offset())); |
1890 __ jmp(ok, Assembler::kNearJump); | 1890 __ jmp(ok, Assembler::kNearJump); |
1891 | 1891 |
1892 __ Bind(&pop_and_fail); | 1892 __ Bind(&pop_and_fail); |
1893 __ popq(RDI); | 1893 __ popq(RDI); |
1894 __ jmp(failure); | 1894 __ jmp(failure); |
1895 } | 1895 } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2119 __ Bind(&true_label); | 2119 __ Bind(&true_label); |
2120 __ LoadObject(RAX, Bool::True()); | 2120 __ LoadObject(RAX, Bool::True()); |
2121 __ ret(); | 2121 __ ret(); |
2122 } | 2122 } |
2123 | 2123 |
2124 #undef __ | 2124 #undef __ |
2125 | 2125 |
2126 } // namespace dart | 2126 } // namespace dart |
2127 | 2127 |
2128 #endif // defined TARGET_ARCH_X64 | 2128 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |