OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // r2: initial map | 126 // r2: initial map |
127 // r7: undefined | 127 // r7: undefined |
128 __ CompareInstanceType(r2, r3, JS_FUNCTION_TYPE); | 128 __ CompareInstanceType(r2, r3, JS_FUNCTION_TYPE); |
129 __ b(eq, &rt_call); | 129 __ b(eq, &rt_call); |
130 | 130 |
131 // Now allocate the JSObject on the heap. | 131 // Now allocate the JSObject on the heap. |
132 // r1: constructor function | 132 // r1: constructor function |
133 // r2: initial map | 133 // r2: initial map |
134 // r7: undefined | 134 // r7: undefined |
135 __ ldrb(r3, FieldMemOperand(r2, Map::kInstanceSizeOffset)); | 135 __ ldrb(r3, FieldMemOperand(r2, Map::kInstanceSizeOffset)); |
136 // Make sure that the maximum heap object size will never cause us | 136 __ AllocateObjectInNewSpace(r3, r4, r5, r6, &rt_call, NO_ALLOCATION_FLAGS); |
137 // problem here, because it is always greater than the maximum | |
138 // instance size that can be represented in a byte. | |
139 ASSERT(Heap::MaxObjectSizeInPagedSpace() >= JSObject::kMaxInstanceSize); | |
140 __ AllocateObjectInNewSpace(r3, r4, r5, r6, &rt_call, false); | |
141 | 137 |
142 // Allocated the JSObject, now initialize the fields. Map is set to initial | 138 // Allocated the JSObject, now initialize the fields. Map is set to initial |
143 // map and properties and elements are set to empty fixed array. | 139 // map and properties and elements are set to empty fixed array. |
144 // r1: constructor function | 140 // r1: constructor function |
145 // r2: initial map | 141 // r2: initial map |
146 // r3: object size | 142 // r3: object size |
147 // r4: JSObject (not tagged) | 143 // r4: JSObject (not tagged) |
148 // r7: undefined | 144 // r7: undefined |
149 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); | 145 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); |
150 __ mov(r5, r4); | 146 __ mov(r5, r4); |
151 ASSERT_EQ(0 * kPointerSize, JSObject::kMapOffset); | 147 ASSERT_EQ(0 * kPointerSize, JSObject::kMapOffset); |
152 __ str(r2, MemOperand(r5, kPointerSize, PostIndex)); | 148 __ str(r2, MemOperand(r5, kPointerSize, PostIndex)); |
153 ASSERT_EQ(1 * kPointerSize, JSObject::kPropertiesOffset); | 149 ASSERT_EQ(1 * kPointerSize, JSObject::kPropertiesOffset); |
154 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); | 150 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
155 ASSERT_EQ(2 * kPointerSize, JSObject::kElementsOffset); | 151 ASSERT_EQ(2 * kPointerSize, JSObject::kElementsOffset); |
156 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); | 152 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
157 | 153 |
158 // Fill all the in-object properties with undefined. | 154 // Fill all the in-object properties with undefined. |
159 // r1: constructor function | 155 // r1: constructor function |
160 // r2: initial map | 156 // r2: initial map |
161 // r3: object size (in words) | 157 // r3: object size (in words) |
162 // r4: JSObject (not tagged) | 158 // r4: JSObject (not tagged) |
163 // r5: First in-object property of JSObject (not tagged) | 159 // r5: First in-object property of JSObject (not tagged) |
164 // r7: undefined | 160 // r7: undefined |
165 __ add(r6, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. | 161 __ add(r6, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
166 ASSERT_EQ(12, JSObject::kHeaderSize); | 162 ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize); |
167 { Label loop, entry; | 163 { Label loop, entry; |
168 __ b(&entry); | 164 __ b(&entry); |
169 __ bind(&loop); | 165 __ bind(&loop); |
170 __ str(r7, MemOperand(r5, kPointerSize, PostIndex)); | 166 __ str(r7, MemOperand(r5, kPointerSize, PostIndex)); |
171 __ bind(&entry); | 167 __ bind(&entry); |
172 __ cmp(r5, Operand(r6)); | 168 __ cmp(r5, Operand(r6)); |
173 __ b(lt, &loop); | 169 __ b(lt, &loop); |
174 } | 170 } |
175 | 171 |
176 // Add the object tag to make the JSObject real, so that we can continue and | 172 // Add the object tag to make the JSObject real, so that we can continue and |
177 // jump into the continuation code at any time from now on. Any failures | 173 // jump into the continuation code at any time from now on. Any failures |
178 // need to undo the allocation, so that the heap is in a consistent state | 174 // need to undo the allocation, so that the heap is in a consistent state |
179 // and verifiable. | 175 // and verifiable. |
180 __ add(r4, r4, Operand(kHeapObjectTag)); | 176 __ add(r4, r4, Operand(kHeapObjectTag)); |
181 | 177 |
182 // Check if a non-empty properties array is needed. Continue with allocated | 178 // Check if a non-empty properties array is needed. Continue with allocated |
183 // object if not fall through to runtime call if it is. | 179 // object if not fall through to runtime call if it is. |
184 // r1: constructor function | 180 // r1: constructor function |
185 // r2: initial map | |
186 // r4: JSObject | 181 // r4: JSObject |
187 // r5: start of next object (not tagged) | 182 // r5: start of next object (not tagged) |
188 // r7: undefined | 183 // r7: undefined |
189 __ ldrb(r3, FieldMemOperand(r2, Map::kUnusedPropertyFieldsOffset)); | 184 __ ldrb(r3, FieldMemOperand(r2, Map::kUnusedPropertyFieldsOffset)); |
190 // The field instance sizes contains both pre-allocated property fields and | 185 // The field instance sizes contains both pre-allocated property fields and |
191 // in-object properties. | 186 // in-object properties. |
192 __ ldr(r0, FieldMemOperand(r2, Map::kInstanceSizesOffset)); | 187 __ ldr(r0, FieldMemOperand(r2, Map::kInstanceSizesOffset)); |
193 __ and_(r6, | 188 __ and_(r6, |
194 r0, | 189 r0, |
195 Operand(0x000000FF << Map::kPreAllocatedPropertyFieldsByte * 8)); | 190 Operand(0x000000FF << Map::kPreAllocatedPropertyFieldsByte * 8)); |
196 __ add(r3, r3, Operand(r6, LSR, Map::kPreAllocatedPropertyFieldsByte * 8)); | 191 __ add(r3, r3, Operand(r6, LSR, Map::kPreAllocatedPropertyFieldsByte * 8)); |
197 __ and_(r6, r0, Operand(0x000000FF << Map::kInObjectPropertiesByte * 8)); | 192 __ and_(r6, r0, Operand(0x000000FF << Map::kInObjectPropertiesByte * 8)); |
198 __ sub(r3, r3, Operand(r6, LSR, Map::kInObjectPropertiesByte * 8), SetCC); | 193 __ sub(r3, r3, Operand(r6, LSR, Map::kInObjectPropertiesByte * 8), SetCC); |
199 | 194 |
200 // Done if no extra properties are to be allocated. | 195 // Done if no extra properties are to be allocated. |
201 __ b(eq, &allocated); | 196 __ b(eq, &allocated); |
202 __ Assert(al, "Property allocation count failed."); | 197 __ Assert(pl, "Property allocation count failed."); |
| 198 |
| 199 // Scale the number of elements by pointer size and add the header for |
| 200 // FixedArrays to the start of the next object calculation from above. |
| 201 // r1: constructor |
| 202 // r3: number of elements in properties array |
| 203 // r4: JSObject |
| 204 // r5: start of next object |
| 205 // r7: undefined |
| 206 __ add(r0, r3, Operand(FixedArray::kHeaderSize / kPointerSize)); |
| 207 __ AllocateObjectInNewSpace(r0, |
| 208 r5, |
| 209 r6, |
| 210 r2, |
| 211 &undo_allocation, |
| 212 RESULT_CONTAINS_TOP); |
| 213 |
| 214 // Initialize the FixedArray. |
| 215 // r1: constructor |
| 216 // r3: number of elements in properties array |
| 217 // r4: JSObject |
| 218 // r5: FixedArray (not tagged) |
| 219 // r7: undefined |
| 220 __ LoadRoot(r6, Heap::kFixedArrayMapRootIndex); |
| 221 __ mov(r2, r5); |
| 222 ASSERT_EQ(0 * kPointerSize, JSObject::kMapOffset); |
| 223 __ str(r6, MemOperand(r2, kPointerSize, PostIndex)); |
| 224 ASSERT_EQ(1 * kPointerSize, Array::kLengthOffset); |
| 225 __ str(r3, MemOperand(r2, kPointerSize, PostIndex)); |
| 226 |
| 227 // Initialize the fields to undefined. |
| 228 // r1: constructor function |
| 229 // r2: First element of FixedArray (not tagged) |
| 230 // r3: number of elements in properties array |
| 231 // r4: JSObject |
| 232 // r5: FixedArray (not tagged) |
| 233 // r7: undefined |
| 234 __ add(r6, r2, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
| 235 ASSERT_EQ(2 * kPointerSize, FixedArray::kHeaderSize); |
| 236 { Label loop, entry; |
| 237 __ b(&entry); |
| 238 __ bind(&loop); |
| 239 __ str(r7, MemOperand(r2, kPointerSize, PostIndex)); |
| 240 __ bind(&entry); |
| 241 __ cmp(r2, Operand(r6)); |
| 242 __ b(lt, &loop); |
| 243 } |
| 244 |
| 245 // Store the initialized FixedArray into the properties field of |
| 246 // the JSObject |
| 247 // r1: constructor function |
| 248 // r4: JSObject |
| 249 // r5: FixedArray (not tagged) |
| 250 __ add(r5, r5, Operand(kHeapObjectTag)); // Add the heap tag. |
| 251 __ str(r5, FieldMemOperand(r4, JSObject::kPropertiesOffset)); |
| 252 |
| 253 // Continue with JSObject being successfully allocated |
| 254 // r1: constructor function |
| 255 // r4: JSObject |
| 256 __ jmp(&allocated); |
203 | 257 |
204 // Undo the setting of the new top so that the heap is verifiable. For | 258 // Undo the setting of the new top so that the heap is verifiable. For |
205 // example, the map's unused properties potentially do not match the | 259 // example, the map's unused properties potentially do not match the |
206 // allocated objects unused properties. | 260 // allocated objects unused properties. |
207 // r4: JSObject (previous new top) | 261 // r4: JSObject (previous new top) |
208 __ bind(&undo_allocation); | 262 __ bind(&undo_allocation); |
209 __ UndoAllocationInNewSpace(r4, r5); | 263 __ UndoAllocationInNewSpace(r4, r5); |
210 } | 264 } |
211 | 265 |
212 // Allocate the new receiver object using the runtime call. | 266 // Allocate the new receiver object using the runtime call. |
| 267 // r1: constructor function |
213 __ bind(&rt_call); | 268 __ bind(&rt_call); |
214 __ push(r1); // argument for Runtime_NewObject | 269 __ push(r1); // argument for Runtime_NewObject |
215 __ CallRuntime(Runtime::kNewObject, 1); | 270 __ CallRuntime(Runtime::kNewObject, 1); |
216 __ mov(r4, r0); | 271 __ mov(r4, r0); |
217 | 272 |
218 // Receiver for constructor call allocated. | 273 // Receiver for constructor call allocated. |
219 // r4: JSObject | 274 // r4: JSObject |
220 __ bind(&allocated); | 275 __ bind(&allocated); |
221 __ push(r4); | 276 __ push(r4); |
222 | 277 |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 // Dont adapt arguments. | 871 // Dont adapt arguments. |
817 // ------------------------------------------- | 872 // ------------------------------------------- |
818 __ bind(&dont_adapt_arguments); | 873 __ bind(&dont_adapt_arguments); |
819 __ Jump(r3); | 874 __ Jump(r3); |
820 } | 875 } |
821 | 876 |
822 | 877 |
823 #undef __ | 878 #undef __ |
824 | 879 |
825 } } // namespace v8::internal | 880 } } // namespace v8::internal |
OLD | NEW |