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