OLD | NEW |
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 4806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4817 __ Ldr(x0, FieldMemOperand(x2, Map::kConstructorOrBackPointerOffset)); | 4817 __ Ldr(x0, FieldMemOperand(x2, Map::kConstructorOrBackPointerOffset)); |
4818 __ CompareAndBranch(x0, x1, ne, &new_object); | 4818 __ CompareAndBranch(x0, x1, ne, &new_object); |
4819 | 4819 |
4820 // Allocate the JSObject on the heap. | 4820 // Allocate the JSObject on the heap. |
4821 Label allocate, done_allocate; | 4821 Label allocate, done_allocate; |
4822 __ Ldrb(x4, FieldMemOperand(x2, Map::kInstanceSizeOffset)); | 4822 __ Ldrb(x4, FieldMemOperand(x2, Map::kInstanceSizeOffset)); |
4823 __ Allocate(x4, x0, x5, x6, &allocate, SIZE_IN_WORDS); | 4823 __ Allocate(x4, x0, x5, x6, &allocate, SIZE_IN_WORDS); |
4824 __ Bind(&done_allocate); | 4824 __ Bind(&done_allocate); |
4825 | 4825 |
4826 // Initialize the JSObject fields. | 4826 // Initialize the JSObject fields. |
4827 __ Mov(x1, x0); | |
4828 STATIC_ASSERT(JSObject::kMapOffset == 0 * kPointerSize); | 4827 STATIC_ASSERT(JSObject::kMapOffset == 0 * kPointerSize); |
4829 __ Str(x2, MemOperand(x1, kPointerSize, PostIndex)); | 4828 __ Str(x2, FieldMemOperand(x0, JSObject::kMapOffset)); |
4830 __ LoadRoot(x3, Heap::kEmptyFixedArrayRootIndex); | 4829 __ LoadRoot(x3, Heap::kEmptyFixedArrayRootIndex); |
4831 STATIC_ASSERT(JSObject::kPropertiesOffset == 1 * kPointerSize); | 4830 STATIC_ASSERT(JSObject::kPropertiesOffset == 1 * kPointerSize); |
4832 STATIC_ASSERT(JSObject::kElementsOffset == 2 * kPointerSize); | 4831 STATIC_ASSERT(JSObject::kElementsOffset == 2 * kPointerSize); |
4833 __ Stp(x3, x3, MemOperand(x1, 2 * kPointerSize, PostIndex)); | 4832 __ Str(x3, FieldMemOperand(x0, JSObject::kPropertiesOffset)); |
| 4833 __ Str(x3, FieldMemOperand(x0, JSObject::kElementsOffset)); |
4834 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); | 4834 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); |
| 4835 __ Add(x1, x0, Operand(JSObject::kHeaderSize - kHeapObjectTag)); |
4835 | 4836 |
4836 // ----------- S t a t e ------------- | 4837 // ----------- S t a t e ------------- |
4837 // -- x0 : result (untagged) | 4838 // -- x0 : result (tagged) |
4838 // -- x1 : result fields (untagged) | 4839 // -- x1 : result fields (untagged) |
4839 // -- x5 : result end (untagged) | 4840 // -- x5 : result end (untagged) |
4840 // -- x2 : initial map | 4841 // -- x2 : initial map |
4841 // -- cp : context | 4842 // -- cp : context |
4842 // -- lr : return address | 4843 // -- lr : return address |
4843 // ----------------------------------- | 4844 // ----------------------------------- |
4844 | 4845 |
4845 // Perform in-object slack tracking if requested. | 4846 // Perform in-object slack tracking if requested. |
4846 Label slack_tracking; | 4847 Label slack_tracking; |
4847 STATIC_ASSERT(Map::kNoSlackTracking == 0); | 4848 STATIC_ASSERT(Map::kNoSlackTracking == 0); |
4848 __ LoadRoot(x6, Heap::kUndefinedValueRootIndex); | 4849 __ LoadRoot(x6, Heap::kUndefinedValueRootIndex); |
4849 __ Ldr(w3, FieldMemOperand(x2, Map::kBitField3Offset)); | 4850 __ Ldr(w3, FieldMemOperand(x2, Map::kBitField3Offset)); |
4850 __ TestAndBranchIfAnySet(w3, Map::ConstructionCounter::kMask, | 4851 __ TestAndBranchIfAnySet(w3, Map::ConstructionCounter::kMask, |
4851 &slack_tracking); | 4852 &slack_tracking); |
4852 { | 4853 { |
4853 // Initialize all in-object fields with undefined. | 4854 // Initialize all in-object fields with undefined. |
4854 __ InitializeFieldsWithFiller(x1, x5, x6); | 4855 __ InitializeFieldsWithFiller(x1, x5, x6); |
4855 | |
4856 // Add the object tag to make the JSObject real. | |
4857 STATIC_ASSERT(kHeapObjectTag == 1); | |
4858 __ Add(x0, x0, kHeapObjectTag); | |
4859 __ Ret(); | 4856 __ Ret(); |
4860 } | 4857 } |
4861 __ Bind(&slack_tracking); | 4858 __ Bind(&slack_tracking); |
4862 { | 4859 { |
4863 // Decrease generous allocation count. | 4860 // Decrease generous allocation count. |
4864 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); | 4861 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); |
4865 __ Sub(w3, w3, 1 << Map::ConstructionCounter::kShift); | 4862 __ Sub(w3, w3, 1 << Map::ConstructionCounter::kShift); |
4866 __ Str(w3, FieldMemOperand(x2, Map::kBitField3Offset)); | 4863 __ Str(w3, FieldMemOperand(x2, Map::kBitField3Offset)); |
4867 | 4864 |
4868 // Initialize the in-object fields with undefined. | 4865 // Initialize the in-object fields with undefined. |
4869 __ Ldrb(x4, FieldMemOperand(x2, Map::kUnusedPropertyFieldsOffset)); | 4866 __ Ldrb(x4, FieldMemOperand(x2, Map::kUnusedPropertyFieldsOffset)); |
4870 __ Sub(x4, x5, Operand(x4, LSL, kPointerSizeLog2)); | 4867 __ Sub(x4, x5, Operand(x4, LSL, kPointerSizeLog2)); |
4871 __ InitializeFieldsWithFiller(x1, x4, x6); | 4868 __ InitializeFieldsWithFiller(x1, x4, x6); |
4872 | 4869 |
4873 // Initialize the remaining (reserved) fields with one pointer filler map. | 4870 // Initialize the remaining (reserved) fields with one pointer filler map. |
4874 __ LoadRoot(x6, Heap::kOnePointerFillerMapRootIndex); | 4871 __ LoadRoot(x6, Heap::kOnePointerFillerMapRootIndex); |
4875 __ InitializeFieldsWithFiller(x1, x5, x6); | 4872 __ InitializeFieldsWithFiller(x1, x5, x6); |
4876 | 4873 |
4877 // Add the object tag to make the JSObject real. | |
4878 STATIC_ASSERT(kHeapObjectTag == 1); | |
4879 __ Add(x0, x0, kHeapObjectTag); | |
4880 | |
4881 // Check if we can finalize the instance size. | 4874 // Check if we can finalize the instance size. |
4882 Label finalize; | 4875 Label finalize; |
4883 STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1); | 4876 STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1); |
4884 __ TestAndBranchIfAllClear(w3, Map::ConstructionCounter::kMask, &finalize); | 4877 __ TestAndBranchIfAllClear(w3, Map::ConstructionCounter::kMask, &finalize); |
4885 __ Ret(); | 4878 __ Ret(); |
4886 | 4879 |
4887 // Finalize the instance size. | 4880 // Finalize the instance size. |
4888 __ Bind(&finalize); | 4881 __ Bind(&finalize); |
4889 { | 4882 { |
4890 FrameScope scope(masm, StackFrame::INTERNAL); | 4883 FrameScope scope(masm, StackFrame::INTERNAL); |
4891 __ Push(x0, x2); | 4884 __ Push(x0, x2); |
4892 __ CallRuntime(Runtime::kFinalizeInstanceSize); | 4885 __ CallRuntime(Runtime::kFinalizeInstanceSize); |
4893 __ Pop(x0); | 4886 __ Pop(x0); |
4894 } | 4887 } |
4895 __ Ret(); | 4888 __ Ret(); |
4896 } | 4889 } |
4897 | 4890 |
4898 // Fall back to %AllocateInNewSpace. | 4891 // Fall back to %AllocateInNewSpace. |
4899 __ Bind(&allocate); | 4892 __ Bind(&allocate); |
4900 { | 4893 { |
4901 FrameScope scope(masm, StackFrame::INTERNAL); | 4894 FrameScope scope(masm, StackFrame::INTERNAL); |
4902 STATIC_ASSERT(kSmiTag == 0); | 4895 STATIC_ASSERT(kSmiTag == 0); |
4903 STATIC_ASSERT(kSmiTagSize == 1); | 4896 STATIC_ASSERT(kSmiTagSize == 1); |
4904 __ Mov(x4, | 4897 __ Mov(x4, |
4905 Operand(x4, LSL, kPointerSizeLog2 + kSmiTagSize + kSmiShiftSize)); | 4898 Operand(x4, LSL, kPointerSizeLog2 + kSmiTagSize + kSmiShiftSize)); |
4906 __ Push(x2, x4); | 4899 __ Push(x2, x4); |
4907 __ CallRuntime(Runtime::kAllocateInNewSpace); | 4900 __ CallRuntime(Runtime::kAllocateInNewSpace); |
4908 __ Pop(x2); | 4901 __ Pop(x2); |
4909 } | 4902 } |
4910 STATIC_ASSERT(kHeapObjectTag == 1); | |
4911 __ Sub(x0, x0, kHeapObjectTag); | |
4912 __ Ldrb(x5, FieldMemOperand(x2, Map::kInstanceSizeOffset)); | 4903 __ Ldrb(x5, FieldMemOperand(x2, Map::kInstanceSizeOffset)); |
4913 __ Add(x5, x0, Operand(x5, LSL, kPointerSizeLog2)); | 4904 __ Add(x5, x0, Operand(x5, LSL, kPointerSizeLog2)); |
| 4905 STATIC_ASSERT(kHeapObjectTag == 1); |
| 4906 __ Sub(x5, x5, kHeapObjectTag); // Subtract the tag from end. |
4914 __ B(&done_allocate); | 4907 __ B(&done_allocate); |
4915 | 4908 |
4916 // Fall back to %NewObject. | 4909 // Fall back to %NewObject. |
4917 __ Bind(&new_object); | 4910 __ Bind(&new_object); |
4918 __ Push(x1, x3); | 4911 __ Push(x1, x3); |
4919 __ TailCallRuntime(Runtime::kNewObject); | 4912 __ TailCallRuntime(Runtime::kNewObject); |
4920 } | 4913 } |
4921 | 4914 |
4922 | 4915 |
4923 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { | 4916 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4967 // Return an empty rest parameter array. | 4960 // Return an empty rest parameter array. |
4968 __ Bind(&no_rest_parameters); | 4961 __ Bind(&no_rest_parameters); |
4969 { | 4962 { |
4970 // ----------- S t a t e ------------- | 4963 // ----------- S t a t e ------------- |
4971 // -- cp : context | 4964 // -- cp : context |
4972 // -- lr : return address | 4965 // -- lr : return address |
4973 // ----------------------------------- | 4966 // ----------------------------------- |
4974 | 4967 |
4975 // Allocate an empty rest parameter array. | 4968 // Allocate an empty rest parameter array. |
4976 Label allocate, done_allocate; | 4969 Label allocate, done_allocate; |
4977 __ Allocate(JSArray::kSize, x0, x1, x2, &allocate, TAG_OBJECT); | 4970 __ Allocate(JSArray::kSize, x0, x1, x2, &allocate, NO_ALLOCATION_FLAGS); |
4978 __ Bind(&done_allocate); | 4971 __ Bind(&done_allocate); |
4979 | 4972 |
4980 // Setup the rest parameter array in x0. | 4973 // Setup the rest parameter array in x0. |
4981 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, x1); | 4974 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, x1); |
4982 __ Str(x1, FieldMemOperand(x0, JSArray::kMapOffset)); | 4975 __ Str(x1, FieldMemOperand(x0, JSArray::kMapOffset)); |
4983 __ LoadRoot(x1, Heap::kEmptyFixedArrayRootIndex); | 4976 __ LoadRoot(x1, Heap::kEmptyFixedArrayRootIndex); |
4984 __ Str(x1, FieldMemOperand(x0, JSArray::kPropertiesOffset)); | 4977 __ Str(x1, FieldMemOperand(x0, JSArray::kPropertiesOffset)); |
4985 __ Str(x1, FieldMemOperand(x0, JSArray::kElementsOffset)); | 4978 __ Str(x1, FieldMemOperand(x0, JSArray::kElementsOffset)); |
4986 __ Mov(x1, Smi::FromInt(0)); | 4979 __ Mov(x1, Smi::FromInt(0)); |
4987 __ Str(x1, FieldMemOperand(x0, JSArray::kLengthOffset)); | 4980 __ Str(x1, FieldMemOperand(x0, JSArray::kLengthOffset)); |
(...skipping 20 matching lines...) Expand all Loading... |
5008 // -- cp : context | 5001 // -- cp : context |
5009 // -- x0 : number of rest parameters | 5002 // -- x0 : number of rest parameters |
5010 // -- x2 : pointer to first rest parameters | 5003 // -- x2 : pointer to first rest parameters |
5011 // -- lr : return address | 5004 // -- lr : return address |
5012 // ----------------------------------- | 5005 // ----------------------------------- |
5013 | 5006 |
5014 // Allocate space for the rest parameter array plus the backing store. | 5007 // Allocate space for the rest parameter array plus the backing store. |
5015 Label allocate, done_allocate; | 5008 Label allocate, done_allocate; |
5016 __ Mov(x1, JSArray::kSize + FixedArray::kHeaderSize); | 5009 __ Mov(x1, JSArray::kSize + FixedArray::kHeaderSize); |
5017 __ Add(x1, x1, Operand(x0, LSL, kPointerSizeLog2)); | 5010 __ Add(x1, x1, Operand(x0, LSL, kPointerSizeLog2)); |
5018 __ Allocate(x1, x3, x4, x5, &allocate, TAG_OBJECT); | 5011 __ Allocate(x1, x3, x4, x5, &allocate, NO_ALLOCATION_FLAGS); |
5019 __ Bind(&done_allocate); | 5012 __ Bind(&done_allocate); |
5020 | 5013 |
5021 // Compute arguments.length in x6. | 5014 // Compute arguments.length in x6. |
5022 __ SmiTag(x6, x0); | 5015 __ SmiTag(x6, x0); |
5023 | 5016 |
5024 // Setup the elements array in x3. | 5017 // Setup the elements array in x3. |
5025 __ LoadRoot(x1, Heap::kFixedArrayMapRootIndex); | 5018 __ LoadRoot(x1, Heap::kFixedArrayMapRootIndex); |
5026 __ Str(x1, FieldMemOperand(x3, FixedArray::kMapOffset)); | 5019 __ Str(x1, FieldMemOperand(x3, FixedArray::kMapOffset)); |
5027 __ Str(x6, FieldMemOperand(x3, FixedArray::kLengthOffset)); | 5020 __ Str(x6, FieldMemOperand(x3, FixedArray::kLengthOffset)); |
5028 __ Add(x4, x3, FixedArray::kHeaderSize); | 5021 __ Add(x4, x3, FixedArray::kHeaderSize); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5185 __ Cmp(mapped_params, 0); | 5178 __ Cmp(mapped_params, 0); |
5186 __ CzeroX(size, eq); | 5179 __ CzeroX(size, eq); |
5187 | 5180 |
5188 // 2. Add the size of the backing store and arguments object. | 5181 // 2. Add the size of the backing store and arguments object. |
5189 __ Add(size, size, Operand(arg_count, LSL, kPointerSizeLog2)); | 5182 __ Add(size, size, Operand(arg_count, LSL, kPointerSizeLog2)); |
5190 __ Add(size, size, FixedArray::kHeaderSize + JSSloppyArgumentsObject::kSize); | 5183 __ Add(size, size, FixedArray::kHeaderSize + JSSloppyArgumentsObject::kSize); |
5191 | 5184 |
5192 // Do the allocation of all three objects in one go. Assign this to x0, as it | 5185 // Do the allocation of all three objects in one go. Assign this to x0, as it |
5193 // will be returned to the caller. | 5186 // will be returned to the caller. |
5194 Register alloc_obj = x0; | 5187 Register alloc_obj = x0; |
5195 __ Allocate(size, alloc_obj, x11, x12, &runtime, TAG_OBJECT); | 5188 __ Allocate(size, alloc_obj, x11, x12, &runtime, NO_ALLOCATION_FLAGS); |
5196 | 5189 |
5197 // Get the arguments boilerplate from the current (global) context. | 5190 // Get the arguments boilerplate from the current (global) context. |
5198 | 5191 |
5199 // x0 alloc_obj pointer to allocated objects (param map, backing | 5192 // x0 alloc_obj pointer to allocated objects (param map, backing |
5200 // store, arguments) | 5193 // store, arguments) |
5201 // x1 function function pointer | 5194 // x1 function function pointer |
5202 // x2 arg_count_smi number of function arguments (smi) | 5195 // x2 arg_count_smi number of function arguments (smi) |
5203 // x3 recv_arg pointer to receiver arguments | 5196 // x3 recv_arg pointer to receiver arguments |
5204 // x4 mapped_params number of mapped parameters, min(params, args) | 5197 // x4 mapped_params number of mapped parameters, min(params, args) |
5205 // x7 param_count number of function parameters | 5198 // x7 param_count number of function parameters |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5419 // -- cp : context | 5412 // -- cp : context |
5420 // -- x0 : number of rest parameters | 5413 // -- x0 : number of rest parameters |
5421 // -- x2 : pointer to first rest parameters | 5414 // -- x2 : pointer to first rest parameters |
5422 // -- lr : return address | 5415 // -- lr : return address |
5423 // ----------------------------------- | 5416 // ----------------------------------- |
5424 | 5417 |
5425 // Allocate space for the strict arguments object plus the backing store. | 5418 // Allocate space for the strict arguments object plus the backing store. |
5426 Label allocate, done_allocate; | 5419 Label allocate, done_allocate; |
5427 __ Mov(x1, JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize); | 5420 __ Mov(x1, JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize); |
5428 __ Add(x1, x1, Operand(x0, LSL, kPointerSizeLog2)); | 5421 __ Add(x1, x1, Operand(x0, LSL, kPointerSizeLog2)); |
5429 __ Allocate(x1, x3, x4, x5, &allocate, TAG_OBJECT); | 5422 __ Allocate(x1, x3, x4, x5, &allocate, NO_ALLOCATION_FLAGS); |
5430 __ Bind(&done_allocate); | 5423 __ Bind(&done_allocate); |
5431 | 5424 |
5432 // Compute arguments.length in x6. | 5425 // Compute arguments.length in x6. |
5433 __ SmiTag(x6, x0); | 5426 __ SmiTag(x6, x0); |
5434 | 5427 |
5435 // Setup the elements array in x3. | 5428 // Setup the elements array in x3. |
5436 __ LoadRoot(x1, Heap::kFixedArrayMapRootIndex); | 5429 __ LoadRoot(x1, Heap::kFixedArrayMapRootIndex); |
5437 __ Str(x1, FieldMemOperand(x3, FixedArray::kMapOffset)); | 5430 __ Str(x1, FieldMemOperand(x3, FixedArray::kMapOffset)); |
5438 __ Str(x6, FieldMemOperand(x3, FixedArray::kLengthOffset)); | 5431 __ Str(x6, FieldMemOperand(x3, FixedArray::kLengthOffset)); |
5439 __ Add(x4, x3, FixedArray::kHeaderSize); | 5432 __ Add(x4, x3, FixedArray::kHeaderSize); |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5962 kStackUnwindSpace, NULL, spill_offset, | 5955 kStackUnwindSpace, NULL, spill_offset, |
5963 return_value_operand, NULL); | 5956 return_value_operand, NULL); |
5964 } | 5957 } |
5965 | 5958 |
5966 #undef __ | 5959 #undef __ |
5967 | 5960 |
5968 } // namespace internal | 5961 } // namespace internal |
5969 } // namespace v8 | 5962 } // namespace v8 |
5970 | 5963 |
5971 #endif // V8_TARGET_ARCH_ARM64 | 5964 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |