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

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

Issue 1708313002: [stubs] Introduce a dedicated FastNewObjectStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove TODO. Created 4 years, 10 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
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/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/handler-compiler.h" 10 #include "src/ic/handler-compiler.h"
(...skipping 4811 matching lines...) Expand 10 before | Expand all | Expand 10 after
4822 4822
4823 Label fast_elements_case; 4823 Label fast_elements_case;
4824 __ CompareAndBranch(kind, FAST_ELEMENTS, eq, &fast_elements_case); 4824 __ CompareAndBranch(kind, FAST_ELEMENTS, eq, &fast_elements_case);
4825 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 4825 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
4826 4826
4827 __ Bind(&fast_elements_case); 4827 __ Bind(&fast_elements_case);
4828 GenerateCase(masm, FAST_ELEMENTS); 4828 GenerateCase(masm, FAST_ELEMENTS);
4829 } 4829 }
4830 4830
4831 4831
4832 void FastNewObjectStub::Generate(MacroAssembler* masm) {
4833 // ----------- S t a t e -------------
4834 // -- x1 : target
4835 // -- x3 : new target
4836 // -- cp : context
4837 // -- lr : return address
4838 // -----------------------------------
4839 __ AssertFunction(x1);
4840 __ AssertReceiver(x3);
4841
4842 // Verify that the new target is a JSFunction.
4843 Label new_object;
4844 __ JumpIfNotObjectType(x3, x2, x2, JS_FUNCTION_TYPE, &new_object);
4845
4846 // Load the initial map and verify that it's in fact a map.
4847 __ Ldr(x2, FieldMemOperand(x3, JSFunction::kPrototypeOrInitialMapOffset));
4848 __ JumpIfSmi(x2, &new_object);
4849 __ JumpIfNotObjectType(x2, x0, x0, MAP_TYPE, &new_object);
4850
4851 // Fall back to runtime if the target differs from the new target's
4852 // initial map constructor.
4853 __ Ldr(x0, FieldMemOperand(x2, Map::kConstructorOrBackPointerOffset));
4854 __ CompareAndBranch(x0, x1, ne, &new_object);
4855
4856 // Allocate the JSObject on the heap.
4857 Label allocate, done_allocate;
4858 __ Ldrb(x4, FieldMemOperand(x2, Map::kInstanceSizeOffset));
4859 __ Allocate(x4, x0, x5, x6, &allocate, SIZE_IN_WORDS);
4860 __ Bind(&done_allocate);
4861
4862 // Initialize the JSObject fields.
4863 __ Mov(x1, x0);
4864 STATIC_ASSERT(JSObject::kMapOffset == 0 * kPointerSize);
4865 __ Str(x2, MemOperand(x1, kPointerSize, PostIndex));
4866 __ LoadRoot(x3, Heap::kEmptyFixedArrayRootIndex);
4867 STATIC_ASSERT(JSObject::kPropertiesOffset == 1 * kPointerSize);
4868 STATIC_ASSERT(JSObject::kElementsOffset == 2 * kPointerSize);
4869 __ Stp(x3, x3, MemOperand(x1, 2 * kPointerSize, PostIndex));
4870 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize);
4871
4872 // ----------- S t a t e -------------
4873 // -- x0 : result (untagged)
4874 // -- x1 : result fields (untagged)
4875 // -- x5 : result end (untagged)
4876 // -- x2 : initial map
4877 // -- cp : context
4878 // -- lr : return address
4879 // -----------------------------------
4880
4881 // Perform in-object slack tracking if requested.
4882 Label slack_tracking;
4883 STATIC_ASSERT(Map::kNoSlackTracking == 0);
4884 __ LoadRoot(x6, Heap::kUndefinedValueRootIndex);
4885 __ Ldr(w3, FieldMemOperand(x2, Map::kBitField3Offset));
4886 __ TestAndBranchIfAnySet(w3, Map::ConstructionCounter::kMask,
4887 &slack_tracking);
4888 {
4889 // Initialize all in-object fields with undefined.
4890 __ InitializeFieldsWithFiller(x1, x5, x6);
4891
4892 // Add the object tag to make the JSObject real.
4893 STATIC_ASSERT(kHeapObjectTag == 1);
4894 __ Add(x0, x0, kHeapObjectTag);
4895 __ Ret();
4896 }
4897 __ Bind(&slack_tracking);
4898 {
4899 // Decrease generous allocation count.
4900 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32);
4901 __ Sub(w3, w3, 1 << Map::ConstructionCounter::kShift);
4902 __ Str(w3, FieldMemOperand(x2, Map::kBitField3Offset));
4903
4904 // Initialize the in-object fields with undefined.
4905 __ Ldrb(x4, FieldMemOperand(x2, Map::kUnusedPropertyFieldsOffset));
4906 __ Sub(x4, x5, Operand(x4, LSL, kPointerSizeLog2));
4907 __ InitializeFieldsWithFiller(x1, x4, x6);
4908
4909 // Initialize the remaining (reserved) fields with one pointer filler map.
4910 __ LoadRoot(x6, Heap::kOnePointerFillerMapRootIndex);
4911 __ InitializeFieldsWithFiller(x1, x5, x6);
4912
4913 // Add the object tag to make the JSObject real.
4914 STATIC_ASSERT(kHeapObjectTag == 1);
4915 __ Add(x0, x0, kHeapObjectTag);
4916
4917 // Check if we can finalize the instance size.
4918 Label finalize;
4919 STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1);
4920 __ TestAndBranchIfAllClear(w3, Map::ConstructionCounter::kMask, &finalize);
4921 __ Ret();
4922
4923 // Finalize the instance size.
4924 __ Bind(&finalize);
4925 {
4926 FrameScope scope(masm, StackFrame::INTERNAL);
4927 __ Push(x0, x2);
4928 __ CallRuntime(Runtime::kFinalizeInstanceSize);
4929 __ Pop(x0);
4930 }
4931 __ Ret();
4932 }
4933
4934 // Fall back to %AllocateInNewSpace.
4935 __ Bind(&allocate);
4936 {
4937 FrameScope scope(masm, StackFrame::INTERNAL);
4938 STATIC_ASSERT(kSmiTag == 0);
4939 STATIC_ASSERT(kSmiTagSize == 1);
4940 __ Mov(x4,
4941 Operand(x4, LSL, kPointerSizeLog2 + kSmiTagSize + kSmiShiftSize));
4942 __ Push(x2, x4);
4943 __ CallRuntime(Runtime::kAllocateInNewSpace);
4944 __ Pop(x2);
4945 }
4946 STATIC_ASSERT(kHeapObjectTag == 1);
4947 __ Sub(x0, x0, kHeapObjectTag);
4948 __ Ldrb(x5, FieldMemOperand(x2, Map::kInstanceSizeOffset));
4949 __ Add(x5, x0, Operand(x5, LSL, kPointerSizeLog2));
4950 __ B(&done_allocate);
4951
4952 // Fall back to %NewObject.
4953 __ Bind(&new_object);
4954 __ Push(x1, x3);
4955 __ TailCallRuntime(Runtime::kNewObject);
4956 }
4957
4958
4832 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { 4959 void FastNewRestParameterStub::Generate(MacroAssembler* masm) {
4833 // ----------- S t a t e ------------- 4960 // ----------- S t a t e -------------
4834 // -- x1 : function 4961 // -- x1 : function
4835 // -- cp : context 4962 // -- cp : context
4836 // -- fp : frame pointer 4963 // -- fp : frame pointer
4837 // -- lr : return address 4964 // -- lr : return address
4838 // ----------------------------------- 4965 // -----------------------------------
4839 __ AssertFunction(x1); 4966 __ AssertFunction(x1);
4840 4967
4841 // For Ignition we need to skip all possible handler/stub frames until 4968 // For Ignition we need to skip all possible handler/stub frames until
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
5868 return_value_operand, NULL); 5995 return_value_operand, NULL);
5869 } 5996 }
5870 5997
5871 5998
5872 #undef __ 5999 #undef __
5873 6000
5874 } // namespace internal 6001 } // namespace internal
5875 } // namespace v8 6002 } // namespace v8
5876 6003
5877 #endif // V8_TARGET_ARCH_ARM64 6004 #endif // V8_TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698