| 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/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 __ cmpq(RCX, RBX); | 1139 __ cmpq(RCX, RBX); |
| 1140 __ j(EQUAL, &type_arguments_ready, Assembler::kNearJump); | 1140 __ j(EQUAL, &type_arguments_ready, Assembler::kNearJump); |
| 1141 // Initialize InstantiatedTypeArguments object at RCX. | 1141 // Initialize InstantiatedTypeArguments object at RCX. |
| 1142 __ movq(Address(RCX, | 1142 __ movq(Address(RCX, |
| 1143 InstantiatedTypeArguments::uninstantiated_type_arguments_offset()), | 1143 InstantiatedTypeArguments::uninstantiated_type_arguments_offset()), |
| 1144 RDI); | 1144 RDI); |
| 1145 __ movq(RDX, Address(RSP, kInstantiatorTypeArgumentsOffset)); | 1145 __ movq(RDX, Address(RSP, kInstantiatorTypeArgumentsOffset)); |
| 1146 __ movq(Address(RCX, | 1146 __ movq(Address(RCX, |
| 1147 InstantiatedTypeArguments::instantiator_type_arguments_offset()), | 1147 InstantiatedTypeArguments::instantiator_type_arguments_offset()), |
| 1148 RDX); | 1148 RDX); |
| 1149 __ LoadObject(RDX, | 1149 const Class& ita_cls = |
| 1150 Class::ZoneHandle(Object::instantiated_type_arguments_class())); | 1150 Class::ZoneHandle(Object::instantiated_type_arguments_class()); |
| 1151 __ LoadObject(RDX, ita_cls); |
| 1151 __ movq(Address(RCX, Instance::class_offset()), RDX); // Set its class. | 1152 __ movq(Address(RCX, Instance::class_offset()), RDX); // Set its class. |
| 1152 // Set the tags. | 1153 // Set the tags. |
| 1153 __ movq(Address(RCX, Instance::tags_offset()), | 1154 uword tags = 0; |
| 1154 Immediate(RawObject::SizeTag::encode(type_args_size))); | 1155 tags = RawObject::SizeTag::update(type_args_size, tags); |
| 1156 tags = RawObject::ClassTag::update(ita_cls.index(), tags); |
| 1157 __ movq(Address(RCX, Instance::tags_offset()), Immediate(tags)); |
| 1155 // Set the new InstantiatedTypeArguments object (RCX) as the type | 1158 // Set the new InstantiatedTypeArguments object (RCX) as the type |
| 1156 // arguments (RDI) of the new object (RAX). | 1159 // arguments (RDI) of the new object (RAX). |
| 1157 __ movq(RDI, RCX); | 1160 __ movq(RDI, RCX); |
| 1158 __ addq(RDI, Immediate(kHeapObjectTag)); | 1161 __ addq(RDI, Immediate(kHeapObjectTag)); |
| 1159 // Set RBX to new object end. | 1162 // Set RBX to new object end. |
| 1160 __ movq(RBX, RCX); | 1163 __ movq(RBX, RCX); |
| 1161 __ Bind(&type_arguments_ready); | 1164 __ Bind(&type_arguments_ready); |
| 1162 // RAX: new object. | 1165 // RAX: new object. |
| 1163 // RDI: new object type arguments. | 1166 // RDI: new object type arguments. |
| 1164 } | 1167 } |
| 1165 | 1168 |
| 1166 // Initialize the class field in the object. | 1169 // Initialize the class field in the object. |
| 1167 // RAX: new object start. | 1170 // RAX: new object start. |
| 1168 // RBX: next object start. | 1171 // RBX: next object start. |
| 1169 // RDI: new object type arguments (if is_cls_parameterized). | 1172 // RDI: new object type arguments (if is_cls_parameterized). |
| 1170 __ LoadObject(RDX, cls); // Load class of object to be allocated. | 1173 __ LoadObject(RDX, cls); // Load class of object to be allocated. |
| 1171 __ movq(Address(RAX, Instance::class_offset()), RDX); | 1174 __ movq(Address(RAX, Instance::class_offset()), RDX); |
| 1172 // Set the tags. | 1175 // Set the tags. |
| 1173 intptr_t tags = 0; | 1176 uword tags = 0; |
| 1174 tags = RawObject::SizeTag::update(instance_size, tags); | 1177 tags = RawObject::SizeTag::update(instance_size, tags); |
| 1175 ASSERT(cls.index() != kIllegalObjectKind); | 1178 ASSERT(cls.index() != kIllegalObjectKind); |
| 1176 tags = RawObject::ClassTag::update(cls.index(), tags); | 1179 tags = RawObject::ClassTag::update(cls.index(), tags); |
| 1177 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); | 1180 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); |
| 1178 | 1181 |
| 1179 // Initialize the remaining words of the object. | 1182 // Initialize the remaining words of the object. |
| 1180 const Immediate raw_null = | 1183 const Immediate raw_null = |
| 1181 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1184 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1182 | 1185 |
| 1183 // RAX: new object start. | 1186 // RAX: new object start. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 // next object start and initialize the object. | 1321 // next object start and initialize the object. |
| 1319 __ movq(RDI, Immediate(heap->TopAddress())); | 1322 __ movq(RDI, Immediate(heap->TopAddress())); |
| 1320 __ movq(Address(RDI, 0), R13); | 1323 __ movq(Address(RDI, 0), R13); |
| 1321 | 1324 |
| 1322 // Initialize the class field in the object. | 1325 // Initialize the class field in the object. |
| 1323 // RAX: new closure object. | 1326 // RAX: new closure object. |
| 1324 // RBX: new context object (only if is_implicit_closure). | 1327 // RBX: new context object (only if is_implicit_closure). |
| 1325 __ LoadObject(R10, cls); // Load signature class of closure. | 1328 __ LoadObject(R10, cls); // Load signature class of closure. |
| 1326 __ movq(Address(RAX, Closure::class_offset()), R10); | 1329 __ movq(Address(RAX, Closure::class_offset()), R10); |
| 1327 // Set the tags. | 1330 // Set the tags. |
| 1328 intptr_t tags = 0; | 1331 uword tags = 0; |
| 1329 tags = RawObject::SizeTag::update(closure_size, tags); | 1332 tags = RawObject::SizeTag::update(closure_size, tags); |
| 1330 tags = RawObject::ClassTag::update(cls.index(), tags); | 1333 tags = RawObject::ClassTag::update(cls.index(), tags); |
| 1331 __ movq(Address(RAX, Closure::tags_offset()), Immediate(tags)); | 1334 __ movq(Address(RAX, Closure::tags_offset()), Immediate(tags)); |
| 1332 | 1335 |
| 1333 // Initialize the function field in the object. | 1336 // Initialize the function field in the object. |
| 1334 // RAX: new closure object. | 1337 // RAX: new closure object. |
| 1335 // RBX: new context object (only if is_implicit_closure). | 1338 // RBX: new context object (only if is_implicit_closure). |
| 1336 // R13: next object start. | 1339 // R13: next object start. |
| 1337 __ LoadObject(R10, func); // Load function of closure to be allocated. | 1340 __ LoadObject(R10, func); // Load function of closure to be allocated. |
| 1338 __ movq(Address(RAX, Closure::function_offset()), R10); | 1341 __ movq(Address(RAX, Closure::function_offset()), R10); |
| 1339 | 1342 |
| 1340 // Setup the context for this closure. | 1343 // Setup the context for this closure. |
| 1341 if (is_implicit_static_closure) { | 1344 if (is_implicit_static_closure) { |
| 1342 ObjectStore* object_store = Isolate::Current()->object_store(); | 1345 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 1343 ASSERT(object_store != NULL); | 1346 ASSERT(object_store != NULL); |
| 1344 const Context& empty_context = | 1347 const Context& empty_context = |
| 1345 Context::ZoneHandle(object_store->empty_context()); | 1348 Context::ZoneHandle(object_store->empty_context()); |
| 1346 __ LoadObject(R10, empty_context); | 1349 __ LoadObject(R10, empty_context); |
| 1347 __ movq(Address(RAX, Closure::context_offset()), R10); | 1350 __ movq(Address(RAX, Closure::context_offset()), R10); |
| 1348 } else if (is_implicit_instance_closure) { | 1351 } else if (is_implicit_instance_closure) { |
| 1349 // Initialize the new context capturing the receiver. | 1352 // Initialize the new context capturing the receiver. |
| 1350 | 1353 |
| 1351 // Set the class field to the Context class. | 1354 // Set the class field to the Context class. |
| 1352 const Class& context_class = Class::ZoneHandle(Object::context_class()); | 1355 const Class& context_class = Class::ZoneHandle(Object::context_class()); |
| 1353 __ LoadObject(R13, context_class); | 1356 __ LoadObject(R13, context_class); |
| 1354 __ movq(Address(RBX, Context::class_offset()), R13); | 1357 __ movq(Address(RBX, Context::class_offset()), R13); |
| 1355 // Set the tags. | 1358 // Set the tags. |
| 1356 intptr_t tags = 0; | 1359 uword tags = 0; |
| 1357 tags = RawObject::SizeTag::update(context_size, tags); | 1360 tags = RawObject::SizeTag::update(context_size, tags); |
| 1358 tags = RawObject::ClassTag::update(context_class.index(), tags); | 1361 tags = RawObject::ClassTag::update(context_class.index(), tags); |
| 1359 __ movq(Address(RBX, Context::tags_offset()), Immediate(tags)); | 1362 __ movq(Address(RBX, Context::tags_offset()), Immediate(tags)); |
| 1360 | 1363 |
| 1361 // Set number of variables field to 1 (for captured receiver). | 1364 // Set number of variables field to 1 (for captured receiver). |
| 1362 __ movq(Address(RBX, Context::num_variables_offset()), Immediate(1)); | 1365 __ movq(Address(RBX, Context::num_variables_offset()), Immediate(1)); |
| 1363 | 1366 |
| 1364 // Set isolate field to isolate of current context. | 1367 // Set isolate field to isolate of current context. |
| 1365 __ movq(R10, FieldAddress(CTX, Context::isolate_offset())); | 1368 __ movq(R10, FieldAddress(CTX, Context::isolate_offset())); |
| 1366 __ movq(Address(RBX, Context::isolate_offset()), R10); | 1369 __ movq(Address(RBX, Context::isolate_offset()), R10); |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 } | 1804 } |
| 1802 | 1805 |
| 1803 | 1806 |
| 1804 void StubCode::GenerateSubtypeTestCacheStub(Assembler* assembler) { | 1807 void StubCode::GenerateSubtypeTestCacheStub(Assembler* assembler) { |
| 1805 __ Unimplemented("SubtypeTestCache Stub"); | 1808 __ Unimplemented("SubtypeTestCache Stub"); |
| 1806 } | 1809 } |
| 1807 | 1810 |
| 1808 } // namespace dart | 1811 } // namespace dart |
| 1809 | 1812 |
| 1810 #endif // defined TARGET_ARCH_X64 | 1813 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |