OLD | NEW |
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 Loading... |
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 __ AllocateObjectInNewSpace(edi, ebx, edi, no_reg, &rt_call, false); | 136 ExternalReference new_space_allocation_top = |
| 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); |
137 // Allocated the JSObject, now initialize the fields. | 144 // Allocated the JSObject, now initialize the fields. |
138 // eax: initial map | 145 // eax: initial map |
139 // ebx: JSObject | 146 // ebx: JSObject |
140 // edi: start of next object | 147 // edi: start of next object |
141 __ mov(Operand(ebx, JSObject::kMapOffset), eax); | 148 __ mov(Operand(ebx, JSObject::kMapOffset), eax); |
142 __ mov(ecx, Factory::empty_fixed_array()); | 149 __ mov(ecx, Factory::empty_fixed_array()); |
143 __ mov(Operand(ebx, JSObject::kPropertiesOffset), ecx); | 150 __ mov(Operand(ebx, JSObject::kPropertiesOffset), ecx); |
144 __ mov(Operand(ebx, JSObject::kElementsOffset), ecx); | 151 __ mov(Operand(ebx, JSObject::kElementsOffset), ecx); |
145 // Set extra fields in the newly allocated object. | 152 // Set extra fields in the newly allocated object. |
146 // eax: initial map | 153 // eax: initial map |
(...skipping 12 matching lines...) Expand all Loading... |
159 } | 166 } |
160 | 167 |
161 // Mostly done with the JSObject. Add the heap tag and store the new top, so | 168 // Mostly done with the JSObject. Add the heap tag and store the new top, so |
162 // that we can continue and jump into the continuation code at any time from | 169 // that we can continue and jump into the continuation code at any time from |
163 // now on. Any failures need to undo the setting of the new top, so that the | 170 // now on. Any failures need to undo the setting of the new top, so that the |
164 // heap is in a consistent state and verifiable. | 171 // heap is in a consistent state and verifiable. |
165 // eax: initial map | 172 // eax: initial map |
166 // ebx: JSObject | 173 // ebx: JSObject |
167 // edi: start of next object | 174 // edi: start of next object |
168 __ or_(Operand(ebx), Immediate(kHeapObjectTag)); | 175 __ or_(Operand(ebx), Immediate(kHeapObjectTag)); |
| 176 __ mov(Operand::StaticVariable(new_space_allocation_top), edi); |
169 | 177 |
170 // Check if a non-empty properties array is needed. | 178 // Check if a non-empty properties array is needed. |
171 // Allocate and initialize a FixedArray if it is. | 179 // Allocate and initialize a FixedArray if it is. |
172 // eax: initial map | 180 // eax: initial map |
173 // ebx: JSObject | 181 // ebx: JSObject |
174 // edi: start of next object | 182 // edi: start of next object |
175 // Calculate the total number of properties described by the map. | 183 // Calculate the total number of properties described by the map. |
176 __ movzx_b(edx, FieldOperand(eax, Map::kUnusedPropertyFieldsOffset)); | 184 __ movzx_b(edx, FieldOperand(eax, Map::kUnusedPropertyFieldsOffset)); |
177 __ movzx_b(ecx, FieldOperand(eax, Map::kPreAllocatedPropertyFieldsOffset)); | 185 __ movzx_b(ecx, FieldOperand(eax, Map::kPreAllocatedPropertyFieldsOffset)); |
178 __ add(edx, Operand(ecx)); | 186 __ add(edx, Operand(ecx)); |
179 // Calculate unused properties past the end of the in-object properties. | 187 // Calculate unused properties past the end of the in-object properties. |
180 __ movzx_b(ecx, FieldOperand(eax, Map::kInObjectPropertiesOffset)); | 188 __ movzx_b(ecx, FieldOperand(eax, Map::kInObjectPropertiesOffset)); |
181 __ sub(edx, Operand(ecx)); | 189 __ sub(edx, Operand(ecx)); |
182 // Done if no extra properties are to be allocated. | 190 // Done if no extra properties are to be allocated. |
183 __ j(zero, &allocated); | 191 __ j(zero, &allocated); |
184 __ Assert(positive, "Property allocation count failed."); | 192 __ Assert(positive, "Property allocation count failed."); |
185 | 193 |
186 // Scale the number of elements by pointer size and add the header for | 194 // Scale the number of elements by pointer size and add the header for |
187 // FixedArrays to the start of the next object calculation from above. | 195 // FixedArrays to the start of the next object calculation from above. |
188 // ebx: JSObject | 196 // ebx: JSObject |
189 // edi: start of next object (will be start of FixedArray) | 197 // edi: start of next object (will be start of FixedArray) |
190 // edx: number of elements in properties array | 198 // edx: number of elements in properties array |
191 ASSERT(Heap::MaxObjectSizeInPagedSpace() > | 199 ASSERT(Heap::MaxObjectSizeInPagedSpace() > |
192 (FixedArray::kHeaderSize + 255*kPointerSize)); | 200 (FixedArray::kHeaderSize + 255*kPointerSize)); |
193 __ AllocateObjectInNewSpace(FixedArray::kHeaderSize, | 201 __ lea(ecx, Operand(edi, edx, times_pointer_size, FixedArray::kHeaderSize)); |
194 times_pointer_size, | 202 __ cmp(ecx, Operand::StaticVariable(new_space_allocation_limit)); |
195 edx, | 203 __ j(above_equal, &undo_allocation); |
196 edi, | 204 __ mov(Operand::StaticVariable(new_space_allocation_top), ecx); |
197 ecx, | |
198 no_reg, | |
199 &undo_allocation, | |
200 true); | |
201 | 205 |
202 // Initialize the FixedArray. | 206 // Initialize the FixedArray. |
203 // ebx: JSObject | 207 // ebx: JSObject |
204 // edi: FixedArray | 208 // edi: FixedArray |
205 // edx: number of elements | 209 // edx: number of elements |
206 // ecx: start of next object | 210 // ecx: start of next object |
207 __ mov(eax, Factory::fixed_array_map()); | 211 __ mov(eax, Factory::fixed_array_map()); |
208 __ mov(Operand(edi, JSObject::kMapOffset), eax); // setup the map | 212 __ mov(Operand(edi, JSObject::kMapOffset), eax); // setup the map |
209 __ mov(Operand(edi, Array::kLengthOffset), edx); // and length | 213 __ mov(Operand(edi, Array::kLengthOffset), edx); // and length |
210 | 214 |
(...skipping 23 matching lines...) Expand all Loading... |
234 | 238 |
235 // Continue with JSObject being successfully allocated | 239 // Continue with JSObject being successfully allocated |
236 // ebx: JSObject | 240 // ebx: JSObject |
237 __ jmp(&allocated); | 241 __ jmp(&allocated); |
238 | 242 |
239 // Undo the setting of the new top so that the heap is verifiable. For | 243 // Undo the setting of the new top so that the heap is verifiable. For |
240 // example, the map's unused properties potentially do not match the | 244 // example, the map's unused properties potentially do not match the |
241 // allocated objects unused properties. | 245 // allocated objects unused properties. |
242 // ebx: JSObject (previous new top) | 246 // ebx: JSObject (previous new top) |
243 __ bind(&undo_allocation); | 247 __ bind(&undo_allocation); |
244 __ UndoAllocationInNewSpace(ebx); | 248 __ xor_(Operand(ebx), Immediate(kHeapObjectTag)); // clear the heap tag |
| 249 __ mov(Operand::StaticVariable(new_space_allocation_top), ebx); |
245 } | 250 } |
246 | 251 |
247 // Allocate the new receiver object using the runtime call. | 252 // Allocate the new receiver object using the runtime call. |
248 // edi: function (constructor) | 253 // edi: function (constructor) |
249 __ bind(&rt_call); | 254 __ bind(&rt_call); |
250 // Must restore edi (constructor) before calling runtime. | 255 // Must restore edi (constructor) before calling runtime. |
251 __ mov(edi, Operand(esp, 0)); | 256 __ mov(edi, Operand(esp, 0)); |
252 __ push(edi); | 257 __ push(edi); |
253 __ CallRuntime(Runtime::kNewObject, 1); | 258 __ CallRuntime(Runtime::kNewObject, 1); |
254 __ mov(ebx, Operand(eax)); // store result in ebx | 259 __ mov(ebx, Operand(eax)); // store result in ebx |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 // Dont adapt arguments. | 774 // Dont adapt arguments. |
770 // ------------------------------------------- | 775 // ------------------------------------------- |
771 __ bind(&dont_adapt_arguments); | 776 __ bind(&dont_adapt_arguments); |
772 __ jmp(Operand(edx)); | 777 __ jmp(Operand(edx)); |
773 } | 778 } |
774 | 779 |
775 | 780 |
776 #undef __ | 781 #undef __ |
777 | 782 |
778 } } // namespace v8::internal | 783 } } // namespace v8::internal |
OLD | NEW |