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

Side by Side Diff: src/ia32/builtins-ia32.cc

Issue 174524: Add allocation support to ia32 macro assembler (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 3 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 | « no previous file | src/ia32/codegen-ia32.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 // Now allocate the JSObject on the heap. 127 // Now allocate the JSObject on the heap.
128 // edi: constructor 128 // edi: constructor
129 // eax: initial map 129 // eax: initial map
130 __ movzx_b(edi, FieldOperand(eax, Map::kInstanceSizeOffset)); 130 __ movzx_b(edi, FieldOperand(eax, Map::kInstanceSizeOffset));
131 __ shl(edi, kPointerSizeLog2); 131 __ shl(edi, kPointerSizeLog2);
132 // Make sure that the maximum heap object size will never cause us 132 // Make sure that the maximum heap object size will never cause us
133 // problem here, because it is always greater than the maximum 133 // problem here, because it is always greater than the maximum
134 // instance size that can be represented in a byte. 134 // instance size that can be represented in a byte.
135 ASSERT(Heap::MaxObjectSizeInPagedSpace() >= JSObject::kMaxInstanceSize); 135 ASSERT(Heap::MaxObjectSizeInPagedSpace() >= JSObject::kMaxInstanceSize);
136 ExternalReference new_space_allocation_top = 136 __ AllocateObjectInNewSpace(edi, ebx, edi, no_reg, &rt_call, false);
137 ExternalReference::new_space_allocation_top_address();
138 __ mov(ebx, Operand::StaticVariable(new_space_allocation_top));
139 __ add(edi, Operand(ebx)); // Calculate new top
140 ExternalReference new_space_allocation_limit =
141 ExternalReference::new_space_allocation_limit_address();
142 __ cmp(edi, Operand::StaticVariable(new_space_allocation_limit));
143 __ j(above_equal, &rt_call);
144 // Allocated the JSObject, now initialize the fields. 137 // Allocated the JSObject, now initialize the fields.
145 // eax: initial map 138 // eax: initial map
146 // ebx: JSObject 139 // ebx: JSObject
147 // edi: start of next object 140 // edi: start of next object
148 __ mov(Operand(ebx, JSObject::kMapOffset), eax); 141 __ mov(Operand(ebx, JSObject::kMapOffset), eax);
149 __ mov(ecx, Factory::empty_fixed_array()); 142 __ mov(ecx, Factory::empty_fixed_array());
150 __ mov(Operand(ebx, JSObject::kPropertiesOffset), ecx); 143 __ mov(Operand(ebx, JSObject::kPropertiesOffset), ecx);
151 __ mov(Operand(ebx, JSObject::kElementsOffset), ecx); 144 __ mov(Operand(ebx, JSObject::kElementsOffset), ecx);
152 // Set extra fields in the newly allocated object. 145 // Set extra fields in the newly allocated object.
153 // eax: initial map 146 // eax: initial map
(...skipping 12 matching lines...) Expand all
166 } 159 }
167 160
168 // Mostly done with the JSObject. Add the heap tag and store the new top, so 161 // Mostly done with the JSObject. Add the heap tag and store the new top, so
169 // that we can continue and jump into the continuation code at any time from 162 // that we can continue and jump into the continuation code at any time from
170 // now on. Any failures need to undo the setting of the new top, so that the 163 // now on. Any failures need to undo the setting of the new top, so that the
171 // heap is in a consistent state and verifiable. 164 // heap is in a consistent state and verifiable.
172 // eax: initial map 165 // eax: initial map
173 // ebx: JSObject 166 // ebx: JSObject
174 // edi: start of next object 167 // edi: start of next object
175 __ or_(Operand(ebx), Immediate(kHeapObjectTag)); 168 __ or_(Operand(ebx), Immediate(kHeapObjectTag));
176 __ mov(Operand::StaticVariable(new_space_allocation_top), edi);
177 169
178 // Check if a non-empty properties array is needed. 170 // Check if a non-empty properties array is needed.
179 // Allocate and initialize a FixedArray if it is. 171 // Allocate and initialize a FixedArray if it is.
180 // eax: initial map 172 // eax: initial map
181 // ebx: JSObject 173 // ebx: JSObject
182 // edi: start of next object 174 // edi: start of next object
183 // Calculate the total number of properties described by the map. 175 // Calculate the total number of properties described by the map.
184 __ movzx_b(edx, FieldOperand(eax, Map::kUnusedPropertyFieldsOffset)); 176 __ movzx_b(edx, FieldOperand(eax, Map::kUnusedPropertyFieldsOffset));
185 __ movzx_b(ecx, FieldOperand(eax, Map::kPreAllocatedPropertyFieldsOffset)); 177 __ movzx_b(ecx, FieldOperand(eax, Map::kPreAllocatedPropertyFieldsOffset));
186 __ add(edx, Operand(ecx)); 178 __ add(edx, Operand(ecx));
187 // Calculate unused properties past the end of the in-object properties. 179 // Calculate unused properties past the end of the in-object properties.
188 __ movzx_b(ecx, FieldOperand(eax, Map::kInObjectPropertiesOffset)); 180 __ movzx_b(ecx, FieldOperand(eax, Map::kInObjectPropertiesOffset));
189 __ sub(edx, Operand(ecx)); 181 __ sub(edx, Operand(ecx));
190 // Done if no extra properties are to be allocated. 182 // Done if no extra properties are to be allocated.
191 __ j(zero, &allocated); 183 __ j(zero, &allocated);
192 __ Assert(positive, "Property allocation count failed."); 184 __ Assert(positive, "Property allocation count failed.");
193 185
194 // Scale the number of elements by pointer size and add the header for 186 // Scale the number of elements by pointer size and add the header for
195 // FixedArrays to the start of the next object calculation from above. 187 // FixedArrays to the start of the next object calculation from above.
196 // ebx: JSObject 188 // ebx: JSObject
197 // edi: start of next object (will be start of FixedArray) 189 // edi: start of next object (will be start of FixedArray)
198 // edx: number of elements in properties array 190 // edx: number of elements in properties array
199 ASSERT(Heap::MaxObjectSizeInPagedSpace() > 191 ASSERT(Heap::MaxObjectSizeInPagedSpace() >
200 (FixedArray::kHeaderSize + 255*kPointerSize)); 192 (FixedArray::kHeaderSize + 255*kPointerSize));
201 __ lea(ecx, Operand(edi, edx, times_pointer_size, FixedArray::kHeaderSize)); 193 __ AllocateObjectInNewSpace(FixedArray::kHeaderSize,
202 __ cmp(ecx, Operand::StaticVariable(new_space_allocation_limit)); 194 times_pointer_size,
203 __ j(above_equal, &undo_allocation); 195 edx,
204 __ mov(Operand::StaticVariable(new_space_allocation_top), ecx); 196 edi,
197 ecx,
198 no_reg,
199 &undo_allocation,
200 true);
205 201
206 // Initialize the FixedArray. 202 // Initialize the FixedArray.
207 // ebx: JSObject 203 // ebx: JSObject
208 // edi: FixedArray 204 // edi: FixedArray
209 // edx: number of elements 205 // edx: number of elements
210 // ecx: start of next object 206 // ecx: start of next object
211 __ mov(eax, Factory::fixed_array_map()); 207 __ mov(eax, Factory::fixed_array_map());
212 __ mov(Operand(edi, JSObject::kMapOffset), eax); // setup the map 208 __ mov(Operand(edi, JSObject::kMapOffset), eax); // setup the map
213 __ mov(Operand(edi, Array::kLengthOffset), edx); // and length 209 __ mov(Operand(edi, Array::kLengthOffset), edx); // and length
214 210
(...skipping 23 matching lines...) Expand all
238 234
239 // Continue with JSObject being successfully allocated 235 // Continue with JSObject being successfully allocated
240 // ebx: JSObject 236 // ebx: JSObject
241 __ jmp(&allocated); 237 __ jmp(&allocated);
242 238
243 // Undo the setting of the new top so that the heap is verifiable. For 239 // Undo the setting of the new top so that the heap is verifiable. For
244 // example, the map's unused properties potentially do not match the 240 // example, the map's unused properties potentially do not match the
245 // allocated objects unused properties. 241 // allocated objects unused properties.
246 // ebx: JSObject (previous new top) 242 // ebx: JSObject (previous new top)
247 __ bind(&undo_allocation); 243 __ bind(&undo_allocation);
248 __ xor_(Operand(ebx), Immediate(kHeapObjectTag)); // clear the heap tag 244 __ UndoAllocationInNewSpace(ebx);
249 __ mov(Operand::StaticVariable(new_space_allocation_top), ebx);
250 } 245 }
251 246
252 // Allocate the new receiver object using the runtime call. 247 // Allocate the new receiver object using the runtime call.
253 // edi: function (constructor) 248 // edi: function (constructor)
254 __ bind(&rt_call); 249 __ bind(&rt_call);
255 // Must restore edi (constructor) before calling runtime. 250 // Must restore edi (constructor) before calling runtime.
256 __ mov(edi, Operand(esp, 0)); 251 __ mov(edi, Operand(esp, 0));
257 __ push(edi); 252 __ push(edi);
258 __ CallRuntime(Runtime::kNewObject, 1); 253 __ CallRuntime(Runtime::kNewObject, 1);
259 __ mov(ebx, Operand(eax)); // store result in ebx 254 __ mov(ebx, Operand(eax)); // store result in ebx
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 // Dont adapt arguments. 769 // Dont adapt arguments.
775 // ------------------------------------------- 770 // -------------------------------------------
776 __ bind(&dont_adapt_arguments); 771 __ bind(&dont_adapt_arguments);
777 __ jmp(Operand(edx)); 772 __ jmp(Operand(edx));
778 } 773 }
779 774
780 775
781 #undef __ 776 #undef __
782 777
783 } } // namespace v8::internal 778 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/ia32/codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698