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

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

Issue 475763002: VM: Small cleanup in optimizer and intrinsics code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // Allocate a GrowableObjectArray using the backing array specified. 136 // Allocate a GrowableObjectArray using the backing array specified.
137 // On stack: type argument (+2), data (+1), return-address (+0). 137 // On stack: type argument (+2), data (+1), return-address (+0).
138 void Intrinsifier::GrowableList_Allocate(Assembler* assembler) { 138 void Intrinsifier::GrowableList_Allocate(Assembler* assembler) {
139 // This snippet of inlined code uses the following registers: 139 // This snippet of inlined code uses the following registers:
140 // EAX, EBX 140 // EAX, EBX
141 // and the newly allocated object is returned in EAX. 141 // and the newly allocated object is returned in EAX.
142 const intptr_t kTypeArgumentsOffset = 2 * kWordSize; 142 const intptr_t kTypeArgumentsOffset = 2 * kWordSize;
143 const intptr_t kArrayOffset = 1 * kWordSize; 143 const intptr_t kArrayOffset = 1 * kWordSize;
144 Label fall_through; 144 Label fall_through;
145 145
146 // Compute the size to be allocated, it is based on the array length 146 // Try allocating in new space.
147 // and is computed as:
148 // RoundedAllocationSize(sizeof(RawGrowableObjectArray)) +
149 intptr_t fixed_size = GrowableObjectArray::InstanceSize();
150
151 Isolate* isolate = Isolate::Current();
152 Heap* heap = isolate->heap();
153
154 __ movl(EAX, Address::Absolute(heap->TopAddress()));
155 __ leal(EBX, Address(EAX, fixed_size));
156
157 // Check if the allocation fits into the remaining space.
158 // EAX: potential new backing array object start.
159 // EBX: potential next object start.
160 __ cmpl(EBX, Address::Absolute(heap->EndAddress()));
161 __ j(ABOVE_EQUAL, &fall_through);
162
163 // Successfully allocated the object(s), now update top to point to
164 // next object start and initialize the object.
165 __ movl(Address::Absolute(heap->TopAddress()), EBX);
166 __ addl(EAX, Immediate(kHeapObjectTag));
167
168 // Initialize the tags.
169 // EAX: new growable array object start as a tagged pointer.
170 const Class& cls = Class::Handle( 147 const Class& cls = Class::Handle(
171 isolate->object_store()->growable_object_array_class()); 148 Isolate::Current()->object_store()->growable_object_array_class());
172 uword tags = 0; 149 __ TryAllocate(cls, &fall_through, Assembler::kNearJump, EAX, EBX);
173 tags = RawObject::SizeTag::update(fixed_size, tags);
174 tags = RawObject::ClassIdTag::update(cls.id(), tags);
175 __ movl(FieldAddress(EAX, GrowableObjectArray::tags_offset()),
176 Immediate(tags));
177 150
178 // Store backing array object in growable array object. 151 // Store backing array object in growable array object.
179 __ movl(EBX, Address(ESP, kArrayOffset)); // data argument. 152 __ movl(EBX, Address(ESP, kArrayOffset)); // data argument.
180 // EAX is new, no barrier needed. 153 // EAX is new, no barrier needed.
181 __ StoreIntoObjectNoBarrier( 154 __ StoreIntoObjectNoBarrier(
182 EAX, 155 EAX,
183 FieldAddress(EAX, GrowableObjectArray::data_offset()), 156 FieldAddress(EAX, GrowableObjectArray::data_offset()),
184 EBX); 157 EBX);
185 158
186 // EAX: new growable array object start as a tagged pointer. 159 // EAX: new growable array object start as a tagged pointer.
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 Isolate::current_tag_offset()); 1748 Isolate::current_tag_offset());
1776 // Set return value to Isolate::current_tag_. 1749 // Set return value to Isolate::current_tag_.
1777 __ movl(EAX, current_tag_addr); 1750 __ movl(EAX, current_tag_addr);
1778 __ ret(); 1751 __ ret();
1779 } 1752 }
1780 1753
1781 #undef __ 1754 #undef __
1782 } // namespace dart 1755 } // namespace dart
1783 1756
1784 #endif // defined TARGET_ARCH_IA32 1757 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698