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/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 4592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4603 Label fast_elements_case; | 4603 Label fast_elements_case; |
4604 __ cmp(r3, Operand(FAST_ELEMENTS)); | 4604 __ cmp(r3, Operand(FAST_ELEMENTS)); |
4605 __ b(eq, &fast_elements_case); | 4605 __ b(eq, &fast_elements_case); |
4606 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 4606 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
4607 | 4607 |
4608 __ bind(&fast_elements_case); | 4608 __ bind(&fast_elements_case); |
4609 GenerateCase(masm, FAST_ELEMENTS); | 4609 GenerateCase(masm, FAST_ELEMENTS); |
4610 } | 4610 } |
4611 | 4611 |
4612 | 4612 |
4613 void CallApiFunctionStub::Generate(MacroAssembler* masm) { | 4613 static void CallApiFunctionStubHelper(MacroAssembler* masm, |
| 4614 const ParameterCount& argc, |
| 4615 bool return_first_arg, |
| 4616 bool call_data_undefined) { |
4614 // ----------- S t a t e ------------- | 4617 // ----------- S t a t e ------------- |
4615 // -- r0 : callee | 4618 // -- r0 : callee |
4616 // -- r4 : call_data | 4619 // -- r4 : call_data |
4617 // -- r2 : holder | 4620 // -- r2 : holder |
4618 // -- r1 : api_function_address | 4621 // -- r1 : api_function_address |
| 4622 // -- r3 : number of arguments if argc is a register |
4619 // -- cp : context | 4623 // -- cp : context |
4620 // -- | 4624 // -- |
4621 // -- sp[0] : last argument | 4625 // -- sp[0] : last argument |
4622 // -- ... | 4626 // -- ... |
4623 // -- sp[(argc - 1)* 4] : first argument | 4627 // -- sp[(argc - 1)* 4] : first argument |
4624 // -- sp[argc * 4] : receiver | 4628 // -- sp[argc * 4] : receiver |
4625 // ----------------------------------- | 4629 // ----------------------------------- |
4626 | 4630 |
4627 Register callee = r0; | 4631 Register callee = r0; |
4628 Register call_data = r4; | 4632 Register call_data = r4; |
4629 Register holder = r2; | 4633 Register holder = r2; |
4630 Register api_function_address = r1; | 4634 Register api_function_address = r1; |
4631 Register context = cp; | 4635 Register context = cp; |
4632 | 4636 |
4633 int argc = this->argc(); | |
4634 bool is_store = this->is_store(); | |
4635 bool call_data_undefined = this->call_data_undefined(); | |
4636 | |
4637 typedef FunctionCallbackArguments FCA; | 4637 typedef FunctionCallbackArguments FCA; |
4638 | 4638 |
4639 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | 4639 STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
4640 STATIC_ASSERT(FCA::kCalleeIndex == 5); | 4640 STATIC_ASSERT(FCA::kCalleeIndex == 5); |
4641 STATIC_ASSERT(FCA::kDataIndex == 4); | 4641 STATIC_ASSERT(FCA::kDataIndex == 4); |
4642 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | 4642 STATIC_ASSERT(FCA::kReturnValueOffset == 3); |
4643 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | 4643 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); |
4644 STATIC_ASSERT(FCA::kIsolateIndex == 1); | 4644 STATIC_ASSERT(FCA::kIsolateIndex == 1); |
4645 STATIC_ASSERT(FCA::kHolderIndex == 0); | 4645 STATIC_ASSERT(FCA::kHolderIndex == 0); |
4646 STATIC_ASSERT(FCA::kArgsLength == 7); | 4646 STATIC_ASSERT(FCA::kArgsLength == 7); |
4647 | 4647 |
| 4648 DCHECK(argc.is_immediate() || r3.is(argc.reg())); |
| 4649 |
4648 // context save | 4650 // context save |
4649 __ push(context); | 4651 __ push(context); |
4650 // load context from callee | 4652 // load context from callee |
4651 __ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); | 4653 __ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
4652 | 4654 |
4653 // callee | 4655 // callee |
4654 __ push(callee); | 4656 __ push(callee); |
4655 | 4657 |
4656 // call data | 4658 // call data |
4657 __ push(call_data); | 4659 __ push(call_data); |
4658 | 4660 |
4659 Register scratch = call_data; | 4661 Register scratch = call_data; |
4660 if (!call_data_undefined) { | 4662 if (!call_data_undefined) { |
4661 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 4663 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
4662 } | 4664 } |
4663 // return value | 4665 // return value |
4664 __ push(scratch); | 4666 __ push(scratch); |
4665 // return value default | 4667 // return value default |
4666 __ push(scratch); | 4668 __ push(scratch); |
4667 // isolate | 4669 // isolate |
4668 __ mov(scratch, | 4670 __ mov(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); |
4669 Operand(ExternalReference::isolate_address(isolate()))); | |
4670 __ push(scratch); | 4671 __ push(scratch); |
4671 // holder | 4672 // holder |
4672 __ push(holder); | 4673 __ push(holder); |
4673 | 4674 |
4674 // Prepare arguments. | 4675 // Prepare arguments. |
4675 __ mov(scratch, sp); | 4676 __ mov(scratch, sp); |
4676 | 4677 |
4677 // Allocate the v8::Arguments structure in the arguments' space since | 4678 // Allocate the v8::Arguments structure in the arguments' space since |
4678 // it's not controlled by GC. | 4679 // it's not controlled by GC. |
4679 const int kApiStackSpace = 4; | 4680 const int kApiStackSpace = 4; |
4680 | 4681 |
4681 FrameScope frame_scope(masm, StackFrame::MANUAL); | 4682 FrameScope frame_scope(masm, StackFrame::MANUAL); |
4682 __ EnterExitFrame(false, kApiStackSpace); | 4683 __ EnterExitFrame(false, kApiStackSpace); |
4683 | 4684 |
4684 DCHECK(!api_function_address.is(r0) && !scratch.is(r0)); | 4685 DCHECK(!api_function_address.is(r0) && !scratch.is(r0)); |
4685 // r0 = FunctionCallbackInfo& | 4686 // r0 = FunctionCallbackInfo& |
4686 // Arguments is after the return address. | 4687 // Arguments is after the return address. |
4687 __ add(r0, sp, Operand(1 * kPointerSize)); | 4688 __ add(r0, sp, Operand(1 * kPointerSize)); |
4688 // FunctionCallbackInfo::implicit_args_ | 4689 // FunctionCallbackInfo::implicit_args_ |
4689 __ str(scratch, MemOperand(r0, 0 * kPointerSize)); | 4690 __ str(scratch, MemOperand(r0, 0 * kPointerSize)); |
4690 // FunctionCallbackInfo::values_ | 4691 if (argc.is_immediate()) { |
4691 __ add(ip, scratch, Operand((FCA::kArgsLength - 1 + argc) * kPointerSize)); | 4692 // FunctionCallbackInfo::values_ |
4692 __ str(ip, MemOperand(r0, 1 * kPointerSize)); | 4693 __ add(ip, scratch, |
4693 // FunctionCallbackInfo::length_ = argc | 4694 Operand((FCA::kArgsLength - 1 + argc.immediate()) * kPointerSize)); |
4694 __ mov(ip, Operand(argc)); | 4695 __ str(ip, MemOperand(r0, 1 * kPointerSize)); |
4695 __ str(ip, MemOperand(r0, 2 * kPointerSize)); | 4696 // FunctionCallbackInfo::length_ = argc |
4696 // FunctionCallbackInfo::is_construct_call = 0 | 4697 __ mov(ip, Operand(argc.immediate())); |
4697 __ mov(ip, Operand::Zero()); | 4698 __ str(ip, MemOperand(r0, 2 * kPointerSize)); |
4698 __ str(ip, MemOperand(r0, 3 * kPointerSize)); | 4699 // FunctionCallbackInfo::is_construct_call_ = 0 |
| 4700 __ mov(ip, Operand::Zero()); |
| 4701 __ str(ip, MemOperand(r0, 3 * kPointerSize)); |
| 4702 } else { |
| 4703 // FunctionCallbackInfo::values_ |
| 4704 __ add(ip, scratch, Operand(argc.reg(), LSL, kPointerSizeLog2)); |
| 4705 __ add(ip, ip, Operand((FCA::kArgsLength - 1) * kPointerSize)); |
| 4706 __ str(ip, MemOperand(r0, 1 * kPointerSize)); |
| 4707 // FunctionCallbackInfo::length_ = argc |
| 4708 __ str(argc.reg(), MemOperand(r0, 2 * kPointerSize)); |
| 4709 // FunctionCallbackInfo::is_construct_call_ |
| 4710 __ add(argc.reg(), argc.reg(), Operand(FCA::kArgsLength + 1)); |
| 4711 __ mov(ip, Operand(argc.reg(), LSL, kPointerSizeLog2)); |
| 4712 __ str(ip, MemOperand(r0, 3 * kPointerSize)); |
| 4713 } |
4699 | 4714 |
4700 const int kStackUnwindSpace = argc + FCA::kArgsLength + 1; | |
4701 ExternalReference thunk_ref = | 4715 ExternalReference thunk_ref = |
4702 ExternalReference::invoke_function_callback(isolate()); | 4716 ExternalReference::invoke_function_callback(masm->isolate()); |
4703 | 4717 |
4704 AllowExternalCallThatCantCauseGC scope(masm); | 4718 AllowExternalCallThatCantCauseGC scope(masm); |
4705 MemOperand context_restore_operand( | 4719 MemOperand context_restore_operand( |
4706 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); | 4720 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); |
4707 // Stores return the first js argument | 4721 // Stores return the first js argument |
4708 int return_value_offset = 0; | 4722 int return_value_offset = 0; |
4709 if (is_store) { | 4723 if (return_first_arg) { |
4710 return_value_offset = 2 + FCA::kArgsLength; | 4724 return_value_offset = 2 + FCA::kArgsLength; |
4711 } else { | 4725 } else { |
4712 return_value_offset = 2 + FCA::kReturnValueOffset; | 4726 return_value_offset = 2 + FCA::kReturnValueOffset; |
4713 } | 4727 } |
4714 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); | 4728 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
| 4729 int stack_space = 0; |
| 4730 MemOperand is_construct_call_operand = MemOperand(sp, 4 * kPointerSize); |
| 4731 MemOperand* stack_space_operand = &is_construct_call_operand; |
| 4732 if (argc.is_immediate()) { |
| 4733 stack_space = argc.immediate() + FCA::kArgsLength + 1; |
| 4734 stack_space_operand = NULL; |
| 4735 } |
| 4736 __ CallApiFunctionAndReturn(api_function_address, thunk_ref, stack_space, |
| 4737 stack_space_operand, return_value_operand, |
| 4738 &context_restore_operand); |
| 4739 } |
4715 | 4740 |
4716 __ CallApiFunctionAndReturn(api_function_address, | 4741 |
4717 thunk_ref, | 4742 void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
4718 kStackUnwindSpace, | 4743 bool call_data_undefined = this->call_data_undefined(); |
4719 return_value_operand, | 4744 CallApiFunctionStubHelper(masm, ParameterCount(r3), false, |
4720 &context_restore_operand); | 4745 call_data_undefined); |
| 4746 } |
| 4747 |
| 4748 |
| 4749 void CallApiAccessorStub::Generate(MacroAssembler* masm) { |
| 4750 bool is_store = this->is_store(); |
| 4751 int argc = is_store ? 1 : 0; |
| 4752 bool call_data_undefined = this->call_data_undefined(); |
| 4753 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store, |
| 4754 call_data_undefined); |
4721 } | 4755 } |
4722 | 4756 |
4723 | 4757 |
4724 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 4758 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
4725 // ----------- S t a t e ------------- | 4759 // ----------- S t a t e ------------- |
4726 // -- sp[0] : name | 4760 // -- sp[0] : name |
4727 // -- sp[4 - kArgsLength*4] : PropertyCallbackArguments object | 4761 // -- sp[4 - kArgsLength*4] : PropertyCallbackArguments object |
4728 // -- ... | 4762 // -- ... |
4729 // -- r2 : api_function_address | 4763 // -- r2 : api_function_address |
4730 // ----------------------------------- | 4764 // ----------------------------------- |
(...skipping 10 matching lines...) Expand all Loading... |
4741 | 4775 |
4742 // Create PropertyAccessorInfo instance on the stack above the exit frame with | 4776 // Create PropertyAccessorInfo instance on the stack above the exit frame with |
4743 // r1 (internal::Object** args_) as the data. | 4777 // r1 (internal::Object** args_) as the data. |
4744 __ str(r1, MemOperand(sp, 1 * kPointerSize)); | 4778 __ str(r1, MemOperand(sp, 1 * kPointerSize)); |
4745 __ add(r1, sp, Operand(1 * kPointerSize)); // r1 = AccessorInfo& | 4779 __ add(r1, sp, Operand(1 * kPointerSize)); // r1 = AccessorInfo& |
4746 | 4780 |
4747 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; | 4781 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; |
4748 | 4782 |
4749 ExternalReference thunk_ref = | 4783 ExternalReference thunk_ref = |
4750 ExternalReference::invoke_accessor_getter_callback(isolate()); | 4784 ExternalReference::invoke_accessor_getter_callback(isolate()); |
4751 __ CallApiFunctionAndReturn(api_function_address, | 4785 __ CallApiFunctionAndReturn(api_function_address, thunk_ref, |
4752 thunk_ref, | 4786 kStackUnwindSpace, NULL, |
4753 kStackUnwindSpace, | 4787 MemOperand(fp, 6 * kPointerSize), NULL); |
4754 MemOperand(fp, 6 * kPointerSize), | |
4755 NULL); | |
4756 } | 4788 } |
4757 | 4789 |
4758 | 4790 |
4759 #undef __ | 4791 #undef __ |
4760 | 4792 |
4761 } } // namespace v8::internal | 4793 } } // namespace v8::internal |
4762 | 4794 |
4763 #endif // V8_TARGET_ARCH_ARM | 4795 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |