| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
| 8 | 8 |
| 9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
| 10 #include "src/debug.h" | 10 #include "src/debug.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 __ b(eq, &normal_new); | 378 __ b(eq, &normal_new); |
| 379 | 379 |
| 380 // Original constructor and function are different. | 380 // Original constructor and function are different. |
| 381 Generate_Runtime_NewObject(masm, create_memento, r3, &count_incremented, | 381 Generate_Runtime_NewObject(masm, create_memento, r3, &count_incremented, |
| 382 &allocated); | 382 &allocated); |
| 383 __ bind(&normal_new); | 383 __ bind(&normal_new); |
| 384 | 384 |
| 385 // Try to allocate the object without transitioning into C code. If any of | 385 // Try to allocate the object without transitioning into C code. If any of |
| 386 // the preconditions is not met, the code bails out to the runtime call. | 386 // the preconditions is not met, the code bails out to the runtime call. |
| 387 if (FLAG_inline_new) { | 387 if (FLAG_inline_new) { |
| 388 Label undo_allocation; | |
| 389 ExternalReference debug_step_in_fp = | 388 ExternalReference debug_step_in_fp = |
| 390 ExternalReference::debug_step_in_fp_address(isolate); | 389 ExternalReference::debug_step_in_fp_address(isolate); |
| 391 __ mov(r2, Operand(debug_step_in_fp)); | 390 __ mov(r2, Operand(debug_step_in_fp)); |
| 392 __ ldr(r2, MemOperand(r2)); | 391 __ ldr(r2, MemOperand(r2)); |
| 393 __ tst(r2, r2); | 392 __ tst(r2, r2); |
| 394 __ b(ne, &rt_call); | 393 __ b(ne, &rt_call); |
| 395 | 394 |
| 396 // Load the initial map and verify that it is in fact a map. | 395 // Load the initial map and verify that it is in fact a map. |
| 397 // r1: constructor function | 396 // r1: constructor function |
| 398 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); | 397 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 Label no_inobject_slack_tracking; | 470 Label no_inobject_slack_tracking; |
| 472 | 471 |
| 473 // Check if slack tracking is enabled. | 472 // Check if slack tracking is enabled. |
| 474 __ ldr(ip, FieldMemOperand(r2, Map::kBitField3Offset)); | 473 __ ldr(ip, FieldMemOperand(r2, Map::kBitField3Offset)); |
| 475 __ DecodeField<Map::Counter>(ip); | 474 __ DecodeField<Map::Counter>(ip); |
| 476 __ cmp(ip, Operand(Map::kSlackTrackingCounterEnd)); | 475 __ cmp(ip, Operand(Map::kSlackTrackingCounterEnd)); |
| 477 __ b(lt, &no_inobject_slack_tracking); | 476 __ b(lt, &no_inobject_slack_tracking); |
| 478 | 477 |
| 479 // Allocate object with a slack. | 478 // Allocate object with a slack. |
| 480 __ ldr(r0, FieldMemOperand(r2, Map::kInstanceSizesOffset)); | 479 __ ldr(r0, FieldMemOperand(r2, Map::kInstanceSizesOffset)); |
| 481 __ Ubfx(r0, r0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte, | 480 __ Ubfx(r0, r0, Map::kInObjectPropertiesByte * kBitsPerByte, |
| 482 kBitsPerByte); | 481 kBitsPerByte); |
| 482 __ ldr(r2, FieldMemOperand(r2, Map::kInstanceAttributesOffset)); |
| 483 __ Ubfx(r2, r2, Map::kUnusedPropertyFieldsByte * kBitsPerByte, |
| 484 kBitsPerByte); |
| 485 __ sub(r0, r0, Operand(r2)); |
| 483 __ add(r0, r5, Operand(r0, LSL, kPointerSizeLog2)); | 486 __ add(r0, r5, Operand(r0, LSL, kPointerSizeLog2)); |
| 484 // r0: offset of first field after pre-allocated fields | 487 // r0: offset of first field after pre-allocated fields |
| 485 if (FLAG_debug_code) { | 488 if (FLAG_debug_code) { |
| 486 __ add(ip, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. | 489 __ add(ip, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
| 487 __ cmp(r0, ip); | 490 __ cmp(r0, ip); |
| 488 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields); | 491 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields); |
| 489 } | 492 } |
| 490 __ InitializeFieldsWithFiller(r5, r0, r6); | 493 __ InitializeFieldsWithFiller(r5, r0, r6); |
| 491 // To allow for truncation. | 494 // To allow for truncation. |
| 492 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex); | 495 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 508 // Load the AllocationSite | 511 // Load the AllocationSite |
| 509 __ ldr(r6, MemOperand(sp, 2 * kPointerSize)); | 512 __ ldr(r6, MemOperand(sp, 2 * kPointerSize)); |
| 510 DCHECK_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset); | 513 DCHECK_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset); |
| 511 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); | 514 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
| 512 } else { | 515 } else { |
| 513 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. | 516 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
| 514 __ InitializeFieldsWithFiller(r5, r0, r6); | 517 __ InitializeFieldsWithFiller(r5, r0, r6); |
| 515 } | 518 } |
| 516 | 519 |
| 517 // Add the object tag to make the JSObject real, so that we can continue | 520 // Add the object tag to make the JSObject real, so that we can continue |
| 518 // and jump into the continuation code at any time from now on. Any | 521 // and jump into the continuation code at any time from now on. |
| 519 // failures need to undo the allocation, so that the heap is in a | |
| 520 // consistent state and verifiable. | |
| 521 __ add(r4, r4, Operand(kHeapObjectTag)); | 522 __ add(r4, r4, Operand(kHeapObjectTag)); |
| 522 | 523 |
| 523 // Check if a non-empty properties array is needed. Continue with | |
| 524 // allocated object if not; allocate and initialize a FixedArray if yes. | |
| 525 // r1: constructor function | |
| 526 // r4: JSObject | |
| 527 // r5: start of next object (not tagged) | |
| 528 __ ldrb(r3, FieldMemOperand(r2, Map::kUnusedPropertyFieldsOffset)); | |
| 529 // The field instance sizes contains both pre-allocated property fields | |
| 530 // and in-object properties. | |
| 531 __ ldr(r0, FieldMemOperand(r2, Map::kInstanceSizesOffset)); | |
| 532 __ Ubfx(r6, r0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte, | |
| 533 kBitsPerByte); | |
| 534 __ add(r3, r3, Operand(r6)); | |
| 535 __ Ubfx(r6, r0, Map::kInObjectPropertiesByte * kBitsPerByte, | |
| 536 kBitsPerByte); | |
| 537 __ sub(r3, r3, Operand(r6), SetCC); | |
| 538 | |
| 539 // Done if no extra properties are to be allocated. | |
| 540 __ b(eq, &allocated); | |
| 541 __ Assert(pl, kPropertyAllocationCountFailed); | |
| 542 | |
| 543 // Scale the number of elements by pointer size and add the header for | |
| 544 // FixedArrays to the start of the next object calculation from above. | |
| 545 // r1: constructor | |
| 546 // r3: number of elements in properties array | |
| 547 // r4: JSObject | |
| 548 // r5: start of next object | |
| 549 __ add(r0, r3, Operand(FixedArray::kHeaderSize / kPointerSize)); | |
| 550 __ Allocate( | |
| 551 r0, | |
| 552 r5, | |
| 553 r6, | |
| 554 r2, | |
| 555 &undo_allocation, | |
| 556 static_cast<AllocationFlags>(RESULT_CONTAINS_TOP | SIZE_IN_WORDS)); | |
| 557 | |
| 558 // Initialize the FixedArray. | |
| 559 // r1: constructor | |
| 560 // r3: number of elements in properties array | |
| 561 // r4: JSObject | |
| 562 // r5: FixedArray (not tagged) | |
| 563 __ LoadRoot(r6, Heap::kFixedArrayMapRootIndex); | |
| 564 __ mov(r2, r5); | |
| 565 DCHECK_EQ(0 * kPointerSize, JSObject::kMapOffset); | |
| 566 __ str(r6, MemOperand(r2, kPointerSize, PostIndex)); | |
| 567 DCHECK_EQ(1 * kPointerSize, FixedArray::kLengthOffset); | |
| 568 __ SmiTag(r0, r3); | |
| 569 __ str(r0, MemOperand(r2, kPointerSize, PostIndex)); | |
| 570 | |
| 571 // Initialize the fields to undefined. | |
| 572 // r1: constructor function | |
| 573 // r2: First element of FixedArray (not tagged) | |
| 574 // r3: number of elements in properties array | |
| 575 // r4: JSObject | |
| 576 // r5: FixedArray (not tagged) | |
| 577 __ add(r6, r2, Operand(r3, LSL, kPointerSizeLog2)); // End of object. | |
| 578 DCHECK_EQ(2 * kPointerSize, FixedArray::kHeaderSize); | |
| 579 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | |
| 580 __ InitializeFieldsWithFiller(r2, r6, r0); | |
| 581 | |
| 582 // Store the initialized FixedArray into the properties field of | |
| 583 // the JSObject | |
| 584 // r1: constructor function | |
| 585 // r4: JSObject | |
| 586 // r5: FixedArray (not tagged) | |
| 587 __ add(r5, r5, Operand(kHeapObjectTag)); // Add the heap tag. | |
| 588 __ str(r5, FieldMemOperand(r4, JSObject::kPropertiesOffset)); | |
| 589 | |
| 590 // Continue with JSObject being successfully allocated | 524 // Continue with JSObject being successfully allocated |
| 591 // r1: constructor function | |
| 592 // r4: JSObject | 525 // r4: JSObject |
| 593 __ jmp(&allocated); | 526 __ jmp(&allocated); |
| 594 | |
| 595 // Undo the setting of the new top so that the heap is verifiable. For | |
| 596 // example, the map's unused properties potentially do not match the | |
| 597 // allocated objects unused properties. | |
| 598 // r4: JSObject (previous new top) | |
| 599 __ bind(&undo_allocation); | |
| 600 __ UndoAllocationInNewSpace(r4, r5); | |
| 601 } | 527 } |
| 602 | 528 |
| 603 // Allocate the new receiver object using the runtime call. | 529 // Allocate the new receiver object using the runtime call. |
| 604 // r1: constructor function | 530 // r1: constructor function |
| 605 __ bind(&rt_call); | 531 __ bind(&rt_call); |
| 606 Generate_Runtime_NewObject(masm, create_memento, r1, &count_incremented, | 532 Generate_Runtime_NewObject(masm, create_memento, r1, &count_incremented, |
| 607 &allocated); | 533 &allocated); |
| 608 | 534 |
| 609 // Receiver for constructor call allocated. | 535 // Receiver for constructor call allocated. |
| 610 // r4: JSObject | 536 // r4: JSObject |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1813 } | 1739 } |
| 1814 } | 1740 } |
| 1815 | 1741 |
| 1816 | 1742 |
| 1817 #undef __ | 1743 #undef __ |
| 1818 | 1744 |
| 1819 } // namespace internal | 1745 } // namespace internal |
| 1820 } // namespace v8 | 1746 } // namespace v8 |
| 1821 | 1747 |
| 1822 #endif // V8_TARGET_ARCH_ARM | 1748 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |