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/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 4580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4591 Label no_rest_parameters; | 4591 Label no_rest_parameters; |
4592 __ LoadP(r5, MemOperand(r5, StandardFrameConstants::kCallerFPOffset)); | 4592 __ LoadP(r5, MemOperand(r5, StandardFrameConstants::kCallerFPOffset)); |
4593 __ LoadP(ip, MemOperand(r5, CommonFrameConstants::kContextOrFrameTypeOffset)); | 4593 __ LoadP(ip, MemOperand(r5, CommonFrameConstants::kContextOrFrameTypeOffset)); |
4594 __ CmpSmiLiteral(ip, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); | 4594 __ CmpSmiLiteral(ip, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
4595 __ bne(&no_rest_parameters); | 4595 __ bne(&no_rest_parameters); |
4596 | 4596 |
4597 // Check if the arguments adaptor frame contains more arguments than | 4597 // Check if the arguments adaptor frame contains more arguments than |
4598 // specified by the function's internal formal parameter count. | 4598 // specified by the function's internal formal parameter count. |
4599 Label rest_parameters; | 4599 Label rest_parameters; |
4600 __ LoadP(r3, MemOperand(r5, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 4600 __ LoadP(r3, MemOperand(r5, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
4601 __ LoadP(r4, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); | 4601 __ LoadP(r6, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
4602 __ LoadWordArith( | 4602 __ LoadWordArith( |
4603 r4, FieldMemOperand(r4, SharedFunctionInfo::kFormalParameterCountOffset)); | 4603 r6, FieldMemOperand(r6, SharedFunctionInfo::kFormalParameterCountOffset)); |
4604 #if V8_TARGET_ARCH_PPC64 | 4604 #if V8_TARGET_ARCH_PPC64 |
4605 __ SmiTag(r4); | 4605 __ SmiTag(r6); |
4606 #endif | 4606 #endif |
4607 __ sub(r3, r3, r4, LeaveOE, SetRC); | 4607 __ sub(r3, r3, r6, LeaveOE, SetRC); |
4608 __ bgt(&rest_parameters, cr0); | 4608 __ bgt(&rest_parameters, cr0); |
4609 | 4609 |
4610 // Return an empty rest parameter array. | 4610 // Return an empty rest parameter array. |
4611 __ bind(&no_rest_parameters); | 4611 __ bind(&no_rest_parameters); |
4612 { | 4612 { |
4613 // ----------- S t a t e ------------- | 4613 // ----------- S t a t e ------------- |
4614 // -- cp : context | 4614 // -- cp : context |
4615 // -- lr : return address | 4615 // -- lr : return address |
4616 // ----------------------------------- | 4616 // ----------------------------------- |
4617 | 4617 |
(...skipping 26 matching lines...) Expand all Loading... |
4644 __ bind(&rest_parameters); | 4644 __ bind(&rest_parameters); |
4645 { | 4645 { |
4646 // Compute the pointer to the first rest parameter (skippping the receiver). | 4646 // Compute the pointer to the first rest parameter (skippping the receiver). |
4647 __ SmiToPtrArrayOffset(r9, r3); | 4647 __ SmiToPtrArrayOffset(r9, r3); |
4648 __ add(r5, r5, r9); | 4648 __ add(r5, r5, r9); |
4649 __ addi(r5, r5, Operand(StandardFrameConstants::kCallerSPOffset)); | 4649 __ addi(r5, r5, Operand(StandardFrameConstants::kCallerSPOffset)); |
4650 | 4650 |
4651 // ----------- S t a t e ------------- | 4651 // ----------- S t a t e ------------- |
4652 // -- cp : context | 4652 // -- cp : context |
4653 // -- r3 : number of rest parameters (tagged) | 4653 // -- r3 : number of rest parameters (tagged) |
| 4654 // -- r4 : function |
4654 // -- r5 : pointer just past first rest parameters | 4655 // -- r5 : pointer just past first rest parameters |
4655 // -- r9 : size of rest parameters | 4656 // -- r9 : size of rest parameters |
4656 // -- lr : return address | 4657 // -- lr : return address |
4657 // ----------------------------------- | 4658 // ----------------------------------- |
4658 | 4659 |
4659 // Allocate space for the rest parameter array plus the backing store. | 4660 // Allocate space for the rest parameter array plus the backing store. |
4660 Label allocate, done_allocate; | 4661 Label allocate, done_allocate; |
4661 __ mov(r4, Operand(JSArray::kSize + FixedArray::kHeaderSize)); | 4662 __ mov(r10, Operand(JSArray::kSize + FixedArray::kHeaderSize)); |
4662 __ add(r4, r4, r9); | 4663 __ add(r10, r10, r9); |
4663 __ Allocate(r4, r6, r7, r8, &allocate, NO_ALLOCATION_FLAGS); | 4664 __ Allocate(r10, r6, r7, r8, &allocate, NO_ALLOCATION_FLAGS); |
4664 __ bind(&done_allocate); | 4665 __ bind(&done_allocate); |
4665 | 4666 |
4666 // Setup the elements array in r6. | 4667 // Setup the elements array in r6. |
4667 __ LoadRoot(r4, Heap::kFixedArrayMapRootIndex); | 4668 __ LoadRoot(r4, Heap::kFixedArrayMapRootIndex); |
4668 __ StoreP(r4, FieldMemOperand(r6, FixedArray::kMapOffset), r0); | 4669 __ StoreP(r4, FieldMemOperand(r6, FixedArray::kMapOffset), r0); |
4669 __ StoreP(r3, FieldMemOperand(r6, FixedArray::kLengthOffset), r0); | 4670 __ StoreP(r3, FieldMemOperand(r6, FixedArray::kLengthOffset), r0); |
4670 __ addi(r7, r6, | 4671 __ addi(r7, r6, |
4671 Operand(FixedArray::kHeaderSize - kHeapObjectTag - kPointerSize)); | 4672 Operand(FixedArray::kHeaderSize - kHeapObjectTag - kPointerSize)); |
4672 { | 4673 { |
4673 Label loop; | 4674 Label loop; |
(...skipping 10 matching lines...) Expand all Loading... |
4684 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, r4); | 4685 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, r4); |
4685 __ StoreP(r4, MemOperand(r7, JSArray::kMapOffset)); | 4686 __ StoreP(r4, MemOperand(r7, JSArray::kMapOffset)); |
4686 __ LoadRoot(r4, Heap::kEmptyFixedArrayRootIndex); | 4687 __ LoadRoot(r4, Heap::kEmptyFixedArrayRootIndex); |
4687 __ StoreP(r4, MemOperand(r7, JSArray::kPropertiesOffset)); | 4688 __ StoreP(r4, MemOperand(r7, JSArray::kPropertiesOffset)); |
4688 __ StoreP(r6, MemOperand(r7, JSArray::kElementsOffset)); | 4689 __ StoreP(r6, MemOperand(r7, JSArray::kElementsOffset)); |
4689 __ StoreP(r3, MemOperand(r7, JSArray::kLengthOffset)); | 4690 __ StoreP(r3, MemOperand(r7, JSArray::kLengthOffset)); |
4690 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); | 4691 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); |
4691 __ addi(r3, r7, Operand(kHeapObjectTag)); | 4692 __ addi(r3, r7, Operand(kHeapObjectTag)); |
4692 __ Ret(); | 4693 __ Ret(); |
4693 | 4694 |
4694 // Fall back to %AllocateInNewSpace. | 4695 // Fall back to %AllocateInNewSpace (if not too big). |
| 4696 Label too_big_for_new_space; |
4695 __ bind(&allocate); | 4697 __ bind(&allocate); |
| 4698 __ cmpi(r10, Operand(Page::kMaxRegularHeapObjectSize)); |
| 4699 __ bgt(&too_big_for_new_space); |
4696 { | 4700 { |
4697 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 4701 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
4698 __ SmiTag(r4); | 4702 __ SmiTag(r10); |
4699 __ Push(r3, r5, r4); | 4703 __ Push(r3, r5, r10); |
4700 __ CallRuntime(Runtime::kAllocateInNewSpace); | 4704 __ CallRuntime(Runtime::kAllocateInNewSpace); |
4701 __ mr(r6, r3); | 4705 __ mr(r6, r3); |
4702 __ Pop(r3, r5); | 4706 __ Pop(r3, r5); |
4703 } | 4707 } |
4704 __ b(&done_allocate); | 4708 __ b(&done_allocate); |
| 4709 |
| 4710 // Fall back to %NewRestParameter. |
| 4711 __ bind(&too_big_for_new_space); |
| 4712 __ push(r4); |
| 4713 __ TailCallRuntime(Runtime::kNewRestParameter); |
4705 } | 4714 } |
4706 } | 4715 } |
4707 | 4716 |
4708 void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) { | 4717 void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) { |
4709 // ----------- S t a t e ------------- | 4718 // ----------- S t a t e ------------- |
4710 // -- r4 : function | 4719 // -- r4 : function |
4711 // -- cp : context | 4720 // -- cp : context |
4712 // -- fp : frame pointer | 4721 // -- fp : frame pointer |
4713 // -- lr : return address | 4722 // -- lr : return address |
4714 // ----------------------------------- | 4723 // ----------------------------------- |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5000 __ bind(&ok); | 5009 __ bind(&ok); |
5001 } | 5010 } |
5002 | 5011 |
5003 // Check if we have an arguments adaptor frame below the function frame. | 5012 // Check if we have an arguments adaptor frame below the function frame. |
5004 Label arguments_adaptor, arguments_done; | 5013 Label arguments_adaptor, arguments_done; |
5005 __ LoadP(r6, MemOperand(r5, StandardFrameConstants::kCallerFPOffset)); | 5014 __ LoadP(r6, MemOperand(r5, StandardFrameConstants::kCallerFPOffset)); |
5006 __ LoadP(ip, MemOperand(r6, CommonFrameConstants::kContextOrFrameTypeOffset)); | 5015 __ LoadP(ip, MemOperand(r6, CommonFrameConstants::kContextOrFrameTypeOffset)); |
5007 __ CmpSmiLiteral(ip, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); | 5016 __ CmpSmiLiteral(ip, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
5008 __ beq(&arguments_adaptor); | 5017 __ beq(&arguments_adaptor); |
5009 { | 5018 { |
5010 __ LoadP(r4, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); | 5019 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
5011 __ LoadWordArith( | 5020 __ LoadWordArith( |
5012 r3, | 5021 r3, |
5013 FieldMemOperand(r4, SharedFunctionInfo::kFormalParameterCountOffset)); | 5022 FieldMemOperand(r7, SharedFunctionInfo::kFormalParameterCountOffset)); |
5014 #if V8_TARGET_ARCH_PPC64 | 5023 #if V8_TARGET_ARCH_PPC64 |
5015 __ SmiTag(r3); | 5024 __ SmiTag(r3); |
5016 #endif | 5025 #endif |
5017 __ SmiToPtrArrayOffset(r9, r3); | 5026 __ SmiToPtrArrayOffset(r9, r3); |
5018 __ add(r5, r5, r9); | 5027 __ add(r5, r5, r9); |
5019 } | 5028 } |
5020 __ b(&arguments_done); | 5029 __ b(&arguments_done); |
5021 __ bind(&arguments_adaptor); | 5030 __ bind(&arguments_adaptor); |
5022 { | 5031 { |
5023 __ LoadP(r3, MemOperand(r6, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 5032 __ LoadP(r3, MemOperand(r6, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
5024 __ SmiToPtrArrayOffset(r9, r3); | 5033 __ SmiToPtrArrayOffset(r9, r3); |
5025 __ add(r5, r6, r9); | 5034 __ add(r5, r6, r9); |
5026 } | 5035 } |
5027 __ bind(&arguments_done); | 5036 __ bind(&arguments_done); |
5028 __ addi(r5, r5, Operand(StandardFrameConstants::kCallerSPOffset)); | 5037 __ addi(r5, r5, Operand(StandardFrameConstants::kCallerSPOffset)); |
5029 | 5038 |
5030 // ----------- S t a t e ------------- | 5039 // ----------- S t a t e ------------- |
5031 // -- cp : context | 5040 // -- cp : context |
5032 // -- r3 : number of rest parameters (tagged) | 5041 // -- r3 : number of rest parameters (tagged) |
| 5042 // -- r4 : function |
5033 // -- r5 : pointer just past first rest parameters | 5043 // -- r5 : pointer just past first rest parameters |
5034 // -- r9 : size of rest parameters | 5044 // -- r9 : size of rest parameters |
5035 // -- lr : return address | 5045 // -- lr : return address |
5036 // ----------------------------------- | 5046 // ----------------------------------- |
5037 | 5047 |
5038 // Allocate space for the strict arguments object plus the backing store. | 5048 // Allocate space for the strict arguments object plus the backing store. |
5039 Label allocate, done_allocate; | 5049 Label allocate, done_allocate; |
5040 __ mov(r4, Operand(JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize)); | 5050 __ mov(r10, |
5041 __ add(r4, r4, r9); | 5051 Operand(JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize)); |
5042 __ Allocate(r4, r6, r7, r8, &allocate, NO_ALLOCATION_FLAGS); | 5052 __ add(r10, r10, r9); |
| 5053 __ Allocate(r10, r6, r7, r8, &allocate, NO_ALLOCATION_FLAGS); |
5043 __ bind(&done_allocate); | 5054 __ bind(&done_allocate); |
5044 | 5055 |
5045 // Setup the elements array in r6. | 5056 // Setup the elements array in r6. |
5046 __ LoadRoot(r4, Heap::kFixedArrayMapRootIndex); | 5057 __ LoadRoot(r4, Heap::kFixedArrayMapRootIndex); |
5047 __ StoreP(r4, FieldMemOperand(r6, FixedArray::kMapOffset), r0); | 5058 __ StoreP(r4, FieldMemOperand(r6, FixedArray::kMapOffset), r0); |
5048 __ StoreP(r3, FieldMemOperand(r6, FixedArray::kLengthOffset), r0); | 5059 __ StoreP(r3, FieldMemOperand(r6, FixedArray::kLengthOffset), r0); |
5049 __ addi(r7, r6, | 5060 __ addi(r7, r6, |
5050 Operand(FixedArray::kHeaderSize - kHeapObjectTag - kPointerSize)); | 5061 Operand(FixedArray::kHeaderSize - kHeapObjectTag - kPointerSize)); |
5051 { | 5062 { |
5052 Label loop, done_loop; | 5063 Label loop, done_loop; |
(...skipping 12 matching lines...) Expand all Loading... |
5065 __ LoadNativeContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX, r4); | 5076 __ LoadNativeContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX, r4); |
5066 __ StoreP(r4, MemOperand(r7, JSStrictArgumentsObject::kMapOffset)); | 5077 __ StoreP(r4, MemOperand(r7, JSStrictArgumentsObject::kMapOffset)); |
5067 __ LoadRoot(r4, Heap::kEmptyFixedArrayRootIndex); | 5078 __ LoadRoot(r4, Heap::kEmptyFixedArrayRootIndex); |
5068 __ StoreP(r4, MemOperand(r7, JSStrictArgumentsObject::kPropertiesOffset)); | 5079 __ StoreP(r4, MemOperand(r7, JSStrictArgumentsObject::kPropertiesOffset)); |
5069 __ StoreP(r6, MemOperand(r7, JSStrictArgumentsObject::kElementsOffset)); | 5080 __ StoreP(r6, MemOperand(r7, JSStrictArgumentsObject::kElementsOffset)); |
5070 __ StoreP(r3, MemOperand(r7, JSStrictArgumentsObject::kLengthOffset)); | 5081 __ StoreP(r3, MemOperand(r7, JSStrictArgumentsObject::kLengthOffset)); |
5071 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize); | 5082 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize); |
5072 __ addi(r3, r7, Operand(kHeapObjectTag)); | 5083 __ addi(r3, r7, Operand(kHeapObjectTag)); |
5073 __ Ret(); | 5084 __ Ret(); |
5074 | 5085 |
5075 // Fall back to %AllocateInNewSpace. | 5086 // Fall back to %AllocateInNewSpace (if not too big). |
| 5087 Label too_big_for_new_space; |
5076 __ bind(&allocate); | 5088 __ bind(&allocate); |
| 5089 __ cmpi(r10, Operand(Page::kMaxRegularHeapObjectSize)); |
| 5090 __ bgt(&too_big_for_new_space); |
5077 { | 5091 { |
5078 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 5092 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
5079 __ SmiTag(r4); | 5093 __ SmiTag(r10); |
5080 __ Push(r3, r5, r4); | 5094 __ Push(r3, r5, r10); |
5081 __ CallRuntime(Runtime::kAllocateInNewSpace); | 5095 __ CallRuntime(Runtime::kAllocateInNewSpace); |
5082 __ mr(r6, r3); | 5096 __ mr(r6, r3); |
5083 __ Pop(r3, r5); | 5097 __ Pop(r3, r5); |
5084 } | 5098 } |
5085 __ b(&done_allocate); | 5099 __ b(&done_allocate); |
| 5100 |
| 5101 // Fall back to %NewStrictArguments. |
| 5102 __ bind(&too_big_for_new_space); |
| 5103 __ push(r4); |
| 5104 __ TailCallRuntime(Runtime::kNewStrictArguments); |
5086 } | 5105 } |
5087 | 5106 |
5088 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { | 5107 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { |
5089 Register context = cp; | 5108 Register context = cp; |
5090 Register result = r3; | 5109 Register result = r3; |
5091 Register slot = r5; | 5110 Register slot = r5; |
5092 | 5111 |
5093 // Go up the context chain to the script context. | 5112 // Go up the context chain to the script context. |
5094 for (int i = 0; i < depth(); ++i) { | 5113 for (int i = 0; i < depth(); ++i) { |
5095 __ LoadP(result, ContextMemOperand(context, Context::PREVIOUS_INDEX)); | 5114 __ LoadP(result, ContextMemOperand(context, Context::PREVIOUS_INDEX)); |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5595 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); | 5614 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); |
5596 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5615 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5597 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5616 kStackUnwindSpace, NULL, return_value_operand, NULL); |
5598 } | 5617 } |
5599 | 5618 |
5600 #undef __ | 5619 #undef __ |
5601 } // namespace internal | 5620 } // namespace internal |
5602 } // namespace v8 | 5621 } // namespace v8 |
5603 | 5622 |
5604 #endif // V8_TARGET_ARCH_PPC | 5623 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |