| 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 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1212 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 1213 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); | 1213 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); |
| 1214 | 1214 |
| 1215 // Initialize the remaining words of the object. | 1215 // Initialize the remaining words of the object. |
| 1216 const Immediate raw_null = | 1216 const Immediate raw_null = |
| 1217 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1217 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1218 | 1218 |
| 1219 // RAX: new object start. | 1219 // RAX: new object start. |
| 1220 // RBX: next object start. | 1220 // RBX: next object start. |
| 1221 // RDX: class of the object to be allocated. | 1221 // RDX: class of the object to be allocated. |
| 1222 // RDI: new object type arguments (if is_cls_parameterized). |
| 1222 // First try inlining the initialization without a loop. | 1223 // First try inlining the initialization without a loop. |
| 1223 if (instance_size < (kInlineInstanceSize * kWordSize) && | 1224 if (instance_size < (kInlineInstanceSize * kWordSize)) { |
| 1224 cls.num_native_fields() == 0) { | |
| 1225 // Check if the object contains any non-header fields. | 1225 // Check if the object contains any non-header fields. |
| 1226 // Small objects are initialized using a consecutive set of writes. | 1226 // Small objects are initialized using a consecutive set of writes. |
| 1227 for (intptr_t current_offset = sizeof(RawObject); | 1227 for (intptr_t current_offset = sizeof(RawObject); |
| 1228 current_offset < instance_size; | 1228 current_offset < instance_size; |
| 1229 current_offset += kWordSize) { | 1229 current_offset += kWordSize) { |
| 1230 __ movq(Address(RAX, current_offset), raw_null); | 1230 __ movq(Address(RAX, current_offset), raw_null); |
| 1231 } | 1231 } |
| 1232 } else { | 1232 } else { |
| 1233 __ leaq(RCX, Address(RAX, sizeof(RawObject))); | 1233 __ leaq(RCX, Address(RAX, sizeof(RawObject))); |
| 1234 // Loop until the whole object is initialized. | 1234 // Loop until the whole object is initialized. |
| 1235 Label init_loop; | |
| 1236 if (cls.num_native_fields() > 0) { | |
| 1237 // Initialize native fields. | |
| 1238 // RAX: new object. | |
| 1239 // RBX: next object start. | |
| 1240 // RDX: class of the object to be allocated. | |
| 1241 // RCX: next word to be initialized. | |
| 1242 intptr_t offset = Class::num_native_fields_offset() - kHeapObjectTag; | |
| 1243 __ movq(RDX, Address(RDX, offset)); | |
| 1244 __ leaq(RDX, Address(RAX, RDX, TIMES_8, sizeof(RawObject))); | |
| 1245 | |
| 1246 // RDX: start of dart fields. | |
| 1247 // RCX: next word to be initialized. | |
| 1248 Label init_native_loop; | |
| 1249 __ Bind(&init_native_loop); | |
| 1250 __ cmpq(RCX, RDX); | |
| 1251 __ j(ABOVE_EQUAL, &init_loop, Assembler::kNearJump); | |
| 1252 __ movq(Address(RCX, 0), Immediate(0)); | |
| 1253 __ addq(RCX, Immediate(kWordSize)); | |
| 1254 __ jmp(&init_native_loop, Assembler::kNearJump); | |
| 1255 } | |
| 1256 // Now initialize the dart fields. | |
| 1257 // RAX: new object. | 1235 // RAX: new object. |
| 1258 // RBX: next object start. | 1236 // RBX: next object start. |
| 1259 // RCX: next word to be initialized. | 1237 // RCX: next word to be initialized. |
| 1238 // RDI: new object type arguments (if is_cls_parameterized). |
| 1239 Label init_loop; |
| 1260 Label done; | 1240 Label done; |
| 1261 __ Bind(&init_loop); | 1241 __ Bind(&init_loop); |
| 1262 __ cmpq(RCX, RBX); | 1242 __ cmpq(RCX, RBX); |
| 1263 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump); | 1243 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump); |
| 1264 __ movq(Address(RCX, 0), raw_null); | 1244 __ movq(Address(RCX, 0), raw_null); |
| 1265 __ addq(RCX, Immediate(kWordSize)); | 1245 __ addq(RCX, Immediate(kWordSize)); |
| 1266 __ jmp(&init_loop, Assembler::kNearJump); | 1246 __ jmp(&init_loop, Assembler::kNearJump); |
| 1267 __ Bind(&done); | 1247 __ Bind(&done); |
| 1268 } | 1248 } |
| 1269 if (is_cls_parameterized) { | 1249 if (is_cls_parameterized) { |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2040 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); | 2020 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); |
| 2041 __ popq(RDX); | 2021 __ popq(RDX); |
| 2042 __ popq(RAX); | 2022 __ popq(RAX); |
| 2043 __ LeaveFrame(); | 2023 __ LeaveFrame(); |
| 2044 __ ret(); | 2024 __ ret(); |
| 2045 } | 2025 } |
| 2046 | 2026 |
| 2047 } // namespace dart | 2027 } // namespace dart |
| 2048 | 2028 |
| 2049 #endif // defined TARGET_ARCH_X64 | 2029 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |