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_ARM | 5 #if V8_TARGET_ARCH_ARM |
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 4516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4527 Label no_rest_parameters; | 4527 Label no_rest_parameters; |
4528 __ ldr(r2, MemOperand(r2, StandardFrameConstants::kCallerFPOffset)); | 4528 __ ldr(r2, MemOperand(r2, StandardFrameConstants::kCallerFPOffset)); |
4529 __ ldr(ip, MemOperand(r2, CommonFrameConstants::kContextOrFrameTypeOffset)); | 4529 __ ldr(ip, MemOperand(r2, CommonFrameConstants::kContextOrFrameTypeOffset)); |
4530 __ cmp(ip, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 4530 __ cmp(ip, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
4531 __ b(ne, &no_rest_parameters); | 4531 __ b(ne, &no_rest_parameters); |
4532 | 4532 |
4533 // Check if the arguments adaptor frame contains more arguments than | 4533 // Check if the arguments adaptor frame contains more arguments than |
4534 // specified by the function's internal formal parameter count. | 4534 // specified by the function's internal formal parameter count. |
4535 Label rest_parameters; | 4535 Label rest_parameters; |
4536 __ ldr(r0, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 4536 __ ldr(r0, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
4537 __ ldr(r1, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 4537 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
4538 __ ldr(r1, | 4538 __ ldr(r3, |
4539 FieldMemOperand(r1, SharedFunctionInfo::kFormalParameterCountOffset)); | 4539 FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset)); |
4540 __ sub(r0, r0, r1, SetCC); | 4540 __ sub(r0, r0, r3, SetCC); |
4541 __ b(gt, &rest_parameters); | 4541 __ b(gt, &rest_parameters); |
4542 | 4542 |
4543 // Return an empty rest parameter array. | 4543 // Return an empty rest parameter array. |
4544 __ bind(&no_rest_parameters); | 4544 __ bind(&no_rest_parameters); |
4545 { | 4545 { |
4546 // ----------- S t a t e ------------- | 4546 // ----------- S t a t e ------------- |
4547 // -- cp : context | 4547 // -- cp : context |
4548 // -- lr : return address | 4548 // -- lr : return address |
4549 // ----------------------------------- | 4549 // ----------------------------------- |
4550 | 4550 |
(...skipping 26 matching lines...) Expand all Loading... |
4577 __ bind(&rest_parameters); | 4577 __ bind(&rest_parameters); |
4578 { | 4578 { |
4579 // Compute the pointer to the first rest parameter (skippping the receiver). | 4579 // Compute the pointer to the first rest parameter (skippping the receiver). |
4580 __ add(r2, r2, Operand(r0, LSL, kPointerSizeLog2 - 1)); | 4580 __ add(r2, r2, Operand(r0, LSL, kPointerSizeLog2 - 1)); |
4581 __ add(r2, r2, | 4581 __ add(r2, r2, |
4582 Operand(StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize)); | 4582 Operand(StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize)); |
4583 | 4583 |
4584 // ----------- S t a t e ------------- | 4584 // ----------- S t a t e ------------- |
4585 // -- cp : context | 4585 // -- cp : context |
4586 // -- r0 : number of rest parameters (tagged) | 4586 // -- r0 : number of rest parameters (tagged) |
| 4587 // -- r1 : function |
4587 // -- r2 : pointer to first rest parameters | 4588 // -- r2 : pointer to first rest parameters |
4588 // -- lr : return address | 4589 // -- lr : return address |
4589 // ----------------------------------- | 4590 // ----------------------------------- |
4590 | 4591 |
4591 // Allocate space for the rest parameter array plus the backing store. | 4592 // Allocate space for the rest parameter array plus the backing store. |
4592 Label allocate, done_allocate; | 4593 Label allocate, done_allocate; |
4593 __ mov(r1, Operand(JSArray::kSize + FixedArray::kHeaderSize)); | 4594 __ mov(r6, Operand(JSArray::kSize + FixedArray::kHeaderSize)); |
4594 __ add(r1, r1, Operand(r0, LSL, kPointerSizeLog2 - 1)); | 4595 __ add(r6, r6, Operand(r0, LSL, kPointerSizeLog2 - 1)); |
4595 __ Allocate(r1, r3, r4, r5, &allocate, NO_ALLOCATION_FLAGS); | 4596 __ Allocate(r6, r3, r4, r5, &allocate, NO_ALLOCATION_FLAGS); |
4596 __ bind(&done_allocate); | 4597 __ bind(&done_allocate); |
4597 | 4598 |
4598 // Setup the elements array in r3. | 4599 // Setup the elements array in r3. |
4599 __ LoadRoot(r1, Heap::kFixedArrayMapRootIndex); | 4600 __ LoadRoot(r1, Heap::kFixedArrayMapRootIndex); |
4600 __ str(r1, FieldMemOperand(r3, FixedArray::kMapOffset)); | 4601 __ str(r1, FieldMemOperand(r3, FixedArray::kMapOffset)); |
4601 __ str(r0, FieldMemOperand(r3, FixedArray::kLengthOffset)); | 4602 __ str(r0, FieldMemOperand(r3, FixedArray::kLengthOffset)); |
4602 __ add(r4, r3, Operand(FixedArray::kHeaderSize)); | 4603 __ add(r4, r3, Operand(FixedArray::kHeaderSize)); |
4603 { | 4604 { |
4604 Label loop, done_loop; | 4605 Label loop, done_loop; |
4605 __ add(r1, r4, Operand(r0, LSL, kPointerSizeLog2 - 1)); | 4606 __ add(r1, r4, Operand(r0, LSL, kPointerSizeLog2 - 1)); |
(...skipping 11 matching lines...) Expand all Loading... |
4617 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, r1); | 4618 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, r1); |
4618 __ str(r1, FieldMemOperand(r4, JSArray::kMapOffset)); | 4619 __ str(r1, FieldMemOperand(r4, JSArray::kMapOffset)); |
4619 __ LoadRoot(r1, Heap::kEmptyFixedArrayRootIndex); | 4620 __ LoadRoot(r1, Heap::kEmptyFixedArrayRootIndex); |
4620 __ str(r1, FieldMemOperand(r4, JSArray::kPropertiesOffset)); | 4621 __ str(r1, FieldMemOperand(r4, JSArray::kPropertiesOffset)); |
4621 __ str(r3, FieldMemOperand(r4, JSArray::kElementsOffset)); | 4622 __ str(r3, FieldMemOperand(r4, JSArray::kElementsOffset)); |
4622 __ str(r0, FieldMemOperand(r4, JSArray::kLengthOffset)); | 4623 __ str(r0, FieldMemOperand(r4, JSArray::kLengthOffset)); |
4623 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); | 4624 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); |
4624 __ mov(r0, r4); | 4625 __ mov(r0, r4); |
4625 __ Ret(); | 4626 __ Ret(); |
4626 | 4627 |
4627 // Fall back to %AllocateInNewSpace. | 4628 // Fall back to %AllocateInNewSpace (if not too big). |
| 4629 Label too_big_for_new_space; |
4628 __ bind(&allocate); | 4630 __ bind(&allocate); |
| 4631 __ cmp(r1, Operand(Page::kMaxRegularHeapObjectSize)); |
| 4632 __ b(gt, &too_big_for_new_space); |
4629 { | 4633 { |
4630 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 4634 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
4631 __ SmiTag(r1); | 4635 __ SmiTag(r1); |
4632 __ Push(r0, r2, r1); | 4636 __ Push(r0, r2, r1); |
4633 __ CallRuntime(Runtime::kAllocateInNewSpace); | 4637 __ CallRuntime(Runtime::kAllocateInNewSpace); |
4634 __ mov(r3, r0); | 4638 __ mov(r3, r0); |
4635 __ Pop(r0, r2); | 4639 __ Pop(r0, r2); |
4636 } | 4640 } |
4637 __ jmp(&done_allocate); | 4641 __ jmp(&done_allocate); |
| 4642 |
| 4643 // Fall back to %NewRestParameter. |
| 4644 __ bind(&too_big_for_new_space); |
| 4645 __ push(r1); |
| 4646 __ TailCallRuntime(Runtime::kNewRestParameter); |
4638 } | 4647 } |
4639 } | 4648 } |
4640 | 4649 |
4641 | 4650 |
4642 void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) { | 4651 void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) { |
4643 // ----------- S t a t e ------------- | 4652 // ----------- S t a t e ------------- |
4644 // -- r1 : function | 4653 // -- r1 : function |
4645 // -- cp : context | 4654 // -- cp : context |
4646 // -- fp : frame pointer | 4655 // -- fp : frame pointer |
4647 // -- lr : return address | 4656 // -- lr : return address |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4886 __ bind(&ok); | 4895 __ bind(&ok); |
4887 } | 4896 } |
4888 | 4897 |
4889 // Check if we have an arguments adaptor frame below the function frame. | 4898 // Check if we have an arguments adaptor frame below the function frame. |
4890 Label arguments_adaptor, arguments_done; | 4899 Label arguments_adaptor, arguments_done; |
4891 __ ldr(r3, MemOperand(r2, StandardFrameConstants::kCallerFPOffset)); | 4900 __ ldr(r3, MemOperand(r2, StandardFrameConstants::kCallerFPOffset)); |
4892 __ ldr(ip, MemOperand(r3, CommonFrameConstants::kContextOrFrameTypeOffset)); | 4901 __ ldr(ip, MemOperand(r3, CommonFrameConstants::kContextOrFrameTypeOffset)); |
4893 __ cmp(ip, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 4902 __ cmp(ip, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
4894 __ b(eq, &arguments_adaptor); | 4903 __ b(eq, &arguments_adaptor); |
4895 { | 4904 { |
4896 __ ldr(r1, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 4905 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
4897 __ ldr(r0, FieldMemOperand( | 4906 __ ldr(r0, FieldMemOperand( |
4898 r1, SharedFunctionInfo::kFormalParameterCountOffset)); | 4907 r4, SharedFunctionInfo::kFormalParameterCountOffset)); |
4899 __ add(r2, r2, Operand(r0, LSL, kPointerSizeLog2 - 1)); | 4908 __ add(r2, r2, Operand(r0, LSL, kPointerSizeLog2 - 1)); |
4900 __ add(r2, r2, | 4909 __ add(r2, r2, |
4901 Operand(StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize)); | 4910 Operand(StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize)); |
4902 } | 4911 } |
4903 __ b(&arguments_done); | 4912 __ b(&arguments_done); |
4904 __ bind(&arguments_adaptor); | 4913 __ bind(&arguments_adaptor); |
4905 { | 4914 { |
4906 __ ldr(r0, MemOperand(r3, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 4915 __ ldr(r0, MemOperand(r3, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
4907 __ add(r2, r3, Operand(r0, LSL, kPointerSizeLog2 - 1)); | 4916 __ add(r2, r3, Operand(r0, LSL, kPointerSizeLog2 - 1)); |
4908 __ add(r2, r2, | 4917 __ add(r2, r2, |
4909 Operand(StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize)); | 4918 Operand(StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize)); |
4910 } | 4919 } |
4911 __ bind(&arguments_done); | 4920 __ bind(&arguments_done); |
4912 | 4921 |
4913 // ----------- S t a t e ------------- | 4922 // ----------- S t a t e ------------- |
4914 // -- cp : context | 4923 // -- cp : context |
4915 // -- r0 : number of rest parameters (tagged) | 4924 // -- r0 : number of rest parameters (tagged) |
| 4925 // -- r1 : function |
4916 // -- r2 : pointer to first rest parameters | 4926 // -- r2 : pointer to first rest parameters |
4917 // -- lr : return address | 4927 // -- lr : return address |
4918 // ----------------------------------- | 4928 // ----------------------------------- |
4919 | 4929 |
4920 // Allocate space for the strict arguments object plus the backing store. | 4930 // Allocate space for the strict arguments object plus the backing store. |
4921 Label allocate, done_allocate; | 4931 Label allocate, done_allocate; |
4922 __ mov(r1, Operand(JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize)); | 4932 __ mov(r6, Operand(JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize)); |
4923 __ add(r1, r1, Operand(r0, LSL, kPointerSizeLog2 - 1)); | 4933 __ add(r6, r6, Operand(r0, LSL, kPointerSizeLog2 - 1)); |
4924 __ Allocate(r1, r3, r4, r5, &allocate, NO_ALLOCATION_FLAGS); | 4934 __ Allocate(r6, r3, r4, r5, &allocate, NO_ALLOCATION_FLAGS); |
4925 __ bind(&done_allocate); | 4935 __ bind(&done_allocate); |
4926 | 4936 |
4927 // Setup the elements array in r3. | 4937 // Setup the elements array in r3. |
4928 __ LoadRoot(r1, Heap::kFixedArrayMapRootIndex); | 4938 __ LoadRoot(r1, Heap::kFixedArrayMapRootIndex); |
4929 __ str(r1, FieldMemOperand(r3, FixedArray::kMapOffset)); | 4939 __ str(r1, FieldMemOperand(r3, FixedArray::kMapOffset)); |
4930 __ str(r0, FieldMemOperand(r3, FixedArray::kLengthOffset)); | 4940 __ str(r0, FieldMemOperand(r3, FixedArray::kLengthOffset)); |
4931 __ add(r4, r3, Operand(FixedArray::kHeaderSize)); | 4941 __ add(r4, r3, Operand(FixedArray::kHeaderSize)); |
4932 { | 4942 { |
4933 Label loop, done_loop; | 4943 Label loop, done_loop; |
4934 __ add(r1, r4, Operand(r0, LSL, kPointerSizeLog2 - 1)); | 4944 __ add(r1, r4, Operand(r0, LSL, kPointerSizeLog2 - 1)); |
(...skipping 11 matching lines...) Expand all Loading... |
4946 __ LoadNativeContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX, r1); | 4956 __ LoadNativeContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX, r1); |
4947 __ str(r1, FieldMemOperand(r4, JSStrictArgumentsObject::kMapOffset)); | 4957 __ str(r1, FieldMemOperand(r4, JSStrictArgumentsObject::kMapOffset)); |
4948 __ LoadRoot(r1, Heap::kEmptyFixedArrayRootIndex); | 4958 __ LoadRoot(r1, Heap::kEmptyFixedArrayRootIndex); |
4949 __ str(r1, FieldMemOperand(r4, JSStrictArgumentsObject::kPropertiesOffset)); | 4959 __ str(r1, FieldMemOperand(r4, JSStrictArgumentsObject::kPropertiesOffset)); |
4950 __ str(r3, FieldMemOperand(r4, JSStrictArgumentsObject::kElementsOffset)); | 4960 __ str(r3, FieldMemOperand(r4, JSStrictArgumentsObject::kElementsOffset)); |
4951 __ str(r0, FieldMemOperand(r4, JSStrictArgumentsObject::kLengthOffset)); | 4961 __ str(r0, FieldMemOperand(r4, JSStrictArgumentsObject::kLengthOffset)); |
4952 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize); | 4962 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize); |
4953 __ mov(r0, r4); | 4963 __ mov(r0, r4); |
4954 __ Ret(); | 4964 __ Ret(); |
4955 | 4965 |
4956 // Fall back to %AllocateInNewSpace. | 4966 // Fall back to %AllocateInNewSpace (if not too big). |
| 4967 Label too_big_for_new_space; |
4957 __ bind(&allocate); | 4968 __ bind(&allocate); |
| 4969 __ cmp(r6, Operand(Page::kMaxRegularHeapObjectSize)); |
| 4970 __ b(gt, &too_big_for_new_space); |
4958 { | 4971 { |
4959 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 4972 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
4960 __ SmiTag(r1); | 4973 __ SmiTag(r6); |
4961 __ Push(r0, r2, r1); | 4974 __ Push(r0, r2, r6); |
4962 __ CallRuntime(Runtime::kAllocateInNewSpace); | 4975 __ CallRuntime(Runtime::kAllocateInNewSpace); |
4963 __ mov(r3, r0); | 4976 __ mov(r3, r0); |
4964 __ Pop(r0, r2); | 4977 __ Pop(r0, r2); |
4965 } | 4978 } |
4966 __ b(&done_allocate); | 4979 __ b(&done_allocate); |
| 4980 |
| 4981 // Fall back to %NewStrictArguments. |
| 4982 __ bind(&too_big_for_new_space); |
| 4983 __ push(r1); |
| 4984 __ TailCallRuntime(Runtime::kNewStrictArguments); |
4967 } | 4985 } |
4968 | 4986 |
4969 | 4987 |
4970 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { | 4988 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { |
4971 Register context = cp; | 4989 Register context = cp; |
4972 Register result = r0; | 4990 Register result = r0; |
4973 Register slot = r2; | 4991 Register slot = r2; |
4974 | 4992 |
4975 // Go up the context chain to the script context. | 4993 // Go up the context chain to the script context. |
4976 for (int i = 0; i < depth(); ++i) { | 4994 for (int i = 0; i < depth(); ++i) { |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5426 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5444 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5427 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5445 kStackUnwindSpace, NULL, return_value_operand, NULL); |
5428 } | 5446 } |
5429 | 5447 |
5430 #undef __ | 5448 #undef __ |
5431 | 5449 |
5432 } // namespace internal | 5450 } // namespace internal |
5433 } // namespace v8 | 5451 } // namespace v8 |
5434 | 5452 |
5435 #endif // V8_TARGET_ARCH_ARM | 5453 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |