| 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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 } | 581 } |
| 582 __ cmpq(RDI, Immediate(0)); | 582 __ cmpq(RDI, Immediate(0)); |
| 583 __ j(LESS, &slow_case); | 583 __ j(LESS, &slow_case); |
| 584 // Check for maximum allowed length. | 584 // Check for maximum allowed length. |
| 585 const Immediate& max_len = | 585 const Immediate& max_len = |
| 586 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements))); | 586 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements))); |
| 587 __ cmpq(RDI, max_len); | 587 __ cmpq(RDI, max_len); |
| 588 __ j(GREATER, &slow_case); | 588 __ j(GREATER, &slow_case); |
| 589 | 589 |
| 590 // Check for allocation tracing. | 590 // Check for allocation tracing. |
| 591 __ MaybeTraceAllocation(kArrayCid, | 591 NOT_IN_PRODUCT(__ MaybeTraceAllocation(kArrayCid, |
| 592 &slow_case, | 592 &slow_case, |
| 593 Assembler::kFarJump); | 593 Assembler::kFarJump)); |
| 594 | 594 |
| 595 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; | 595 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; |
| 596 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi. | 596 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi. |
| 597 ASSERT(kSmiTagShift == 1); | 597 ASSERT(kSmiTagShift == 1); |
| 598 __ andq(RDI, Immediate(-kObjectAlignment)); | 598 __ andq(RDI, Immediate(-kObjectAlignment)); |
| 599 | 599 |
| 600 const intptr_t cid = kArrayCid; | 600 const intptr_t cid = kArrayCid; |
| 601 Heap::Space space = Heap::SpaceForAllocation(cid); | 601 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 602 __ movq(R13, Address(THR, Thread::heap_offset())); | 602 __ movq(R13, Address(THR, Thread::heap_offset())); |
| 603 __ movq(RAX, Address(R13, Heap::TopOffset(space))); | 603 __ movq(RAX, Address(R13, Heap::TopOffset(space))); |
| 604 | 604 |
| 605 // RDI: allocation size. | 605 // RDI: allocation size. |
| 606 __ movq(RCX, RAX); | 606 __ movq(RCX, RAX); |
| 607 __ addq(RCX, RDI); | 607 __ addq(RCX, RDI); |
| 608 __ j(CARRY, &slow_case); | 608 __ j(CARRY, &slow_case); |
| 609 | 609 |
| 610 // Check if the allocation fits into the remaining space. | 610 // Check if the allocation fits into the remaining space. |
| 611 // RAX: potential new object start. | 611 // RAX: potential new object start. |
| 612 // RCX: potential next object start. | 612 // RCX: potential next object start. |
| 613 // RDI: allocation size. | 613 // RDI: allocation size. |
| 614 // R13: heap. | 614 // R13: heap. |
| 615 __ cmpq(RCX, Address(R13, Heap::EndOffset(space))); | 615 __ cmpq(RCX, Address(R13, Heap::EndOffset(space))); |
| 616 __ j(ABOVE_EQUAL, &slow_case); | 616 __ j(ABOVE_EQUAL, &slow_case); |
| 617 | 617 |
| 618 // Successfully allocated the object(s), now update top to point to | 618 // Successfully allocated the object(s), now update top to point to |
| 619 // next object start and initialize the object. | 619 // next object start and initialize the object. |
| 620 __ movq(Address(R13, Heap::TopOffset(space)), RCX); | 620 __ movq(Address(R13, Heap::TopOffset(space)), RCX); |
| 621 __ addq(RAX, Immediate(kHeapObjectTag)); | 621 __ addq(RAX, Immediate(kHeapObjectTag)); |
| 622 __ UpdateAllocationStatsWithSize(cid, RDI, space); | 622 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, RDI, space)); |
| 623 // Initialize the tags. | 623 // Initialize the tags. |
| 624 // RAX: new object start as a tagged pointer. | 624 // RAX: new object start as a tagged pointer. |
| 625 // RDI: allocation size. | 625 // RDI: allocation size. |
| 626 { | 626 { |
| 627 Label size_tag_overflow, done; | 627 Label size_tag_overflow, done; |
| 628 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 628 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| 629 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 629 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
| 630 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); | 630 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); |
| 631 __ jmp(&done, Assembler::kNearJump); | 631 __ jmp(&done, Assembler::kNearJump); |
| 632 | 632 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 __ LoadObject(R9, Object::null_object()); | 836 __ LoadObject(R9, Object::null_object()); |
| 837 if (FLAG_inline_alloc) { | 837 if (FLAG_inline_alloc) { |
| 838 Label slow_case; | 838 Label slow_case; |
| 839 // First compute the rounded instance size. | 839 // First compute the rounded instance size. |
| 840 // R10: number of context variables. | 840 // R10: number of context variables. |
| 841 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); | 841 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); |
| 842 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); | 842 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); |
| 843 __ andq(R13, Immediate(-kObjectAlignment)); | 843 __ andq(R13, Immediate(-kObjectAlignment)); |
| 844 | 844 |
| 845 // Check for allocation tracing. | 845 // Check for allocation tracing. |
| 846 __ MaybeTraceAllocation(kContextCid, | 846 NOT_IN_PRODUCT(__ MaybeTraceAllocation(kContextCid, |
| 847 &slow_case, | 847 &slow_case, |
| 848 Assembler::kFarJump); | 848 Assembler::kFarJump)); |
| 849 | 849 |
| 850 // Now allocate the object. | 850 // Now allocate the object. |
| 851 // R10: number of context variables. | 851 // R10: number of context variables. |
| 852 const intptr_t cid = kContextCid; | 852 const intptr_t cid = kContextCid; |
| 853 Heap::Space space = Heap::SpaceForAllocation(cid); | 853 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 854 __ movq(RCX, Address(THR, Thread::heap_offset())); | 854 __ movq(RCX, Address(THR, Thread::heap_offset())); |
| 855 __ movq(RAX, Address(RCX, Heap::TopOffset(space))); | 855 __ movq(RAX, Address(RCX, Heap::TopOffset(space))); |
| 856 __ addq(R13, RAX); | 856 __ addq(R13, RAX); |
| 857 // Check if the allocation fits into the remaining space. | 857 // Check if the allocation fits into the remaining space. |
| 858 // RAX: potential new object. | 858 // RAX: potential new object. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 870 // next object start and initialize the object. | 870 // next object start and initialize the object. |
| 871 // RAX: new object. | 871 // RAX: new object. |
| 872 // R13: next object start. | 872 // R13: next object start. |
| 873 // R10: number of context variables. | 873 // R10: number of context variables. |
| 874 // RCX: heap. | 874 // RCX: heap. |
| 875 __ movq(Address(RCX, Heap::TopOffset(space)), R13); | 875 __ movq(Address(RCX, Heap::TopOffset(space)), R13); |
| 876 // R13: Size of allocation in bytes. | 876 // R13: Size of allocation in bytes. |
| 877 __ subq(R13, RAX); | 877 __ subq(R13, RAX); |
| 878 __ addq(RAX, Immediate(kHeapObjectTag)); | 878 __ addq(RAX, Immediate(kHeapObjectTag)); |
| 879 // Generate isolate-independent code to allow sharing between isolates. | 879 // Generate isolate-independent code to allow sharing between isolates. |
| 880 __ UpdateAllocationStatsWithSize(cid, R13, space); | 880 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, R13, space)); |
| 881 | 881 |
| 882 // Calculate the size tag. | 882 // Calculate the size tag. |
| 883 // RAX: new object. | 883 // RAX: new object. |
| 884 // R10: number of context variables. | 884 // R10: number of context variables. |
| 885 { | 885 { |
| 886 Label size_tag_overflow, done; | 886 Label size_tag_overflow, done; |
| 887 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); | 887 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); |
| 888 __ andq(R13, Immediate(-kObjectAlignment)); | 888 __ andq(R13, Immediate(-kObjectAlignment)); |
| 889 __ cmpq(R13, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 889 __ cmpq(R13, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| 890 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 890 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 // RAX: potential new object start. | 1061 // RAX: potential new object start. |
| 1062 // RBX: potential next object start. | 1062 // RBX: potential next object start. |
| 1063 // RCX: heap. | 1063 // RCX: heap. |
| 1064 __ cmpq(RBX, Address(RCX, Heap::EndOffset(space))); | 1064 __ cmpq(RBX, Address(RCX, Heap::EndOffset(space))); |
| 1065 if (FLAG_use_slow_path) { | 1065 if (FLAG_use_slow_path) { |
| 1066 __ jmp(&slow_case); | 1066 __ jmp(&slow_case); |
| 1067 } else { | 1067 } else { |
| 1068 __ j(ABOVE_EQUAL, &slow_case); | 1068 __ j(ABOVE_EQUAL, &slow_case); |
| 1069 } | 1069 } |
| 1070 __ movq(Address(RCX, Heap::TopOffset(space)), RBX); | 1070 __ movq(Address(RCX, Heap::TopOffset(space)), RBX); |
| 1071 __ UpdateAllocationStats(cls.id(), space); | 1071 NOT_IN_PRODUCT(__ UpdateAllocationStats(cls.id(), space)); |
| 1072 | 1072 |
| 1073 // RAX: new object start (untagged). | 1073 // RAX: new object start (untagged). |
| 1074 // RBX: next object start. | 1074 // RBX: next object start. |
| 1075 // RDX: new object type arguments (if is_cls_parameterized). | 1075 // RDX: new object type arguments (if is_cls_parameterized). |
| 1076 // Set the tags. | 1076 // Set the tags. |
| 1077 uword tags = 0; | 1077 uword tags = 0; |
| 1078 tags = RawObject::SizeTag::update(instance_size, tags); | 1078 tags = RawObject::SizeTag::update(instance_size, tags); |
| 1079 ASSERT(cls.id() != kIllegalCid); | 1079 ASSERT(cls.id() != kIllegalCid); |
| 1080 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1080 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 1081 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); | 1081 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 } | 2218 } |
| 2219 | 2219 |
| 2220 | 2220 |
| 2221 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { | 2221 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { |
| 2222 __ int3(); | 2222 __ int3(); |
| 2223 } | 2223 } |
| 2224 | 2224 |
| 2225 } // namespace dart | 2225 } // namespace dart |
| 2226 | 2226 |
| 2227 #endif // defined TARGET_ARCH_X64 | 2227 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |