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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 | 657 |
658 const intptr_t fixed_size_plus_alignment_padding = | 658 const intptr_t fixed_size_plus_alignment_padding = |
659 sizeof(RawArray) + kObjectAlignment - 1; | 659 sizeof(RawArray) + kObjectAlignment - 1; |
660 // RDI is a Smi. | 660 // RDI is a Smi. |
661 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size_plus_alignment_padding)); | 661 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size_plus_alignment_padding)); |
662 ASSERT(kSmiTagShift == 1); | 662 ASSERT(kSmiTagShift == 1); |
663 __ andq(RDI, Immediate(-kObjectAlignment)); | 663 __ andq(RDI, Immediate(-kObjectAlignment)); |
664 | 664 |
665 const intptr_t cid = kArrayCid; | 665 const intptr_t cid = kArrayCid; |
666 Heap::Space space = Heap::kNew; | 666 Heap::Space space = Heap::kNew; |
667 __ movq(R13, Address(THR, Thread::heap_offset())); | 667 __ movq(RAX, Address(THR, Thread::top_offset())); |
668 __ movq(RAX, Address(R13, Heap::TopOffset(space))); | |
669 | 668 |
670 // RDI: allocation size. | 669 // RDI: allocation size. |
671 __ movq(RCX, RAX); | 670 __ movq(RCX, RAX); |
672 __ addq(RCX, RDI); | 671 __ addq(RCX, RDI); |
673 __ j(CARRY, &slow_case); | 672 __ j(CARRY, &slow_case); |
674 | 673 |
675 // Check if the allocation fits into the remaining space. | 674 // Check if the allocation fits into the remaining space. |
676 // RAX: potential new object start. | 675 // RAX: potential new object start. |
677 // RCX: potential next object start. | 676 // RCX: potential next object start. |
678 // RDI: allocation size. | 677 // RDI: allocation size. |
679 // R13: heap. | 678 // R13: heap. |
680 __ cmpq(RCX, Address(R13, Heap::EndOffset(space))); | 679 __ cmpq(RCX, Address(THR, Thread::end_offset())); |
681 __ j(ABOVE_EQUAL, &slow_case); | 680 __ j(ABOVE_EQUAL, &slow_case); |
682 | 681 |
683 // Successfully allocated the object(s), now update top to point to | 682 // Successfully allocated the object(s), now update top to point to |
684 // next object start and initialize the object. | 683 // next object start and initialize the object. |
685 __ movq(Address(R13, Heap::TopOffset(space)), RCX); | 684 __ movq(Address(THR, Thread::top_offset()), RCX); |
686 __ addq(RAX, Immediate(kHeapObjectTag)); | 685 __ addq(RAX, Immediate(kHeapObjectTag)); |
687 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, RDI, space)); | 686 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, RDI, space)); |
688 // Initialize the tags. | 687 // Initialize the tags. |
689 // RAX: new object start as a tagged pointer. | 688 // RAX: new object start as a tagged pointer. |
690 // RDI: allocation size. | 689 // RDI: allocation size. |
691 { | 690 { |
692 Label size_tag_overflow, done; | 691 Label size_tag_overflow, done; |
693 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 692 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
694 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 693 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
695 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); | 694 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 __ andq(R13, Immediate(-kObjectAlignment)); | 904 __ andq(R13, Immediate(-kObjectAlignment)); |
906 | 905 |
907 // Check for allocation tracing. | 906 // Check for allocation tracing. |
908 NOT_IN_PRODUCT( | 907 NOT_IN_PRODUCT( |
909 __ MaybeTraceAllocation(kContextCid, &slow_case, Assembler::kFarJump)); | 908 __ MaybeTraceAllocation(kContextCid, &slow_case, Assembler::kFarJump)); |
910 | 909 |
911 // Now allocate the object. | 910 // Now allocate the object. |
912 // R10: number of context variables. | 911 // R10: number of context variables. |
913 const intptr_t cid = kContextCid; | 912 const intptr_t cid = kContextCid; |
914 Heap::Space space = Heap::kNew; | 913 Heap::Space space = Heap::kNew; |
915 __ movq(RCX, Address(THR, Thread::heap_offset())); | 914 __ movq(RAX, Address(THR, Thread::top_offset())); |
916 __ movq(RAX, Address(RCX, Heap::TopOffset(space))); | |
917 __ addq(R13, RAX); | 915 __ addq(R13, RAX); |
918 // Check if the allocation fits into the remaining space. | 916 // Check if the allocation fits into the remaining space. |
919 // RAX: potential new object. | 917 // RAX: potential new object. |
920 // R13: potential next object start. | 918 // R13: potential next object start. |
921 // R10: number of context variables. | 919 // R10: number of context variables. |
922 // RCX: heap. | 920 // RCX: heap. |
923 __ cmpq(R13, Address(RCX, Heap::EndOffset(space))); | 921 __ cmpq(R13, Address(THR, Thread::end_offset())); |
924 if (FLAG_use_slow_path) { | 922 if (FLAG_use_slow_path) { |
925 __ jmp(&slow_case); | 923 __ jmp(&slow_case); |
926 } else { | 924 } else { |
927 __ j(ABOVE_EQUAL, &slow_case); | 925 __ j(ABOVE_EQUAL, &slow_case); |
928 } | 926 } |
929 | 927 |
930 // Successfully allocated the object, now update top to point to | 928 // Successfully allocated the object, now update top to point to |
931 // next object start and initialize the object. | 929 // next object start and initialize the object. |
932 // RAX: new object. | 930 // RAX: new object. |
933 // R13: next object start. | 931 // R13: next object start. |
934 // R10: number of context variables. | 932 // R10: number of context variables. |
935 // RCX: heap. | 933 // RCX: heap. |
936 __ movq(Address(RCX, Heap::TopOffset(space)), R13); | 934 __ movq(Address(THR, Thread::top_offset()), R13); |
937 // R13: Size of allocation in bytes. | 935 // R13: Size of allocation in bytes. |
938 __ subq(R13, RAX); | 936 __ subq(R13, RAX); |
939 __ addq(RAX, Immediate(kHeapObjectTag)); | 937 __ addq(RAX, Immediate(kHeapObjectTag)); |
940 // Generate isolate-independent code to allow sharing between isolates. | 938 // Generate isolate-independent code to allow sharing between isolates. |
941 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, R13, space)); | 939 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, R13, space)); |
942 | 940 |
943 // Calculate the size tag. | 941 // Calculate the size tag. |
944 // RAX: new object. | 942 // RAX: new object. |
945 // R10: number of context variables. | 943 // R10: number of context variables. |
946 { | 944 { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 // RDX: instantiated type arguments. | 1102 // RDX: instantiated type arguments. |
1105 } | 1103 } |
1106 Isolate* isolate = Isolate::Current(); | 1104 Isolate* isolate = Isolate::Current(); |
1107 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && | 1105 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && |
1108 !cls.TraceAllocation(isolate)) { | 1106 !cls.TraceAllocation(isolate)) { |
1109 Label slow_case; | 1107 Label slow_case; |
1110 // Allocate the object and update top to point to | 1108 // Allocate the object and update top to point to |
1111 // next object start and initialize the allocated object. | 1109 // next object start and initialize the allocated object. |
1112 // RDX: instantiated type arguments (if is_cls_parameterized). | 1110 // RDX: instantiated type arguments (if is_cls_parameterized). |
1113 Heap::Space space = Heap::kNew; | 1111 Heap::Space space = Heap::kNew; |
1114 __ movq(RCX, Address(THR, Thread::heap_offset())); | 1112 __ movq(RAX, Address(THR, Thread::top_offset())); |
1115 __ movq(RAX, Address(RCX, Heap::TopOffset(space))); | |
1116 __ leaq(RBX, Address(RAX, instance_size)); | 1113 __ leaq(RBX, Address(RAX, instance_size)); |
1117 // Check if the allocation fits into the remaining space. | 1114 // Check if the allocation fits into the remaining space. |
1118 // RAX: potential new object start. | 1115 // RAX: potential new object start. |
1119 // RBX: potential next object start. | 1116 // RBX: potential next object start. |
1120 // RCX: heap. | 1117 // RCX: heap. |
1121 __ cmpq(RBX, Address(RCX, Heap::EndOffset(space))); | 1118 __ cmpq(RBX, Address(THR, Thread::end_offset())); |
1122 if (FLAG_use_slow_path) { | 1119 if (FLAG_use_slow_path) { |
1123 __ jmp(&slow_case); | 1120 __ jmp(&slow_case); |
1124 } else { | 1121 } else { |
1125 __ j(ABOVE_EQUAL, &slow_case); | 1122 __ j(ABOVE_EQUAL, &slow_case); |
1126 } | 1123 } |
1127 __ movq(Address(RCX, Heap::TopOffset(space)), RBX); | 1124 __ movq(Address(THR, Thread::top_offset()), RBX); |
1128 NOT_IN_PRODUCT(__ UpdateAllocationStats(cls.id(), space)); | 1125 NOT_IN_PRODUCT(__ UpdateAllocationStats(cls.id(), space)); |
1129 | 1126 |
1130 // RAX: new object start (untagged). | 1127 // RAX: new object start (untagged). |
1131 // RBX: next object start. | 1128 // RBX: next object start. |
1132 // RDX: new object type arguments (if is_cls_parameterized). | 1129 // RDX: new object type arguments (if is_cls_parameterized). |
1133 // Set the tags. | 1130 // Set the tags. |
1134 uword tags = 0; | 1131 uword tags = 0; |
1135 tags = RawObject::SizeTag::update(instance_size, tags); | 1132 tags = RawObject::SizeTag::update(instance_size, tags); |
1136 ASSERT(cls.id() != kIllegalCid); | 1133 ASSERT(cls.id() != kIllegalCid); |
1137 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1134 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2319 } | 2316 } |
2320 | 2317 |
2321 | 2318 |
2322 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { | 2319 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { |
2323 __ int3(); | 2320 __ int3(); |
2324 } | 2321 } |
2325 | 2322 |
2326 } // namespace dart | 2323 } // namespace dart |
2327 | 2324 |
2328 #endif // defined TARGET_ARCH_X64 | 2325 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |