| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // Need to collect. Call into runtime system. | 337 // Need to collect. Call into runtime system. |
| 338 __ bind(&gc); | 338 __ bind(&gc); |
| 339 __ TailCallRuntime(Runtime::kPushBlockContext, 2, 1); | 339 __ TailCallRuntime(Runtime::kPushBlockContext, 2, 1); |
| 340 } | 340 } |
| 341 | 341 |
| 342 | 342 |
| 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 Label* fail) { | 348 Label* fail) { |
| 348 // Registers on entry: | 349 // Registers on entry: |
| 349 // | 350 // |
| 350 // r3: boilerplate literal array. | 351 // r3: boilerplate literal array. |
| 351 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS); | 352 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS); |
| 352 | 353 |
| 353 // All sizes here are multiples of kPointerSize. | 354 // All sizes here are multiples of kPointerSize. |
| 354 int elements_size = 0; | 355 int elements_size = 0; |
| 355 if (length > 0) { | 356 if (length > 0) { |
| 356 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | 357 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS |
| 357 ? FixedDoubleArray::SizeFor(length) | 358 ? FixedDoubleArray::SizeFor(length) |
| 358 : FixedArray::SizeFor(length); | 359 : FixedArray::SizeFor(length); |
| 359 } | 360 } |
| 360 int size = JSArray::kSize + elements_size; | 361 int size = JSArray::kSize; |
| 362 int allocation_info_start = size; |
| 363 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { |
| 364 size += AllocationSiteInfo::kSize; |
| 365 } |
| 366 size += elements_size; |
| 361 | 367 |
| 362 // 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 |
| 363 // allocation. This avoids multiple limit checks. | 369 // allocation. This avoids multiple limit checks. |
| 364 AllocationFlags flags = TAG_OBJECT; | 370 AllocationFlags flags = TAG_OBJECT; |
| 365 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) { | 371 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) { |
| 366 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags); | 372 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags); |
| 367 } | 373 } |
| 368 __ AllocateInNewSpace(size, r0, r1, r2, fail, flags); | 374 __ AllocateInNewSpace(size, r0, r1, r2, fail, flags); |
| 369 | 375 |
| 376 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { |
| 377 __ mov(r2, Operand(Handle<Map>(masm->isolate()->heap()-> |
| 378 allocation_site_info_map()))); |
| 379 __ str(r2, FieldMemOperand(r0, allocation_info_start)); |
| 380 __ str(r3, FieldMemOperand(r0, allocation_info_start + kPointerSize)); |
| 381 } |
| 382 |
| 370 // Copy the JS array part. | 383 // Copy the JS array part. |
| 371 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { | 384 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
| 372 if ((i != JSArray::kElementsOffset) || (length == 0)) { | 385 if ((i != JSArray::kElementsOffset) || (length == 0)) { |
| 373 __ ldr(r1, FieldMemOperand(r3, i)); | 386 __ ldr(r1, FieldMemOperand(r3, i)); |
| 374 __ str(r1, FieldMemOperand(r0, i)); | 387 __ str(r1, FieldMemOperand(r0, i)); |
| 375 } | 388 } |
| 376 } | 389 } |
| 377 | 390 |
| 378 if (length > 0) { | 391 if (length > 0) { |
| 379 // 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 |
| 380 // elements pointer in the resulting object. | 393 // elements pointer in the resulting object. |
| 381 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset)); | 394 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset)); |
| 382 __ add(r2, r0, Operand(JSArray::kSize)); | 395 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { |
| 396 __ add(r2, r0, Operand(JSArray::kSize + AllocationSiteInfo::kSize)); |
| 397 } else { |
| 398 __ add(r2, r0, Operand(JSArray::kSize)); |
| 399 } |
| 383 __ str(r2, FieldMemOperand(r0, JSArray::kElementsOffset)); | 400 __ str(r2, FieldMemOperand(r0, JSArray::kElementsOffset)); |
| 384 | 401 |
| 385 // Copy the elements array. | 402 // Copy the elements array. |
| 386 ASSERT((elements_size % kPointerSize) == 0); | 403 ASSERT((elements_size % kPointerSize) == 0); |
| 387 __ CopyFields(r2, r3, r1.bit(), elements_size / kPointerSize); | 404 __ CopyFields(r2, r3, r1.bit(), elements_size / kPointerSize); |
| 388 } | 405 } |
| 389 } | 406 } |
| 390 | 407 |
| 391 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { | 408 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { |
| 392 // Stack layout on entry: | 409 // Stack layout on entry: |
| 393 // | 410 // |
| 394 // [sp]: constant elements. | 411 // [sp]: constant elements. |
| 395 // [sp + kPointerSize]: literal index. | 412 // [sp + kPointerSize]: literal index. |
| 396 // [sp + (2 * kPointerSize)]: literals array. | 413 // [sp + (2 * kPointerSize)]: literals array. |
| 397 | 414 |
| 398 // Load boilerplate object into r3 and check if we need to create a | 415 // Load boilerplate object into r3 and check if we need to create a |
| 399 // boilerplate. | 416 // boilerplate. |
| 400 Label slow_case; | 417 Label slow_case; |
| 401 __ ldr(r3, MemOperand(sp, 2 * kPointerSize)); | 418 __ ldr(r3, MemOperand(sp, 2 * kPointerSize)); |
| 402 __ ldr(r0, MemOperand(sp, 1 * kPointerSize)); | 419 __ ldr(r0, MemOperand(sp, 1 * kPointerSize)); |
| 403 __ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 420 __ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 404 __ ldr(r3, MemOperand(r3, r0, LSL, kPointerSizeLog2 - kSmiTagSize)); | 421 __ ldr(r3, MemOperand(r3, r0, LSL, kPointerSizeLog2 - kSmiTagSize)); |
| 405 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); | 422 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); |
| 406 __ b(eq, &slow_case); | 423 __ b(eq, &slow_case); |
| 407 | 424 |
| 408 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 |
| 409 if (mode == CLONE_ANY_ELEMENTS) { | 433 if (mode == CLONE_ANY_ELEMENTS) { |
| 410 Label double_elements, check_fast_elements; | 434 Label double_elements, check_fast_elements; |
| 411 __ ldr(r0, FieldMemOperand(r3, JSArray::kElementsOffset)); | 435 __ ldr(r0, FieldMemOperand(r3, JSArray::kElementsOffset)); |
| 412 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | 436 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 413 __ CompareRoot(r0, Heap::kFixedCOWArrayMapRootIndex); | 437 __ CompareRoot(r0, Heap::kFixedCOWArrayMapRootIndex); |
| 414 __ b(ne, &check_fast_elements); | 438 __ b(ne, &check_fast_elements); |
| 415 GenerateFastCloneShallowArrayCommon(masm, 0, | 439 GenerateFastCloneShallowArrayCommon(masm, 0, |
| 416 COPY_ON_WRITE_ELEMENTS, &slow_case); | 440 COPY_ON_WRITE_ELEMENTS, |
| 441 allocation_site_info_mode, |
| 442 &slow_case); |
| 417 // Return and remove the on-stack parameters. | 443 // Return and remove the on-stack parameters. |
| 418 __ add(sp, sp, Operand(3 * kPointerSize)); | 444 __ add(sp, sp, Operand(3 * kPointerSize)); |
| 419 __ Ret(); | 445 __ Ret(); |
| 420 | 446 |
| 421 __ bind(&check_fast_elements); | 447 __ bind(&check_fast_elements); |
| 422 __ CompareRoot(r0, Heap::kFixedArrayMapRootIndex); | 448 __ CompareRoot(r0, Heap::kFixedArrayMapRootIndex); |
| 423 __ b(ne, &double_elements); | 449 __ b(ne, &double_elements); |
| 424 GenerateFastCloneShallowArrayCommon(masm, length_, | 450 GenerateFastCloneShallowArrayCommon(masm, length_, |
| 425 CLONE_ELEMENTS, &slow_case); | 451 CLONE_ELEMENTS, |
| 452 allocation_site_info_mode, |
| 453 &slow_case); |
| 426 // Return and remove the on-stack parameters. | 454 // Return and remove the on-stack parameters. |
| 427 __ add(sp, sp, Operand(3 * kPointerSize)); | 455 __ add(sp, sp, Operand(3 * kPointerSize)); |
| 428 __ Ret(); | 456 __ Ret(); |
| 429 | 457 |
| 430 __ bind(&double_elements); | 458 __ bind(&double_elements); |
| 431 mode = CLONE_DOUBLE_ELEMENTS; | 459 mode = CLONE_DOUBLE_ELEMENTS; |
| 432 // Fall through to generate the code to handle double elements. | 460 // Fall through to generate the code to handle double elements. |
| 433 } | 461 } |
| 434 | 462 |
| 435 if (FLAG_debug_code) { | 463 if (FLAG_debug_code) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 447 expected_map_index = Heap::kFixedCOWArrayMapRootIndex; | 475 expected_map_index = Heap::kFixedCOWArrayMapRootIndex; |
| 448 } | 476 } |
| 449 __ push(r3); | 477 __ push(r3); |
| 450 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset)); | 478 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset)); |
| 451 __ ldr(r3, FieldMemOperand(r3, HeapObject::kMapOffset)); | 479 __ ldr(r3, FieldMemOperand(r3, HeapObject::kMapOffset)); |
| 452 __ CompareRoot(r3, expected_map_index); | 480 __ CompareRoot(r3, expected_map_index); |
| 453 __ Assert(eq, message); | 481 __ Assert(eq, message); |
| 454 __ pop(r3); | 482 __ pop(r3); |
| 455 } | 483 } |
| 456 | 484 |
| 457 GenerateFastCloneShallowArrayCommon(masm, length_, mode, &slow_case); | 485 GenerateFastCloneShallowArrayCommon(masm, length_, mode, |
| 486 allocation_site_info_mode, &slow_case); |
| 458 | 487 |
| 459 // Return and remove the on-stack parameters. | 488 // Return and remove the on-stack parameters. |
| 460 __ add(sp, sp, Operand(3 * kPointerSize)); | 489 __ add(sp, sp, Operand(3 * kPointerSize)); |
| 461 __ Ret(); | 490 __ Ret(); |
| 462 | 491 |
| 463 __ bind(&slow_case); | 492 __ bind(&slow_case); |
| 464 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); | 493 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); |
| 465 } | 494 } |
| 466 | 495 |
| 467 | 496 |
| (...skipping 7242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7710 | 7739 |
| 7711 __ Pop(lr, r5, r1); | 7740 __ Pop(lr, r5, r1); |
| 7712 __ Ret(); | 7741 __ Ret(); |
| 7713 } | 7742 } |
| 7714 | 7743 |
| 7715 #undef __ | 7744 #undef __ |
| 7716 | 7745 |
| 7717 } } // namespace v8::internal | 7746 } } // namespace v8::internal |
| 7718 | 7747 |
| 7719 #endif // V8_TARGET_ARCH_ARM | 7748 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |