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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 | 233 |
234 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { | 234 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { |
235 // Stack layout on entry: | 235 // Stack layout on entry: |
236 // | 236 // |
237 // [esp + kPointerSize]: constant elements. | 237 // [esp + kPointerSize]: constant elements. |
238 // [esp + (2 * kPointerSize)]: literal index. | 238 // [esp + (2 * kPointerSize)]: literal index. |
239 // [esp + (3 * kPointerSize)]: literals array. | 239 // [esp + (3 * kPointerSize)]: literals array. |
240 | 240 |
241 // All sizes here are multiples of kPointerSize. | 241 // All sizes here are multiples of kPointerSize. |
242 int elements_size = (length_ > 0) ? FixedArray::SizeFor(length_) : 0; | 242 int elements_size = 0; |
| 243 if (length_ > 0) { |
| 244 elements_size = mode_ == CLONE_DOUBLE_ELEMENTS |
| 245 ? FixedDoubleArray::SizeFor(length_) |
| 246 : FixedArray::SizeFor(length_); |
| 247 } |
243 int size = JSArray::kSize + elements_size; | 248 int size = JSArray::kSize + elements_size; |
244 | 249 |
245 // Load boilerplate object into ecx and check if we need to create a | 250 // Load boilerplate object into ecx and check if we need to create a |
246 // boilerplate. | 251 // boilerplate. |
247 Label slow_case; | 252 Label slow_case; |
248 __ mov(ecx, Operand(esp, 3 * kPointerSize)); | 253 __ mov(ecx, Operand(esp, 3 * kPointerSize)); |
249 __ mov(eax, Operand(esp, 2 * kPointerSize)); | 254 __ mov(eax, Operand(esp, 2 * kPointerSize)); |
250 STATIC_ASSERT(kPointerSize == 4); | 255 STATIC_ASSERT(kPointerSize == 4); |
251 STATIC_ASSERT(kSmiTagSize == 1); | 256 STATIC_ASSERT(kSmiTagSize == 1); |
252 STATIC_ASSERT(kSmiTag == 0); | 257 STATIC_ASSERT(kSmiTag == 0); |
253 __ mov(ecx, FieldOperand(ecx, eax, times_half_pointer_size, | 258 __ mov(ecx, FieldOperand(ecx, eax, times_half_pointer_size, |
254 FixedArray::kHeaderSize)); | 259 FixedArray::kHeaderSize)); |
255 Factory* factory = masm->isolate()->factory(); | 260 Factory* factory = masm->isolate()->factory(); |
256 __ cmp(ecx, factory->undefined_value()); | 261 __ cmp(ecx, factory->undefined_value()); |
257 __ j(equal, &slow_case); | 262 __ j(equal, &slow_case); |
258 | 263 |
259 if (FLAG_debug_code) { | 264 if (FLAG_debug_code) { |
260 const char* message; | 265 const char* message; |
261 Handle<Map> expected_map; | 266 Handle<Map> expected_map; |
262 if (mode_ == CLONE_ELEMENTS) { | 267 if (mode_ == CLONE_ELEMENTS) { |
263 message = "Expected (writable) fixed array"; | 268 message = "Expected (writable) fixed array"; |
264 expected_map = factory->fixed_array_map(); | 269 expected_map = factory->fixed_array_map(); |
| 270 } else if (mode_ == CLONE_DOUBLE_ELEMENTS) { |
| 271 message = "Expected (writable) fixed double array"; |
| 272 expected_map = factory->fixed_double_array_map(); |
265 } else { | 273 } else { |
266 ASSERT(mode_ == COPY_ON_WRITE_ELEMENTS); | 274 ASSERT(mode_ == COPY_ON_WRITE_ELEMENTS); |
267 message = "Expected copy-on-write fixed array"; | 275 message = "Expected copy-on-write fixed array"; |
268 expected_map = factory->fixed_cow_array_map(); | 276 expected_map = factory->fixed_cow_array_map(); |
269 } | 277 } |
270 __ push(ecx); | 278 __ push(ecx); |
271 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); | 279 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); |
272 __ cmp(FieldOperand(ecx, HeapObject::kMapOffset), expected_map); | 280 __ cmp(FieldOperand(ecx, HeapObject::kMapOffset), expected_map); |
273 __ Assert(equal, message); | 281 __ Assert(equal, message); |
274 __ pop(ecx); | 282 __ pop(ecx); |
(...skipping 12 matching lines...) Expand all Loading... |
287 } | 295 } |
288 | 296 |
289 if (length_ > 0) { | 297 if (length_ > 0) { |
290 // Get hold of the elements array of the boilerplate and setup the | 298 // Get hold of the elements array of the boilerplate and setup the |
291 // elements pointer in the resulting object. | 299 // elements pointer in the resulting object. |
292 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); | 300 __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset)); |
293 __ lea(edx, Operand(eax, JSArray::kSize)); | 301 __ lea(edx, Operand(eax, JSArray::kSize)); |
294 __ mov(FieldOperand(eax, JSArray::kElementsOffset), edx); | 302 __ mov(FieldOperand(eax, JSArray::kElementsOffset), edx); |
295 | 303 |
296 // Copy the elements array. | 304 // Copy the elements array. |
297 for (int i = 0; i < elements_size; i += kPointerSize) { | 305 if (mode_ == CLONE_ELEMENTS) { |
298 __ mov(ebx, FieldOperand(ecx, i)); | 306 for (int i = 0; i < elements_size; i += kPointerSize) { |
299 __ mov(FieldOperand(edx, i), ebx); | 307 __ mov(ebx, FieldOperand(ecx, i)); |
| 308 __ mov(FieldOperand(edx, i), ebx); |
| 309 } |
| 310 } else { |
| 311 ASSERT(mode_ == CLONE_DOUBLE_ELEMENTS); |
| 312 int i; |
| 313 for (i = 0; i < FixedDoubleArray::kHeaderSize; i += kPointerSize) { |
| 314 __ mov(ebx, FieldOperand(ecx, i)); |
| 315 __ mov(FieldOperand(edx, i), ebx); |
| 316 } |
| 317 while (i < elements_size) { |
| 318 __ fld_d(FieldOperand(ecx, i)); |
| 319 __ fstp_d(FieldOperand(edx, i)); |
| 320 i += kDoubleSize; |
| 321 } |
| 322 ASSERT(i == elements_size); |
300 } | 323 } |
301 } | 324 } |
302 | 325 |
303 // Return and remove the on-stack parameters. | 326 // Return and remove the on-stack parameters. |
304 __ ret(3 * kPointerSize); | 327 __ ret(3 * kPointerSize); |
305 | 328 |
306 __ bind(&slow_case); | 329 __ bind(&slow_case); |
307 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); | 330 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); |
308 } | 331 } |
309 | 332 |
(...skipping 6937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7247 // Restore registers. | 7270 // Restore registers. |
7248 __ pop(eax); | 7271 __ pop(eax); |
7249 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 7272 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
7250 } | 7273 } |
7251 | 7274 |
7252 #undef __ | 7275 #undef __ |
7253 | 7276 |
7254 } } // namespace v8::internal | 7277 } } // namespace v8::internal |
7255 | 7278 |
7256 #endif // V8_TARGET_ARCH_IA32 | 7279 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |