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