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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 // Check for maximum allowed length. | 639 // Check for maximum allowed length. |
640 const Immediate& max_len = | 640 const Immediate& max_len = |
641 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements))); | 641 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements))); |
642 __ cmpq(RDI, max_len); | 642 __ cmpq(RDI, max_len); |
643 __ j(GREATER, &slow_case); | 643 __ j(GREATER, &slow_case); |
644 | 644 |
645 // Check for allocation tracing. | 645 // Check for allocation tracing. |
646 NOT_IN_PRODUCT( | 646 NOT_IN_PRODUCT( |
647 __ MaybeTraceAllocation(kArrayCid, &slow_case, Assembler::kFarJump)); | 647 __ MaybeTraceAllocation(kArrayCid, &slow_case, Assembler::kFarJump)); |
648 | 648 |
649 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; | 649 const intptr_t fixed_size_plus_alignment_padding = |
650 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi. | 650 sizeof(RawArray) + kObjectAlignment - 1; |
| 651 // RDI is a Smi. |
| 652 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size_plus_alignment_padding)); |
651 ASSERT(kSmiTagShift == 1); | 653 ASSERT(kSmiTagShift == 1); |
652 __ andq(RDI, Immediate(-kObjectAlignment)); | 654 __ andq(RDI, Immediate(-kObjectAlignment)); |
653 | 655 |
654 const intptr_t cid = kArrayCid; | 656 const intptr_t cid = kArrayCid; |
655 Heap::Space space = Heap::kNew; | 657 Heap::Space space = Heap::kNew; |
656 __ movq(R13, Address(THR, Thread::heap_offset())); | 658 __ movq(R13, Address(THR, Thread::heap_offset())); |
657 __ movq(RAX, Address(R13, Heap::TopOffset(space))); | 659 __ movq(RAX, Address(R13, Heap::TopOffset(space))); |
658 | 660 |
659 // RDI: allocation size. | 661 // RDI: allocation size. |
660 __ movq(RCX, RAX); | 662 __ movq(RCX, RAX); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 // Input: | 883 // Input: |
882 // R10: number of context variables. | 884 // R10: number of context variables. |
883 // Output: | 885 // Output: |
884 // RAX: new allocated RawContext object. | 886 // RAX: new allocated RawContext object. |
885 void StubCode::GenerateAllocateContextStub(Assembler* assembler) { | 887 void StubCode::GenerateAllocateContextStub(Assembler* assembler) { |
886 __ LoadObject(R9, Object::null_object()); | 888 __ LoadObject(R9, Object::null_object()); |
887 if (FLAG_inline_alloc) { | 889 if (FLAG_inline_alloc) { |
888 Label slow_case; | 890 Label slow_case; |
889 // First compute the rounded instance size. | 891 // First compute the rounded instance size. |
890 // R10: number of context variables. | 892 // R10: number of context variables. |
891 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); | 893 intptr_t fixed_size_plus_alignment_padding = |
892 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); | 894 (sizeof(RawContext) + kObjectAlignment - 1); |
| 895 __ leaq(R13, Address(R10, TIMES_8, fixed_size_plus_alignment_padding)); |
893 __ andq(R13, Immediate(-kObjectAlignment)); | 896 __ andq(R13, Immediate(-kObjectAlignment)); |
894 | 897 |
895 // Check for allocation tracing. | 898 // Check for allocation tracing. |
896 NOT_IN_PRODUCT( | 899 NOT_IN_PRODUCT( |
897 __ MaybeTraceAllocation(kContextCid, &slow_case, Assembler::kFarJump)); | 900 __ MaybeTraceAllocation(kContextCid, &slow_case, Assembler::kFarJump)); |
898 | 901 |
899 // Now allocate the object. | 902 // Now allocate the object. |
900 // R10: number of context variables. | 903 // R10: number of context variables. |
901 const intptr_t cid = kContextCid; | 904 const intptr_t cid = kContextCid; |
902 Heap::Space space = Heap::kNew; | 905 Heap::Space space = Heap::kNew; |
(...skipping 23 matching lines...) Expand all Loading... |
926 __ subq(R13, RAX); | 929 __ subq(R13, RAX); |
927 __ addq(RAX, Immediate(kHeapObjectTag)); | 930 __ addq(RAX, Immediate(kHeapObjectTag)); |
928 // Generate isolate-independent code to allow sharing between isolates. | 931 // Generate isolate-independent code to allow sharing between isolates. |
929 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, R13, space)); | 932 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, R13, space)); |
930 | 933 |
931 // Calculate the size tag. | 934 // Calculate the size tag. |
932 // RAX: new object. | 935 // RAX: new object. |
933 // R10: number of context variables. | 936 // R10: number of context variables. |
934 { | 937 { |
935 Label size_tag_overflow, done; | 938 Label size_tag_overflow, done; |
936 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); | 939 __ leaq(R13, Address(R10, TIMES_8, fixed_size_plus_alignment_padding)); |
937 __ andq(R13, Immediate(-kObjectAlignment)); | 940 __ andq(R13, Immediate(-kObjectAlignment)); |
938 __ cmpq(R13, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 941 __ cmpq(R13, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
939 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 942 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
940 __ shlq(R13, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); | 943 __ shlq(R13, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); |
941 __ jmp(&done); | 944 __ jmp(&done); |
942 | 945 |
943 __ Bind(&size_tag_overflow); | 946 __ Bind(&size_tag_overflow); |
944 // Set overflow size tag value. | 947 // Set overflow size tag value. |
945 __ movq(R13, Immediate(0)); | 948 __ movq(R13, Immediate(0)); |
946 | 949 |
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2235 | 2238 |
2236 | 2239 |
2237 // Called from switchable IC calls. | 2240 // Called from switchable IC calls. |
2238 // RDI: receiver | 2241 // RDI: receiver |
2239 // RBX: SingleTargetCache | 2242 // RBX: SingleTargetCache |
2240 // Passed to target:: | 2243 // Passed to target:: |
2241 // CODE_REG: target Code object | 2244 // CODE_REG: target Code object |
2242 void StubCode::GenerateSingleTargetCallStub(Assembler* assembler) { | 2245 void StubCode::GenerateSingleTargetCallStub(Assembler* assembler) { |
2243 Label miss; | 2246 Label miss; |
2244 __ LoadClassIdMayBeSmi(RAX, RDI); | 2247 __ LoadClassIdMayBeSmi(RAX, RDI); |
2245 __ movl(R9, FieldAddress(RBX, SingleTargetCache::lower_limit_offset())); | 2248 __ movzxw(R9, FieldAddress(RBX, SingleTargetCache::lower_limit_offset())); |
2246 __ movl(R10, FieldAddress(RBX, SingleTargetCache::upper_limit_offset())); | 2249 __ movzxw(R10, FieldAddress(RBX, SingleTargetCache::upper_limit_offset())); |
2247 __ cmpq(RAX, R9); | 2250 __ cmpq(RAX, R9); |
2248 __ j(LESS, &miss, Assembler::kNearJump); | 2251 __ j(LESS, &miss, Assembler::kNearJump); |
2249 __ cmpq(RAX, R10); | 2252 __ cmpq(RAX, R10); |
2250 __ j(GREATER, &miss, Assembler::kNearJump); | 2253 __ j(GREATER, &miss, Assembler::kNearJump); |
2251 __ movq(RCX, FieldAddress(RBX, SingleTargetCache::entry_point_offset())); | 2254 __ movq(RCX, FieldAddress(RBX, SingleTargetCache::entry_point_offset())); |
2252 __ movq(CODE_REG, FieldAddress(RBX, SingleTargetCache::target_offset())); | 2255 __ movq(CODE_REG, FieldAddress(RBX, SingleTargetCache::target_offset())); |
2253 __ jmp(RCX); | 2256 __ jmp(RCX); |
2254 | 2257 |
2255 __ Bind(&miss); | 2258 __ Bind(&miss); |
2256 __ EnterStubFrame(); | 2259 __ EnterStubFrame(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2298 } | 2301 } |
2299 | 2302 |
2300 | 2303 |
2301 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { | 2304 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { |
2302 __ int3(); | 2305 __ int3(); |
2303 } | 2306 } |
2304 | 2307 |
2305 } // namespace dart | 2308 } // namespace dart |
2306 | 2309 |
2307 #endif // defined TARGET_ARCH_X64 | 2310 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |