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

Side by Side Diff: src/arm64/code-stubs-arm64.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/arm/code-stubs-arm.cc ('k') | src/compiler/js-create-lowering.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_ARM64 5 #if V8_TARGET_ARCH_ARM64
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/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 4795 matching lines...) Expand 10 before | Expand all | Expand 10 after
4806 __ Ldr(x2, MemOperand(x2, CommonFrameConstants::kCallerFPOffset)); 4806 __ Ldr(x2, MemOperand(x2, CommonFrameConstants::kCallerFPOffset));
4807 __ Ldr(x3, MemOperand(x2, CommonFrameConstants::kContextOrFrameTypeOffset)); 4807 __ Ldr(x3, MemOperand(x2, CommonFrameConstants::kContextOrFrameTypeOffset));
4808 __ Cmp(x3, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); 4808 __ Cmp(x3, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
4809 __ B(ne, &no_rest_parameters); 4809 __ B(ne, &no_rest_parameters);
4810 4810
4811 // Check if the arguments adaptor frame contains more arguments than 4811 // Check if the arguments adaptor frame contains more arguments than
4812 // specified by the function's internal formal parameter count. 4812 // specified by the function's internal formal parameter count.
4813 Label rest_parameters; 4813 Label rest_parameters;
4814 __ Ldrsw(x0, UntagSmiMemOperand( 4814 __ Ldrsw(x0, UntagSmiMemOperand(
4815 x2, ArgumentsAdaptorFrameConstants::kLengthOffset)); 4815 x2, ArgumentsAdaptorFrameConstants::kLengthOffset));
4816 __ Ldr(x1, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); 4816 __ Ldr(x3, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset));
4817 __ Ldrsw( 4817 __ Ldrsw(
4818 x1, FieldMemOperand(x1, SharedFunctionInfo::kFormalParameterCountOffset)); 4818 x3, FieldMemOperand(x3, SharedFunctionInfo::kFormalParameterCountOffset));
4819 __ Subs(x0, x0, x1); 4819 __ Subs(x0, x0, x3);
4820 __ B(gt, &rest_parameters); 4820 __ B(gt, &rest_parameters);
4821 4821
4822 // Return an empty rest parameter array. 4822 // Return an empty rest parameter array.
4823 __ Bind(&no_rest_parameters); 4823 __ Bind(&no_rest_parameters);
4824 { 4824 {
4825 // ----------- S t a t e ------------- 4825 // ----------- S t a t e -------------
4826 // -- cp : context 4826 // -- cp : context
4827 // -- lr : return address 4827 // -- lr : return address
4828 // ----------------------------------- 4828 // -----------------------------------
4829 4829
(...skipping 25 matching lines...) Expand all
4855 4855
4856 __ Bind(&rest_parameters); 4856 __ Bind(&rest_parameters);
4857 { 4857 {
4858 // Compute the pointer to the first rest parameter (skippping the receiver). 4858 // Compute the pointer to the first rest parameter (skippping the receiver).
4859 __ Add(x2, x2, Operand(x0, LSL, kPointerSizeLog2)); 4859 __ Add(x2, x2, Operand(x0, LSL, kPointerSizeLog2));
4860 __ Add(x2, x2, StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize); 4860 __ Add(x2, x2, StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize);
4861 4861
4862 // ----------- S t a t e ------------- 4862 // ----------- S t a t e -------------
4863 // -- cp : context 4863 // -- cp : context
4864 // -- x0 : number of rest parameters 4864 // -- x0 : number of rest parameters
4865 // -- x1 : function
4865 // -- x2 : pointer to first rest parameters 4866 // -- x2 : pointer to first rest parameters
4866 // -- lr : return address 4867 // -- lr : return address
4867 // ----------------------------------- 4868 // -----------------------------------
4868 4869
4869 // Allocate space for the rest parameter array plus the backing store. 4870 // Allocate space for the rest parameter array plus the backing store.
4870 Label allocate, done_allocate; 4871 Label allocate, done_allocate;
4871 __ Mov(x1, JSArray::kSize + FixedArray::kHeaderSize); 4872 __ Mov(x6, JSArray::kSize + FixedArray::kHeaderSize);
4872 __ Add(x1, x1, Operand(x0, LSL, kPointerSizeLog2)); 4873 __ Add(x6, x6, Operand(x0, LSL, kPointerSizeLog2));
4873 __ Allocate(x1, x3, x4, x5, &allocate, NO_ALLOCATION_FLAGS); 4874 __ Allocate(x6, x3, x4, x5, &allocate, NO_ALLOCATION_FLAGS);
4874 __ Bind(&done_allocate); 4875 __ Bind(&done_allocate);
4875 4876
4876 // Compute arguments.length in x6. 4877 // Compute arguments.length in x6.
4877 __ SmiTag(x6, x0); 4878 __ SmiTag(x6, x0);
4878 4879
4879 // Setup the elements array in x3. 4880 // Setup the elements array in x3.
4880 __ LoadRoot(x1, Heap::kFixedArrayMapRootIndex); 4881 __ LoadRoot(x1, Heap::kFixedArrayMapRootIndex);
4881 __ Str(x1, FieldMemOperand(x3, FixedArray::kMapOffset)); 4882 __ Str(x1, FieldMemOperand(x3, FixedArray::kMapOffset));
4882 __ Str(x6, FieldMemOperand(x3, FixedArray::kLengthOffset)); 4883 __ Str(x6, FieldMemOperand(x3, FixedArray::kLengthOffset));
4883 __ Add(x4, x3, FixedArray::kHeaderSize); 4884 __ Add(x4, x3, FixedArray::kHeaderSize);
(...skipping 14 matching lines...) Expand all
4898 // Setup the rest parameter array in x0. 4899 // Setup the rest parameter array in x0.
4899 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, x1); 4900 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, x1);
4900 __ Str(x1, FieldMemOperand(x0, JSArray::kMapOffset)); 4901 __ Str(x1, FieldMemOperand(x0, JSArray::kMapOffset));
4901 __ LoadRoot(x1, Heap::kEmptyFixedArrayRootIndex); 4902 __ LoadRoot(x1, Heap::kEmptyFixedArrayRootIndex);
4902 __ Str(x1, FieldMemOperand(x0, JSArray::kPropertiesOffset)); 4903 __ Str(x1, FieldMemOperand(x0, JSArray::kPropertiesOffset));
4903 __ Str(x3, FieldMemOperand(x0, JSArray::kElementsOffset)); 4904 __ Str(x3, FieldMemOperand(x0, JSArray::kElementsOffset));
4904 __ Str(x6, FieldMemOperand(x0, JSArray::kLengthOffset)); 4905 __ Str(x6, FieldMemOperand(x0, JSArray::kLengthOffset));
4905 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); 4906 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize);
4906 __ Ret(); 4907 __ Ret();
4907 4908
4908 // Fall back to %AllocateInNewSpace. 4909 // Fall back to %AllocateInNewSpace (if not too big).
4910 Label too_big_for_new_space;
4909 __ Bind(&allocate); 4911 __ Bind(&allocate);
4912 __ Cmp(x6, Operand(Page::kMaxRegularHeapObjectSize));
4913 __ B(gt, &too_big_for_new_space);
4910 { 4914 {
4911 FrameScope scope(masm, StackFrame::INTERNAL); 4915 FrameScope scope(masm, StackFrame::INTERNAL);
4912 __ SmiTag(x0); 4916 __ SmiTag(x0);
4913 __ SmiTag(x1); 4917 __ SmiTag(x6);
4914 __ Push(x0, x2, x1); 4918 __ Push(x0, x2, x6);
4915 __ CallRuntime(Runtime::kAllocateInNewSpace); 4919 __ CallRuntime(Runtime::kAllocateInNewSpace);
4916 __ Mov(x3, x0); 4920 __ Mov(x3, x0);
4917 __ Pop(x2, x0); 4921 __ Pop(x2, x0);
4918 __ SmiUntag(x0); 4922 __ SmiUntag(x0);
4919 } 4923 }
4920 __ B(&done_allocate); 4924 __ B(&done_allocate);
4925
4926 // Fall back to %NewRestParameter.
4927 __ Bind(&too_big_for_new_space);
4928 __ Push(x1);
4929 __ TailCallRuntime(Runtime::kNewRestParameter);
4921 } 4930 }
4922 } 4931 }
4923 4932
4924 4933
4925 void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) { 4934 void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) {
4926 // ----------- S t a t e ------------- 4935 // ----------- S t a t e -------------
4927 // -- x1 : function 4936 // -- x1 : function
4928 // -- cp : context 4937 // -- cp : context
4929 // -- fp : frame pointer 4938 // -- fp : frame pointer
4930 // -- lr : return address 4939 // -- lr : return address
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
5247 __ Bind(&ok); 5256 __ Bind(&ok);
5248 } 5257 }
5249 5258
5250 // Check if we have an arguments adaptor frame below the function frame. 5259 // Check if we have an arguments adaptor frame below the function frame.
5251 Label arguments_adaptor, arguments_done; 5260 Label arguments_adaptor, arguments_done;
5252 __ Ldr(x3, MemOperand(x2, StandardFrameConstants::kCallerFPOffset)); 5261 __ Ldr(x3, MemOperand(x2, StandardFrameConstants::kCallerFPOffset));
5253 __ Ldr(x4, MemOperand(x3, CommonFrameConstants::kContextOrFrameTypeOffset)); 5262 __ Ldr(x4, MemOperand(x3, CommonFrameConstants::kContextOrFrameTypeOffset));
5254 __ Cmp(x4, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); 5263 __ Cmp(x4, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
5255 __ B(eq, &arguments_adaptor); 5264 __ B(eq, &arguments_adaptor);
5256 { 5265 {
5257 __ Ldr(x1, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); 5266 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset));
5258 __ Ldrsw(x0, FieldMemOperand( 5267 __ Ldrsw(x0, FieldMemOperand(
5259 x1, SharedFunctionInfo::kFormalParameterCountOffset)); 5268 x4, SharedFunctionInfo::kFormalParameterCountOffset));
5260 __ Add(x2, x2, Operand(x0, LSL, kPointerSizeLog2)); 5269 __ Add(x2, x2, Operand(x0, LSL, kPointerSizeLog2));
5261 __ Add(x2, x2, StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize); 5270 __ Add(x2, x2, StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize);
5262 } 5271 }
5263 __ B(&arguments_done); 5272 __ B(&arguments_done);
5264 __ Bind(&arguments_adaptor); 5273 __ Bind(&arguments_adaptor);
5265 { 5274 {
5266 __ Ldrsw(x0, UntagSmiMemOperand( 5275 __ Ldrsw(x0, UntagSmiMemOperand(
5267 x3, ArgumentsAdaptorFrameConstants::kLengthOffset)); 5276 x3, ArgumentsAdaptorFrameConstants::kLengthOffset));
5268 __ Add(x2, x3, Operand(x0, LSL, kPointerSizeLog2)); 5277 __ Add(x2, x3, Operand(x0, LSL, kPointerSizeLog2));
5269 __ Add(x2, x2, StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize); 5278 __ Add(x2, x2, StandardFrameConstants::kCallerSPOffset - 1 * kPointerSize);
5270 } 5279 }
5271 __ Bind(&arguments_done); 5280 __ Bind(&arguments_done);
5272 5281
5273 // ----------- S t a t e ------------- 5282 // ----------- S t a t e -------------
5274 // -- cp : context 5283 // -- cp : context
5275 // -- x0 : number of rest parameters 5284 // -- x0 : number of rest parameters
5285 // -- x1 : function
5276 // -- x2 : pointer to first rest parameters 5286 // -- x2 : pointer to first rest parameters
5277 // -- lr : return address 5287 // -- lr : return address
5278 // ----------------------------------- 5288 // -----------------------------------
5279 5289
5280 // Allocate space for the strict arguments object plus the backing store. 5290 // Allocate space for the strict arguments object plus the backing store.
5281 Label allocate, done_allocate; 5291 Label allocate, done_allocate;
5282 __ Mov(x1, JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize); 5292 __ Mov(x6, JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize);
5283 __ Add(x1, x1, Operand(x0, LSL, kPointerSizeLog2)); 5293 __ Add(x6, x6, Operand(x0, LSL, kPointerSizeLog2));
5284 __ Allocate(x1, x3, x4, x5, &allocate, NO_ALLOCATION_FLAGS); 5294 __ Allocate(x6, x3, x4, x5, &allocate, NO_ALLOCATION_FLAGS);
5285 __ Bind(&done_allocate); 5295 __ Bind(&done_allocate);
5286 5296
5287 // Compute arguments.length in x6. 5297 // Compute arguments.length in x6.
5288 __ SmiTag(x6, x0); 5298 __ SmiTag(x6, x0);
5289 5299
5290 // Setup the elements array in x3. 5300 // Setup the elements array in x3.
5291 __ LoadRoot(x1, Heap::kFixedArrayMapRootIndex); 5301 __ LoadRoot(x1, Heap::kFixedArrayMapRootIndex);
5292 __ Str(x1, FieldMemOperand(x3, FixedArray::kMapOffset)); 5302 __ Str(x1, FieldMemOperand(x3, FixedArray::kMapOffset));
5293 __ Str(x6, FieldMemOperand(x3, FixedArray::kLengthOffset)); 5303 __ Str(x6, FieldMemOperand(x3, FixedArray::kLengthOffset));
5294 __ Add(x4, x3, FixedArray::kHeaderSize); 5304 __ Add(x4, x3, FixedArray::kHeaderSize);
(...skipping 14 matching lines...) Expand all
5309 // Setup the strict arguments object in x0. 5319 // Setup the strict arguments object in x0.
5310 __ LoadNativeContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX, x1); 5320 __ LoadNativeContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX, x1);
5311 __ Str(x1, FieldMemOperand(x0, JSStrictArgumentsObject::kMapOffset)); 5321 __ Str(x1, FieldMemOperand(x0, JSStrictArgumentsObject::kMapOffset));
5312 __ LoadRoot(x1, Heap::kEmptyFixedArrayRootIndex); 5322 __ LoadRoot(x1, Heap::kEmptyFixedArrayRootIndex);
5313 __ Str(x1, FieldMemOperand(x0, JSStrictArgumentsObject::kPropertiesOffset)); 5323 __ Str(x1, FieldMemOperand(x0, JSStrictArgumentsObject::kPropertiesOffset));
5314 __ Str(x3, FieldMemOperand(x0, JSStrictArgumentsObject::kElementsOffset)); 5324 __ Str(x3, FieldMemOperand(x0, JSStrictArgumentsObject::kElementsOffset));
5315 __ Str(x6, FieldMemOperand(x0, JSStrictArgumentsObject::kLengthOffset)); 5325 __ Str(x6, FieldMemOperand(x0, JSStrictArgumentsObject::kLengthOffset));
5316 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize); 5326 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize);
5317 __ Ret(); 5327 __ Ret();
5318 5328
5319 // Fall back to %AllocateInNewSpace. 5329 // Fall back to %AllocateInNewSpace (if not too big).
5330 Label too_big_for_new_space;
5320 __ Bind(&allocate); 5331 __ Bind(&allocate);
5332 __ Cmp(x6, Operand(Page::kMaxRegularHeapObjectSize));
5333 __ B(gt, &too_big_for_new_space);
5321 { 5334 {
5322 FrameScope scope(masm, StackFrame::INTERNAL); 5335 FrameScope scope(masm, StackFrame::INTERNAL);
5323 __ SmiTag(x0); 5336 __ SmiTag(x0);
5324 __ SmiTag(x1); 5337 __ SmiTag(x6);
5325 __ Push(x0, x2, x1); 5338 __ Push(x0, x2, x6);
5326 __ CallRuntime(Runtime::kAllocateInNewSpace); 5339 __ CallRuntime(Runtime::kAllocateInNewSpace);
5327 __ Mov(x3, x0); 5340 __ Mov(x3, x0);
5328 __ Pop(x2, x0); 5341 __ Pop(x2, x0);
5329 __ SmiUntag(x0); 5342 __ SmiUntag(x0);
5330 } 5343 }
5331 __ B(&done_allocate); 5344 __ B(&done_allocate);
5345
5346 // Fall back to %NewStrictArguments.
5347 __ Bind(&too_big_for_new_space);
5348 __ Push(x1);
5349 __ TailCallRuntime(Runtime::kNewStrictArguments);
5332 } 5350 }
5333 5351
5334 5352
5335 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { 5353 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) {
5336 Register context = cp; 5354 Register context = cp;
5337 Register result = x0; 5355 Register result = x0;
5338 Register slot = x2; 5356 Register slot = x2;
5339 Label slow_case; 5357 Label slow_case;
5340 5358
5341 // Go up the context chain to the script context. 5359 // Go up the context chain to the script context.
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
5822 kStackUnwindSpace, NULL, spill_offset, 5840 kStackUnwindSpace, NULL, spill_offset,
5823 return_value_operand, NULL); 5841 return_value_operand, NULL);
5824 } 5842 }
5825 5843
5826 #undef __ 5844 #undef __
5827 5845
5828 } // namespace internal 5846 } // namespace internal
5829 } // namespace v8 5847 } // namespace v8
5830 5848
5831 #endif // V8_TARGET_ARCH_ARM64 5849 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/compiler/js-create-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698