| 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 // EDX is Smi. | 594 // EDX is Smi. |
| 595 __ leal(EBX, Address(EDX, TIMES_2, fixed_size_plus_alignment_padding)); | 595 __ leal(EBX, Address(EDX, TIMES_2, fixed_size_plus_alignment_padding)); |
| 596 ASSERT(kSmiTagShift == 1); | 596 ASSERT(kSmiTagShift == 1); |
| 597 __ andl(EBX, Immediate(-kObjectAlignment)); | 597 __ andl(EBX, Immediate(-kObjectAlignment)); |
| 598 | 598 |
| 599 // ECX: array element type. | 599 // ECX: array element type. |
| 600 // EDX: array length as Smi. | 600 // EDX: array length as Smi. |
| 601 // EBX: allocation size. | 601 // EBX: allocation size. |
| 602 | 602 |
| 603 const intptr_t cid = kArrayCid; | 603 const intptr_t cid = kArrayCid; |
| 604 Heap::Space space = Heap::kNew; | 604 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
| 605 __ movl(EDI, Address(THR, Thread::heap_offset())); | 605 __ movl(EAX, Address(THR, Thread::top_offset())); |
| 606 __ movl(EAX, Address(EDI, Heap::TopOffset(space))); | |
| 607 __ addl(EBX, EAX); | 606 __ addl(EBX, EAX); |
| 608 __ j(CARRY, &slow_case); | 607 __ j(CARRY, &slow_case); |
| 609 | 608 |
| 610 // Check if the allocation fits into the remaining space. | 609 // Check if the allocation fits into the remaining space. |
| 611 // EAX: potential new object start. | 610 // EAX: potential new object start. |
| 612 // EBX: potential next object start. | 611 // EBX: potential next object start. |
| 613 // EDI: heap. | |
| 614 // ECX: array element type. | 612 // ECX: array element type. |
| 615 // EDX: array length as Smi). | 613 // EDX: array length as Smi). |
| 616 __ cmpl(EBX, Address(EDI, Heap::EndOffset(space))); | 614 __ cmpl(EBX, Address(THR, Thread::end_offset())); |
| 617 __ j(ABOVE_EQUAL, &slow_case); | 615 __ j(ABOVE_EQUAL, &slow_case); |
| 618 | 616 |
| 619 // Successfully allocated the object(s), now update top to point to | 617 // Successfully allocated the object(s), now update top to point to |
| 620 // next object start and initialize the object. | 618 // next object start and initialize the object. |
| 621 __ movl(Address(EDI, Heap::TopOffset(space)), EBX); | 619 __ movl(Address(THR, Thread::top_offset()), EBX); |
| 622 __ subl(EBX, EAX); | 620 __ subl(EBX, EAX); |
| 623 __ addl(EAX, Immediate(kHeapObjectTag)); | 621 __ addl(EAX, Immediate(kHeapObjectTag)); |
| 624 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, EBX, EDI, space)); | 622 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, EBX, EDI, space)); |
| 625 | 623 |
| 626 // Initialize the tags. | 624 // Initialize the tags. |
| 627 // EAX: new object start as a tagged pointer. | 625 // EAX: new object start as a tagged pointer. |
| 628 // EBX: allocation size. | 626 // EBX: allocation size. |
| 629 // ECX: array element type. | 627 // ECX: array element type. |
| 630 // EDX: array length as Smi. | 628 // EDX: array length as Smi. |
| 631 { | 629 { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 (sizeof(RawContext) + kObjectAlignment - 1); | 817 (sizeof(RawContext) + kObjectAlignment - 1); |
| 820 __ leal(EBX, Address(EDX, TIMES_4, fixed_size_plus_alignment_padding)); | 818 __ leal(EBX, Address(EDX, TIMES_4, fixed_size_plus_alignment_padding)); |
| 821 __ andl(EBX, Immediate(-kObjectAlignment)); | 819 __ andl(EBX, Immediate(-kObjectAlignment)); |
| 822 | 820 |
| 823 NOT_IN_PRODUCT(__ MaybeTraceAllocation(kContextCid, EAX, &slow_case, | 821 NOT_IN_PRODUCT(__ MaybeTraceAllocation(kContextCid, EAX, &slow_case, |
| 824 Assembler::kFarJump)); | 822 Assembler::kFarJump)); |
| 825 | 823 |
| 826 // Now allocate the object. | 824 // Now allocate the object. |
| 827 // EDX: number of context variables. | 825 // EDX: number of context variables. |
| 828 const intptr_t cid = kContextCid; | 826 const intptr_t cid = kContextCid; |
| 829 Heap::Space space = Heap::kNew; | 827 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
| 830 __ movl(ECX, Address(THR, Thread::heap_offset())); | 828 __ movl(EAX, Address(THR, Thread::top_offset())); |
| 831 __ movl(EAX, Address(ECX, Heap::TopOffset(space))); | |
| 832 __ addl(EBX, EAX); | 829 __ addl(EBX, EAX); |
| 833 // Check if the allocation fits into the remaining space. | 830 // Check if the allocation fits into the remaining space. |
| 834 // EAX: potential new object. | 831 // EAX: potential new object. |
| 835 // EBX: potential next object start. | 832 // EBX: potential next object start. |
| 836 // EDX: number of context variables. | 833 // EDX: number of context variables. |
| 837 __ cmpl(EBX, Address(ECX, Heap::EndOffset(space))); | 834 __ cmpl(EBX, Address(THR, Thread::end_offset())); |
| 838 if (FLAG_use_slow_path) { | 835 if (FLAG_use_slow_path) { |
| 839 __ jmp(&slow_case); | 836 __ jmp(&slow_case); |
| 840 } else { | 837 } else { |
| 841 #if defined(DEBUG) | 838 #if defined(DEBUG) |
| 842 static const bool kJumpLength = Assembler::kFarJump; | 839 static const bool kJumpLength = Assembler::kFarJump; |
| 843 #else | 840 #else |
| 844 static const bool kJumpLength = Assembler::kNearJump; | 841 static const bool kJumpLength = Assembler::kNearJump; |
| 845 #endif // DEBUG | 842 #endif // DEBUG |
| 846 __ j(ABOVE_EQUAL, &slow_case, kJumpLength); | 843 __ j(ABOVE_EQUAL, &slow_case, kJumpLength); |
| 847 } | 844 } |
| 848 | 845 |
| 849 // Successfully allocated the object, now update top to point to | 846 // Successfully allocated the object, now update top to point to |
| 850 // next object start and initialize the object. | 847 // next object start and initialize the object. |
| 851 // EAX: new object. | 848 // EAX: new object. |
| 852 // EBX: next object start. | 849 // EBX: next object start. |
| 853 // EDX: number of context variables. | 850 // EDX: number of context variables. |
| 854 __ movl(Address(ECX, Heap::TopOffset(space)), EBX); | 851 __ movl(Address(THR, Thread::top_offset()), EBX); |
| 855 // EBX: Size of allocation in bytes. | 852 // EBX: Size of allocation in bytes. |
| 856 __ subl(EBX, EAX); | 853 __ subl(EBX, EAX); |
| 857 __ addl(EAX, Immediate(kHeapObjectTag)); | 854 __ addl(EAX, Immediate(kHeapObjectTag)); |
| 858 // Generate isolate-independent code to allow sharing between isolates. | 855 // Generate isolate-independent code to allow sharing between isolates. |
| 859 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, EBX, EDI, space)); | 856 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, EBX, EDI, space)); |
| 860 | 857 |
| 861 // Calculate the size tag. | 858 // Calculate the size tag. |
| 862 // EAX: new object. | 859 // EAX: new object. |
| 863 // EDX: number of context variables. | 860 // EDX: number of context variables. |
| 864 { | 861 { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 __ movl(EDX, Address(ESP, kObjectTypeArgumentsOffset)); | 1024 __ movl(EDX, Address(ESP, kObjectTypeArgumentsOffset)); |
| 1028 // EDX: instantiated type arguments. | 1025 // EDX: instantiated type arguments. |
| 1029 } | 1026 } |
| 1030 Isolate* isolate = Isolate::Current(); | 1027 Isolate* isolate = Isolate::Current(); |
| 1031 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && | 1028 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && |
| 1032 !cls.TraceAllocation(isolate)) { | 1029 !cls.TraceAllocation(isolate)) { |
| 1033 Label slow_case; | 1030 Label slow_case; |
| 1034 // Allocate the object and update top to point to | 1031 // Allocate the object and update top to point to |
| 1035 // next object start and initialize the allocated object. | 1032 // next object start and initialize the allocated object. |
| 1036 // EDX: instantiated type arguments (if is_cls_parameterized). | 1033 // EDX: instantiated type arguments (if is_cls_parameterized). |
| 1037 Heap::Space space = Heap::kNew; | 1034 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
| 1038 __ movl(EDI, Address(THR, Thread::heap_offset())); | 1035 __ movl(EAX, Address(THR, Thread::top_offset())); |
| 1039 __ movl(EAX, Address(EDI, Heap::TopOffset(space))); | |
| 1040 __ leal(EBX, Address(EAX, instance_size)); | 1036 __ leal(EBX, Address(EAX, instance_size)); |
| 1041 // Check if the allocation fits into the remaining space. | 1037 // Check if the allocation fits into the remaining space. |
| 1042 // EAX: potential new object start. | 1038 // EAX: potential new object start. |
| 1043 // EBX: potential next object start. | 1039 // EBX: potential next object start. |
| 1044 // EDI: heap. | 1040 __ cmpl(EBX, Address(THR, Thread::end_offset())); |
| 1045 __ cmpl(EBX, Address(EDI, Heap::EndOffset(space))); | |
| 1046 if (FLAG_use_slow_path) { | 1041 if (FLAG_use_slow_path) { |
| 1047 __ jmp(&slow_case); | 1042 __ jmp(&slow_case); |
| 1048 } else { | 1043 } else { |
| 1049 __ j(ABOVE_EQUAL, &slow_case); | 1044 __ j(ABOVE_EQUAL, &slow_case); |
| 1050 } | 1045 } |
| 1051 __ movl(Address(EDI, Heap::TopOffset(space)), EBX); | 1046 __ movl(Address(THR, Thread::top_offset()), EBX); |
| 1052 NOT_IN_PRODUCT(__ UpdateAllocationStats(cls.id(), ECX, space)); | 1047 NOT_IN_PRODUCT(__ UpdateAllocationStats(cls.id(), ECX, space)); |
| 1053 | 1048 |
| 1054 // EAX: new object start (untagged). | 1049 // EAX: new object start (untagged). |
| 1055 // EBX: next object start. | 1050 // EBX: next object start. |
| 1056 // EDX: new object type arguments (if is_cls_parameterized). | 1051 // EDX: new object type arguments (if is_cls_parameterized). |
| 1057 // Set the tags. | 1052 // Set the tags. |
| 1058 uint32_t tags = 0; | 1053 uint32_t tags = 0; |
| 1059 tags = RawObject::SizeTag::update(instance_size, tags); | 1054 tags = RawObject::SizeTag::update(instance_size, tags); |
| 1060 ASSERT(cls.id() != kIllegalCid); | 1055 ASSERT(cls.id() != kIllegalCid); |
| 1061 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1056 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 __ int3(); | 2070 __ int3(); |
| 2076 } | 2071 } |
| 2077 | 2072 |
| 2078 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { | 2073 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { |
| 2079 __ int3(); | 2074 __ int3(); |
| 2080 } | 2075 } |
| 2081 | 2076 |
| 2082 } // namespace dart | 2077 } // namespace dart |
| 2083 | 2078 |
| 2084 #endif // defined TARGET_ARCH_IA32 | 2079 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |