OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 __ pop(rdi); | 213 __ pop(rdi); |
214 __ pop(rax); | 214 __ pop(rax); |
215 | 215 |
216 __ bind(&allocate); | 216 __ bind(&allocate); |
217 } | 217 } |
218 | 218 |
219 // Now allocate the JSObject on the heap. | 219 // Now allocate the JSObject on the heap. |
220 __ movzxbq(rdi, FieldOperand(rax, Map::kInstanceSizeOffset)); | 220 __ movzxbq(rdi, FieldOperand(rax, Map::kInstanceSizeOffset)); |
221 __ shl(rdi, Immediate(kPointerSizeLog2)); | 221 __ shl(rdi, Immediate(kPointerSizeLog2)); |
222 // rdi: size of new object | 222 // rdi: size of new object |
223 __ AllocateInNewSpace(rdi, | 223 __ Allocate(rdi, |
224 rbx, | 224 rbx, |
225 rdi, | 225 rdi, |
226 no_reg, | 226 no_reg, |
227 &rt_call, | 227 &rt_call, |
228 NO_ALLOCATION_FLAGS); | 228 NO_ALLOCATION_FLAGS); |
229 // Allocated the JSObject, now initialize the fields. | 229 // Allocated the JSObject, now initialize the fields. |
230 // rax: initial map | 230 // rax: initial map |
231 // rbx: JSObject (not HeapObject tagged - the actual address). | 231 // rbx: JSObject (not HeapObject tagged - the actual address). |
232 // rdi: start of next object | 232 // rdi: start of next object |
233 __ movq(Operand(rbx, JSObject::kMapOffset), rax); | 233 __ movq(Operand(rbx, JSObject::kMapOffset), rax); |
234 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex); | 234 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex); |
235 __ movq(Operand(rbx, JSObject::kPropertiesOffset), rcx); | 235 __ movq(Operand(rbx, JSObject::kPropertiesOffset), rcx); |
236 __ movq(Operand(rbx, JSObject::kElementsOffset), rcx); | 236 __ movq(Operand(rbx, JSObject::kElementsOffset), rcx); |
237 // Set extra fields in the newly allocated object. | 237 // Set extra fields in the newly allocated object. |
238 // rax: initial map | 238 // rax: initial map |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 __ subq(rdx, rcx); | 280 __ subq(rdx, rcx); |
281 // Done if no extra properties are to be allocated. | 281 // Done if no extra properties are to be allocated. |
282 __ j(zero, &allocated); | 282 __ j(zero, &allocated); |
283 __ Assert(positive, "Property allocation count failed."); | 283 __ Assert(positive, "Property allocation count failed."); |
284 | 284 |
285 // Scale the number of elements by pointer size and add the header for | 285 // Scale the number of elements by pointer size and add the header for |
286 // FixedArrays to the start of the next object calculation from above. | 286 // FixedArrays to the start of the next object calculation from above. |
287 // rbx: JSObject | 287 // rbx: JSObject |
288 // rdi: start of next object (will be start of FixedArray) | 288 // rdi: start of next object (will be start of FixedArray) |
289 // rdx: number of elements in properties array | 289 // rdx: number of elements in properties array |
290 __ AllocateInNewSpace(FixedArray::kHeaderSize, | 290 __ Allocate(FixedArray::kHeaderSize, |
291 times_pointer_size, | 291 times_pointer_size, |
292 rdx, | 292 rdx, |
293 rdi, | 293 rdi, |
294 rax, | 294 rax, |
295 no_reg, | 295 no_reg, |
296 &undo_allocation, | 296 &undo_allocation, |
297 RESULT_CONTAINS_TOP); | 297 RESULT_CONTAINS_TOP); |
298 | 298 |
299 // Initialize the FixedArray. | 299 // Initialize the FixedArray. |
300 // rbx: JSObject | 300 // rbx: JSObject |
301 // rdi: FixedArray | 301 // rdi: FixedArray |
302 // rdx: number of elements | 302 // rdx: number of elements |
303 // rax: start of next object | 303 // rax: start of next object |
304 __ LoadRoot(rcx, Heap::kFixedArrayMapRootIndex); | 304 __ LoadRoot(rcx, Heap::kFixedArrayMapRootIndex); |
305 __ movq(Operand(rdi, HeapObject::kMapOffset), rcx); // setup the map | 305 __ movq(Operand(rdi, HeapObject::kMapOffset), rcx); // setup the map |
306 __ Integer32ToSmi(rdx, rdx); | 306 __ Integer32ToSmi(rdx, rdx); |
307 __ movq(Operand(rdi, FixedArray::kLengthOffset), rdx); // and length | 307 __ movq(Operand(rdi, FixedArray::kLengthOffset), rdx); // and length |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 | 1209 |
1210 if (FLAG_debug_code) { // Assert that array size is not zero. | 1210 if (FLAG_debug_code) { // Assert that array size is not zero. |
1211 __ testq(array_size, array_size); | 1211 __ testq(array_size, array_size); |
1212 __ Assert(not_zero, "array size is unexpectedly 0"); | 1212 __ Assert(not_zero, "array size is unexpectedly 0"); |
1213 } | 1213 } |
1214 | 1214 |
1215 // Allocate the JSArray object together with space for a FixedArray with the | 1215 // Allocate the JSArray object together with space for a FixedArray with the |
1216 // requested elements. | 1216 // requested elements. |
1217 SmiIndex index = | 1217 SmiIndex index = |
1218 masm->SmiToIndex(kScratchRegister, array_size, kPointerSizeLog2); | 1218 masm->SmiToIndex(kScratchRegister, array_size, kPointerSizeLog2); |
1219 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize, | 1219 __ Allocate(JSArray::kSize + FixedArray::kHeaderSize, |
1220 index.scale, | 1220 index.scale, |
1221 index.reg, | 1221 index.reg, |
1222 result, | 1222 result, |
1223 elements_array_end, | 1223 elements_array_end, |
1224 scratch, | 1224 scratch, |
1225 gc_required, | 1225 gc_required, |
1226 TAG_OBJECT); | 1226 TAG_OBJECT); |
1227 | 1227 |
1228 // Allocated the JSArray. Now initialize the fields except for the elements | 1228 // Allocated the JSArray. Now initialize the fields except for the elements |
1229 // array. | 1229 // array. |
1230 // result: JSObject | 1230 // result: JSObject |
1231 // elements_array: initial map | 1231 // elements_array: initial map |
1232 // elements_array_end: start of next object | 1232 // elements_array_end: start of next object |
1233 // array_size: size of array (smi) | 1233 // array_size: size of array (smi) |
1234 Factory* factory = masm->isolate()->factory(); | 1234 Factory* factory = masm->isolate()->factory(); |
1235 __ movq(FieldOperand(result, JSObject::kMapOffset), elements_array); | 1235 __ movq(FieldOperand(result, JSObject::kMapOffset), elements_array); |
1236 __ Move(elements_array, factory->empty_fixed_array()); | 1236 __ Move(elements_array, factory->empty_fixed_array()); |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1897 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
1898 generator.Generate(); | 1898 generator.Generate(); |
1899 } | 1899 } |
1900 | 1900 |
1901 | 1901 |
1902 #undef __ | 1902 #undef __ |
1903 | 1903 |
1904 } } // namespace v8::internal | 1904 } } // namespace v8::internal |
1905 | 1905 |
1906 #endif // V8_TARGET_ARCH_X64 | 1906 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |