| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 /* near_jump = */ false, | 606 /* near_jump = */ false, |
| 607 /* inline_isolate = */ false); | 607 /* inline_isolate = */ false); |
| 608 | 608 |
| 609 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; | 609 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; |
| 610 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi. | 610 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi. |
| 611 ASSERT(kSmiTagShift == 1); | 611 ASSERT(kSmiTagShift == 1); |
| 612 __ andq(RDI, Immediate(-kObjectAlignment)); | 612 __ andq(RDI, Immediate(-kObjectAlignment)); |
| 613 | 613 |
| 614 const intptr_t cid = kArrayCid; | 614 const intptr_t cid = kArrayCid; |
| 615 Heap::Space space = Heap::SpaceForAllocation(cid); | 615 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 616 __ LoadIsolate(R13); | 616 __ movq(R13, Address(THR, Thread::heap_offset())); |
| 617 __ movq(R13, Address(R13, Isolate::heap_offset())); | |
| 618 __ movq(RAX, Address(R13, Heap::TopOffset(space))); | 617 __ movq(RAX, Address(R13, Heap::TopOffset(space))); |
| 619 | 618 |
| 620 // RDI: allocation size. | 619 // RDI: allocation size. |
| 621 __ movq(RCX, RAX); | 620 __ movq(RCX, RAX); |
| 622 __ addq(RCX, RDI); | 621 __ addq(RCX, RDI); |
| 623 __ j(CARRY, &slow_case); | 622 __ j(CARRY, &slow_case); |
| 624 | 623 |
| 625 // Check if the allocation fits into the remaining space. | 624 // Check if the allocation fits into the remaining space. |
| 626 // RAX: potential new object start. | 625 // RAX: potential new object start. |
| 627 // RCX: potential next object start. | 626 // RCX: potential next object start. |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 // First compute the rounded instance size. | 855 // First compute the rounded instance size. |
| 857 // R10: number of context variables. | 856 // R10: number of context variables. |
| 858 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); | 857 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); |
| 859 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); | 858 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); |
| 860 __ andq(R13, Immediate(-kObjectAlignment)); | 859 __ andq(R13, Immediate(-kObjectAlignment)); |
| 861 | 860 |
| 862 // Now allocate the object. | 861 // Now allocate the object. |
| 863 // R10: number of context variables. | 862 // R10: number of context variables. |
| 864 const intptr_t cid = kContextCid; | 863 const intptr_t cid = kContextCid; |
| 865 Heap::Space space = Heap::SpaceForAllocation(cid); | 864 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 866 __ LoadIsolate(RCX); | 865 __ movq(RCX, Address(THR, Thread::heap_offset())); |
| 867 __ movq(RCX, Address(RCX, Isolate::heap_offset())); | |
| 868 __ movq(RAX, Address(RCX, Heap::TopOffset(space))); | 866 __ movq(RAX, Address(RCX, Heap::TopOffset(space))); |
| 869 __ addq(R13, RAX); | 867 __ addq(R13, RAX); |
| 870 // Check if the allocation fits into the remaining space. | 868 // Check if the allocation fits into the remaining space. |
| 871 // RAX: potential new object. | 869 // RAX: potential new object. |
| 872 // R13: potential next object start. | 870 // R13: potential next object start. |
| 873 // R10: number of context variables. | 871 // R10: number of context variables. |
| 874 // RCX: heap. | 872 // RCX: heap. |
| 875 __ cmpq(R13, Address(RCX, Heap::EndOffset(space))); | 873 __ cmpq(R13, Address(RCX, Heap::EndOffset(space))); |
| 876 if (FLAG_use_slow_path) { | 874 if (FLAG_use_slow_path) { |
| 877 __ jmp(&slow_case); | 875 __ jmp(&slow_case); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 if (is_cls_parameterized) { | 1065 if (is_cls_parameterized) { |
| 1068 __ movq(RDX, Address(RSP, kObjectTypeArgumentsOffset)); | 1066 __ movq(RDX, Address(RSP, kObjectTypeArgumentsOffset)); |
| 1069 // RDX: instantiated type arguments. | 1067 // RDX: instantiated type arguments. |
| 1070 } | 1068 } |
| 1071 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && | 1069 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && |
| 1072 !cls.trace_allocation()) { | 1070 !cls.trace_allocation()) { |
| 1073 Label slow_case; | 1071 Label slow_case; |
| 1074 // Allocate the object and update top to point to | 1072 // Allocate the object and update top to point to |
| 1075 // next object start and initialize the allocated object. | 1073 // next object start and initialize the allocated object. |
| 1076 // RDX: instantiated type arguments (if is_cls_parameterized). | 1074 // RDX: instantiated type arguments (if is_cls_parameterized). |
| 1077 Heap* heap = Isolate::Current()->heap(); | |
| 1078 Heap::Space space = Heap::SpaceForAllocation(cls.id()); | 1075 Heap::Space space = Heap::SpaceForAllocation(cls.id()); |
| 1079 __ movq(RCX, Immediate(heap->TopAddress(space))); | 1076 __ movq(RCX, Address(THR, Thread::heap_offset())); |
| 1080 __ movq(RAX, Address(RCX, 0)); | 1077 __ movq(RAX, Address(RCX, Heap::TopOffset(space))); |
| 1081 __ leaq(RBX, Address(RAX, instance_size)); | 1078 __ leaq(RBX, Address(RAX, instance_size)); |
| 1082 // Check if the allocation fits into the remaining space. | 1079 // Check if the allocation fits into the remaining space. |
| 1083 // RAX: potential new object start. | 1080 // RAX: potential new object start. |
| 1084 // RBX: potential next object start. | 1081 // RBX: potential next object start. |
| 1085 // RCX: heap top address. | 1082 // RCX: heap. |
| 1086 __ movq(R13, Immediate(heap->EndAddress(space))); | 1083 __ cmpq(RBX, Address(RCX, Heap::EndOffset(space))); |
| 1087 __ cmpq(RBX, Address(R13, 0)); | |
| 1088 if (FLAG_use_slow_path) { | 1084 if (FLAG_use_slow_path) { |
| 1089 __ jmp(&slow_case); | 1085 __ jmp(&slow_case); |
| 1090 } else { | 1086 } else { |
| 1091 __ j(ABOVE_EQUAL, &slow_case); | 1087 __ j(ABOVE_EQUAL, &slow_case); |
| 1092 } | 1088 } |
| 1093 __ movq(Address(RCX, 0), RBX); | 1089 __ movq(Address(RCX, Heap::TopOffset(space)), RBX); |
| 1094 __ UpdateAllocationStats(cls.id(), space); | 1090 __ UpdateAllocationStats(cls.id(), space, /* inline_isolate = */ false); |
| 1095 | 1091 |
| 1096 // RAX: new object start (untagged). | 1092 // RAX: new object start (untagged). |
| 1097 // RBX: next object start. | 1093 // RBX: next object start. |
| 1098 // RDX: new object type arguments (if is_cls_parameterized). | 1094 // RDX: new object type arguments (if is_cls_parameterized). |
| 1099 // Set the tags. | 1095 // Set the tags. |
| 1100 uword tags = 0; | 1096 uword tags = 0; |
| 1101 tags = RawObject::SizeTag::update(instance_size, tags); | 1097 tags = RawObject::SizeTag::update(instance_size, tags); |
| 1102 ASSERT(cls.id() != kIllegalCid); | 1098 ASSERT(cls.id() != kIllegalCid); |
| 1103 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1099 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 1104 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); | 1100 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2153 // Result: | 2149 // Result: |
| 2154 // RCX: entry point. | 2150 // RCX: entry point. |
| 2155 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2151 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 2156 EmitMegamorphicLookup(assembler, RDI, RBX, RCX); | 2152 EmitMegamorphicLookup(assembler, RDI, RBX, RCX); |
| 2157 __ ret(); | 2153 __ ret(); |
| 2158 } | 2154 } |
| 2159 | 2155 |
| 2160 } // namespace dart | 2156 } // namespace dart |
| 2161 | 2157 |
| 2162 #endif // defined TARGET_ARCH_X64 | 2158 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |