Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: runtime/vm/stub_code_ia32.cc

Issue 1241863002: VM: Refactor allocation stats code and remove duplicate code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/stub_code_arm64.cc ('k') | runtime/vm/stub_code_mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 __ leal(EDI, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi. 616 __ leal(EDI, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi.
617 ASSERT(kSmiTagShift == 1); 617 ASSERT(kSmiTagShift == 1);
618 __ andl(EDI, Immediate(-kObjectAlignment)); 618 __ andl(EDI, Immediate(-kObjectAlignment));
619 619
620 // ECX: array element type. 620 // ECX: array element type.
621 // EDX: array length as Smi. 621 // EDX: array length as Smi.
622 // EDI: allocation size. 622 // EDI: allocation size.
623 623
624 Heap* heap = isolate->heap(); 624 Heap* heap = isolate->heap();
625 const intptr_t cid = kArrayCid; 625 const intptr_t cid = kArrayCid;
626 Heap::Space space = heap->SpaceForAllocation(cid); 626 Heap::Space space = Heap::SpaceForAllocation(cid);
627 __ movl(EAX, Address::Absolute(heap->TopAddress(space))); 627 __ movl(EAX, Address::Absolute(heap->TopAddress(space)));
628 __ movl(EBX, EAX); 628 __ movl(EBX, EAX);
629 629
630 // EDI: allocation size. 630 // EDI: allocation size.
631 __ addl(EBX, EDI); 631 __ addl(EBX, EDI);
632 __ j(CARRY, &slow_case); 632 __ j(CARRY, &slow_case);
633 633
634 // Check if the allocation fits into the remaining space. 634 // Check if the allocation fits into the remaining space.
635 // EAX: potential new object start. 635 // EAX: potential new object start.
636 // EBX: potential next object start. 636 // EBX: potential next object start.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 // Input: 834 // Input:
835 // EDX: number of context variables. 835 // EDX: number of context variables.
836 // Output: 836 // Output:
837 // EAX: new allocated RawContext object. 837 // EAX: new allocated RawContext object.
838 // EBX and EDX are destroyed. 838 // EBX and EDX are destroyed.
839 void StubCode::GenerateAllocateContextStub(Assembler* assembler) { 839 void StubCode::GenerateAllocateContextStub(Assembler* assembler) {
840 const Immediate& raw_null = 840 const Immediate& raw_null =
841 Immediate(reinterpret_cast<intptr_t>(Object::null())); 841 Immediate(reinterpret_cast<intptr_t>(Object::null()));
842 if (FLAG_inline_alloc) { 842 if (FLAG_inline_alloc) {
843 Label slow_case; 843 Label slow_case;
844 Isolate* isolate = Isolate::Current();
845 Heap* heap = isolate->heap();
846 // First compute the rounded instance size. 844 // First compute the rounded instance size.
847 // EDX: number of context variables. 845 // EDX: number of context variables.
848 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); 846 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1);
849 __ leal(EBX, Address(EDX, TIMES_4, fixed_size)); 847 __ leal(EBX, Address(EDX, TIMES_4, fixed_size));
850 __ andl(EBX, Immediate(-kObjectAlignment)); 848 __ andl(EBX, Immediate(-kObjectAlignment));
851 849
852 // Now allocate the object. 850 // Now allocate the object.
853 // EDX: number of context variables. 851 // EDX: number of context variables.
854 const intptr_t cid = kContextCid; 852 const intptr_t cid = kContextCid;
855 Heap::Space space = heap->SpaceForAllocation(cid); 853 Heap::Space space = Heap::SpaceForAllocation(cid);
856 __ movl(EAX, Address::Absolute(heap->TopAddress(space))); 854 __ LoadIsolate(ECX);
855 __ movl(ECX, Address(ECX, Isolate::heap_offset()));
856 __ movl(EAX, Address(ECX, Heap::TopOffset(space)));
857 __ addl(EBX, EAX); 857 __ addl(EBX, EAX);
858 // Check if the allocation fits into the remaining space. 858 // Check if the allocation fits into the remaining space.
859 // EAX: potential new object. 859 // EAX: potential new object.
860 // EBX: potential next object start. 860 // EBX: potential next object start.
861 // EDX: number of context variables. 861 // EDX: number of context variables.
862 __ cmpl(EBX, Address::Absolute(heap->EndAddress(space))); 862 __ cmpl(EBX, Address(ECX, Heap::EndOffset(space)));
863 if (FLAG_use_slow_path) { 863 if (FLAG_use_slow_path) {
864 __ jmp(&slow_case); 864 __ jmp(&slow_case);
865 } else { 865 } else {
866 #if defined(DEBUG) 866 #if defined(DEBUG)
867 static const bool kJumpLength = Assembler::kFarJump; 867 static const bool kJumpLength = Assembler::kFarJump;
868 #else 868 #else
869 static const bool kJumpLength = Assembler::kNearJump; 869 static const bool kJumpLength = Assembler::kNearJump;
870 #endif // DEBUG 870 #endif // DEBUG
871 __ j(ABOVE_EQUAL, &slow_case, kJumpLength); 871 __ j(ABOVE_EQUAL, &slow_case, kJumpLength);
872 } 872 }
873 873
874 // Successfully allocated the object, now update top to point to 874 // Successfully allocated the object, now update top to point to
875 // next object start and initialize the object. 875 // next object start and initialize the object.
876 // EAX: new object. 876 // EAX: new object.
877 // EBX: next object start. 877 // EBX: next object start.
878 // EDX: number of context variables. 878 // EDX: number of context variables.
879 __ movl(Address::Absolute(heap->TopAddress(space)), EBX); 879 __ movl(Address(ECX, Heap::TopOffset(space)), EBX);
880 __ addl(EAX, Immediate(kHeapObjectTag)); 880 __ addl(EAX, Immediate(kHeapObjectTag));
881 // EBX: Size of allocation in bytes. 881 // EBX: Size of allocation in bytes.
882 __ subl(EBX, EAX); 882 __ subl(EBX, EAX);
883 __ UpdateAllocationStatsWithSize(cid, EBX, kNoRegister, space); 883 // Generate isolate-independent code to allow sharing between isolates.
884 __ UpdateAllocationStatsWithSize(cid, EBX, EDI, space,
885 /* inline_isolate = */ false);
884 886
885 // Calculate the size tag. 887 // Calculate the size tag.
886 // EAX: new object. 888 // EAX: new object.
887 // EDX: number of context variables. 889 // EDX: number of context variables.
888 { 890 {
889 Label size_tag_overflow, done; 891 Label size_tag_overflow, done;
890 __ leal(EBX, Address(EDX, TIMES_4, fixed_size)); 892 __ leal(EBX, Address(EDX, TIMES_4, fixed_size));
891 __ andl(EBX, Immediate(-kObjectAlignment)); 893 __ andl(EBX, Immediate(-kObjectAlignment));
892 __ cmpl(EBX, Immediate(RawObject::SizeTag::kMaxSizeTag)); 894 __ cmpl(EBX, Immediate(RawObject::SizeTag::kMaxSizeTag));
893 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); 895 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 __ movl(EDX, Address(ESP, kObjectTypeArgumentsOffset)); 1060 __ movl(EDX, Address(ESP, kObjectTypeArgumentsOffset));
1059 // EDX: instantiated type arguments. 1061 // EDX: instantiated type arguments.
1060 } 1062 }
1061 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && 1063 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) &&
1062 !cls.trace_allocation()) { 1064 !cls.trace_allocation()) {
1063 Label slow_case; 1065 Label slow_case;
1064 // Allocate the object and update top to point to 1066 // Allocate the object and update top to point to
1065 // next object start and initialize the allocated object. 1067 // next object start and initialize the allocated object.
1066 // EDX: instantiated type arguments (if is_cls_parameterized). 1068 // EDX: instantiated type arguments (if is_cls_parameterized).
1067 Heap* heap = Isolate::Current()->heap(); 1069 Heap* heap = Isolate::Current()->heap();
1068 Heap::Space space = heap->SpaceForAllocation(cls.id()); 1070 Heap::Space space = Heap::SpaceForAllocation(cls.id());
1069 __ movl(EAX, Address::Absolute(heap->TopAddress(space))); 1071 __ movl(EAX, Address::Absolute(heap->TopAddress(space)));
1070 __ leal(EBX, Address(EAX, instance_size)); 1072 __ leal(EBX, Address(EAX, instance_size));
1071 // Check if the allocation fits into the remaining space. 1073 // Check if the allocation fits into the remaining space.
1072 // EAX: potential new object start. 1074 // EAX: potential new object start.
1073 // EBX: potential next object start. 1075 // EBX: potential next object start.
1074 __ cmpl(EBX, Address::Absolute(heap->EndAddress(space))); 1076 __ cmpl(EBX, Address::Absolute(heap->EndAddress(space)));
1075 if (FLAG_use_slow_path) { 1077 if (FLAG_use_slow_path) {
1076 __ jmp(&slow_case); 1078 __ jmp(&slow_case);
1077 } else { 1079 } else {
1078 __ j(ABOVE_EQUAL, &slow_case); 1080 __ j(ABOVE_EQUAL, &slow_case);
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 // EBX: entry point. 2127 // EBX: entry point.
2126 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { 2128 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2127 EmitMegamorphicLookup(assembler, EDI, EBX, EBX); 2129 EmitMegamorphicLookup(assembler, EDI, EBX, EBX);
2128 __ ret(); 2130 __ ret();
2129 } 2131 }
2130 2132
2131 2133
2132 } // namespace dart 2134 } // namespace dart
2133 2135
2134 #endif // defined TARGET_ARCH_IA32 2136 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_arm64.cc ('k') | runtime/vm/stub_code_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698