| 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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 // Check for maximum allowed length. | 648 // Check for maximum allowed length. |
| 649 const Immediate& max_len = | 649 const Immediate& max_len = |
| 650 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements))); | 650 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements))); |
| 651 __ cmpq(RDI, max_len); | 651 __ cmpq(RDI, max_len); |
| 652 __ j(GREATER, &slow_case); | 652 __ j(GREATER, &slow_case); |
| 653 | 653 |
| 654 // Check for allocation tracing. | 654 // Check for allocation tracing. |
| 655 NOT_IN_PRODUCT( | 655 NOT_IN_PRODUCT( |
| 656 __ MaybeTraceAllocation(kArrayCid, &slow_case, Assembler::kFarJump)); | 656 __ MaybeTraceAllocation(kArrayCid, &slow_case, Assembler::kFarJump)); |
| 657 | 657 |
| 658 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; | 658 const intptr_t fixed_size_plus_alignment_padding = |
| 659 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi. | 659 sizeof(RawArray) + kObjectAlignment - 1; |
| 660 // RDI is a Smi. |
| 661 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size_plus_alignment_padding)); |
| 660 ASSERT(kSmiTagShift == 1); | 662 ASSERT(kSmiTagShift == 1); |
| 661 __ andq(RDI, Immediate(-kObjectAlignment)); | 663 __ andq(RDI, Immediate(-kObjectAlignment)); |
| 662 | 664 |
| 663 const intptr_t cid = kArrayCid; | 665 const intptr_t cid = kArrayCid; |
| 664 Heap::Space space = Heap::kNew; | 666 Heap::Space space = Heap::kNew; |
| 665 __ movq(R13, Address(THR, Thread::heap_offset())); | 667 __ movq(R13, Address(THR, Thread::heap_offset())); |
| 666 __ movq(RAX, Address(R13, Heap::TopOffset(space))); | 668 __ movq(RAX, Address(R13, Heap::TopOffset(space))); |
| 667 | 669 |
| 668 // RDI: allocation size. | 670 // RDI: allocation size. |
| 669 __ movq(RCX, RAX); | 671 __ movq(RCX, RAX); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 // Input: | 892 // Input: |
| 891 // R10: number of context variables. | 893 // R10: number of context variables. |
| 892 // Output: | 894 // Output: |
| 893 // RAX: new allocated RawContext object. | 895 // RAX: new allocated RawContext object. |
| 894 void StubCode::GenerateAllocateContextStub(Assembler* assembler) { | 896 void StubCode::GenerateAllocateContextStub(Assembler* assembler) { |
| 895 __ LoadObject(R9, Object::null_object()); | 897 __ LoadObject(R9, Object::null_object()); |
| 896 if (FLAG_inline_alloc) { | 898 if (FLAG_inline_alloc) { |
| 897 Label slow_case; | 899 Label slow_case; |
| 898 // First compute the rounded instance size. | 900 // First compute the rounded instance size. |
| 899 // R10: number of context variables. | 901 // R10: number of context variables. |
| 900 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); | 902 intptr_t fixed_size_plus_alignment_padding = |
| 901 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); | 903 (sizeof(RawContext) + kObjectAlignment - 1); |
| 904 __ leaq(R13, Address(R10, TIMES_8, fixed_size_plus_alignment_padding)); |
| 902 __ andq(R13, Immediate(-kObjectAlignment)); | 905 __ andq(R13, Immediate(-kObjectAlignment)); |
| 903 | 906 |
| 904 // Check for allocation tracing. | 907 // Check for allocation tracing. |
| 905 NOT_IN_PRODUCT( | 908 NOT_IN_PRODUCT( |
| 906 __ MaybeTraceAllocation(kContextCid, &slow_case, Assembler::kFarJump)); | 909 __ MaybeTraceAllocation(kContextCid, &slow_case, Assembler::kFarJump)); |
| 907 | 910 |
| 908 // Now allocate the object. | 911 // Now allocate the object. |
| 909 // R10: number of context variables. | 912 // R10: number of context variables. |
| 910 const intptr_t cid = kContextCid; | 913 const intptr_t cid = kContextCid; |
| 911 Heap::Space space = Heap::kNew; | 914 Heap::Space space = Heap::kNew; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 935 __ subq(R13, RAX); | 938 __ subq(R13, RAX); |
| 936 __ addq(RAX, Immediate(kHeapObjectTag)); | 939 __ addq(RAX, Immediate(kHeapObjectTag)); |
| 937 // Generate isolate-independent code to allow sharing between isolates. | 940 // Generate isolate-independent code to allow sharing between isolates. |
| 938 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, R13, space)); | 941 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, R13, space)); |
| 939 | 942 |
| 940 // Calculate the size tag. | 943 // Calculate the size tag. |
| 941 // RAX: new object. | 944 // RAX: new object. |
| 942 // R10: number of context variables. | 945 // R10: number of context variables. |
| 943 { | 946 { |
| 944 Label size_tag_overflow, done; | 947 Label size_tag_overflow, done; |
| 945 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); | 948 __ leaq(R13, Address(R10, TIMES_8, fixed_size_plus_alignment_padding)); |
| 946 __ andq(R13, Immediate(-kObjectAlignment)); | 949 __ andq(R13, Immediate(-kObjectAlignment)); |
| 947 __ cmpq(R13, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 950 __ cmpq(R13, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| 948 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 951 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
| 949 __ shlq(R13, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); | 952 __ shlq(R13, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); |
| 950 __ jmp(&done); | 953 __ jmp(&done); |
| 951 | 954 |
| 952 __ Bind(&size_tag_overflow); | 955 __ Bind(&size_tag_overflow); |
| 953 // Set overflow size tag value. | 956 // Set overflow size tag value. |
| 954 __ movq(R13, Immediate(0)); | 957 __ movq(R13, Immediate(0)); |
| 955 | 958 |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 | 2256 |
| 2254 | 2257 |
| 2255 // Called from switchable IC calls. | 2258 // Called from switchable IC calls. |
| 2256 // RDI: receiver | 2259 // RDI: receiver |
| 2257 // RBX: SingleTargetCache | 2260 // RBX: SingleTargetCache |
| 2258 // Passed to target:: | 2261 // Passed to target:: |
| 2259 // CODE_REG: target Code object | 2262 // CODE_REG: target Code object |
| 2260 void StubCode::GenerateSingleTargetCallStub(Assembler* assembler) { | 2263 void StubCode::GenerateSingleTargetCallStub(Assembler* assembler) { |
| 2261 Label miss; | 2264 Label miss; |
| 2262 __ LoadClassIdMayBeSmi(RAX, RDI); | 2265 __ LoadClassIdMayBeSmi(RAX, RDI); |
| 2263 __ movl(R9, FieldAddress(RBX, SingleTargetCache::lower_limit_offset())); | 2266 __ movzxw(R9, FieldAddress(RBX, SingleTargetCache::lower_limit_offset())); |
| 2264 __ movl(R10, FieldAddress(RBX, SingleTargetCache::upper_limit_offset())); | 2267 __ movzxw(R10, FieldAddress(RBX, SingleTargetCache::upper_limit_offset())); |
| 2265 __ cmpq(RAX, R9); | 2268 __ cmpq(RAX, R9); |
| 2266 __ j(LESS, &miss, Assembler::kNearJump); | 2269 __ j(LESS, &miss, Assembler::kNearJump); |
| 2267 __ cmpq(RAX, R10); | 2270 __ cmpq(RAX, R10); |
| 2268 __ j(GREATER, &miss, Assembler::kNearJump); | 2271 __ j(GREATER, &miss, Assembler::kNearJump); |
| 2269 __ movq(RCX, FieldAddress(RBX, SingleTargetCache::entry_point_offset())); | 2272 __ movq(RCX, FieldAddress(RBX, SingleTargetCache::entry_point_offset())); |
| 2270 __ movq(CODE_REG, FieldAddress(RBX, SingleTargetCache::target_offset())); | 2273 __ movq(CODE_REG, FieldAddress(RBX, SingleTargetCache::target_offset())); |
| 2271 __ jmp(RCX); | 2274 __ jmp(RCX); |
| 2272 | 2275 |
| 2273 __ Bind(&miss); | 2276 __ Bind(&miss); |
| 2274 __ EnterStubFrame(); | 2277 __ EnterStubFrame(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2316 } | 2319 } |
| 2317 | 2320 |
| 2318 | 2321 |
| 2319 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { | 2322 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { |
| 2320 __ int3(); | 2323 __ int3(); |
| 2321 } | 2324 } |
| 2322 | 2325 |
| 2323 } // namespace dart | 2326 } // namespace dart |
| 2324 | 2327 |
| 2325 #endif // defined TARGET_ARCH_X64 | 2328 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |