| 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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements))); | 632 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements))); |
| 633 __ cmpq(RDI, max_len); | 633 __ cmpq(RDI, max_len); |
| 634 __ j(GREATER, &slow_case); | 634 __ j(GREATER, &slow_case); |
| 635 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; | 635 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; |
| 636 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi. | 636 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi. |
| 637 ASSERT(kSmiTagShift == 1); | 637 ASSERT(kSmiTagShift == 1); |
| 638 __ andq(RDI, Immediate(-kObjectAlignment)); | 638 __ andq(RDI, Immediate(-kObjectAlignment)); |
| 639 | 639 |
| 640 Heap* heap = isolate->heap(); | 640 Heap* heap = isolate->heap(); |
| 641 const intptr_t cid = kArrayCid; | 641 const intptr_t cid = kArrayCid; |
| 642 Heap::Space space = heap->SpaceForAllocation(cid); | 642 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 643 __ movq(RAX, Immediate(heap->TopAddress(space))); | 643 __ movq(RAX, Immediate(heap->TopAddress(space))); |
| 644 __ movq(RAX, Address(RAX, 0)); | 644 __ movq(RAX, Address(RAX, 0)); |
| 645 | 645 |
| 646 // RDI: allocation size. | 646 // RDI: allocation size. |
| 647 __ movq(RCX, RAX); | 647 __ movq(RCX, RAX); |
| 648 __ addq(RCX, RDI); | 648 __ addq(RCX, RDI); |
| 649 __ j(CARRY, &slow_case); | 649 __ j(CARRY, &slow_case); |
| 650 | 650 |
| 651 // Check if the allocation fits into the remaining space. | 651 // Check if the allocation fits into the remaining space. |
| 652 // RAX: potential new object start. | 652 // RAX: potential new object start. |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 | 874 |
| 875 // Called for inline allocation of contexts. | 875 // Called for inline allocation of contexts. |
| 876 // Input: | 876 // Input: |
| 877 // R10: number of context variables. | 877 // R10: number of context variables. |
| 878 // Output: | 878 // Output: |
| 879 // RAX: new allocated RawContext object. | 879 // RAX: new allocated RawContext object. |
| 880 void StubCode::GenerateAllocateContextStub(Assembler* assembler) { | 880 void StubCode::GenerateAllocateContextStub(Assembler* assembler) { |
| 881 __ LoadObject(R12, Object::null_object(), PP); | 881 __ LoadObject(R12, Object::null_object(), PP); |
| 882 if (FLAG_inline_alloc) { | 882 if (FLAG_inline_alloc) { |
| 883 Label slow_case; | 883 Label slow_case; |
| 884 Isolate* isolate = Isolate::Current(); | |
| 885 Heap* heap = isolate->heap(); | |
| 886 // First compute the rounded instance size. | 884 // First compute the rounded instance size. |
| 887 // R10: number of context variables. | 885 // R10: number of context variables. |
| 888 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); | 886 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); |
| 889 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); | 887 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); |
| 890 __ andq(R13, Immediate(-kObjectAlignment)); | 888 __ andq(R13, Immediate(-kObjectAlignment)); |
| 891 | 889 |
| 892 // Now allocate the object. | 890 // Now allocate the object. |
| 893 // R10: number of context variables. | 891 // R10: number of context variables. |
| 894 const intptr_t cid = kContextCid; | 892 const intptr_t cid = kContextCid; |
| 895 Heap::Space space = heap->SpaceForAllocation(cid); | 893 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 896 __ movq(RAX, Immediate(heap->TopAddress(space))); | 894 __ LoadIsolate(RCX); |
| 897 __ movq(RAX, Address(RAX, 0)); | 895 __ movq(RCX, Address(RCX, Isolate::heap_offset())); |
| 896 __ movq(RAX, Address(RCX, Heap::TopOffset(space))); |
| 898 __ addq(R13, RAX); | 897 __ addq(R13, RAX); |
| 899 // Check if the allocation fits into the remaining space. | 898 // Check if the allocation fits into the remaining space. |
| 900 // RAX: potential new object. | 899 // RAX: potential new object. |
| 901 // R13: potential next object start. | 900 // R13: potential next object start. |
| 902 // R10: number of context variables. | 901 // R10: number of context variables. |
| 903 __ movq(RDI, Immediate(heap->EndAddress(space))); | 902 // RCX: heap. |
| 904 __ cmpq(R13, Address(RDI, 0)); | 903 __ cmpq(R13, Address(RCX, Heap::EndOffset(space))); |
| 905 if (FLAG_use_slow_path) { | 904 if (FLAG_use_slow_path) { |
| 906 __ jmp(&slow_case); | 905 __ jmp(&slow_case); |
| 907 } else { | 906 } else { |
| 908 __ j(ABOVE_EQUAL, &slow_case); | 907 __ j(ABOVE_EQUAL, &slow_case); |
| 909 } | 908 } |
| 910 | 909 |
| 911 // Successfully allocated the object, now update top to point to | 910 // Successfully allocated the object, now update top to point to |
| 912 // next object start and initialize the object. | 911 // next object start and initialize the object. |
| 913 // RAX: new object. | 912 // RAX: new object. |
| 914 // R13: next object start. | 913 // R13: next object start. |
| 915 // R10: number of context variables. | 914 // R10: number of context variables. |
| 916 __ movq(RDI, Immediate(heap->TopAddress(space))); | 915 // RCX: heap. |
| 917 __ movq(Address(RDI, 0), R13); | 916 __ movq(Address(RCX, Heap::TopOffset(space)), R13); |
| 918 __ addq(RAX, Immediate(kHeapObjectTag)); | 917 __ addq(RAX, Immediate(kHeapObjectTag)); |
| 919 // R13: Size of allocation in bytes. | 918 // R13: Size of allocation in bytes. |
| 920 __ subq(R13, RAX); | 919 __ subq(R13, RAX); |
| 921 __ UpdateAllocationStatsWithSize(cid, R13, space); | 920 // Generate isolate-independent code to allow sharing between isolates. |
| 921 __ UpdateAllocationStatsWithSize(cid, R13, space, |
| 922 /* inline_isolate */ false); |
| 922 | 923 |
| 923 // Calculate the size tag. | 924 // Calculate the size tag. |
| 924 // RAX: new object. | 925 // RAX: new object. |
| 925 // R10: number of context variables. | 926 // R10: number of context variables. |
| 926 { | 927 { |
| 927 Label size_tag_overflow, done; | 928 Label size_tag_overflow, done; |
| 928 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); | 929 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); |
| 929 __ andq(R13, Immediate(-kObjectAlignment)); | 930 __ andq(R13, Immediate(-kObjectAlignment)); |
| 930 __ cmpq(R13, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 931 __ cmpq(R13, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| 931 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 932 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 __ movq(RDX, Address(RSP, kObjectTypeArgumentsOffset)); | 1096 __ movq(RDX, Address(RSP, kObjectTypeArgumentsOffset)); |
| 1096 // RDX: instantiated type arguments. | 1097 // RDX: instantiated type arguments. |
| 1097 } | 1098 } |
| 1098 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && | 1099 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && |
| 1099 !cls.trace_allocation()) { | 1100 !cls.trace_allocation()) { |
| 1100 Label slow_case; | 1101 Label slow_case; |
| 1101 // Allocate the object and update top to point to | 1102 // Allocate the object and update top to point to |
| 1102 // next object start and initialize the allocated object. | 1103 // next object start and initialize the allocated object. |
| 1103 // RDX: instantiated type arguments (if is_cls_parameterized). | 1104 // RDX: instantiated type arguments (if is_cls_parameterized). |
| 1104 Heap* heap = Isolate::Current()->heap(); | 1105 Heap* heap = Isolate::Current()->heap(); |
| 1105 Heap::Space space = heap->SpaceForAllocation(cls.id()); | 1106 Heap::Space space = Heap::SpaceForAllocation(cls.id()); |
| 1106 __ movq(RCX, Immediate(heap->TopAddress(space))); | 1107 __ movq(RCX, Immediate(heap->TopAddress(space))); |
| 1107 __ movq(RAX, Address(RCX, 0)); | 1108 __ movq(RAX, Address(RCX, 0)); |
| 1108 __ leaq(RBX, Address(RAX, instance_size)); | 1109 __ leaq(RBX, Address(RAX, instance_size)); |
| 1109 // Check if the allocation fits into the remaining space. | 1110 // Check if the allocation fits into the remaining space. |
| 1110 // RAX: potential new object start. | 1111 // RAX: potential new object start. |
| 1111 // RBX: potential next object start. | 1112 // RBX: potential next object start. |
| 1112 // RCX: heap top address. | 1113 // RCX: heap top address. |
| 1113 __ movq(R13, Immediate(heap->EndAddress(space))); | 1114 __ movq(R13, Immediate(heap->EndAddress(space))); |
| 1114 __ cmpq(RBX, Address(R13, 0)); | 1115 __ cmpq(RBX, Address(R13, 0)); |
| 1115 if (FLAG_use_slow_path) { | 1116 if (FLAG_use_slow_path) { |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 // Result: | 2184 // Result: |
| 2184 // RCX: entry point. | 2185 // RCX: entry point. |
| 2185 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2186 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 2186 EmitMegamorphicLookup(assembler, RDI, RBX, RCX); | 2187 EmitMegamorphicLookup(assembler, RDI, RBX, RCX); |
| 2187 __ ret(); | 2188 __ ret(); |
| 2188 } | 2189 } |
| 2189 | 2190 |
| 2190 } // namespace dart | 2191 } // namespace dart |
| 2191 | 2192 |
| 2192 #endif // defined TARGET_ARCH_X64 | 2193 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |