| 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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 // EDX is Smi. | 613 // EDX is Smi. |
| 614 __ leal(EBX, Address(EDX, TIMES_2, fixed_size_plus_alignment_padding)); | 614 __ leal(EBX, Address(EDX, TIMES_2, fixed_size_plus_alignment_padding)); |
| 615 ASSERT(kSmiTagShift == 1); | 615 ASSERT(kSmiTagShift == 1); |
| 616 __ andl(EBX, Immediate(-kObjectAlignment)); | 616 __ andl(EBX, Immediate(-kObjectAlignment)); |
| 617 | 617 |
| 618 // ECX: array element type. | 618 // ECX: array element type. |
| 619 // EDX: array length as Smi. | 619 // EDX: array length as Smi. |
| 620 // EBX: allocation size. | 620 // EBX: allocation size. |
| 621 | 621 |
| 622 const intptr_t cid = kArrayCid; | 622 const intptr_t cid = kArrayCid; |
| 623 Heap::Space space = Heap::kNew; | 623 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
| 624 __ movl(EDI, Address(THR, Thread::heap_offset())); | 624 __ movl(EAX, Address(THR, Thread::top_offset())); |
| 625 __ movl(EAX, Address(EDI, Heap::TopOffset(space))); | |
| 626 __ addl(EBX, EAX); | 625 __ addl(EBX, EAX); |
| 627 __ j(CARRY, &slow_case); | 626 __ j(CARRY, &slow_case); |
| 628 | 627 |
| 629 // Check if the allocation fits into the remaining space. | 628 // Check if the allocation fits into the remaining space. |
| 630 // EAX: potential new object start. | 629 // EAX: potential new object start. |
| 631 // EBX: potential next object start. | 630 // EBX: potential next object start. |
| 632 // EDI: heap. | |
| 633 // ECX: array element type. | 631 // ECX: array element type. |
| 634 // EDX: array length as Smi). | 632 // EDX: array length as Smi). |
| 635 __ cmpl(EBX, Address(EDI, Heap::EndOffset(space))); | 633 __ cmpl(EBX, Address(THR, Thread::end_offset())); |
| 636 __ j(ABOVE_EQUAL, &slow_case); | 634 __ j(ABOVE_EQUAL, &slow_case); |
| 637 | 635 |
| 638 // Successfully allocated the object(s), now update top to point to | 636 // Successfully allocated the object(s), now update top to point to |
| 639 // next object start and initialize the object. | 637 // next object start and initialize the object. |
| 640 __ movl(Address(EDI, Heap::TopOffset(space)), EBX); | 638 __ movl(Address(THR, Thread::top_offset()), EBX); |
| 641 __ subl(EBX, EAX); | 639 __ subl(EBX, EAX); |
| 642 __ addl(EAX, Immediate(kHeapObjectTag)); | 640 __ addl(EAX, Immediate(kHeapObjectTag)); |
| 643 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, EBX, EDI, space)); | 641 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, EBX, EDI, space)); |
| 644 | 642 |
| 645 // Initialize the tags. | 643 // Initialize the tags. |
| 646 // EAX: new object start as a tagged pointer. | 644 // EAX: new object start as a tagged pointer. |
| 647 // EBX: allocation size. | 645 // EBX: allocation size. |
| 648 // ECX: array element type. | 646 // ECX: array element type. |
| 649 // EDX: array length as Smi. | 647 // EDX: array length as Smi. |
| 650 { | 648 { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 (sizeof(RawContext) + kObjectAlignment - 1); | 838 (sizeof(RawContext) + kObjectAlignment - 1); |
| 841 __ leal(EBX, Address(EDX, TIMES_4, fixed_size_plus_alignment_padding)); | 839 __ leal(EBX, Address(EDX, TIMES_4, fixed_size_plus_alignment_padding)); |
| 842 __ andl(EBX, Immediate(-kObjectAlignment)); | 840 __ andl(EBX, Immediate(-kObjectAlignment)); |
| 843 | 841 |
| 844 NOT_IN_PRODUCT(__ MaybeTraceAllocation(kContextCid, EAX, &slow_case, | 842 NOT_IN_PRODUCT(__ MaybeTraceAllocation(kContextCid, EAX, &slow_case, |
| 845 Assembler::kFarJump)); | 843 Assembler::kFarJump)); |
| 846 | 844 |
| 847 // Now allocate the object. | 845 // Now allocate the object. |
| 848 // EDX: number of context variables. | 846 // EDX: number of context variables. |
| 849 const intptr_t cid = kContextCid; | 847 const intptr_t cid = kContextCid; |
| 850 Heap::Space space = Heap::kNew; | 848 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
| 851 __ movl(ECX, Address(THR, Thread::heap_offset())); | 849 __ movl(EAX, Address(THR, Thread::top_offset())); |
| 852 __ movl(EAX, Address(ECX, Heap::TopOffset(space))); | |
| 853 __ addl(EBX, EAX); | 850 __ addl(EBX, EAX); |
| 854 // Check if the allocation fits into the remaining space. | 851 // Check if the allocation fits into the remaining space. |
| 855 // EAX: potential new object. | 852 // EAX: potential new object. |
| 856 // EBX: potential next object start. | 853 // EBX: potential next object start. |
| 857 // EDX: number of context variables. | 854 // EDX: number of context variables. |
| 858 __ cmpl(EBX, Address(ECX, Heap::EndOffset(space))); | 855 __ cmpl(EBX, Address(THR, Thread::end_offset())); |
| 859 if (FLAG_use_slow_path) { | 856 if (FLAG_use_slow_path) { |
| 860 __ jmp(&slow_case); | 857 __ jmp(&slow_case); |
| 861 } else { | 858 } else { |
| 862 #if defined(DEBUG) | 859 #if defined(DEBUG) |
| 863 static const bool kJumpLength = Assembler::kFarJump; | 860 static const bool kJumpLength = Assembler::kFarJump; |
| 864 #else | 861 #else |
| 865 static const bool kJumpLength = Assembler::kNearJump; | 862 static const bool kJumpLength = Assembler::kNearJump; |
| 866 #endif // DEBUG | 863 #endif // DEBUG |
| 867 __ j(ABOVE_EQUAL, &slow_case, kJumpLength); | 864 __ j(ABOVE_EQUAL, &slow_case, kJumpLength); |
| 868 } | 865 } |
| 869 | 866 |
| 870 // Successfully allocated the object, now update top to point to | 867 // Successfully allocated the object, now update top to point to |
| 871 // next object start and initialize the object. | 868 // next object start and initialize the object. |
| 872 // EAX: new object. | 869 // EAX: new object. |
| 873 // EBX: next object start. | 870 // EBX: next object start. |
| 874 // EDX: number of context variables. | 871 // EDX: number of context variables. |
| 875 __ movl(Address(ECX, Heap::TopOffset(space)), EBX); | 872 __ movl(Address(THR, Thread::top_offset()), EBX); |
| 876 // EBX: Size of allocation in bytes. | 873 // EBX: Size of allocation in bytes. |
| 877 __ subl(EBX, EAX); | 874 __ subl(EBX, EAX); |
| 878 __ addl(EAX, Immediate(kHeapObjectTag)); | 875 __ addl(EAX, Immediate(kHeapObjectTag)); |
| 879 // Generate isolate-independent code to allow sharing between isolates. | 876 // Generate isolate-independent code to allow sharing between isolates. |
| 880 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, EBX, EDI, space)); | 877 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, EBX, EDI, space)); |
| 881 | 878 |
| 882 // Calculate the size tag. | 879 // Calculate the size tag. |
| 883 // EAX: new object. | 880 // EAX: new object. |
| 884 // EDX: number of context variables. | 881 // EDX: number of context variables. |
| 885 { | 882 { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 __ movl(EDX, Address(ESP, kObjectTypeArgumentsOffset)); | 1047 __ movl(EDX, Address(ESP, kObjectTypeArgumentsOffset)); |
| 1051 // EDX: instantiated type arguments. | 1048 // EDX: instantiated type arguments. |
| 1052 } | 1049 } |
| 1053 Isolate* isolate = Isolate::Current(); | 1050 Isolate* isolate = Isolate::Current(); |
| 1054 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && | 1051 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && |
| 1055 !cls.TraceAllocation(isolate)) { | 1052 !cls.TraceAllocation(isolate)) { |
| 1056 Label slow_case; | 1053 Label slow_case; |
| 1057 // Allocate the object and update top to point to | 1054 // Allocate the object and update top to point to |
| 1058 // next object start and initialize the allocated object. | 1055 // next object start and initialize the allocated object. |
| 1059 // EDX: instantiated type arguments (if is_cls_parameterized). | 1056 // EDX: instantiated type arguments (if is_cls_parameterized). |
| 1060 Heap::Space space = Heap::kNew; | 1057 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
| 1061 __ movl(EDI, Address(THR, Thread::heap_offset())); | 1058 __ movl(EAX, Address(THR, Thread::top_offset())); |
| 1062 __ movl(EAX, Address(EDI, Heap::TopOffset(space))); | |
| 1063 __ leal(EBX, Address(EAX, instance_size)); | 1059 __ leal(EBX, Address(EAX, instance_size)); |
| 1064 // Check if the allocation fits into the remaining space. | 1060 // Check if the allocation fits into the remaining space. |
| 1065 // EAX: potential new object start. | 1061 // EAX: potential new object start. |
| 1066 // EBX: potential next object start. | 1062 // EBX: potential next object start. |
| 1067 // EDI: heap. | 1063 __ cmpl(EBX, Address(THR, Thread::end_offset())); |
| 1068 __ cmpl(EBX, Address(EDI, Heap::EndOffset(space))); | |
| 1069 if (FLAG_use_slow_path) { | 1064 if (FLAG_use_slow_path) { |
| 1070 __ jmp(&slow_case); | 1065 __ jmp(&slow_case); |
| 1071 } else { | 1066 } else { |
| 1072 __ j(ABOVE_EQUAL, &slow_case); | 1067 __ j(ABOVE_EQUAL, &slow_case); |
| 1073 } | 1068 } |
| 1074 __ movl(Address(EDI, Heap::TopOffset(space)), EBX); | 1069 __ movl(Address(THR, Thread::top_offset()), EBX); |
| 1075 NOT_IN_PRODUCT(__ UpdateAllocationStats(cls.id(), ECX, space)); | 1070 NOT_IN_PRODUCT(__ UpdateAllocationStats(cls.id(), ECX, space)); |
| 1076 | 1071 |
| 1077 // EAX: new object start (untagged). | 1072 // EAX: new object start (untagged). |
| 1078 // EBX: next object start. | 1073 // EBX: next object start. |
| 1079 // EDX: new object type arguments (if is_cls_parameterized). | 1074 // EDX: new object type arguments (if is_cls_parameterized). |
| 1080 // Set the tags. | 1075 // Set the tags. |
| 1081 uint32_t tags = 0; | 1076 uint32_t tags = 0; |
| 1082 tags = RawObject::SizeTag::update(instance_size, tags); | 1077 tags = RawObject::SizeTag::update(instance_size, tags); |
| 1083 ASSERT(cls.id() != kIllegalCid); | 1078 ASSERT(cls.id() != kIllegalCid); |
| 1084 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1079 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 } | 2131 } |
| 2137 | 2132 |
| 2138 | 2133 |
| 2139 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { | 2134 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { |
| 2140 __ int3(); | 2135 __ int3(); |
| 2141 } | 2136 } |
| 2142 | 2137 |
| 2143 } // namespace dart | 2138 } // namespace dart |
| 2144 | 2139 |
| 2145 #endif // defined TARGET_ARCH_IA32 | 2140 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |