| 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1232 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 1233 __ movl(Address(EAX, Instance::tags_offset()), Immediate(tags)); | 1233 __ movl(Address(EAX, Instance::tags_offset()), Immediate(tags)); |
| 1234 | 1234 |
| 1235 // Initialize the remaining words of the object. | 1235 // Initialize the remaining words of the object. |
| 1236 const Immediate raw_null = | 1236 const Immediate raw_null = |
| 1237 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1237 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1238 | 1238 |
| 1239 // EAX: new object start. | 1239 // EAX: new object start. |
| 1240 // EBX: next object start. | 1240 // EBX: next object start. |
| 1241 // EDX: class of the object to be allocated. | 1241 // EDX: class of the object to be allocated. |
| 1242 // EDI: new object type arguments (if is_cls_parameterized). |
| 1242 // First try inlining the initialization without a loop. | 1243 // First try inlining the initialization without a loop. |
| 1243 if (instance_size < (kInlineInstanceSize * kWordSize) && | 1244 if (instance_size < (kInlineInstanceSize * kWordSize)) { |
| 1244 cls.num_native_fields() == 0) { | |
| 1245 // Check if the object contains any non-header fields. | 1245 // Check if the object contains any non-header fields. |
| 1246 // Small objects are initialized using a consecutive set of writes. | 1246 // Small objects are initialized using a consecutive set of writes. |
| 1247 for (intptr_t current_offset = sizeof(RawObject); | 1247 for (intptr_t current_offset = sizeof(RawObject); |
| 1248 current_offset < instance_size; | 1248 current_offset < instance_size; |
| 1249 current_offset += kWordSize) { | 1249 current_offset += kWordSize) { |
| 1250 __ movl(Address(EAX, current_offset), raw_null); | 1250 __ movl(Address(EAX, current_offset), raw_null); |
| 1251 } | 1251 } |
| 1252 } else { | 1252 } else { |
| 1253 __ leal(ECX, Address(EAX, sizeof(RawObject))); | 1253 __ leal(ECX, Address(EAX, sizeof(RawObject))); |
| 1254 // Loop until the whole object is initialized. | 1254 // Loop until the whole object is initialized. |
| 1255 Label init_loop; | |
| 1256 if (cls.num_native_fields() > 0) { | |
| 1257 // Initialize native fields. | |
| 1258 // EAX: new object. | |
| 1259 // EBX: next object start. | |
| 1260 // EDX: class of the object to be allocated. | |
| 1261 // ECX: next word to be initialized. | |
| 1262 intptr_t offset = Class::num_native_fields_offset() - kHeapObjectTag; | |
| 1263 __ movl(EDX, Address(EDX, offset)); | |
| 1264 __ leal(EDX, Address(EAX, EDX, TIMES_4, sizeof(RawObject))); | |
| 1265 | |
| 1266 // EDX: start of dart fields. | |
| 1267 // ECX: next word to be initialized. | |
| 1268 Label init_native_loop; | |
| 1269 __ Bind(&init_native_loop); | |
| 1270 __ cmpl(ECX, EDX); | |
| 1271 __ j(ABOVE_EQUAL, &init_loop, Assembler::kNearJump); | |
| 1272 __ movl(Address(ECX, 0), Immediate(0)); | |
| 1273 __ addl(ECX, Immediate(kWordSize)); | |
| 1274 __ jmp(&init_native_loop, Assembler::kNearJump); | |
| 1275 } | |
| 1276 // Now initialize the dart fields. | |
| 1277 // EAX: new object. | 1255 // EAX: new object. |
| 1278 // EBX: next object start. | 1256 // EBX: next object start. |
| 1279 // ECX: next word to be initialized. | 1257 // ECX: next word to be initialized. |
| 1258 // EDI: new object type arguments (if is_cls_parameterized). |
| 1259 Label init_loop; |
| 1280 Label done; | 1260 Label done; |
| 1281 __ Bind(&init_loop); | 1261 __ Bind(&init_loop); |
| 1282 __ cmpl(ECX, EBX); | 1262 __ cmpl(ECX, EBX); |
| 1283 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump); | 1263 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump); |
| 1284 __ movl(Address(ECX, 0), raw_null); | 1264 __ movl(Address(ECX, 0), raw_null); |
| 1285 __ addl(ECX, Immediate(kWordSize)); | 1265 __ addl(ECX, Immediate(kWordSize)); |
| 1286 __ jmp(&init_loop, Assembler::kNearJump); | 1266 __ jmp(&init_loop, Assembler::kNearJump); |
| 1287 __ Bind(&done); | 1267 __ Bind(&done); |
| 1288 } | 1268 } |
| 1289 if (is_cls_parameterized) { | 1269 if (is_cls_parameterized) { |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); | 2060 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); |
| 2081 __ popl(EDX); | 2061 __ popl(EDX); |
| 2082 __ popl(EAX); | 2062 __ popl(EAX); |
| 2083 __ LeaveFrame(); | 2063 __ LeaveFrame(); |
| 2084 __ ret(); | 2064 __ ret(); |
| 2085 } | 2065 } |
| 2086 | 2066 |
| 2087 } // namespace dart | 2067 } // namespace dart |
| 2088 | 2068 |
| 2089 #endif // defined TARGET_ARCH_IA32 | 2069 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |