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/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 // RSP + 8 : type arguments of instantiator (only if class is parameterized). | 1087 // RSP + 8 : type arguments of instantiator (only if class is parameterized). |
1088 // RSP : points to return address. | 1088 // RSP : points to return address. |
1089 void StubCode::GenerateAllocationStubForClass(Assembler* assembler, | 1089 void StubCode::GenerateAllocationStubForClass(Assembler* assembler, |
1090 const Class& cls) { | 1090 const Class& cls) { |
1091 const intptr_t kObjectTypeArgumentsOffset = 2 * kWordSize; | 1091 const intptr_t kObjectTypeArgumentsOffset = 2 * kWordSize; |
1092 const intptr_t kInstantiatorTypeArgumentsOffset = 1 * kWordSize; | 1092 const intptr_t kInstantiatorTypeArgumentsOffset = 1 * kWordSize; |
1093 const Immediate raw_null = | 1093 const Immediate raw_null = |
1094 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1094 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
1095 // The generated code is different if the class is parameterized. | 1095 // The generated code is different if the class is parameterized. |
1096 const bool is_cls_parameterized = | 1096 const bool is_cls_parameterized = |
1097 cls.type_arguments_instance_field_offset() != Class::kNoTypeArguments; | 1097 cls.type_arguments_field_offset() != Class::kNoTypeArguments; |
1098 // kInlineInstanceSize is a constant used as a threshold for determining | 1098 // kInlineInstanceSize is a constant used as a threshold for determining |
1099 // when the object initialization should be done as a loop or as | 1099 // when the object initialization should be done as a loop or as |
1100 // straight line code. | 1100 // straight line code. |
1101 const int kInlineInstanceSize = 12; // In words. | 1101 const int kInlineInstanceSize = 12; // In words. |
1102 const intptr_t instance_size = cls.instance_size(); | 1102 const intptr_t instance_size = cls.instance_size(); |
1103 ASSERT(instance_size > 0); | 1103 ASSERT(instance_size > 0); |
1104 const intptr_t type_args_size = InstantiatedTypeArguments::InstanceSize(); | 1104 const intptr_t type_args_size = InstantiatedTypeArguments::InstanceSize(); |
1105 if (FLAG_inline_alloc && | 1105 if (FLAG_inline_alloc && |
1106 PageSpace::IsPageAllocatableSize(instance_size + type_args_size)) { | 1106 PageSpace::IsPageAllocatableSize(instance_size + type_args_size)) { |
1107 Label slow_case; | 1107 Label slow_case; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 __ cmpq(RCX, RBX); | 1215 __ cmpq(RCX, RBX); |
1216 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump); | 1216 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump); |
1217 __ movq(Address(RCX, 0), raw_null); | 1217 __ movq(Address(RCX, 0), raw_null); |
1218 __ addq(RCX, Immediate(kWordSize)); | 1218 __ addq(RCX, Immediate(kWordSize)); |
1219 __ jmp(&init_loop, Assembler::kNearJump); | 1219 __ jmp(&init_loop, Assembler::kNearJump); |
1220 __ Bind(&done); | 1220 __ Bind(&done); |
1221 } | 1221 } |
1222 if (is_cls_parameterized) { | 1222 if (is_cls_parameterized) { |
1223 // RDI: new object type arguments. | 1223 // RDI: new object type arguments. |
1224 // Set the type arguments in the new object. | 1224 // Set the type arguments in the new object. |
1225 __ movq(Address(RAX, cls.type_arguments_instance_field_offset()), RDI); | 1225 __ movq(Address(RAX, cls.type_arguments_field_offset()), RDI); |
1226 } | 1226 } |
1227 // Done allocating and initializing the instance. | 1227 // Done allocating and initializing the instance. |
1228 // RAX: new object. | 1228 // RAX: new object. |
1229 __ addq(RAX, Immediate(kHeapObjectTag)); | 1229 __ addq(RAX, Immediate(kHeapObjectTag)); |
1230 __ ret(); | 1230 __ ret(); |
1231 | 1231 |
1232 __ Bind(&slow_case); | 1232 __ Bind(&slow_case); |
1233 } | 1233 } |
1234 if (is_cls_parameterized) { | 1234 if (is_cls_parameterized) { |
1235 __ movq(RAX, Address(RSP, kObjectTypeArgumentsOffset)); | 1235 __ movq(RAX, Address(RSP, kObjectTypeArgumentsOffset)); |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; | 1838 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; |
1839 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; | 1839 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; |
1840 const intptr_t kCacheOffsetInBytes = 3 * kWordSize; | 1840 const intptr_t kCacheOffsetInBytes = 3 * kWordSize; |
1841 __ movq(RAX, Address(RSP, kInstanceOffsetInBytes)); | 1841 __ movq(RAX, Address(RSP, kInstanceOffsetInBytes)); |
1842 if (n > 1) { | 1842 if (n > 1) { |
1843 __ LoadClass(R10, RAX); | 1843 __ LoadClass(R10, RAX); |
1844 // Compute instance type arguments into R13. | 1844 // Compute instance type arguments into R13. |
1845 Label has_no_type_arguments; | 1845 Label has_no_type_arguments; |
1846 __ movq(R13, raw_null); | 1846 __ movq(R13, raw_null); |
1847 __ movq(RDI, FieldAddress(R10, | 1847 __ movq(RDI, FieldAddress(R10, |
1848 Class::type_arguments_instance_field_offset_offset())); | 1848 Class::type_arguments_field_offset_offset())); |
1849 __ cmpq(RDI, Immediate(Class::kNoTypeArguments)); | 1849 __ cmpq(RDI, Immediate(Class::kNoTypeArguments)); |
1850 __ j(EQUAL, &has_no_type_arguments, Assembler::kNearJump); | 1850 __ j(EQUAL, &has_no_type_arguments, Assembler::kNearJump); |
1851 __ movq(R13, FieldAddress(RAX, RDI, TIMES_1, 0)); | 1851 __ movq(R13, FieldAddress(RAX, RDI, TIMES_1, 0)); |
1852 __ Bind(&has_no_type_arguments); | 1852 __ Bind(&has_no_type_arguments); |
1853 } | 1853 } |
1854 __ LoadClassId(R10, RAX); | 1854 __ LoadClassId(R10, RAX); |
1855 // RAX: instance, R10: instance class id. | 1855 // RAX: instance, R10: instance class id. |
1856 // R13: instance type arguments or null, used only if n > 1. | 1856 // R13: instance type arguments or null, used only if n > 1. |
1857 __ movq(RDX, Address(RSP, kCacheOffsetInBytes)); | 1857 __ movq(RDX, Address(RSP, kCacheOffsetInBytes)); |
1858 // RDX: SubtypeTestCache. | 1858 // RDX: SubtypeTestCache. |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2163 __ cmpq(left, right); | 2163 __ cmpq(left, right); |
2164 __ Bind(&done); | 2164 __ Bind(&done); |
2165 __ popq(right); | 2165 __ popq(right); |
2166 __ popq(left); | 2166 __ popq(left); |
2167 __ ret(); | 2167 __ ret(); |
2168 } | 2168 } |
2169 | 2169 |
2170 } // namespace dart | 2170 } // namespace dart |
2171 | 2171 |
2172 #endif // defined TARGET_ARCH_X64 | 2172 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |