| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/assembler_macros.h" | 9 #include "vm/assembler_macros.h" |
| 10 #include "vm/code_generator.h" | 10 #include "vm/code_generator.h" |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 // R10: Array length as Smi. | 657 // R10: Array length as Smi. |
| 658 | 658 |
| 659 // Store the type argument field. | 659 // Store the type argument field. |
| 660 __ StoreIntoObject(RAX, | 660 __ StoreIntoObject(RAX, |
| 661 FieldAddress(RAX, Array::type_arguments_offset()), | 661 FieldAddress(RAX, Array::type_arguments_offset()), |
| 662 RBX); | 662 RBX); |
| 663 | 663 |
| 664 // Set the length field. | 664 // Set the length field. |
| 665 __ StoreIntoObject(RAX, FieldAddress(RAX, Array::length_offset()), R10); | 665 __ StoreIntoObject(RAX, FieldAddress(RAX, Array::length_offset()), R10); |
| 666 | 666 |
| 667 // Store class value for array. | |
| 668 __ movq(RBX, FieldAddress(CTX, Context::isolate_offset())); | |
| 669 __ movq(RBX, Address(RBX, Isolate::object_store_offset())); | |
| 670 __ movq(RBX, Address(RBX, ObjectStore::array_class_offset())); | |
| 671 __ StoreIntoObject(RAX, FieldAddress(RAX, Array::class_offset()), RBX); | |
| 672 // Calculate the size tag. | 667 // Calculate the size tag. |
| 673 // RAX: new object start as a tagged pointer. | 668 // RAX: new object start as a tagged pointer. |
| 674 // R12: new object end address. | 669 // R12: new object end address. |
| 675 // R10: Array length as Smi. | 670 // R10: Array length as Smi. |
| 676 { | 671 { |
| 677 Label size_tag_overflow, done; | 672 Label size_tag_overflow, done; |
| 678 __ leaq(RBX, Address(R10, TIMES_4, fixed_size)); // R10 is Smi. | 673 __ leaq(RBX, Address(R10, TIMES_4, fixed_size)); // R10 is Smi. |
| 679 ASSERT(kSmiTagShift == 1); | 674 ASSERT(kSmiTagShift == 1); |
| 680 __ andq(RBX, Immediate(-kObjectAlignment)); | 675 __ andq(RBX, Immediate(-kObjectAlignment)); |
| 681 __ cmpq(RBX, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 676 __ cmpq(RBX, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 | 977 |
| 983 // Successfully allocated the object, now update top to point to | 978 // Successfully allocated the object, now update top to point to |
| 984 // next object start and initialize the object. | 979 // next object start and initialize the object. |
| 985 // RAX: new object. | 980 // RAX: new object. |
| 986 // R13: next object start. | 981 // R13: next object start. |
| 987 // R10: number of context variables. | 982 // R10: number of context variables. |
| 988 __ movq(RDI, Immediate(heap->TopAddress())); | 983 __ movq(RDI, Immediate(heap->TopAddress())); |
| 989 __ movq(Address(RDI, 0), R13); | 984 __ movq(Address(RDI, 0), R13); |
| 990 __ addq(RAX, Immediate(kHeapObjectTag)); | 985 __ addq(RAX, Immediate(kHeapObjectTag)); |
| 991 | 986 |
| 992 // Initialize the class field in the context object. | |
| 993 // RAX: new object. | |
| 994 // R10: number of context variables. | |
| 995 __ LoadObject(R13, context_class); // Load up class field of context. | |
| 996 __ StoreIntoObject(RAX, | |
| 997 FieldAddress(RAX, Context::class_offset()), | |
| 998 R13); | |
| 999 // Calculate the size tag. | 987 // Calculate the size tag. |
| 1000 // RAX: new object. | 988 // RAX: new object. |
| 1001 // R10: number of context variables. | 989 // R10: number of context variables. |
| 1002 { | 990 { |
| 1003 Label size_tag_overflow, done; | 991 Label size_tag_overflow, done; |
| 1004 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); | 992 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); |
| 1005 __ andq(R13, Immediate(-kObjectAlignment)); | 993 __ andq(R13, Immediate(-kObjectAlignment)); |
| 1006 __ cmpq(R13, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 994 __ cmpq(R13, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| 1007 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 995 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
| 1008 __ shlq(R13, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2)); | 996 __ shlq(R13, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2)); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 // Initialize InstantiatedTypeArguments object at RCX. | 1136 // Initialize InstantiatedTypeArguments object at RCX. |
| 1149 __ movq(Address(RCX, | 1137 __ movq(Address(RCX, |
| 1150 InstantiatedTypeArguments::uninstantiated_type_arguments_offset()), | 1138 InstantiatedTypeArguments::uninstantiated_type_arguments_offset()), |
| 1151 RDI); | 1139 RDI); |
| 1152 __ movq(RDX, Address(RSP, kInstantiatorTypeArgumentsOffset)); | 1140 __ movq(RDX, Address(RSP, kInstantiatorTypeArgumentsOffset)); |
| 1153 __ movq(Address(RCX, | 1141 __ movq(Address(RCX, |
| 1154 InstantiatedTypeArguments::instantiator_type_arguments_offset()), | 1142 InstantiatedTypeArguments::instantiator_type_arguments_offset()), |
| 1155 RDX); | 1143 RDX); |
| 1156 const Class& ita_cls = | 1144 const Class& ita_cls = |
| 1157 Class::ZoneHandle(Object::instantiated_type_arguments_class()); | 1145 Class::ZoneHandle(Object::instantiated_type_arguments_class()); |
| 1158 __ LoadObject(RDX, ita_cls); | |
| 1159 __ movq(Address(RCX, Instance::class_offset()), RDX); // Set its class. | |
| 1160 // Set the tags. | 1146 // Set the tags. |
| 1161 uword tags = 0; | 1147 uword tags = 0; |
| 1162 tags = RawObject::SizeTag::update(type_args_size, tags); | 1148 tags = RawObject::SizeTag::update(type_args_size, tags); |
| 1163 tags = RawObject::ClassIdTag::update(ita_cls.id(), tags); | 1149 tags = RawObject::ClassIdTag::update(ita_cls.id(), tags); |
| 1164 __ movq(Address(RCX, Instance::tags_offset()), Immediate(tags)); | 1150 __ movq(Address(RCX, Instance::tags_offset()), Immediate(tags)); |
| 1165 // Set the new InstantiatedTypeArguments object (RCX) as the type | 1151 // Set the new InstantiatedTypeArguments object (RCX) as the type |
| 1166 // arguments (RDI) of the new object (RAX). | 1152 // arguments (RDI) of the new object (RAX). |
| 1167 __ movq(RDI, RCX); | 1153 __ movq(RDI, RCX); |
| 1168 __ addq(RDI, Immediate(kHeapObjectTag)); | 1154 __ addq(RDI, Immediate(kHeapObjectTag)); |
| 1169 // Set RBX to new object end. | 1155 // Set RBX to new object end. |
| 1170 __ movq(RBX, RCX); | 1156 __ movq(RBX, RCX); |
| 1171 __ Bind(&type_arguments_ready); | 1157 __ Bind(&type_arguments_ready); |
| 1172 // RAX: new object. | 1158 // RAX: new object. |
| 1173 // RDI: new object type arguments. | 1159 // RDI: new object type arguments. |
| 1174 } | 1160 } |
| 1175 | 1161 |
| 1176 // Initialize the class field in the object. | |
| 1177 // RAX: new object start. | 1162 // RAX: new object start. |
| 1178 // RBX: next object start. | 1163 // RBX: next object start. |
| 1179 // RDI: new object type arguments (if is_cls_parameterized). | 1164 // RDI: new object type arguments (if is_cls_parameterized). |
| 1180 __ LoadObject(RDX, cls); // Load class of object to be allocated. | 1165 __ LoadObject(RDX, cls); // Load class of object to be allocated. |
| 1181 __ movq(Address(RAX, Instance::class_offset()), RDX); | |
| 1182 // Set the tags. | 1166 // Set the tags. |
| 1183 uword tags = 0; | 1167 uword tags = 0; |
| 1184 tags = RawObject::SizeTag::update(instance_size, tags); | 1168 tags = RawObject::SizeTag::update(instance_size, tags); |
| 1185 ASSERT(cls.id() != kIllegalObjectKind); | 1169 ASSERT(cls.id() != kIllegalObjectKind); |
| 1186 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1170 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 1187 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); | 1171 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); |
| 1188 | 1172 |
| 1189 // Initialize the remaining words of the object. | 1173 // Initialize the remaining words of the object. |
| 1190 const Immediate raw_null = | 1174 const Immediate raw_null = |
| 1191 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1175 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 __ jmp(&slow_case); | 1304 __ jmp(&slow_case); |
| 1321 } else { | 1305 } else { |
| 1322 __ j(ABOVE_EQUAL, &slow_case); | 1306 __ j(ABOVE_EQUAL, &slow_case); |
| 1323 } | 1307 } |
| 1324 | 1308 |
| 1325 // Successfully allocated the object, now update top to point to | 1309 // Successfully allocated the object, now update top to point to |
| 1326 // next object start and initialize the object. | 1310 // next object start and initialize the object. |
| 1327 __ movq(RDI, Immediate(heap->TopAddress())); | 1311 __ movq(RDI, Immediate(heap->TopAddress())); |
| 1328 __ movq(Address(RDI, 0), R13); | 1312 __ movq(Address(RDI, 0), R13); |
| 1329 | 1313 |
| 1330 // Initialize the class field in the object. | |
| 1331 // RAX: new closure object. | 1314 // RAX: new closure object. |
| 1332 // RBX: new context object (only if is_implicit_closure). | 1315 // RBX: new context object (only if is_implicit_closure). |
| 1333 __ LoadObject(R10, cls); // Load signature class of closure. | |
| 1334 __ movq(Address(RAX, Closure::class_offset()), R10); | |
| 1335 // Set the tags. | 1316 // Set the tags. |
| 1336 uword tags = 0; | 1317 uword tags = 0; |
| 1337 tags = RawObject::SizeTag::update(closure_size, tags); | 1318 tags = RawObject::SizeTag::update(closure_size, tags); |
| 1338 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1319 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 1339 __ movq(Address(RAX, Closure::tags_offset()), Immediate(tags)); | 1320 __ movq(Address(RAX, Closure::tags_offset()), Immediate(tags)); |
| 1340 | 1321 |
| 1341 // Initialize the function field in the object. | 1322 // Initialize the function field in the object. |
| 1342 // RAX: new closure object. | 1323 // RAX: new closure object. |
| 1343 // RBX: new context object (only if is_implicit_closure). | 1324 // RBX: new context object (only if is_implicit_closure). |
| 1344 // R13: next object start. | 1325 // R13: next object start. |
| 1345 __ LoadObject(R10, func); // Load function of closure to be allocated. | 1326 __ LoadObject(R10, func); // Load function of closure to be allocated. |
| 1346 __ movq(Address(RAX, Closure::function_offset()), R10); | 1327 __ movq(Address(RAX, Closure::function_offset()), R10); |
| 1347 | 1328 |
| 1348 // Setup the context for this closure. | 1329 // Setup the context for this closure. |
| 1349 if (is_implicit_static_closure) { | 1330 if (is_implicit_static_closure) { |
| 1350 ObjectStore* object_store = Isolate::Current()->object_store(); | 1331 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 1351 ASSERT(object_store != NULL); | 1332 ASSERT(object_store != NULL); |
| 1352 const Context& empty_context = | 1333 const Context& empty_context = |
| 1353 Context::ZoneHandle(object_store->empty_context()); | 1334 Context::ZoneHandle(object_store->empty_context()); |
| 1354 __ LoadObject(R10, empty_context); | 1335 __ LoadObject(R10, empty_context); |
| 1355 __ movq(Address(RAX, Closure::context_offset()), R10); | 1336 __ movq(Address(RAX, Closure::context_offset()), R10); |
| 1356 } else if (is_implicit_instance_closure) { | 1337 } else if (is_implicit_instance_closure) { |
| 1357 // Initialize the new context capturing the receiver. | 1338 // Initialize the new context capturing the receiver. |
| 1358 | 1339 |
| 1359 // Set the class field to the Context class. | |
| 1360 const Class& context_class = Class::ZoneHandle(Object::context_class()); | 1340 const Class& context_class = Class::ZoneHandle(Object::context_class()); |
| 1361 __ LoadObject(R13, context_class); | |
| 1362 __ movq(Address(RBX, Context::class_offset()), R13); | |
| 1363 // Set the tags. | 1341 // Set the tags. |
| 1364 uword tags = 0; | 1342 uword tags = 0; |
| 1365 tags = RawObject::SizeTag::update(context_size, tags); | 1343 tags = RawObject::SizeTag::update(context_size, tags); |
| 1366 tags = RawObject::ClassIdTag::update(context_class.id(), tags); | 1344 tags = RawObject::ClassIdTag::update(context_class.id(), tags); |
| 1367 __ movq(Address(RBX, Context::tags_offset()), Immediate(tags)); | 1345 __ movq(Address(RBX, Context::tags_offset()), Immediate(tags)); |
| 1368 | 1346 |
| 1369 // Set number of variables field to 1 (for captured receiver). | 1347 // Set number of variables field to 1 (for captured receiver). |
| 1370 __ movq(Address(RBX, Context::num_variables_offset()), Immediate(1)); | 1348 __ movq(Address(RBX, Context::num_variables_offset()), Immediate(1)); |
| 1371 | 1349 |
| 1372 // Set isolate field to isolate of current context. | 1350 // Set isolate field to isolate of current context. |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 // TOS + 2: instance. | 1824 // TOS + 2: instance. |
| 1847 // TOS + 3: cache array. | 1825 // TOS + 3: cache array. |
| 1848 // Result in RCX: null -> not found, otherwise result (true or false). | 1826 // Result in RCX: null -> not found, otherwise result (true or false). |
| 1849 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { | 1827 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { |
| 1850 GenerateSubtypeNTestCacheStub(assembler, 3); | 1828 GenerateSubtypeNTestCacheStub(assembler, 3); |
| 1851 } | 1829 } |
| 1852 | 1830 |
| 1853 } // namespace dart | 1831 } // namespace dart |
| 1854 | 1832 |
| 1855 #endif // defined TARGET_ARCH_X64 | 1833 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |