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 #if V8_TARGET_ARCH_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 3546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3557 } | 3557 } |
3558 | 3558 |
3559 Label fast_elements_case; | 3559 Label fast_elements_case; |
3560 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); | 3560 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); |
3561 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 3561 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
3562 | 3562 |
3563 __ bind(&fast_elements_case); | 3563 __ bind(&fast_elements_case); |
3564 GenerateCase(masm, FAST_ELEMENTS); | 3564 GenerateCase(masm, FAST_ELEMENTS); |
3565 } | 3565 } |
3566 | 3566 |
3567 | |
3568 void FastNewObjectStub::Generate(MacroAssembler* masm) { | |
3569 // ----------- S t a t e ------------- | |
3570 // -- a1 : target | |
3571 // -- a3 : new target | |
3572 // -- cp : context | |
3573 // -- ra : return address | |
3574 // ----------------------------------- | |
3575 __ AssertFunction(a1); | |
3576 __ AssertReceiver(a3); | |
3577 | |
3578 // Verify that the new target is a JSFunction. | |
3579 Label new_object; | |
3580 __ GetObjectType(a3, a2, a2); | |
3581 __ Branch(&new_object, ne, a2, Operand(JS_FUNCTION_TYPE)); | |
3582 | |
3583 // Load the initial map and verify that it's in fact a map. | |
3584 __ lw(a2, FieldMemOperand(a3, JSFunction::kPrototypeOrInitialMapOffset)); | |
3585 __ JumpIfSmi(a2, &new_object); | |
3586 __ GetObjectType(a2, a0, a0); | |
3587 __ Branch(&new_object, ne, a0, Operand(MAP_TYPE)); | |
3588 | |
3589 // Fall back to runtime if the target differs from the new target's | |
3590 // initial map constructor. | |
3591 __ lw(a0, FieldMemOperand(a2, Map::kConstructorOrBackPointerOffset)); | |
3592 __ Branch(&new_object, ne, a0, Operand(a1)); | |
3593 | |
3594 // Allocate the JSObject on the heap. | |
3595 Label allocate, done_allocate; | |
3596 __ lbu(t0, FieldMemOperand(a2, Map::kInstanceSizeOffset)); | |
3597 __ Allocate(t0, v0, t1, a0, &allocate, SIZE_IN_WORDS); | |
3598 __ bind(&done_allocate); | |
3599 | |
3600 // Initialize the JSObject fields. | |
3601 __ sw(a2, FieldMemOperand(v0, JSObject::kMapOffset)); | |
3602 __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex); | |
3603 __ sw(a3, FieldMemOperand(v0, JSObject::kPropertiesOffset)); | |
3604 __ sw(a3, FieldMemOperand(v0, JSObject::kElementsOffset)); | |
3605 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); | |
3606 __ Addu(a1, v0, Operand(JSObject::kHeaderSize - kHeapObjectTag)); | |
3607 | |
3608 // ----------- S t a t e ------------- | |
3609 // -- v0 : result (tagged) | |
3610 // -- a1 : result fields (untagged) | |
3611 // -- t1 : result end (untagged) | |
3612 // -- a2 : initial map | |
3613 // -- cp : context | |
3614 // -- ra : return address | |
3615 // ----------------------------------- | |
3616 | |
3617 // Perform in-object slack tracking if requested. | |
3618 Label slack_tracking; | |
3619 STATIC_ASSERT(Map::kNoSlackTracking == 0); | |
3620 __ lw(a3, FieldMemOperand(a2, Map::kBitField3Offset)); | |
3621 __ And(at, a3, Operand(Map::ConstructionCounter::kMask)); | |
3622 __ Branch(USE_DELAY_SLOT, &slack_tracking, ne, at, Operand(0)); | |
3623 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); // In delay slot. | |
3624 { | |
3625 // Initialize all in-object fields with undefined. | |
3626 __ InitializeFieldsWithFiller(a1, t1, a0); | |
3627 __ Ret(); | |
3628 } | |
3629 __ bind(&slack_tracking); | |
3630 { | |
3631 // Decrease generous allocation count. | |
3632 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); | |
3633 __ Subu(a3, a3, Operand(1 << Map::ConstructionCounter::kShift)); | |
3634 __ sw(a3, FieldMemOperand(a2, Map::kBitField3Offset)); | |
3635 | |
3636 // Initialize the in-object fields with undefined. | |
3637 __ lbu(t0, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset)); | |
3638 __ sll(t0, t0, kPointerSizeLog2); | |
3639 __ subu(t0, t1, t0); | |
3640 __ InitializeFieldsWithFiller(a1, t0, a0); | |
3641 | |
3642 // Initialize the remaining (reserved) fields with one pointer filler map. | |
3643 __ LoadRoot(a0, Heap::kOnePointerFillerMapRootIndex); | |
3644 __ InitializeFieldsWithFiller(a1, t1, a0); | |
3645 | |
3646 // Check if we can finalize the instance size. | |
3647 Label finalize; | |
3648 STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1); | |
3649 __ And(a3, a3, Operand(Map::ConstructionCounter::kMask)); | |
3650 __ Branch(&finalize, eq, a3, Operand(zero_reg)); | |
3651 __ Ret(); | |
3652 | |
3653 // Finalize the instance size. | |
3654 __ bind(&finalize); | |
3655 { | |
3656 FrameScope scope(masm, StackFrame::INTERNAL); | |
3657 __ Push(v0, a2); | |
3658 __ CallRuntime(Runtime::kFinalizeInstanceSize); | |
3659 __ Pop(v0); | |
3660 } | |
3661 __ Ret(); | |
3662 } | |
3663 | |
3664 // Fall back to %AllocateInNewSpace. | |
3665 __ bind(&allocate); | |
3666 { | |
3667 FrameScope scope(masm, StackFrame::INTERNAL); | |
3668 STATIC_ASSERT(kSmiTag == 0); | |
3669 STATIC_ASSERT(kSmiTagSize == 1); | |
3670 __ sll(t0, t0, kPointerSizeLog2 + kSmiTagSize); | |
3671 __ Push(a2, t0); | |
3672 __ CallRuntime(Runtime::kAllocateInNewSpace); | |
3673 __ Pop(a2); | |
3674 } | |
3675 __ lbu(t1, FieldMemOperand(a2, Map::kInstanceSizeOffset)); | |
3676 __ Lsa(t1, v0, t1, kPointerSizeLog2); | |
3677 STATIC_ASSERT(kHeapObjectTag == 1); | |
3678 __ Subu(t1, t1, Operand(kHeapObjectTag)); | |
3679 __ jmp(&done_allocate); | |
3680 | |
3681 // Fall back to %NewObject. | |
3682 __ bind(&new_object); | |
3683 __ Push(a1, a3); | |
3684 __ TailCallRuntime(Runtime::kNewObject); | |
3685 } | |
3686 | |
3687 | |
3688 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { | 3567 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { |
3689 // ----------- S t a t e ------------- | 3568 // ----------- S t a t e ------------- |
3690 // -- a1 : function | 3569 // -- a1 : function |
3691 // -- cp : context | 3570 // -- cp : context |
3692 // -- fp : frame pointer | 3571 // -- fp : frame pointer |
3693 // -- ra : return address | 3572 // -- ra : return address |
3694 // ----------------------------------- | 3573 // ----------------------------------- |
3695 __ AssertFunction(a1); | 3574 __ AssertFunction(a1); |
3696 | 3575 |
3697 // Make a2 point to the JavaScript frame. | 3576 // Make a2 point to the JavaScript frame. |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4483 kStackUnwindSpace, kInvalidStackOffset, | 4362 kStackUnwindSpace, kInvalidStackOffset, |
4484 return_value_operand, NULL); | 4363 return_value_operand, NULL); |
4485 } | 4364 } |
4486 | 4365 |
4487 #undef __ | 4366 #undef __ |
4488 | 4367 |
4489 } // namespace internal | 4368 } // namespace internal |
4490 } // namespace v8 | 4369 } // namespace v8 |
4491 | 4370 |
4492 #endif // V8_TARGET_ARCH_MIPS | 4371 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |