| 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/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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 __ ret(); | 731 __ ret(); |
| 732 } | 732 } |
| 733 | 733 |
| 734 // Unable to allocate the array using the fast inline code, just call | 734 // Unable to allocate the array using the fast inline code, just call |
| 735 // into the runtime. | 735 // into the runtime. |
| 736 __ Bind(&slow_case); | 736 __ Bind(&slow_case); |
| 737 __ EnterFrame(0); | 737 __ EnterFrame(0); |
| 738 __ pushq(raw_null); // Setup space on stack for return value. | 738 __ pushq(raw_null); // Setup space on stack for return value. |
| 739 __ pushq(R10); // Array length as Smi. | 739 __ pushq(R10); // Array length as Smi. |
| 740 __ pushq(RBX); // Element type. | 740 __ pushq(RBX); // Element type. |
| 741 __ pushq(raw_null); // Null instantiator. | |
| 742 __ CallRuntimeFromStub(kAllocateArrayRuntimeEntry); | 741 __ CallRuntimeFromStub(kAllocateArrayRuntimeEntry); |
| 743 __ popq(RAX); // Pop instantiator. | |
| 744 __ popq(RAX); // Pop element type argument. | 742 __ popq(RAX); // Pop element type argument. |
| 745 __ popq(R10); // Pop array length argument. | 743 __ popq(R10); // Pop array length argument. |
| 746 __ popq(RAX); // Pop return value from return slot. | 744 __ popq(RAX); // Pop return value from return slot. |
| 747 __ LeaveFrame(); | 745 __ LeaveFrame(); |
| 748 __ ret(); | 746 __ ret(); |
| 749 } | 747 } |
| 750 | 748 |
| 751 | 749 |
| 752 // Input parameters: | 750 // Input parameters: |
| 753 // R10: Arguments descriptor array (num_args is first Smi element, closure | 751 // R10: Arguments descriptor array (num_args is first Smi element, closure |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 if (FLAG_inline_alloc && | 1112 if (FLAG_inline_alloc && |
| 1115 PageSpace::IsPageAllocatableSize(instance_size + type_args_size)) { | 1113 PageSpace::IsPageAllocatableSize(instance_size + type_args_size)) { |
| 1116 Label slow_case; | 1114 Label slow_case; |
| 1117 Heap* heap = Isolate::Current()->heap(); | 1115 Heap* heap = Isolate::Current()->heap(); |
| 1118 __ movq(RAX, Immediate(heap->TopAddress())); | 1116 __ movq(RAX, Immediate(heap->TopAddress())); |
| 1119 __ movq(RAX, Address(RAX, 0)); | 1117 __ movq(RAX, Address(RAX, 0)); |
| 1120 __ leaq(RBX, Address(RAX, instance_size)); | 1118 __ leaq(RBX, Address(RAX, instance_size)); |
| 1121 if (is_cls_parameterized) { | 1119 if (is_cls_parameterized) { |
| 1122 __ movq(RCX, RBX); | 1120 __ movq(RCX, RBX); |
| 1123 // A new InstantiatedTypeArguments object only needs to be allocated if | 1121 // A new InstantiatedTypeArguments object only needs to be allocated if |
| 1124 // the instantiator is non-null. | 1122 // the instantiator is provided (not kNoInstantiator, but may be null). |
| 1125 Label null_instantiator; | 1123 Label no_instantiator; |
| 1126 __ cmpq(Address(RSP, kInstantiatorTypeArgumentsOffset), raw_null); | 1124 __ cmpq(Address(RSP, kInstantiatorTypeArgumentsOffset), |
| 1127 __ j(EQUAL, &null_instantiator, Assembler::kNearJump); | 1125 Immediate(Smi::RawValue(StubCode::kNoInstantiator))); |
| 1126 __ j(EQUAL, &no_instantiator, Assembler::kNearJump); |
| 1128 __ addq(RBX, Immediate(type_args_size)); | 1127 __ addq(RBX, Immediate(type_args_size)); |
| 1129 __ Bind(&null_instantiator); | 1128 __ Bind(&no_instantiator); |
| 1130 // RCX: potential new object end and, if RCX != RBX, potential new | 1129 // RCX: potential new object end and, if RCX != RBX, potential new |
| 1131 // InstantiatedTypeArguments object start. | 1130 // InstantiatedTypeArguments object start. |
| 1132 } | 1131 } |
| 1133 // Check if the allocation fits into the remaining space. | 1132 // Check if the allocation fits into the remaining space. |
| 1134 // RAX: potential new object start. | 1133 // RAX: potential new object start. |
| 1135 // RBX: potential next object start. | 1134 // RBX: potential next object start. |
| 1136 __ movq(RDI, Immediate(heap->EndAddress())); | 1135 __ movq(RDI, Immediate(heap->EndAddress())); |
| 1137 __ cmpq(RBX, Address(RDI, 0)); | 1136 __ cmpq(RBX, Address(RDI, 0)); |
| 1138 if (FLAG_use_slow_path) { | 1137 if (FLAG_use_slow_path) { |
| 1139 __ jmp(&slow_case); | 1138 __ jmp(&slow_case); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 } | 1262 } |
| 1264 // Create a stub frame. | 1263 // Create a stub frame. |
| 1265 __ EnterFrame(0); | 1264 __ EnterFrame(0); |
| 1266 __ pushq(raw_null); // Setup space on stack for return value. | 1265 __ pushq(raw_null); // Setup space on stack for return value. |
| 1267 __ PushObject(cls); // Push class of object to be allocated. | 1266 __ PushObject(cls); // Push class of object to be allocated. |
| 1268 if (is_cls_parameterized) { | 1267 if (is_cls_parameterized) { |
| 1269 __ pushq(RAX); // Push type arguments of object to be allocated. | 1268 __ pushq(RAX); // Push type arguments of object to be allocated. |
| 1270 __ pushq(RDX); // Push type arguments of instantiator. | 1269 __ pushq(RDX); // Push type arguments of instantiator. |
| 1271 } else { | 1270 } else { |
| 1272 __ pushq(raw_null); // Push null type arguments. | 1271 __ pushq(raw_null); // Push null type arguments. |
| 1273 __ pushq(raw_null); // Push null instantiator. | 1272 __ pushq(Immediate(Smi::RawValue(StubCode::kNoInstantiator))); |
| 1274 } | 1273 } |
| 1275 __ CallRuntimeFromStub(kAllocateObjectRuntimeEntry); // Allocate object. | 1274 __ CallRuntimeFromStub(kAllocateObjectRuntimeEntry); // Allocate object. |
| 1276 __ popq(RAX); // Pop argument (instantiator). | 1275 __ popq(RAX); // Pop argument (instantiator). |
| 1277 __ popq(RAX); // Pop argument (type arguments of object). | 1276 __ popq(RAX); // Pop argument (type arguments of object). |
| 1278 __ popq(RAX); // Pop argument (class of object). | 1277 __ popq(RAX); // Pop argument (class of object). |
| 1279 __ popq(RAX); // Pop result (newly allocated object). | 1278 __ popq(RAX); // Pop result (newly allocated object). |
| 1280 // RAX: new object | 1279 // RAX: new object |
| 1281 // Restore the frame pointer. | 1280 // Restore the frame pointer. |
| 1282 __ LeaveFrame(); | 1281 __ LeaveFrame(); |
| 1283 __ ret(); | 1282 __ ret(); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1730 } | 1729 } |
| 1731 | 1730 |
| 1732 | 1731 |
| 1733 void StubCode::GenerateIsRawSubTypeStub(Assembler* assembler) { | 1732 void StubCode::GenerateIsRawSubTypeStub(Assembler* assembler) { |
| 1734 __ Unimplemented("IsRawSubType Stub"); | 1733 __ Unimplemented("IsRawSubType Stub"); |
| 1735 } | 1734 } |
| 1736 | 1735 |
| 1737 } // namespace dart | 1736 } // namespace dart |
| 1738 | 1737 |
| 1739 #endif // defined TARGET_ARCH_X64 | 1738 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |