OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 4686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4697 | 4697 |
4698 Label fast_elements_case; | 4698 Label fast_elements_case; |
4699 __ cmpi(r6, Operand(FAST_ELEMENTS)); | 4699 __ cmpi(r6, Operand(FAST_ELEMENTS)); |
4700 __ beq(&fast_elements_case); | 4700 __ beq(&fast_elements_case); |
4701 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 4701 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
4702 | 4702 |
4703 __ bind(&fast_elements_case); | 4703 __ bind(&fast_elements_case); |
4704 GenerateCase(masm, FAST_ELEMENTS); | 4704 GenerateCase(masm, FAST_ELEMENTS); |
4705 } | 4705 } |
4706 | 4706 |
| 4707 void FastNewObjectStub::Generate(MacroAssembler* masm) { |
| 4708 // ----------- S t a t e ------------- |
| 4709 // -- r4 : target |
| 4710 // -- r6 : new target |
| 4711 // -- cp : context |
| 4712 // -- lr : return address |
| 4713 // ----------------------------------- |
| 4714 __ AssertFunction(r4); |
| 4715 __ AssertReceiver(r6); |
| 4716 |
| 4717 // Verify that the new target is a JSFunction. |
| 4718 Label new_object; |
| 4719 __ CompareObjectType(r6, r5, r5, JS_FUNCTION_TYPE); |
| 4720 __ bne(&new_object); |
| 4721 |
| 4722 // Load the initial map and verify that it's in fact a map. |
| 4723 __ LoadP(r5, FieldMemOperand(r6, JSFunction::kPrototypeOrInitialMapOffset)); |
| 4724 __ JumpIfSmi(r5, &new_object); |
| 4725 __ CompareObjectType(r5, r3, r3, MAP_TYPE); |
| 4726 __ bne(&new_object); |
| 4727 |
| 4728 // Fall back to runtime if the target differs from the new target's |
| 4729 // initial map constructor. |
| 4730 __ LoadP(r3, FieldMemOperand(r5, Map::kConstructorOrBackPointerOffset)); |
| 4731 __ cmp(r3, r4); |
| 4732 __ bne(&new_object); |
| 4733 |
| 4734 // Allocate the JSObject on the heap. |
| 4735 Label allocate, done_allocate; |
| 4736 __ lbz(r7, FieldMemOperand(r5, Map::kInstanceSizeOffset)); |
| 4737 __ Allocate(r7, r3, r8, r9, &allocate, SIZE_IN_WORDS); |
| 4738 __ bind(&done_allocate); |
| 4739 |
| 4740 // Initialize the JSObject fields. |
| 4741 __ StoreP(r5, MemOperand(r3, JSObject::kMapOffset)); |
| 4742 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); |
| 4743 __ StoreP(r6, MemOperand(r3, JSObject::kPropertiesOffset)); |
| 4744 __ StoreP(r6, MemOperand(r3, JSObject::kElementsOffset)); |
| 4745 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); |
| 4746 __ addi(r4, r3, Operand(JSObject::kHeaderSize)); |
| 4747 |
| 4748 // ----------- S t a t e ------------- |
| 4749 // -- r3 : result (untagged) |
| 4750 // -- r4 : result fields (untagged) |
| 4751 // -- r8 : result end (untagged) |
| 4752 // -- r5 : initial map |
| 4753 // -- cp : context |
| 4754 // -- lr : return address |
| 4755 // ----------------------------------- |
| 4756 |
| 4757 // Perform in-object slack tracking if requested. |
| 4758 Label slack_tracking; |
| 4759 STATIC_ASSERT(Map::kNoSlackTracking == 0); |
| 4760 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); |
| 4761 __ lwz(r6, FieldMemOperand(r5, Map::kBitField3Offset)); |
| 4762 __ DecodeField<Map::ConstructionCounter>(r10, r6, SetRC); |
| 4763 __ bne(&slack_tracking, cr0); |
| 4764 { |
| 4765 // Initialize all in-object fields with undefined. |
| 4766 __ InitializeFieldsWithFiller(r4, r8, r9); |
| 4767 |
| 4768 // Add the object tag to make the JSObject real. |
| 4769 __ addi(r3, r3, Operand(kHeapObjectTag)); |
| 4770 __ Ret(); |
| 4771 } |
| 4772 __ bind(&slack_tracking); |
| 4773 { |
| 4774 // Decrease generous allocation count. |
| 4775 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); |
| 4776 __ Add(r6, r6, -(1 << Map::ConstructionCounter::kShift), r0); |
| 4777 __ stw(r6, FieldMemOperand(r5, Map::kBitField3Offset)); |
| 4778 |
| 4779 // Initialize the in-object fields with undefined. |
| 4780 __ lbz(r7, FieldMemOperand(r5, Map::kUnusedPropertyFieldsOffset)); |
| 4781 __ ShiftLeftImm(r7, r7, Operand(kPointerSizeLog2)); |
| 4782 __ sub(r7, r8, r7); |
| 4783 __ InitializeFieldsWithFiller(r4, r7, r9); |
| 4784 |
| 4785 // Initialize the remaining (reserved) fields with one pointer filler map. |
| 4786 __ LoadRoot(r9, Heap::kOnePointerFillerMapRootIndex); |
| 4787 __ InitializeFieldsWithFiller(r4, r8, r9); |
| 4788 |
| 4789 // Add the object tag to make the JSObject real. |
| 4790 __ addi(r3, r3, Operand(kHeapObjectTag)); |
| 4791 |
| 4792 // Check if we can finalize the instance size. |
| 4793 __ cmpi(r10, Operand(Map::kSlackTrackingCounterEnd)); |
| 4794 __ Ret(ne); |
| 4795 |
| 4796 // Finalize the instance size. |
| 4797 { |
| 4798 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 4799 __ Push(r3, r5); |
| 4800 __ CallRuntime(Runtime::kFinalizeInstanceSize); |
| 4801 __ Pop(r3); |
| 4802 } |
| 4803 __ Ret(); |
| 4804 } |
| 4805 |
| 4806 // Fall back to %AllocateInNewSpace. |
| 4807 __ bind(&allocate); |
| 4808 { |
| 4809 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 4810 STATIC_ASSERT(kSmiTag == 0); |
| 4811 __ ShiftLeftImm(r7, r7, |
| 4812 Operand(kPointerSizeLog2 + kSmiTagSize + kSmiShiftSize)); |
| 4813 __ Push(r5, r7); |
| 4814 __ CallRuntime(Runtime::kAllocateInNewSpace); |
| 4815 __ Pop(r5); |
| 4816 } |
| 4817 __ subi(r3, r3, Operand(kHeapObjectTag)); |
| 4818 __ lbz(r8, FieldMemOperand(r5, Map::kInstanceSizeOffset)); |
| 4819 __ ShiftLeftImm(r8, r8, Operand(kPointerSizeLog2)); |
| 4820 __ add(r8, r3, r8); |
| 4821 __ b(&done_allocate); |
| 4822 |
| 4823 // Fall back to %NewObject. |
| 4824 __ bind(&new_object); |
| 4825 __ Push(r4, r6); |
| 4826 __ TailCallRuntime(Runtime::kNewObject); |
| 4827 } |
| 4828 |
4707 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { | 4829 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { |
4708 // ----------- S t a t e ------------- | 4830 // ----------- S t a t e ------------- |
4709 // -- r4 : function | 4831 // -- r4 : function |
4710 // -- cp : context | 4832 // -- cp : context |
4711 // -- fp : frame pointer | 4833 // -- fp : frame pointer |
4712 // -- lr : return address | 4834 // -- lr : return address |
4713 // ----------------------------------- | 4835 // ----------------------------------- |
4714 __ AssertFunction(r4); | 4836 __ AssertFunction(r4); |
4715 | 4837 |
4716 // For Ignition we need to skip all possible handler/stub frames until | 4838 // For Ignition we need to skip all possible handler/stub frames until |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5733 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5855 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5734 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5856 kStackUnwindSpace, NULL, return_value_operand, NULL); |
5735 } | 5857 } |
5736 | 5858 |
5737 | 5859 |
5738 #undef __ | 5860 #undef __ |
5739 } // namespace internal | 5861 } // namespace internal |
5740 } // namespace v8 | 5862 } // namespace v8 |
5741 | 5863 |
5742 #endif // V8_TARGET_ARCH_PPC | 5864 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |