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

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

Issue 284013002: Improve performance of stubcode based array allocation moving stub to isolate specific area. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intrinsifier_arm64.cc ('k') | runtime/vm/intrinsifier_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 // The intrinsic code below is executed before a method has built its frame. 5 // The intrinsic code below is executed before a method has built its frame.
6 // The return address is on the stack and the arguments below it. 6 // The return address is on the stack and the arguments below it.
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved.
8 // Each intrinsification method returns true if the corresponding 8 // Each intrinsification method returns true if the corresponding
9 // Dart method was intrinsified. 9 // Dart method was intrinsified.
10 10
(...skipping 10 matching lines...) Expand all
21 #include "vm/stub_code.h" 21 #include "vm/stub_code.h"
22 #include "vm/symbols.h" 22 #include "vm/symbols.h"
23 23
24 namespace dart { 24 namespace dart {
25 25
26 DECLARE_FLAG(bool, enable_type_checks); 26 DECLARE_FLAG(bool, enable_type_checks);
27 27
28 28
29 #define __ assembler-> 29 #define __ assembler->
30 30
31 void Intrinsifier::List_Allocate(Assembler* assembler) {
32 // This snippet of inlined code uses the following registers:
33 // EAX, EBX, EDI
34 // and the newly allocated object is returned in EAX.
35 const intptr_t kTypeArgumentsOffset = 2 * kWordSize;
36 const intptr_t kArrayLengthOffset = 1 * kWordSize;
37 Label fall_through;
38
39 // Compute the size to be allocated, it is based on the array length
40 // and is computed as:
41 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
42 __ movl(EDI, Address(ESP, kArrayLengthOffset)); // Array length.
43 // Check that length is a positive Smi.
44 __ testl(EDI, Immediate(kSmiTagMask));
45 __ j(NOT_ZERO, &fall_through);
46 __ cmpl(EDI, Immediate(0));
47 __ j(LESS, &fall_through);
48 // Check for maximum allowed length.
49 const Immediate& max_len =
50 Immediate(reinterpret_cast<int32_t>(Smi::New(Array::kMaxElements)));
51 __ cmpl(EDI, max_len);
52 __ j(GREATER, &fall_through);
53 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
54 __ leal(EDI, Address(EDI, TIMES_2, fixed_size)); // EDI is a Smi.
55 ASSERT(kSmiTagShift == 1);
56 __ andl(EDI, Immediate(-kObjectAlignment));
57
58 Isolate* isolate = Isolate::Current();
59 Heap* heap = isolate->heap();
60
61 __ movl(EAX, Address::Absolute(heap->TopAddress()));
62 __ movl(EBX, EAX);
63
64 // EDI: allocation size.
65 __ addl(EBX, EDI);
66 __ j(CARRY, &fall_through);
67
68 // Check if the allocation fits into the remaining space.
69 // EAX: potential new object start.
70 // EBX: potential next object start.
71 // EDI: allocation size.
72 __ cmpl(EBX, Address::Absolute(heap->EndAddress()));
73 __ j(ABOVE_EQUAL, &fall_through);
74
75 // Successfully allocated the object(s), now update top to point to
76 // next object start and initialize the object.
77 __ movl(Address::Absolute(heap->TopAddress()), EBX);
78 __ addl(EAX, Immediate(kHeapObjectTag));
79 __ UpdateAllocationStatsWithSize(kArrayCid, EDI, kNoRegister);
80
81 // Initialize the tags.
82 // EAX: new object start as a tagged pointer.
83 // EBX: new object end address.
84 // EDI: allocation size.
85 {
86 Label size_tag_overflow, done;
87 __ cmpl(EDI, Immediate(RawObject::SizeTag::kMaxSizeTag));
88 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump);
89 __ shll(EDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2));
90 __ jmp(&done, Assembler::kNearJump);
91
92 __ Bind(&size_tag_overflow);
93 __ movl(EDI, Immediate(0));
94 __ Bind(&done);
95
96 // Get the class index and insert it into the tags.
97 const Class& cls = Class::Handle(isolate->object_store()->array_class());
98 __ orl(EDI, Immediate(RawObject::ClassIdTag::encode(cls.id())));
99 __ movl(FieldAddress(EAX, Array::tags_offset()), EDI); // Tags.
100 }
101
102 // EAX: new object start as a tagged pointer.
103 // EBX: new object end address.
104 // Store the type argument field.
105 __ movl(EDI, Address(ESP, kTypeArgumentsOffset)); // type argument.
106 __ StoreIntoObjectNoBarrier(EAX,
107 FieldAddress(EAX, Array::type_arguments_offset()),
108 EDI);
109
110 // Set the length field.
111 __ movl(EDI, Address(ESP, kArrayLengthOffset)); // Array Length.
112 __ StoreIntoObjectNoBarrier(EAX,
113 FieldAddress(EAX, Array::length_offset()),
114 EDI);
115
116 // Initialize all array elements to raw_null.
117 // EAX: new object start as a tagged pointer.
118 // EBX: new object end address.
119 // EDI: iterator which initially points to the start of the variable
120 // data area to be initialized.
121 const Immediate& raw_null =
122 Immediate(reinterpret_cast<intptr_t>(Object::null()));
123 __ leal(EDI, FieldAddress(EAX, sizeof(RawArray)));
124 Label done;
125 Label init_loop;
126 __ Bind(&init_loop);
127 __ cmpl(EDI, EBX);
128 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump);
129 __ movl(Address(EDI, 0), raw_null);
130 __ addl(EDI, Immediate(kWordSize));
131 __ jmp(&init_loop, Assembler::kNearJump);
132 __ Bind(&done);
133 __ ret(); // returns the newly allocated object in EAX.
134
135 __ Bind(&fall_through);
136 }
137
138 31
139 void Intrinsifier::Array_getLength(Assembler* assembler) { 32 void Intrinsifier::Array_getLength(Assembler* assembler) {
140 __ movl(EAX, Address(ESP, + 1 * kWordSize)); 33 __ movl(EAX, Address(ESP, + 1 * kWordSize));
141 __ movl(EAX, FieldAddress(EAX, Array::length_offset())); 34 __ movl(EAX, FieldAddress(EAX, Array::length_offset()));
142 __ ret(); 35 __ ret();
143 } 36 }
144 37
145 38
146 void Intrinsifier::ImmutableList_getLength(Assembler* assembler) { 39 void Intrinsifier::ImmutableList_getLength(Assembler* assembler) {
147 return Array_getLength(assembler); 40 return Array_getLength(assembler);
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 static ScaleFactor GetScaleFactor(intptr_t size) { 445 static ScaleFactor GetScaleFactor(intptr_t size) {
553 switch (size) { 446 switch (size) {
554 case 1: return TIMES_1; 447 case 1: return TIMES_1;
555 case 2: return TIMES_2; 448 case 2: return TIMES_2;
556 case 4: return TIMES_4; 449 case 4: return TIMES_4;
557 case 8: return TIMES_8; 450 case 8: return TIMES_8;
558 case 16: return TIMES_16; 451 case 16: return TIMES_16;
559 } 452 }
560 UNREACHABLE(); 453 UNREACHABLE();
561 return static_cast<ScaleFactor>(0); 454 return static_cast<ScaleFactor>(0);
562 }; 455 }
563 456
564 457
565 #define TYPED_DATA_ALLOCATOR(clazz) \ 458 #define TYPED_DATA_ALLOCATOR(clazz) \
566 void Intrinsifier::TypedData_##clazz##_new(Assembler* assembler) { \ 459 void Intrinsifier::TypedData_##clazz##_new(Assembler* assembler) { \
567 intptr_t size = TypedData::ElementSizeInBytes(kTypedData##clazz##Cid); \ 460 intptr_t size = TypedData::ElementSizeInBytes(kTypedData##clazz##Cid); \
568 intptr_t max_len = TypedData::MaxElements(kTypedData##clazz##Cid); \ 461 intptr_t max_len = TypedData::MaxElements(kTypedData##clazz##Cid); \
569 ScaleFactor scale = GetScaleFactor(size); \ 462 ScaleFactor scale = GetScaleFactor(size); \
570 TYPED_ARRAY_ALLOCATION(TypedData, kTypedData##clazz##Cid, max_len, scale); \ 463 TYPED_ARRAY_ALLOCATION(TypedData, kTypedData##clazz##Cid, max_len, scale); \
571 } \ 464 } \
572 void Intrinsifier::TypedData_##clazz##_factory(Assembler* assembler) { \ 465 void Intrinsifier::TypedData_##clazz##_factory(Assembler* assembler) { \
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 Isolate::current_tag_offset()); 1675 Isolate::current_tag_offset());
1783 // Set return value to Isolate::current_tag_. 1676 // Set return value to Isolate::current_tag_.
1784 __ movl(EAX, current_tag_addr); 1677 __ movl(EAX, current_tag_addr);
1785 __ ret(); 1678 __ ret();
1786 } 1679 }
1787 1680
1788 #undef __ 1681 #undef __
1789 } // namespace dart 1682 } // namespace dart
1790 1683
1791 #endif // defined TARGET_ARCH_IA32 1684 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_arm64.cc ('k') | runtime/vm/intrinsifier_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698