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

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

Issue 2054853002: Fix arguments object stubs for large arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Port to most architectures. Created 4 years, 6 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 | « src/ia32/code-stubs-ia32.cc ('k') | src/mips64/code-stubs-mips64.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 #if V8_TARGET_ARCH_MIPS 5 #if V8_TARGET_ARCH_MIPS
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 4706 matching lines...) Expand 10 before | Expand all | Expand 10 after
4717 Label no_rest_parameters; 4717 Label no_rest_parameters;
4718 __ lw(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset)); 4718 __ lw(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset));
4719 __ lw(a3, MemOperand(a2, CommonFrameConstants::kContextOrFrameTypeOffset)); 4719 __ lw(a3, MemOperand(a2, CommonFrameConstants::kContextOrFrameTypeOffset));
4720 __ Branch(&no_rest_parameters, ne, a3, 4720 __ Branch(&no_rest_parameters, ne, a3,
4721 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); 4721 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
4722 4722
4723 // Check if the arguments adaptor frame contains more arguments than 4723 // Check if the arguments adaptor frame contains more arguments than
4724 // specified by the function's internal formal parameter count. 4724 // specified by the function's internal formal parameter count.
4725 Label rest_parameters; 4725 Label rest_parameters;
4726 __ lw(a0, MemOperand(a2, ArgumentsAdaptorFrameConstants::kLengthOffset)); 4726 __ lw(a0, MemOperand(a2, ArgumentsAdaptorFrameConstants::kLengthOffset));
4727 __ lw(a1, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); 4727 __ lw(a3, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
4728 __ lw(a1, 4728 __ lw(a3,
4729 FieldMemOperand(a1, SharedFunctionInfo::kFormalParameterCountOffset)); 4729 FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset));
4730 __ Subu(a0, a0, Operand(a1)); 4730 __ Subu(a0, a0, Operand(a3));
4731 __ Branch(&rest_parameters, gt, a0, Operand(zero_reg)); 4731 __ Branch(&rest_parameters, gt, a0, Operand(zero_reg));
4732 4732
4733 // Return an empty rest parameter array. 4733 // Return an empty rest parameter array.
4734 __ bind(&no_rest_parameters); 4734 __ bind(&no_rest_parameters);
4735 { 4735 {
4736 // ----------- S t a t e ------------- 4736 // ----------- S t a t e -------------
4737 // -- cp : context 4737 // -- cp : context
4738 // -- ra : return address 4738 // -- ra : return address
4739 // ----------------------------------- 4739 // -----------------------------------
4740 4740
(...skipping 26 matching lines...) Expand all
4767 __ bind(&rest_parameters); 4767 __ bind(&rest_parameters);
4768 { 4768 {
4769 // Compute the pointer to the first rest parameter (skippping the receiver). 4769 // Compute the pointer to the first rest parameter (skippping the receiver).
4770 __ Lsa(a2, a2, a0, kPointerSizeLog2 - 1); 4770 __ Lsa(a2, a2, a0, kPointerSizeLog2 - 1);
4771 __ Addu(a2, a2, Operand(StandardFrameConstants::kCallerSPOffset - 4771 __ Addu(a2, a2, Operand(StandardFrameConstants::kCallerSPOffset -
4772 1 * kPointerSize)); 4772 1 * kPointerSize));
4773 4773
4774 // ----------- S t a t e ------------- 4774 // ----------- S t a t e -------------
4775 // -- cp : context 4775 // -- cp : context
4776 // -- a0 : number of rest parameters (tagged) 4776 // -- a0 : number of rest parameters (tagged)
4777 // -- a1 : function
4777 // -- a2 : pointer to first rest parameters 4778 // -- a2 : pointer to first rest parameters
4778 // -- ra : return address 4779 // -- ra : return address
4779 // ----------------------------------- 4780 // -----------------------------------
4780 4781
4781 // Allocate space for the rest parameter array plus the backing store. 4782 // Allocate space for the rest parameter array plus the backing store.
4782 Label allocate, done_allocate; 4783 Label allocate, done_allocate;
4783 __ li(a1, Operand(JSArray::kSize + FixedArray::kHeaderSize)); 4784 __ li(t0, Operand(JSArray::kSize + FixedArray::kHeaderSize));
4784 __ Lsa(a1, a1, a0, kPointerSizeLog2 - 1); 4785 __ Lsa(t0, t0, a0, kPointerSizeLog2 - 1);
4785 __ Allocate(a1, v0, a3, t0, &allocate, NO_ALLOCATION_FLAGS); 4786 __ Allocate(t0, v0, a3, t1, &allocate, NO_ALLOCATION_FLAGS);
4786 __ bind(&done_allocate); 4787 __ bind(&done_allocate);
4787 4788
4788 // Setup the elements array in v0. 4789 // Setup the elements array in v0.
4789 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex); 4790 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex);
4790 __ sw(at, FieldMemOperand(v0, FixedArray::kMapOffset)); 4791 __ sw(at, FieldMemOperand(v0, FixedArray::kMapOffset));
4791 __ sw(a0, FieldMemOperand(v0, FixedArray::kLengthOffset)); 4792 __ sw(a0, FieldMemOperand(v0, FixedArray::kLengthOffset));
4792 __ Addu(a3, v0, Operand(FixedArray::kHeaderSize)); 4793 __ Addu(a3, v0, Operand(FixedArray::kHeaderSize));
4793 { 4794 {
4794 Label loop, done_loop; 4795 Label loop, done_loop;
4795 __ sll(at, a0, kPointerSizeLog2 - 1); 4796 __ sll(at, a0, kPointerSizeLog2 - 1);
(...skipping 12 matching lines...) Expand all
4808 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, at); 4809 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, at);
4809 __ sw(at, FieldMemOperand(a3, JSArray::kMapOffset)); 4810 __ sw(at, FieldMemOperand(a3, JSArray::kMapOffset));
4810 __ LoadRoot(at, Heap::kEmptyFixedArrayRootIndex); 4811 __ LoadRoot(at, Heap::kEmptyFixedArrayRootIndex);
4811 __ sw(at, FieldMemOperand(a3, JSArray::kPropertiesOffset)); 4812 __ sw(at, FieldMemOperand(a3, JSArray::kPropertiesOffset));
4812 __ sw(v0, FieldMemOperand(a3, JSArray::kElementsOffset)); 4813 __ sw(v0, FieldMemOperand(a3, JSArray::kElementsOffset));
4813 __ sw(a0, FieldMemOperand(a3, JSArray::kLengthOffset)); 4814 __ sw(a0, FieldMemOperand(a3, JSArray::kLengthOffset));
4814 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); 4815 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize);
4815 __ Ret(USE_DELAY_SLOT); 4816 __ Ret(USE_DELAY_SLOT);
4816 __ mov(v0, a3); // In delay slot 4817 __ mov(v0, a3); // In delay slot
4817 4818
4818 // Fall back to %AllocateInNewSpace. 4819 // Fall back to %AllocateInNewSpace (if not too big).
4820 Label too_big_for_new_space;
4819 __ bind(&allocate); 4821 __ bind(&allocate);
4822 __ Branch(&too_big_for_new_space, gt, t0,
4823 Operand(Page::kMaxRegularHeapObjectSize));
4820 { 4824 {
4821 FrameScope scope(masm, StackFrame::INTERNAL); 4825 FrameScope scope(masm, StackFrame::INTERNAL);
4822 __ SmiTag(a1); 4826 __ SmiTag(t0);
4823 __ Push(a0, a2, a1); 4827 __ Push(a0, a2, t0);
4824 __ CallRuntime(Runtime::kAllocateInNewSpace); 4828 __ CallRuntime(Runtime::kAllocateInNewSpace);
4825 __ Pop(a0, a2); 4829 __ Pop(a0, a2);
4826 } 4830 }
4827 __ jmp(&done_allocate); 4831 __ jmp(&done_allocate);
4832
4833 // Fall back to %NewStrictArguments.
4834 __ bind(&too_big_for_new_space);
4835 __ Push(a1);
4836 __ TailCallRuntime(Runtime::kNewStrictArguments);
4828 } 4837 }
4829 } 4838 }
4830 4839
4831 4840
4832 void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) { 4841 void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) {
4833 // ----------- S t a t e ------------- 4842 // ----------- S t a t e -------------
4834 // -- a1 : function 4843 // -- a1 : function
4835 // -- cp : context 4844 // -- cp : context
4836 // -- fp : frame pointer 4845 // -- fp : frame pointer
4837 // -- ra : return address 4846 // -- ra : return address
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
5083 __ bind(&ok); 5092 __ bind(&ok);
5084 } 5093 }
5085 5094
5086 // Check if we have an arguments adaptor frame below the function frame. 5095 // Check if we have an arguments adaptor frame below the function frame.
5087 Label arguments_adaptor, arguments_done; 5096 Label arguments_adaptor, arguments_done;
5088 __ lw(a3, MemOperand(a2, StandardFrameConstants::kCallerFPOffset)); 5097 __ lw(a3, MemOperand(a2, StandardFrameConstants::kCallerFPOffset));
5089 __ lw(a0, MemOperand(a3, CommonFrameConstants::kContextOrFrameTypeOffset)); 5098 __ lw(a0, MemOperand(a3, CommonFrameConstants::kContextOrFrameTypeOffset));
5090 __ Branch(&arguments_adaptor, eq, a0, 5099 __ Branch(&arguments_adaptor, eq, a0,
5091 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); 5100 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
5092 { 5101 {
5093 __ lw(a1, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); 5102 __ lw(t0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
5094 __ lw(a0, 5103 __ lw(a0,
5095 FieldMemOperand(a1, SharedFunctionInfo::kFormalParameterCountOffset)); 5104 FieldMemOperand(t0, SharedFunctionInfo::kFormalParameterCountOffset));
5096 __ Lsa(a2, a2, a0, kPointerSizeLog2 - 1); 5105 __ Lsa(a2, a2, a0, kPointerSizeLog2 - 1);
5097 __ Addu(a2, a2, Operand(StandardFrameConstants::kCallerSPOffset - 5106 __ Addu(a2, a2, Operand(StandardFrameConstants::kCallerSPOffset -
5098 1 * kPointerSize)); 5107 1 * kPointerSize));
5099 } 5108 }
5100 __ Branch(&arguments_done); 5109 __ Branch(&arguments_done);
5101 __ bind(&arguments_adaptor); 5110 __ bind(&arguments_adaptor);
5102 { 5111 {
5103 __ lw(a0, MemOperand(a3, ArgumentsAdaptorFrameConstants::kLengthOffset)); 5112 __ lw(a0, MemOperand(a3, ArgumentsAdaptorFrameConstants::kLengthOffset));
5104 __ Lsa(a2, a3, a0, kPointerSizeLog2 - 1); 5113 __ Lsa(a2, a3, a0, kPointerSizeLog2 - 1);
5105 __ Addu(a2, a2, Operand(StandardFrameConstants::kCallerSPOffset - 5114 __ Addu(a2, a2, Operand(StandardFrameConstants::kCallerSPOffset -
5106 1 * kPointerSize)); 5115 1 * kPointerSize));
5107 } 5116 }
5108 __ bind(&arguments_done); 5117 __ bind(&arguments_done);
5109 5118
5110 // ----------- S t a t e ------------- 5119 // ----------- S t a t e -------------
5111 // -- cp : context 5120 // -- cp : context
5112 // -- a0 : number of rest parameters (tagged) 5121 // -- a0 : number of rest parameters (tagged)
5122 // -- a1 : function
5113 // -- a2 : pointer to first rest parameters 5123 // -- a2 : pointer to first rest parameters
5114 // -- ra : return address 5124 // -- ra : return address
5115 // ----------------------------------- 5125 // -----------------------------------
5116 5126
5117 // Allocate space for the strict arguments object plus the backing store. 5127 // Allocate space for the strict arguments object plus the backing store.
5118 Label allocate, done_allocate; 5128 Label allocate, done_allocate;
5119 __ li(a1, Operand(JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize)); 5129 __ li(t0, Operand(JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize));
5120 __ Lsa(a1, a1, a0, kPointerSizeLog2 - 1); 5130 __ Lsa(t0, t0, a0, kPointerSizeLog2 - 1);
5121 __ Allocate(a1, v0, a3, t0, &allocate, NO_ALLOCATION_FLAGS); 5131 __ Allocate(t0, v0, a3, t1, &allocate, NO_ALLOCATION_FLAGS);
5122 __ bind(&done_allocate); 5132 __ bind(&done_allocate);
5123 5133
5124 // Setup the elements array in v0. 5134 // Setup the elements array in v0.
5125 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex); 5135 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex);
5126 __ sw(at, FieldMemOperand(v0, FixedArray::kMapOffset)); 5136 __ sw(at, FieldMemOperand(v0, FixedArray::kMapOffset));
5127 __ sw(a0, FieldMemOperand(v0, FixedArray::kLengthOffset)); 5137 __ sw(a0, FieldMemOperand(v0, FixedArray::kLengthOffset));
5128 __ Addu(a3, v0, Operand(FixedArray::kHeaderSize)); 5138 __ Addu(a3, v0, Operand(FixedArray::kHeaderSize));
5129 { 5139 {
5130 Label loop, done_loop; 5140 Label loop, done_loop;
5131 __ sll(at, a0, kPointerSizeLog2 - 1); 5141 __ sll(at, a0, kPointerSizeLog2 - 1);
(...skipping 12 matching lines...) Expand all
5144 __ LoadNativeContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX, at); 5154 __ LoadNativeContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX, at);
5145 __ sw(at, FieldMemOperand(a3, JSStrictArgumentsObject::kMapOffset)); 5155 __ sw(at, FieldMemOperand(a3, JSStrictArgumentsObject::kMapOffset));
5146 __ LoadRoot(at, Heap::kEmptyFixedArrayRootIndex); 5156 __ LoadRoot(at, Heap::kEmptyFixedArrayRootIndex);
5147 __ sw(at, FieldMemOperand(a3, JSStrictArgumentsObject::kPropertiesOffset)); 5157 __ sw(at, FieldMemOperand(a3, JSStrictArgumentsObject::kPropertiesOffset));
5148 __ sw(v0, FieldMemOperand(a3, JSStrictArgumentsObject::kElementsOffset)); 5158 __ sw(v0, FieldMemOperand(a3, JSStrictArgumentsObject::kElementsOffset));
5149 __ sw(a0, FieldMemOperand(a3, JSStrictArgumentsObject::kLengthOffset)); 5159 __ sw(a0, FieldMemOperand(a3, JSStrictArgumentsObject::kLengthOffset));
5150 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize); 5160 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize);
5151 __ Ret(USE_DELAY_SLOT); 5161 __ Ret(USE_DELAY_SLOT);
5152 __ mov(v0, a3); // In delay slot 5162 __ mov(v0, a3); // In delay slot
5153 5163
5154 // Fall back to %AllocateInNewSpace. 5164 // Fall back to %AllocateInNewSpace (if not too big).
5165 Label too_big_for_new_space;
5155 __ bind(&allocate); 5166 __ bind(&allocate);
5167 __ Branch(&too_big_for_new_space, gt, t0,
5168 Operand(Page::kMaxRegularHeapObjectSize));
5156 { 5169 {
5157 FrameScope scope(masm, StackFrame::INTERNAL); 5170 FrameScope scope(masm, StackFrame::INTERNAL);
5158 __ SmiTag(a1); 5171 __ SmiTag(t0);
5159 __ Push(a0, a2, a1); 5172 __ Push(a0, a2, t0);
5160 __ CallRuntime(Runtime::kAllocateInNewSpace); 5173 __ CallRuntime(Runtime::kAllocateInNewSpace);
5161 __ Pop(a0, a2); 5174 __ Pop(a0, a2);
5162 } 5175 }
5163 __ jmp(&done_allocate); 5176 __ jmp(&done_allocate);
5177
5178 // Fall back to %NewStrictArguments.
5179 __ bind(&too_big_for_new_space);
5180 __ Push(a1);
5181 __ TailCallRuntime(Runtime::kNewStrictArguments);
5164 } 5182 }
5165 5183
5166 5184
5167 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { 5185 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) {
5168 Register context_reg = cp; 5186 Register context_reg = cp;
5169 Register slot_reg = a2; 5187 Register slot_reg = a2;
5170 Register result_reg = v0; 5188 Register result_reg = v0;
5171 Label slow_case; 5189 Label slow_case;
5172 5190
5173 // Go up context chain to the script context. 5191 // Go up context chain to the script context.
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
5612 kStackUnwindSpace, kInvalidStackOffset, 5630 kStackUnwindSpace, kInvalidStackOffset,
5613 return_value_operand, NULL); 5631 return_value_operand, NULL);
5614 } 5632 }
5615 5633
5616 #undef __ 5634 #undef __
5617 5635
5618 } // namespace internal 5636 } // namespace internal
5619 } // namespace v8 5637 } // namespace v8
5620 5638
5621 #endif // V8_TARGET_ARCH_MIPS 5639 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/mips64/code-stubs-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698