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