| 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 __ cmpq(RBX, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 681 __ cmpq(RBX, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| 682 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 682 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
| 683 __ shlq(RBX, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2)); | 683 __ shlq(RBX, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2)); |
| 684 __ jmp(&done); | 684 __ jmp(&done); |
| 685 | 685 |
| 686 __ Bind(&size_tag_overflow); | 686 __ Bind(&size_tag_overflow); |
| 687 __ movq(RBX, Immediate(0)); | 687 __ movq(RBX, Immediate(0)); |
| 688 __ Bind(&done); | 688 __ Bind(&done); |
| 689 | 689 |
| 690 // Get the class index and insert it into the tags. | 690 // Get the class index and insert it into the tags. |
| 691 __ orq(RBX, Immediate(RawObject::ClassTag::encode(kArray))); | 691 __ orq(RBX, Immediate(RawObject::ClassIdTag::encode(kArray))); |
| 692 __ movq(FieldAddress(RAX, Array::tags_offset()), RBX); | 692 __ movq(FieldAddress(RAX, Array::tags_offset()), RBX); |
| 693 } | 693 } |
| 694 | 694 |
| 695 // Initialize all array elements to raw_null. | 695 // Initialize all array elements to raw_null. |
| 696 // RAX: new object start as a tagged pointer. | 696 // RAX: new object start as a tagged pointer. |
| 697 // R12: new object end address. | 697 // R12: new object end address. |
| 698 __ leaq(RBX, FieldAddress(RAX, Array::data_offset())); | 698 __ leaq(RBX, FieldAddress(RAX, Array::data_offset())); |
| 699 // RBX: iterator which initially points to the start of the variable | 699 // RBX: iterator which initially points to the start of the variable |
| 700 // data area to be initialized. | 700 // data area to be initialized. |
| 701 Label done; | 701 Label done; |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 | 1010 |
| 1011 __ Bind(&size_tag_overflow); | 1011 __ Bind(&size_tag_overflow); |
| 1012 // Set overflow size tag value. | 1012 // Set overflow size tag value. |
| 1013 __ movq(R13, Immediate(0)); | 1013 __ movq(R13, Immediate(0)); |
| 1014 | 1014 |
| 1015 __ Bind(&done); | 1015 __ Bind(&done); |
| 1016 // RAX: new object. | 1016 // RAX: new object. |
| 1017 // R10: number of context variables. | 1017 // R10: number of context variables. |
| 1018 // R13: size and bit tags. | 1018 // R13: size and bit tags. |
| 1019 __ orq(R13, | 1019 __ orq(R13, |
| 1020 Immediate(RawObject::ClassTag::encode(context_class.index()))); | 1020 Immediate(RawObject::ClassIdTag::encode(context_class.id()))); |
| 1021 __ movq(FieldAddress(RAX, Context::tags_offset()), R13); // Tags. | 1021 __ movq(FieldAddress(RAX, Context::tags_offset()), R13); // Tags. |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 // Setup up number of context variables field. | 1024 // Setup up number of context variables field. |
| 1025 // RAX: new object. | 1025 // RAX: new object. |
| 1026 // R10: number of context variables as integer value (not object). | 1026 // R10: number of context variables as integer value (not object). |
| 1027 __ movq(FieldAddress(RAX, Context::num_variables_offset()), R10); | 1027 __ movq(FieldAddress(RAX, Context::num_variables_offset()), R10); |
| 1028 | 1028 |
| 1029 // Setup isolate field. | 1029 // Setup isolate field. |
| 1030 // Load Isolate pointer from Context structure into R13. | 1030 // Load Isolate pointer from Context structure into R13. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 __ movq(Address(RCX, | 1153 __ movq(Address(RCX, |
| 1154 InstantiatedTypeArguments::instantiator_type_arguments_offset()), | 1154 InstantiatedTypeArguments::instantiator_type_arguments_offset()), |
| 1155 RDX); | 1155 RDX); |
| 1156 const Class& ita_cls = | 1156 const Class& ita_cls = |
| 1157 Class::ZoneHandle(Object::instantiated_type_arguments_class()); | 1157 Class::ZoneHandle(Object::instantiated_type_arguments_class()); |
| 1158 __ LoadObject(RDX, ita_cls); | 1158 __ LoadObject(RDX, ita_cls); |
| 1159 __ movq(Address(RCX, Instance::class_offset()), RDX); // Set its class. | 1159 __ movq(Address(RCX, Instance::class_offset()), RDX); // Set its class. |
| 1160 // Set the tags. | 1160 // Set the tags. |
| 1161 uword tags = 0; | 1161 uword tags = 0; |
| 1162 tags = RawObject::SizeTag::update(type_args_size, tags); | 1162 tags = RawObject::SizeTag::update(type_args_size, tags); |
| 1163 tags = RawObject::ClassTag::update(ita_cls.index(), tags); | 1163 tags = RawObject::ClassIdTag::update(ita_cls.id(), tags); |
| 1164 __ movq(Address(RCX, Instance::tags_offset()), Immediate(tags)); | 1164 __ movq(Address(RCX, Instance::tags_offset()), Immediate(tags)); |
| 1165 // Set the new InstantiatedTypeArguments object (RCX) as the type | 1165 // Set the new InstantiatedTypeArguments object (RCX) as the type |
| 1166 // arguments (RDI) of the new object (RAX). | 1166 // arguments (RDI) of the new object (RAX). |
| 1167 __ movq(RDI, RCX); | 1167 __ movq(RDI, RCX); |
| 1168 __ addq(RDI, Immediate(kHeapObjectTag)); | 1168 __ addq(RDI, Immediate(kHeapObjectTag)); |
| 1169 // Set RBX to new object end. | 1169 // Set RBX to new object end. |
| 1170 __ movq(RBX, RCX); | 1170 __ movq(RBX, RCX); |
| 1171 __ Bind(&type_arguments_ready); | 1171 __ Bind(&type_arguments_ready); |
| 1172 // RAX: new object. | 1172 // RAX: new object. |
| 1173 // RDI: new object type arguments. | 1173 // RDI: new object type arguments. |
| 1174 } | 1174 } |
| 1175 | 1175 |
| 1176 // Initialize the class field in the object. | 1176 // Initialize the class field in the object. |
| 1177 // RAX: new object start. | 1177 // RAX: new object start. |
| 1178 // RBX: next object start. | 1178 // RBX: next object start. |
| 1179 // RDI: new object type arguments (if is_cls_parameterized). | 1179 // RDI: new object type arguments (if is_cls_parameterized). |
| 1180 __ LoadObject(RDX, cls); // Load class of object to be allocated. | 1180 __ LoadObject(RDX, cls); // Load class of object to be allocated. |
| 1181 __ movq(Address(RAX, Instance::class_offset()), RDX); | 1181 __ movq(Address(RAX, Instance::class_offset()), RDX); |
| 1182 // Set the tags. | 1182 // Set the tags. |
| 1183 uword tags = 0; | 1183 uword tags = 0; |
| 1184 tags = RawObject::SizeTag::update(instance_size, tags); | 1184 tags = RawObject::SizeTag::update(instance_size, tags); |
| 1185 ASSERT(cls.index() != kIllegalObjectKind); | 1185 ASSERT(cls.id() != kIllegalObjectKind); |
| 1186 tags = RawObject::ClassTag::update(cls.index(), tags); | 1186 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 1187 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); | 1187 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); |
| 1188 | 1188 |
| 1189 // Initialize the remaining words of the object. | 1189 // Initialize the remaining words of the object. |
| 1190 const Immediate raw_null = | 1190 const Immediate raw_null = |
| 1191 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1191 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1192 | 1192 |
| 1193 // RAX: new object start. | 1193 // RAX: new object start. |
| 1194 // RBX: next object start. | 1194 // RBX: next object start. |
| 1195 // RDX: class of the object to be allocated. | 1195 // RDX: class of the object to be allocated. |
| 1196 // First try inlining the initialization without a loop. | 1196 // First try inlining the initialization without a loop. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 __ movq(Address(RDI, 0), R13); | 1330 __ movq(Address(RDI, 0), R13); |
| 1331 | 1331 |
| 1332 // Initialize the class field in the object. | 1332 // Initialize the class field in the object. |
| 1333 // RAX: new closure object. | 1333 // RAX: new closure object. |
| 1334 // RBX: new context object (only if is_implicit_closure). | 1334 // RBX: new context object (only if is_implicit_closure). |
| 1335 __ LoadObject(R10, cls); // Load signature class of closure. | 1335 __ LoadObject(R10, cls); // Load signature class of closure. |
| 1336 __ movq(Address(RAX, Closure::class_offset()), R10); | 1336 __ movq(Address(RAX, Closure::class_offset()), R10); |
| 1337 // Set the tags. | 1337 // Set the tags. |
| 1338 uword tags = 0; | 1338 uword tags = 0; |
| 1339 tags = RawObject::SizeTag::update(closure_size, tags); | 1339 tags = RawObject::SizeTag::update(closure_size, tags); |
| 1340 tags = RawObject::ClassTag::update(cls.index(), tags); | 1340 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 1341 __ movq(Address(RAX, Closure::tags_offset()), Immediate(tags)); | 1341 __ movq(Address(RAX, Closure::tags_offset()), Immediate(tags)); |
| 1342 | 1342 |
| 1343 // Initialize the function field in the object. | 1343 // Initialize the function field in the object. |
| 1344 // RAX: new closure object. | 1344 // RAX: new closure object. |
| 1345 // RBX: new context object (only if is_implicit_closure). | 1345 // RBX: new context object (only if is_implicit_closure). |
| 1346 // R13: next object start. | 1346 // R13: next object start. |
| 1347 __ LoadObject(R10, func); // Load function of closure to be allocated. | 1347 __ LoadObject(R10, func); // Load function of closure to be allocated. |
| 1348 __ movq(Address(RAX, Closure::function_offset()), R10); | 1348 __ movq(Address(RAX, Closure::function_offset()), R10); |
| 1349 | 1349 |
| 1350 // Setup the context for this closure. | 1350 // Setup the context for this closure. |
| 1351 if (is_implicit_static_closure) { | 1351 if (is_implicit_static_closure) { |
| 1352 ObjectStore* object_store = Isolate::Current()->object_store(); | 1352 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 1353 ASSERT(object_store != NULL); | 1353 ASSERT(object_store != NULL); |
| 1354 const Context& empty_context = | 1354 const Context& empty_context = |
| 1355 Context::ZoneHandle(object_store->empty_context()); | 1355 Context::ZoneHandle(object_store->empty_context()); |
| 1356 __ LoadObject(R10, empty_context); | 1356 __ LoadObject(R10, empty_context); |
| 1357 __ movq(Address(RAX, Closure::context_offset()), R10); | 1357 __ movq(Address(RAX, Closure::context_offset()), R10); |
| 1358 } else if (is_implicit_instance_closure) { | 1358 } else if (is_implicit_instance_closure) { |
| 1359 // Initialize the new context capturing the receiver. | 1359 // Initialize the new context capturing the receiver. |
| 1360 | 1360 |
| 1361 // Set the class field to the Context class. | 1361 // Set the class field to the Context class. |
| 1362 const Class& context_class = Class::ZoneHandle(Object::context_class()); | 1362 const Class& context_class = Class::ZoneHandle(Object::context_class()); |
| 1363 __ LoadObject(R13, context_class); | 1363 __ LoadObject(R13, context_class); |
| 1364 __ movq(Address(RBX, Context::class_offset()), R13); | 1364 __ movq(Address(RBX, Context::class_offset()), R13); |
| 1365 // Set the tags. | 1365 // Set the tags. |
| 1366 uword tags = 0; | 1366 uword tags = 0; |
| 1367 tags = RawObject::SizeTag::update(context_size, tags); | 1367 tags = RawObject::SizeTag::update(context_size, tags); |
| 1368 tags = RawObject::ClassTag::update(context_class.index(), tags); | 1368 tags = RawObject::ClassIdTag::update(context_class.id(), tags); |
| 1369 __ movq(Address(RBX, Context::tags_offset()), Immediate(tags)); | 1369 __ movq(Address(RBX, Context::tags_offset()), Immediate(tags)); |
| 1370 | 1370 |
| 1371 // Set number of variables field to 1 (for captured receiver). | 1371 // Set number of variables field to 1 (for captured receiver). |
| 1372 __ movq(Address(RBX, Context::num_variables_offset()), Immediate(1)); | 1372 __ movq(Address(RBX, Context::num_variables_offset()), Immediate(1)); |
| 1373 | 1373 |
| 1374 // Set isolate field to isolate of current context. | 1374 // Set isolate field to isolate of current context. |
| 1375 __ movq(R10, FieldAddress(CTX, Context::isolate_offset())); | 1375 __ movq(R10, FieldAddress(CTX, Context::isolate_offset())); |
| 1376 __ movq(Address(RBX, Context::isolate_offset()), R10); | 1376 __ movq(Address(RBX, Context::isolate_offset()), R10); |
| 1377 | 1377 |
| 1378 // Set the parent field to null. | 1378 // Set the parent field to null. |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1855 // TOS + 2: instance. | 1855 // TOS + 2: instance. |
| 1856 // TOS + 3: cache array. | 1856 // TOS + 3: cache array. |
| 1857 // Result in RCX: null -> not found, otherwise result (true or false). | 1857 // Result in RCX: null -> not found, otherwise result (true or false). |
| 1858 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { | 1858 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { |
| 1859 GenerateSubtypeNTestCacheStub(assembler, 3); | 1859 GenerateSubtypeNTestCacheStub(assembler, 3); |
| 1860 } | 1860 } |
| 1861 | 1861 |
| 1862 } // namespace dart | 1862 } // namespace dart |
| 1863 | 1863 |
| 1864 #endif // defined TARGET_ARCH_X64 | 1864 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |