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

Side by Side Diff: src/x64/code-stubs-x64.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/mips64/code-stubs-mips64.cc ('k') | test/mjsunit/regress/regress-crbug-614727.js » ('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_X64 5 #if V8_TARGET_ARCH_X64
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 4450 matching lines...) Expand 10 before | Expand all | Expand 10 after
4461 } 4461 }
4462 4462
4463 __ bind(&rest_parameters); 4463 __ bind(&rest_parameters);
4464 { 4464 {
4465 // Compute the pointer to the first rest parameter (skippping the receiver). 4465 // Compute the pointer to the first rest parameter (skippping the receiver).
4466 __ leap(rbx, Operand(rbx, rax, times_pointer_size, 4466 __ leap(rbx, Operand(rbx, rax, times_pointer_size,
4467 StandardFrameConstants::kCallerSPOffset - 4467 StandardFrameConstants::kCallerSPOffset -
4468 1 * kPointerSize)); 4468 1 * kPointerSize));
4469 4469
4470 // ----------- S t a t e ------------- 4470 // ----------- S t a t e -------------
4471 // -- rdi : function
4471 // -- rsi : context 4472 // -- rsi : context
4472 // -- rax : number of rest parameters 4473 // -- rax : number of rest parameters
4473 // -- rbx : pointer to first rest parameters 4474 // -- rbx : pointer to first rest parameters
4474 // -- rsp[0] : return address 4475 // -- rsp[0] : return address
4475 // ----------------------------------- 4476 // -----------------------------------
4476 4477
4477 // Allocate space for the rest parameter array plus the backing store. 4478 // Allocate space for the rest parameter array plus the backing store.
4478 Label allocate, done_allocate; 4479 Label allocate, done_allocate;
4479 __ leal(rcx, Operand(rax, times_pointer_size, 4480 __ leal(rcx, Operand(rax, times_pointer_size,
4480 JSArray::kSize + FixedArray::kHeaderSize)); 4481 JSArray::kSize + FixedArray::kHeaderSize));
4481 __ Allocate(rcx, rdx, rdi, no_reg, &allocate, NO_ALLOCATION_FLAGS); 4482 __ Allocate(rcx, rdx, r8, no_reg, &allocate, NO_ALLOCATION_FLAGS);
4482 __ bind(&done_allocate); 4483 __ bind(&done_allocate);
4483 4484
4484 // Compute the arguments.length in rdi. 4485 // Compute the arguments.length in rdi.
4485 __ Integer32ToSmi(rdi, rax); 4486 __ Integer32ToSmi(rdi, rax);
4486 4487
4487 // Setup the elements array in rdx. 4488 // Setup the elements array in rdx.
4488 __ LoadRoot(rcx, Heap::kFixedArrayMapRootIndex); 4489 __ LoadRoot(rcx, Heap::kFixedArrayMapRootIndex);
4489 __ movp(FieldOperand(rdx, FixedArray::kMapOffset), rcx); 4490 __ movp(FieldOperand(rdx, FixedArray::kMapOffset), rcx);
4490 __ movp(FieldOperand(rdx, FixedArray::kLengthOffset), rdi); 4491 __ movp(FieldOperand(rdx, FixedArray::kLengthOffset), rdi);
4491 { 4492 {
(...skipping 17 matching lines...) Expand all
4509 Operand(rdx, rax, times_pointer_size, FixedArray::kHeaderSize)); 4510 Operand(rdx, rax, times_pointer_size, FixedArray::kHeaderSize));
4510 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, rcx); 4511 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, rcx);
4511 __ movp(FieldOperand(rax, JSArray::kMapOffset), rcx); 4512 __ movp(FieldOperand(rax, JSArray::kMapOffset), rcx);
4512 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex); 4513 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex);
4513 __ movp(FieldOperand(rax, JSArray::kPropertiesOffset), rcx); 4514 __ movp(FieldOperand(rax, JSArray::kPropertiesOffset), rcx);
4514 __ movp(FieldOperand(rax, JSArray::kElementsOffset), rdx); 4515 __ movp(FieldOperand(rax, JSArray::kElementsOffset), rdx);
4515 __ movp(FieldOperand(rax, JSArray::kLengthOffset), rdi); 4516 __ movp(FieldOperand(rax, JSArray::kLengthOffset), rdi);
4516 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); 4517 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize);
4517 __ Ret(); 4518 __ Ret();
4518 4519
4519 // Fall back to %AllocateInNewSpace. 4520 // Fall back to %AllocateInNewSpace (if not too big).
4521 Label too_big_for_new_space;
4520 __ bind(&allocate); 4522 __ bind(&allocate);
4523 __ cmpl(rcx, Immediate(Page::kMaxRegularHeapObjectSize));
4524 __ j(greater, &too_big_for_new_space);
4521 { 4525 {
4522 FrameScope scope(masm, StackFrame::INTERNAL); 4526 FrameScope scope(masm, StackFrame::INTERNAL);
4523 __ Integer32ToSmi(rax, rax); 4527 __ Integer32ToSmi(rax, rax);
4524 __ Integer32ToSmi(rcx, rcx); 4528 __ Integer32ToSmi(rcx, rcx);
4525 __ Push(rax); 4529 __ Push(rax);
4526 __ Push(rbx); 4530 __ Push(rbx);
4527 __ Push(rcx); 4531 __ Push(rcx);
4528 __ CallRuntime(Runtime::kAllocateInNewSpace); 4532 __ CallRuntime(Runtime::kAllocateInNewSpace);
4529 __ movp(rdx, rax); 4533 __ movp(rdx, rax);
4530 __ Pop(rbx); 4534 __ Pop(rbx);
4531 __ Pop(rax); 4535 __ Pop(rax);
4532 __ SmiToInteger32(rax, rax); 4536 __ SmiToInteger32(rax, rax);
4533 } 4537 }
4534 __ jmp(&done_allocate); 4538 __ jmp(&done_allocate);
4539
4540 // Fall back to %NewRestParameter.
4541 __ bind(&too_big_for_new_space);
4542 __ PopReturnAddressTo(kScratchRegister);
4543 __ Push(rdi);
4544 __ PushReturnAddressFrom(kScratchRegister);
4545 __ TailCallRuntime(Runtime::kNewRestParameter);
4535 } 4546 }
4536 } 4547 }
4537 4548
4538 4549
4539 void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) { 4550 void FastNewSloppyArgumentsStub::Generate(MacroAssembler* masm) {
4540 // ----------- S t a t e ------------- 4551 // ----------- S t a t e -------------
4541 // -- rdi : function 4552 // -- rdi : function
4542 // -- rsi : context 4553 // -- rsi : context
4543 // -- rbp : frame pointer 4554 // -- rbp : frame pointer
4544 // -- rsp[0] : return address 4555 // -- rsp[0] : return address
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
4815 rax, Operand(rbx, ArgumentsAdaptorFrameConstants::kLengthOffset)); 4826 rax, Operand(rbx, ArgumentsAdaptorFrameConstants::kLengthOffset));
4816 __ leap(rbx, Operand(rbx, rax, times_pointer_size, 4827 __ leap(rbx, Operand(rbx, rax, times_pointer_size,
4817 StandardFrameConstants::kCallerSPOffset - 4828 StandardFrameConstants::kCallerSPOffset -
4818 1 * kPointerSize)); 4829 1 * kPointerSize));
4819 } 4830 }
4820 __ bind(&arguments_done); 4831 __ bind(&arguments_done);
4821 4832
4822 // ----------- S t a t e ------------- 4833 // ----------- S t a t e -------------
4823 // -- rax : number of arguments 4834 // -- rax : number of arguments
4824 // -- rbx : pointer to the first argument 4835 // -- rbx : pointer to the first argument
4836 // -- rdi : function
4825 // -- rsi : context 4837 // -- rsi : context
4826 // -- rsp[0] : return address 4838 // -- rsp[0] : return address
4827 // ----------------------------------- 4839 // -----------------------------------
4828 4840
4829 // Allocate space for the strict arguments object plus the backing store. 4841 // Allocate space for the strict arguments object plus the backing store.
4830 Label allocate, done_allocate; 4842 Label allocate, done_allocate;
4831 __ leal(rcx, Operand(rax, times_pointer_size, JSStrictArgumentsObject::kSize + 4843 __ leal(rcx, Operand(rax, times_pointer_size, JSStrictArgumentsObject::kSize +
4832 FixedArray::kHeaderSize)); 4844 FixedArray::kHeaderSize));
4833 __ Allocate(rcx, rdx, rdi, no_reg, &allocate, NO_ALLOCATION_FLAGS); 4845 __ Allocate(rcx, rdx, r8, no_reg, &allocate, NO_ALLOCATION_FLAGS);
4834 __ bind(&done_allocate); 4846 __ bind(&done_allocate);
4835 4847
4836 // Compute the arguments.length in rdi. 4848 // Compute the arguments.length in rdi.
4837 __ Integer32ToSmi(rdi, rax); 4849 __ Integer32ToSmi(rdi, rax);
4838 4850
4839 // Setup the elements array in rdx. 4851 // Setup the elements array in rdx.
4840 __ LoadRoot(rcx, Heap::kFixedArrayMapRootIndex); 4852 __ LoadRoot(rcx, Heap::kFixedArrayMapRootIndex);
4841 __ movp(FieldOperand(rdx, FixedArray::kMapOffset), rcx); 4853 __ movp(FieldOperand(rdx, FixedArray::kMapOffset), rcx);
4842 __ movp(FieldOperand(rdx, FixedArray::kLengthOffset), rdi); 4854 __ movp(FieldOperand(rdx, FixedArray::kLengthOffset), rdi);
4843 { 4855 {
(...skipping 17 matching lines...) Expand all
4861 Operand(rdx, rax, times_pointer_size, FixedArray::kHeaderSize)); 4873 Operand(rdx, rax, times_pointer_size, FixedArray::kHeaderSize));
4862 __ LoadNativeContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX, rcx); 4874 __ LoadNativeContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX, rcx);
4863 __ movp(FieldOperand(rax, JSStrictArgumentsObject::kMapOffset), rcx); 4875 __ movp(FieldOperand(rax, JSStrictArgumentsObject::kMapOffset), rcx);
4864 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex); 4876 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex);
4865 __ movp(FieldOperand(rax, JSStrictArgumentsObject::kPropertiesOffset), rcx); 4877 __ movp(FieldOperand(rax, JSStrictArgumentsObject::kPropertiesOffset), rcx);
4866 __ movp(FieldOperand(rax, JSStrictArgumentsObject::kElementsOffset), rdx); 4878 __ movp(FieldOperand(rax, JSStrictArgumentsObject::kElementsOffset), rdx);
4867 __ movp(FieldOperand(rax, JSStrictArgumentsObject::kLengthOffset), rdi); 4879 __ movp(FieldOperand(rax, JSStrictArgumentsObject::kLengthOffset), rdi);
4868 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize); 4880 STATIC_ASSERT(JSStrictArgumentsObject::kSize == 4 * kPointerSize);
4869 __ Ret(); 4881 __ Ret();
4870 4882
4871 // Fall back to %AllocateInNewSpace. 4883 // Fall back to %AllocateInNewSpace (if not too big).
4884 Label too_big_for_new_space;
4872 __ bind(&allocate); 4885 __ bind(&allocate);
4886 __ cmpl(rcx, Immediate(Page::kMaxRegularHeapObjectSize));
4887 __ j(greater, &too_big_for_new_space);
4873 { 4888 {
4874 FrameScope scope(masm, StackFrame::INTERNAL); 4889 FrameScope scope(masm, StackFrame::INTERNAL);
4875 __ Integer32ToSmi(rax, rax); 4890 __ Integer32ToSmi(rax, rax);
4876 __ Integer32ToSmi(rcx, rcx); 4891 __ Integer32ToSmi(rcx, rcx);
4877 __ Push(rax); 4892 __ Push(rax);
4878 __ Push(rbx); 4893 __ Push(rbx);
4879 __ Push(rcx); 4894 __ Push(rcx);
4880 __ CallRuntime(Runtime::kAllocateInNewSpace); 4895 __ CallRuntime(Runtime::kAllocateInNewSpace);
4881 __ movp(rdx, rax); 4896 __ movp(rdx, rax);
4882 __ Pop(rbx); 4897 __ Pop(rbx);
4883 __ Pop(rax); 4898 __ Pop(rax);
4884 __ SmiToInteger32(rax, rax); 4899 __ SmiToInteger32(rax, rax);
4885 } 4900 }
4886 __ jmp(&done_allocate); 4901 __ jmp(&done_allocate);
4902
4903 // Fall back to %NewStrictArguments.
4904 __ bind(&too_big_for_new_space);
4905 __ PopReturnAddressTo(kScratchRegister);
4906 __ Push(rdi);
4907 __ PushReturnAddressFrom(kScratchRegister);
4908 __ TailCallRuntime(Runtime::kNewStrictArguments);
4887 } 4909 }
4888 4910
4889 4911
4890 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { 4912 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) {
4891 Register context_reg = rsi; 4913 Register context_reg = rsi;
4892 Register slot_reg = rbx; 4914 Register slot_reg = rbx;
4893 Register result_reg = rax; 4915 Register result_reg = rax;
4894 Label slow_case; 4916 Label slow_case;
4895 4917
4896 // Go up context chain to the script context. 4918 // Go up context chain to the script context.
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
5425 kStackUnwindSpace, nullptr, return_value_operand, 5447 kStackUnwindSpace, nullptr, return_value_operand,
5426 NULL); 5448 NULL);
5427 } 5449 }
5428 5450
5429 #undef __ 5451 #undef __
5430 5452
5431 } // namespace internal 5453 } // namespace internal
5432 } // namespace v8 5454 } // namespace v8
5433 5455
5434 #endif // V8_TARGET_ARCH_X64 5456 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/mips64/code-stubs-mips64.cc ('k') | test/mjsunit/regress/regress-crbug-614727.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698