| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 Register scratch3, | 97 Register scratch3, |
| 98 Label* gc_required) { | 98 Label* gc_required) { |
| 99 const int initial_capacity = JSArray::kPreallocatedArrayElements; | 99 const int initial_capacity = JSArray::kPreallocatedArrayElements; |
| 100 STATIC_ASSERT(initial_capacity >= 0); | 100 STATIC_ASSERT(initial_capacity >= 0); |
| 101 // Load the initial map from the array function. | 101 // Load the initial map from the array function. |
| 102 __ ldr(scratch1, FieldMemOperand(array_function, | 102 __ ldr(scratch1, FieldMemOperand(array_function, |
| 103 JSFunction::kPrototypeOrInitialMapOffset)); | 103 JSFunction::kPrototypeOrInitialMapOffset)); |
| 104 | 104 |
| 105 // Allocate the JSArray object together with space for a fixed array with the | 105 // Allocate the JSArray object together with space for a fixed array with the |
| 106 // requested elements. | 106 // requested elements. |
| 107 int size = JSArray::kSize + FixedArray::SizeFor(initial_capacity); | 107 int size = JSArray::kSize; |
| 108 if (initial_capacity > 0) { |
| 109 size += FixedArray::SizeFor(initial_capacity); |
| 110 } |
| 108 __ AllocateInNewSpace(size, | 111 __ AllocateInNewSpace(size, |
| 109 result, | 112 result, |
| 110 scratch2, | 113 scratch2, |
| 111 scratch3, | 114 scratch3, |
| 112 gc_required, | 115 gc_required, |
| 113 TAG_OBJECT); | 116 TAG_OBJECT); |
| 114 | 117 |
| 115 // Allocated the JSArray. Now initialize the fields except for the elements | 118 // Allocated the JSArray. Now initialize the fields except for the elements |
| 116 // array. | 119 // array. |
| 117 // result: JSObject | 120 // result: JSObject |
| 118 // scratch1: initial map | 121 // scratch1: initial map |
| 119 // scratch2: start of next object | 122 // scratch2: start of next object |
| 120 __ str(scratch1, FieldMemOperand(result, JSObject::kMapOffset)); | 123 __ str(scratch1, FieldMemOperand(result, JSObject::kMapOffset)); |
| 121 __ LoadRoot(scratch1, Heap::kEmptyFixedArrayRootIndex); | 124 __ LoadRoot(scratch1, Heap::kEmptyFixedArrayRootIndex); |
| 122 __ str(scratch1, FieldMemOperand(result, JSArray::kPropertiesOffset)); | 125 __ str(scratch1, FieldMemOperand(result, JSArray::kPropertiesOffset)); |
| 123 // Field JSArray::kElementsOffset is initialized later. | 126 // Field JSArray::kElementsOffset is initialized later. |
| 124 __ mov(scratch3, Operand(0, RelocInfo::NONE)); | 127 __ mov(scratch3, Operand(0, RelocInfo::NONE)); |
| 125 __ str(scratch3, FieldMemOperand(result, JSArray::kLengthOffset)); | 128 __ str(scratch3, FieldMemOperand(result, JSArray::kLengthOffset)); |
| 126 | 129 |
| 130 if (initial_capacity == 0) { |
| 131 __ str(scratch1, FieldMemOperand(result, JSArray::kElementsOffset)); |
| 132 return; |
| 133 } |
| 134 |
| 127 // Calculate the location of the elements array and set elements array member | 135 // Calculate the location of the elements array and set elements array member |
| 128 // of the JSArray. | 136 // of the JSArray. |
| 129 // result: JSObject | 137 // result: JSObject |
| 130 // scratch2: start of next object | 138 // scratch2: start of next object |
| 131 __ add(scratch1, result, Operand(JSArray::kSize)); | 139 __ add(scratch1, result, Operand(JSArray::kSize)); |
| 132 __ str(scratch1, FieldMemOperand(result, JSArray::kElementsOffset)); | 140 __ str(scratch1, FieldMemOperand(result, JSArray::kElementsOffset)); |
| 133 | 141 |
| 134 // Clear the heap tag on the elements array. | 142 // Clear the heap tag on the elements array. |
| 135 STATIC_ASSERT(kSmiTag == 0); | |
| 136 __ sub(scratch1, scratch1, Operand(kHeapObjectTag)); | 143 __ sub(scratch1, scratch1, Operand(kHeapObjectTag)); |
| 137 | 144 |
| 138 // Initialize the FixedArray and fill it with holes. FixedArray length is | 145 // Initialize the FixedArray and fill it with holes. FixedArray length is |
| 139 // stored as a smi. | 146 // stored as a smi. |
| 140 // result: JSObject | 147 // result: JSObject |
| 141 // scratch1: elements array (untagged) | 148 // scratch1: elements array (untagged) |
| 142 // scratch2: start of next object | 149 // scratch2: start of next object |
| 143 __ LoadRoot(scratch3, Heap::kFixedArrayMapRootIndex); | 150 __ LoadRoot(scratch3, Heap::kFixedArrayMapRootIndex); |
| 144 ASSERT_EQ(0 * kPointerSize, FixedArray::kMapOffset); | 151 STATIC_ASSERT(0 * kPointerSize == FixedArray::kMapOffset); |
| 145 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex)); | 152 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex)); |
| 146 __ mov(scratch3, Operand(Smi::FromInt(initial_capacity))); | 153 __ mov(scratch3, Operand(Smi::FromInt(initial_capacity))); |
| 147 ASSERT_EQ(1 * kPointerSize, FixedArray::kLengthOffset); | 154 STATIC_ASSERT(1 * kPointerSize == FixedArray::kLengthOffset); |
| 148 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex)); | 155 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex)); |
| 149 | 156 |
| 150 // Fill the FixedArray with the hole value. Inline the code if short. | 157 // Fill the FixedArray with the hole value. Inline the code if short. |
| 151 if (initial_capacity == 0) return; | 158 STATIC_ASSERT(2 * kPointerSize == FixedArray::kHeaderSize); |
| 152 ASSERT_EQ(2 * kPointerSize, FixedArray::kHeaderSize); | |
| 153 __ LoadRoot(scratch3, Heap::kTheHoleValueRootIndex); | 159 __ LoadRoot(scratch3, Heap::kTheHoleValueRootIndex); |
| 154 static const int kLoopUnfoldLimit = 4; | 160 static const int kLoopUnfoldLimit = 4; |
| 155 if (initial_capacity <= kLoopUnfoldLimit) { | 161 if (initial_capacity <= kLoopUnfoldLimit) { |
| 156 for (int i = 0; i < initial_capacity; i++) { | 162 for (int i = 0; i < initial_capacity; i++) { |
| 157 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex)); | 163 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex)); |
| 158 } | 164 } |
| 159 } else { | 165 } else { |
| 160 Label loop, entry; | 166 Label loop, entry; |
| 161 __ add(scratch2, scratch1, Operand(initial_capacity * kPointerSize)); | 167 __ add(scratch2, scratch1, Operand(initial_capacity * kPointerSize)); |
| 162 __ b(&entry); | 168 __ b(&entry); |
| (...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 __ bind(&dont_adapt_arguments); | 1714 __ bind(&dont_adapt_arguments); |
| 1709 __ Jump(r3); | 1715 __ Jump(r3); |
| 1710 } | 1716 } |
| 1711 | 1717 |
| 1712 | 1718 |
| 1713 #undef __ | 1719 #undef __ |
| 1714 | 1720 |
| 1715 } } // namespace v8::internal | 1721 } } // namespace v8::internal |
| 1716 | 1722 |
| 1717 #endif // V8_TARGET_ARCH_ARM | 1723 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |