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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 static void GenerateFastCloneShallowArrayCommon( | 343 static void GenerateFastCloneShallowArrayCommon( |
344 MacroAssembler* masm, | 344 MacroAssembler* masm, |
345 int length, | 345 int length, |
346 FastCloneShallowArrayStub::Mode mode, | 346 FastCloneShallowArrayStub::Mode mode, |
347 AllocationSiteInfoMode allocation_site_info_mode, | 347 AllocationSiteInfoMode allocation_site_info_mode, |
348 Label* fail) { | 348 Label* fail) { |
349 // Registers on entry: | 349 // Registers on entry: |
350 // | 350 // |
351 // r3: boilerplate literal array. | 351 // r3: boilerplate literal array. |
352 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS); | 352 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS); |
| 353 bool tracking_on = allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO; |
353 | 354 |
354 // All sizes here are multiples of kPointerSize. | 355 // All sizes here are multiples of kPointerSize. |
355 int elements_size = 0; | 356 int elements_size = 0; |
356 if (length > 0) { | 357 if (length > 0) { |
357 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | 358 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS |
358 ? FixedDoubleArray::SizeFor(length) | 359 ? FixedDoubleArray::SizeFor(length) |
359 : FixedArray::SizeFor(length); | 360 : FixedArray::SizeFor(length); |
360 } | 361 } |
| 362 |
361 int size = JSArray::kSize; | 363 int size = JSArray::kSize; |
362 int allocation_info_start = size; | 364 int allocation_info_start = size; |
363 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { | 365 size += tracking_on ? AllocationSiteInfo::kSize + elements_size |
364 size += AllocationSiteInfo::kSize; | 366 : elements_size; |
365 } | |
366 size += elements_size; | |
367 | 367 |
368 // Allocate both the JS array and the elements array in one big | 368 // Allocate both the JS array and the elements array in one big |
369 // allocation. This avoids multiple limit checks. | 369 // allocation. This avoids multiple limit checks. |
370 AllocationFlags flags = TAG_OBJECT; | 370 AllocationFlags flags = TAG_OBJECT; |
371 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) { | 371 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) { |
372 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags); | 372 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags); |
373 } | 373 } |
374 __ AllocateInNewSpace(size, r0, r1, r2, fail, flags); | 374 __ AllocateInNewSpace(size, r0, r1, r2, fail, flags); |
375 | 375 |
376 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { | 376 if (tracking_on) { |
377 __ mov(r2, Operand(Handle<Map>(masm->isolate()->heap()-> | 377 __ mov(r2, Operand(Handle<Map>(masm->isolate()->heap()-> |
378 allocation_site_info_map()))); | 378 allocation_site_info_map()))); |
379 __ str(r2, FieldMemOperand(r0, allocation_info_start)); | 379 __ str(r2, FieldMemOperand(r0, allocation_info_start)); |
380 __ str(r3, FieldMemOperand(r0, allocation_info_start + kPointerSize)); | 380 __ str(r3, FieldMemOperand(r0, allocation_info_start + kPointerSize)); |
381 } | 381 } |
382 | 382 |
383 // Copy the JS array part. | 383 // Copy the JS array part. |
384 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { | 384 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
385 if ((i != JSArray::kElementsOffset) || (length == 0)) { | 385 if ((i != JSArray::kElementsOffset) || (length == 0)) { |
386 __ ldr(r1, FieldMemOperand(r3, i)); | 386 __ ldr(r1, FieldMemOperand(r3, i)); |
387 __ str(r1, FieldMemOperand(r0, i)); | 387 __ str(r1, FieldMemOperand(r0, i)); |
388 } | 388 } |
389 } | 389 } |
390 | 390 |
391 if (length > 0) { | 391 if (length > 0) { |
392 // Get hold of the elements array of the boilerplate and setup the | 392 // Get hold of the elements array of the boilerplate and setup the |
393 // elements pointer in the resulting object. | 393 // elements pointer in the resulting object. |
394 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset)); | 394 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset)); |
395 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { | 395 if (tracking_on) { |
396 __ add(r2, r0, Operand(JSArray::kSize + AllocationSiteInfo::kSize)); | 396 __ add(r2, r0, Operand(JSArray::kSize + AllocationSiteInfo::kSize)); |
397 } else { | 397 } else { |
398 __ add(r2, r0, Operand(JSArray::kSize)); | 398 __ add(r2, r0, Operand(JSArray::kSize)); |
399 } | 399 } |
400 __ str(r2, FieldMemOperand(r0, JSArray::kElementsOffset)); | 400 __ str(r2, FieldMemOperand(r0, JSArray::kElementsOffset)); |
401 | 401 |
402 // Copy the elements array. | 402 // Copy the elements array. |
403 ASSERT((elements_size % kPointerSize) == 0); | 403 ASSERT((elements_size % kPointerSize) == 0); |
404 __ CopyFields(r2, r3, r1.bit(), elements_size / kPointerSize); | 404 __ CopyFields(r2, r3, r1.bit(), elements_size / kPointerSize); |
405 } | 405 } |
(...skipping 10 matching lines...) Expand all Loading... |
416 // boilerplate. | 416 // boilerplate. |
417 Label slow_case; | 417 Label slow_case; |
418 __ ldr(r3, MemOperand(sp, 2 * kPointerSize)); | 418 __ ldr(r3, MemOperand(sp, 2 * kPointerSize)); |
419 __ ldr(r0, MemOperand(sp, 1 * kPointerSize)); | 419 __ ldr(r0, MemOperand(sp, 1 * kPointerSize)); |
420 __ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 420 __ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
421 __ ldr(r3, MemOperand(r3, r0, LSL, kPointerSizeLog2 - kSmiTagSize)); | 421 __ ldr(r3, MemOperand(r3, r0, LSL, kPointerSizeLog2 - kSmiTagSize)); |
422 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); | 422 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); |
423 __ b(eq, &slow_case); | 423 __ b(eq, &slow_case); |
424 | 424 |
425 FastCloneShallowArrayStub::Mode mode = mode_; | 425 FastCloneShallowArrayStub::Mode mode = mode_; |
426 AllocationSiteInfoMode allocation_site_info_mode = | |
427 DONT_TRACK_ALLOCATION_SITE_INFO; | |
428 if (mode == CLONE_ANY_ELEMENTS_WITH_ALLOCATION_SITE_INFO) { | |
429 mode = CLONE_ANY_ELEMENTS; | |
430 allocation_site_info_mode = TRACK_ALLOCATION_SITE_INFO; | |
431 } | |
432 | |
433 if (mode == CLONE_ANY_ELEMENTS) { | 426 if (mode == CLONE_ANY_ELEMENTS) { |
434 Label double_elements, check_fast_elements; | 427 Label double_elements, check_fast_elements; |
435 __ ldr(r0, FieldMemOperand(r3, JSArray::kElementsOffset)); | 428 __ ldr(r0, FieldMemOperand(r3, JSArray::kElementsOffset)); |
436 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | 429 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); |
437 __ CompareRoot(r0, Heap::kFixedCOWArrayMapRootIndex); | 430 __ CompareRoot(r0, Heap::kFixedCOWArrayMapRootIndex); |
438 __ b(ne, &check_fast_elements); | 431 __ b(ne, &check_fast_elements); |
439 GenerateFastCloneShallowArrayCommon(masm, 0, | 432 GenerateFastCloneShallowArrayCommon(masm, 0, COPY_ON_WRITE_ELEMENTS, |
440 COPY_ON_WRITE_ELEMENTS, | 433 allocation_site_info_mode_, |
441 allocation_site_info_mode, | |
442 &slow_case); | 434 &slow_case); |
443 // Return and remove the on-stack parameters. | 435 // Return and remove the on-stack parameters. |
444 __ add(sp, sp, Operand(3 * kPointerSize)); | 436 __ add(sp, sp, Operand(3 * kPointerSize)); |
445 __ Ret(); | 437 __ Ret(); |
446 | 438 |
447 __ bind(&check_fast_elements); | 439 __ bind(&check_fast_elements); |
448 __ CompareRoot(r0, Heap::kFixedArrayMapRootIndex); | 440 __ CompareRoot(r0, Heap::kFixedArrayMapRootIndex); |
449 __ b(ne, &double_elements); | 441 __ b(ne, &double_elements); |
450 GenerateFastCloneShallowArrayCommon(masm, length_, | 442 GenerateFastCloneShallowArrayCommon(masm, length_, CLONE_ELEMENTS, |
451 CLONE_ELEMENTS, | 443 allocation_site_info_mode_, |
452 allocation_site_info_mode, | |
453 &slow_case); | 444 &slow_case); |
454 // Return and remove the on-stack parameters. | 445 // Return and remove the on-stack parameters. |
455 __ add(sp, sp, Operand(3 * kPointerSize)); | 446 __ add(sp, sp, Operand(3 * kPointerSize)); |
456 __ Ret(); | 447 __ Ret(); |
457 | 448 |
458 __ bind(&double_elements); | 449 __ bind(&double_elements); |
459 mode = CLONE_DOUBLE_ELEMENTS; | 450 mode = CLONE_DOUBLE_ELEMENTS; |
460 // Fall through to generate the code to handle double elements. | 451 // Fall through to generate the code to handle double elements. |
461 } | 452 } |
462 | 453 |
(...skipping 13 matching lines...) Expand all Loading... |
476 } | 467 } |
477 __ push(r3); | 468 __ push(r3); |
478 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset)); | 469 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset)); |
479 __ ldr(r3, FieldMemOperand(r3, HeapObject::kMapOffset)); | 470 __ ldr(r3, FieldMemOperand(r3, HeapObject::kMapOffset)); |
480 __ CompareRoot(r3, expected_map_index); | 471 __ CompareRoot(r3, expected_map_index); |
481 __ Assert(eq, message); | 472 __ Assert(eq, message); |
482 __ pop(r3); | 473 __ pop(r3); |
483 } | 474 } |
484 | 475 |
485 GenerateFastCloneShallowArrayCommon(masm, length_, mode, | 476 GenerateFastCloneShallowArrayCommon(masm, length_, mode, |
486 allocation_site_info_mode, &slow_case); | 477 allocation_site_info_mode_, |
| 478 &slow_case); |
487 | 479 |
488 // Return and remove the on-stack parameters. | 480 // Return and remove the on-stack parameters. |
489 __ add(sp, sp, Operand(3 * kPointerSize)); | 481 __ add(sp, sp, Operand(3 * kPointerSize)); |
490 __ Ret(); | 482 __ Ret(); |
491 | 483 |
492 __ bind(&slow_case); | 484 __ bind(&slow_case); |
493 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); | 485 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); |
494 } | 486 } |
495 | 487 |
496 | 488 |
(...skipping 7260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7757 | 7749 |
7758 __ Pop(lr, r5, r1); | 7750 __ Pop(lr, r5, r1); |
7759 __ Ret(); | 7751 __ Ret(); |
7760 } | 7752 } |
7761 | 7753 |
7762 #undef __ | 7754 #undef __ |
7763 | 7755 |
7764 } } // namespace v8::internal | 7756 } } // namespace v8::internal |
7765 | 7757 |
7766 #endif // V8_TARGET_ARCH_ARM | 7758 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |