Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: src/arm/code-stubs-arm.cc

Issue 849103007: arm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8.h ('k') | src/arm/interface-descriptors-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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));
4691 Register length_value = r3;
4692 if (argc.is_immediate()) {
4693 __ add(scratch, scratch,
4694 Operand((FCA::kArgsLength - 1 + argc.immediate()) * kPointerSize));
4695 // FunctionCallbackInfo::length_
4696 __ mov(ip, Operand(argc.immediate()));
4697 __ str(ip, MemOperand(r0, 2 * kPointerSize));
4698 } else {
4699 __ add(scratch, scratch, Operand(length_value, LSL, 2));
dcarney 2015/01/15 10:11:36 2 should be kPointerSizeLog2
4700 __ add(scratch, scratch, Operand((FCA::kArgsLength - 1) * kPointerSize));
dcarney 2015/01/15 10:11:37 should be able to do this with fused add multiply,
4701 // FunctionCallbackInfo::length_
4702 __ mov(ip, length_value);
4703 __ str(ip, MemOperand(r0, 2 * kPointerSize));
4704 }
4690 // FunctionCallbackInfo::values_ 4705 // FunctionCallbackInfo::values_
4691 __ add(ip, scratch, Operand((FCA::kArgsLength - 1 + argc) * kPointerSize)); 4706 __ str(scratch, MemOperand(r0, 1 * kPointerSize));
4692 __ str(ip, MemOperand(r0, 1 * kPointerSize)); 4707 if (argc.is_immediate()) {
4693 // FunctionCallbackInfo::length_ = argc 4708 // FunctionCallbackInfo::is_construct_call
4694 __ mov(ip, Operand(argc)); 4709 __ mov(ip, Operand::Zero());
4695 __ str(ip, MemOperand(r0, 2 * kPointerSize)); 4710 __ str(ip, MemOperand(r0, 3 * kPointerSize));
4696 // FunctionCallbackInfo::is_construct_call = 0 4711 } else {
4697 __ mov(ip, Operand::Zero()); 4712 // FunctionCallbackInfo::is_conetruct_call
4698 __ str(ip, MemOperand(r0, 3 * kPointerSize)); 4713 __ add(length_value, length_value, Operand(FCA::kArgsLength + 1));
4714 __ mov(ip, Operand(length_value, LSL, 3));
dcarney 2015/01/15 10:11:36 3 should be kPointerSizeLog2 + 1 to make it clear
4715 __ str(ip, MemOperand(r0, 3 * kPointerSize));
4716 }
4699 4717
4700 const int kStackUnwindSpace = argc + FCA::kArgsLength + 1;
4701 ExternalReference thunk_ref = 4718 ExternalReference thunk_ref =
4702 ExternalReference::invoke_function_callback(isolate()); 4719 ExternalReference::invoke_function_callback(masm->isolate());
4703 4720
4704 AllowExternalCallThatCantCauseGC scope(masm); 4721 AllowExternalCallThatCantCauseGC scope(masm);
4705 MemOperand context_restore_operand( 4722 MemOperand context_restore_operand(
4706 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); 4723 fp, (2 + FCA::kContextSaveIndex) * kPointerSize);
4707 // Stores return the first js argument 4724 // Stores return the first js argument
4708 int return_value_offset = 0; 4725 int return_value_offset = 0;
4709 if (is_store) { 4726 if (return_first_arg) {
4710 return_value_offset = 2 + FCA::kArgsLength; 4727 return_value_offset = 2 + FCA::kArgsLength;
4711 } else { 4728 } else {
4712 return_value_offset = 2 + FCA::kReturnValueOffset; 4729 return_value_offset = 2 + FCA::kReturnValueOffset;
4713 } 4730 }
4714 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); 4731 MemOperand return_value_operand(fp, return_value_offset * kPointerSize);
4732 int stack_space = 0;
4733 MemOperand is_construct_call_operand = MemOperand(r0, 3 * kPointerSize);
4734 MemOperand* stack_space_operand = &is_construct_call_operand;
4735 if (argc.is_immediate()) {
4736 stack_space = argc.immediate() + FCA::kArgsLength;
4737 stack_space_operand = NULL;
4738 }
4739 __ CallApiFunctionAndReturn(api_function_address, thunk_ref, stack_space,
4740 stack_space_operand, return_value_operand,
4741 &context_restore_operand);
4742 }
4715 4743
4716 __ CallApiFunctionAndReturn(api_function_address, 4744
4717 thunk_ref, 4745 void CallApiFunctionStub::Generate(MacroAssembler* masm) {
4718 kStackUnwindSpace, 4746 bool call_data_undefined = this->call_data_undefined();
4719 return_value_operand, 4747 CallApiFunctionStubHelper(masm, ParameterCount(r3), false,
4720 &context_restore_operand); 4748 call_data_undefined);
4749 }
4750
4751
4752 void CallApiAccessorStub::Generate(MacroAssembler* masm) {
4753 bool is_store = this->is_store();
4754 int argc = is_store ? 1 : 0;
4755 bool call_data_undefined = this->call_data_undefined();
4756 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store,
4757 call_data_undefined);
4721 } 4758 }
4722 4759
4723 4760
4724 void CallApiGetterStub::Generate(MacroAssembler* masm) { 4761 void CallApiGetterStub::Generate(MacroAssembler* masm) {
4725 // ----------- S t a t e ------------- 4762 // ----------- S t a t e -------------
4726 // -- sp[0] : name 4763 // -- sp[0] : name
4727 // -- sp[4 - kArgsLength*4] : PropertyCallbackArguments object 4764 // -- sp[4 - kArgsLength*4] : PropertyCallbackArguments object
4728 // -- ... 4765 // -- ...
4729 // -- r2 : api_function_address 4766 // -- r2 : api_function_address
4730 // ----------------------------------- 4767 // -----------------------------------
(...skipping 10 matching lines...) Expand all
4741 4778
4742 // Create PropertyAccessorInfo instance on the stack above the exit frame with 4779 // Create PropertyAccessorInfo instance on the stack above the exit frame with
4743 // r1 (internal::Object** args_) as the data. 4780 // r1 (internal::Object** args_) as the data.
4744 __ str(r1, MemOperand(sp, 1 * kPointerSize)); 4781 __ str(r1, MemOperand(sp, 1 * kPointerSize));
4745 __ add(r1, sp, Operand(1 * kPointerSize)); // r1 = AccessorInfo& 4782 __ add(r1, sp, Operand(1 * kPointerSize)); // r1 = AccessorInfo&
4746 4783
4747 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; 4784 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1;
4748 4785
4749 ExternalReference thunk_ref = 4786 ExternalReference thunk_ref =
4750 ExternalReference::invoke_accessor_getter_callback(isolate()); 4787 ExternalReference::invoke_accessor_getter_callback(isolate());
4751 __ CallApiFunctionAndReturn(api_function_address, 4788 __ CallApiFunctionAndReturn(api_function_address, thunk_ref,
4752 thunk_ref, 4789 kStackUnwindSpace, NULL,
4753 kStackUnwindSpace, 4790 MemOperand(fp, 6 * kPointerSize), NULL);
4754 MemOperand(fp, 6 * kPointerSize),
4755 NULL);
4756 } 4791 }
4757 4792
4758 4793
4759 #undef __ 4794 #undef __
4760 4795
4761 } } // namespace v8::internal 4796 } } // namespace v8::internal
4762 4797
4763 #endif // V8_TARGET_ARCH_ARM 4798 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/arm/interface-descriptors-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698