| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 __ ret(); | 737 __ ret(); |
| 738 } | 738 } |
| 739 | 739 |
| 740 // Unable to allocate the array using the fast inline code, just call | 740 // Unable to allocate the array using the fast inline code, just call |
| 741 // into the runtime. | 741 // into the runtime. |
| 742 __ Bind(&slow_case); | 742 __ Bind(&slow_case); |
| 743 __ EnterFrame(0); | 743 __ EnterFrame(0); |
| 744 __ pushl(raw_null); // Setup space on stack for return value. | 744 __ pushl(raw_null); // Setup space on stack for return value. |
| 745 __ pushl(EDX); // Array length as Smi. | 745 __ pushl(EDX); // Array length as Smi. |
| 746 __ pushl(ECX); // Element type. | 746 __ pushl(ECX); // Element type. |
| 747 __ pushl(raw_null); // Null instantiator. | |
| 748 __ CallRuntimeFromStub(kAllocateArrayRuntimeEntry); | 747 __ CallRuntimeFromStub(kAllocateArrayRuntimeEntry); |
| 749 __ popl(EAX); // Pop instantiator. | |
| 750 __ popl(EAX); // Pop element type argument. | 748 __ popl(EAX); // Pop element type argument. |
| 751 __ popl(EDX); // Pop array length argument. | 749 __ popl(EDX); // Pop array length argument. |
| 752 __ popl(EAX); // Pop return value from return slot. | 750 __ popl(EAX); // Pop return value from return slot. |
| 753 __ LeaveFrame(); | 751 __ LeaveFrame(); |
| 754 __ ret(); | 752 __ ret(); |
| 755 } | 753 } |
| 756 | 754 |
| 757 | 755 |
| 758 // Input parameters: | 756 // Input parameters: |
| 759 // EDX: Arguments descriptor array (num_args is first Smi element, closure | 757 // EDX: Arguments descriptor array (num_args is first Smi element, closure |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 const intptr_t type_args_size = InstantiatedTypeArguments::InstanceSize(); | 1116 const intptr_t type_args_size = InstantiatedTypeArguments::InstanceSize(); |
| 1119 if (FLAG_inline_alloc && | 1117 if (FLAG_inline_alloc && |
| 1120 PageSpace::IsPageAllocatableSize(instance_size + type_args_size)) { | 1118 PageSpace::IsPageAllocatableSize(instance_size + type_args_size)) { |
| 1121 Label slow_case; | 1119 Label slow_case; |
| 1122 Heap* heap = Isolate::Current()->heap(); | 1120 Heap* heap = Isolate::Current()->heap(); |
| 1123 __ movl(EAX, Address::Absolute(heap->TopAddress())); | 1121 __ movl(EAX, Address::Absolute(heap->TopAddress())); |
| 1124 __ leal(EBX, Address(EAX, instance_size)); | 1122 __ leal(EBX, Address(EAX, instance_size)); |
| 1125 if (is_cls_parameterized) { | 1123 if (is_cls_parameterized) { |
| 1126 __ movl(ECX, EBX); | 1124 __ movl(ECX, EBX); |
| 1127 // A new InstantiatedTypeArguments object only needs to be allocated if | 1125 // A new InstantiatedTypeArguments object only needs to be allocated if |
| 1128 // the instantiator is non-null. | 1126 // the instantiator is provided (not kNoInstantiator, but may be null). |
| 1129 Label null_instantiator; | 1127 Label no_instantiator; |
| 1130 __ cmpl(Address(ESP, kInstantiatorTypeArgumentsOffset), raw_null); | 1128 __ cmpl(Address(ESP, kInstantiatorTypeArgumentsOffset), |
| 1131 __ j(EQUAL, &null_instantiator, Assembler::kNearJump); | 1129 Immediate(Smi::RawValue(StubCode::kNoInstantiator))); |
| 1130 __ j(EQUAL, &no_instantiator, Assembler::kNearJump); |
| 1132 __ addl(EBX, Immediate(type_args_size)); | 1131 __ addl(EBX, Immediate(type_args_size)); |
| 1133 __ Bind(&null_instantiator); | 1132 __ Bind(&no_instantiator); |
| 1134 // ECX: potential new object end and, if ECX != EBX, potential new | 1133 // ECX: potential new object end and, if ECX != EBX, potential new |
| 1135 // InstantiatedTypeArguments object start. | 1134 // InstantiatedTypeArguments object start. |
| 1136 } | 1135 } |
| 1137 // Check if the allocation fits into the remaining space. | 1136 // Check if the allocation fits into the remaining space. |
| 1138 // EAX: potential new object start. | 1137 // EAX: potential new object start. |
| 1139 // EBX: potential next object start. | 1138 // EBX: potential next object start. |
| 1140 __ cmpl(EBX, Address::Absolute(heap->EndAddress())); | 1139 __ cmpl(EBX, Address::Absolute(heap->EndAddress())); |
| 1141 if (FLAG_use_slow_path) { | 1140 if (FLAG_use_slow_path) { |
| 1142 __ jmp(&slow_case); | 1141 __ jmp(&slow_case); |
| 1143 } else { | 1142 } else { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 } | 1264 } |
| 1266 // Create a stub frame. | 1265 // Create a stub frame. |
| 1267 __ EnterFrame(0); | 1266 __ EnterFrame(0); |
| 1268 __ pushl(raw_null); // Setup space on stack for return value. | 1267 __ pushl(raw_null); // Setup space on stack for return value. |
| 1269 __ PushObject(cls); // Push class of object to be allocated. | 1268 __ PushObject(cls); // Push class of object to be allocated. |
| 1270 if (is_cls_parameterized) { | 1269 if (is_cls_parameterized) { |
| 1271 __ pushl(EAX); // Push type arguments of object to be allocated. | 1270 __ pushl(EAX); // Push type arguments of object to be allocated. |
| 1272 __ pushl(EDX); // Push type arguments of instantiator. | 1271 __ pushl(EDX); // Push type arguments of instantiator. |
| 1273 } else { | 1272 } else { |
| 1274 __ pushl(raw_null); // Push null type arguments. | 1273 __ pushl(raw_null); // Push null type arguments. |
| 1275 __ pushl(raw_null); // Push null instantiator. | 1274 __ pushl(Immediate(Smi::RawValue(StubCode::kNoInstantiator))); |
| 1276 } | 1275 } |
| 1277 __ CallRuntimeFromStub(kAllocateObjectRuntimeEntry); // Allocate object. | 1276 __ CallRuntimeFromStub(kAllocateObjectRuntimeEntry); // Allocate object. |
| 1278 __ popl(EAX); // Pop argument (instantiator). | 1277 __ popl(EAX); // Pop argument (instantiator). |
| 1279 __ popl(EAX); // Pop argument (type arguments of object). | 1278 __ popl(EAX); // Pop argument (type arguments of object). |
| 1280 __ popl(EAX); // Pop argument (class of object). | 1279 __ popl(EAX); // Pop argument (class of object). |
| 1281 __ popl(EAX); // Pop result (newly allocated object). | 1280 __ popl(EAX); // Pop result (newly allocated object). |
| 1282 // EAX: new object | 1281 // EAX: new object |
| 1283 // Restore the frame pointer. | 1282 // Restore the frame pointer. |
| 1284 __ LeaveFrame(); | 1283 __ LeaveFrame(); |
| 1285 __ ret(); | 1284 __ ret(); |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); | 1830 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); |
| 1832 __ cmpl(EDX, ECX); | 1831 __ cmpl(EDX, ECX); |
| 1833 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); | 1832 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); |
| 1834 __ jmp(&found, Assembler::kNearJump); | 1833 __ jmp(&found, Assembler::kNearJump); |
| 1835 } | 1834 } |
| 1836 | 1835 |
| 1837 | 1836 |
| 1838 } // namespace dart | 1837 } // namespace dart |
| 1839 | 1838 |
| 1840 #endif // defined TARGET_ARCH_IA32 | 1839 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |