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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 __ leap(r8, Operand(r8, rcx, times_pointer_size, FixedArray::kHeaderSize)); | 915 __ leap(r8, Operand(r8, rcx, times_pointer_size, FixedArray::kHeaderSize)); |
916 | 916 |
917 // 3. Arguments object. | 917 // 3. Arguments object. |
918 __ addp(r8, Immediate(Heap::kSloppyArgumentsObjectSize)); | 918 __ addp(r8, Immediate(Heap::kSloppyArgumentsObjectSize)); |
919 | 919 |
920 // Do the allocation of all three objects in one go. | 920 // Do the allocation of all three objects in one go. |
921 __ Allocate(r8, rax, rdx, rdi, &runtime, TAG_OBJECT); | 921 __ Allocate(r8, rax, rdx, rdi, &runtime, TAG_OBJECT); |
922 | 922 |
923 // rax = address of new object(s) (tagged) | 923 // rax = address of new object(s) (tagged) |
924 // rcx = argument count (untagged) | 924 // rcx = argument count (untagged) |
925 // Get the arguments map from the current native context into rdi. | 925 // Get the arguments boilerplate from the current native context into rdi. |
926 Label has_mapped_parameters, instantiate; | 926 Label has_mapped_parameters, copy; |
927 __ movp(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 927 __ movp(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
928 __ movp(rdi, FieldOperand(rdi, GlobalObject::kNativeContextOffset)); | 928 __ movp(rdi, FieldOperand(rdi, GlobalObject::kNativeContextOffset)); |
929 __ testp(rbx, rbx); | 929 __ testp(rbx, rbx); |
930 __ j(not_zero, &has_mapped_parameters, Label::kNear); | 930 __ j(not_zero, &has_mapped_parameters, Label::kNear); |
931 | 931 |
932 const int kIndex = Context::SLOPPY_ARGUMENTS_MAP_INDEX; | 932 const int kIndex = Context::SLOPPY_ARGUMENTS_BOILERPLATE_INDEX; |
933 __ movp(rdi, Operand(rdi, Context::SlotOffset(kIndex))); | 933 __ movp(rdi, Operand(rdi, Context::SlotOffset(kIndex))); |
934 __ jmp(&instantiate, Label::kNear); | 934 __ jmp(©, Label::kNear); |
935 | 935 |
936 const int kAliasedIndex = Context::ALIASED_ARGUMENTS_MAP_INDEX; | 936 const int kAliasedIndex = Context::ALIASED_ARGUMENTS_BOILERPLATE_INDEX; |
937 __ bind(&has_mapped_parameters); | 937 __ bind(&has_mapped_parameters); |
938 __ movp(rdi, Operand(rdi, Context::SlotOffset(kAliasedIndex))); | 938 __ movp(rdi, Operand(rdi, Context::SlotOffset(kAliasedIndex))); |
939 __ bind(&instantiate); | 939 __ bind(©); |
940 | 940 |
941 // rax = address of new object (tagged) | 941 // rax = address of new object (tagged) |
942 // rbx = mapped parameter count (untagged) | 942 // rbx = mapped parameter count (untagged) |
943 // rcx = argument count (untagged) | 943 // rcx = argument count (untagged) |
944 // rdi = address of arguments map (tagged) | 944 // rdi = address of boilerplate object (tagged) |
945 __ movp(FieldOperand(rax, JSObject::kMapOffset), rdi); | 945 // Copy the JS object part. |
946 __ LoadRoot(kScratchRegister, Heap::kEmptyFixedArrayRootIndex); | 946 for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) { |
947 __ movp(FieldOperand(rax, JSObject::kPropertiesOffset), kScratchRegister); | 947 __ movp(rdx, FieldOperand(rdi, i)); |
948 __ movp(FieldOperand(rax, JSObject::kElementsOffset), kScratchRegister); | 948 __ movp(FieldOperand(rax, i), rdx); |
| 949 } |
949 | 950 |
950 // Set up the callee in-object property. | 951 // Set up the callee in-object property. |
951 STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1); | 952 STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1); |
952 __ movp(rdx, args.GetArgumentOperand(0)); | 953 __ movp(rdx, args.GetArgumentOperand(0)); |
953 __ AssertNotSmi(rdx); | |
954 __ movp(FieldOperand(rax, JSObject::kHeaderSize + | 954 __ movp(FieldOperand(rax, JSObject::kHeaderSize + |
955 Heap::kArgumentsCalleeIndex * kPointerSize), | 955 Heap::kArgumentsCalleeIndex * kPointerSize), |
956 rdx); | 956 rdx); |
957 | 957 |
958 // Use the length (smi tagged) and set that as an in-object property too. | 958 // Use the length (smi tagged) and set that as an in-object property too. |
959 // Note: rcx is tagged from here on. | 959 // Note: rcx is tagged from here on. |
960 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); | 960 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); |
961 __ Integer32ToSmi(rcx, rcx); | 961 __ Integer32ToSmi(rcx, rcx); |
962 __ movp(FieldOperand(rax, JSObject::kHeaderSize + | 962 __ movp(FieldOperand(rax, JSObject::kHeaderSize + |
963 Heap::kArgumentsLengthIndex * kPointerSize), | 963 Heap::kArgumentsLengthIndex * kPointerSize), |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 __ bind(&try_allocate); | 1133 __ bind(&try_allocate); |
1134 __ testp(rcx, rcx); | 1134 __ testp(rcx, rcx); |
1135 __ j(zero, &add_arguments_object, Label::kNear); | 1135 __ j(zero, &add_arguments_object, Label::kNear); |
1136 __ leap(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); | 1136 __ leap(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); |
1137 __ bind(&add_arguments_object); | 1137 __ bind(&add_arguments_object); |
1138 __ addp(rcx, Immediate(Heap::kStrictArgumentsObjectSize)); | 1138 __ addp(rcx, Immediate(Heap::kStrictArgumentsObjectSize)); |
1139 | 1139 |
1140 // Do the allocation of both objects in one go. | 1140 // Do the allocation of both objects in one go. |
1141 __ Allocate(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); | 1141 __ Allocate(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); |
1142 | 1142 |
1143 // Get the arguments map from the current native context. | 1143 // Get the arguments boilerplate from the current native context. |
1144 __ movp(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 1144 __ movp(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
1145 __ movp(rdi, FieldOperand(rdi, GlobalObject::kNativeContextOffset)); | 1145 __ movp(rdi, FieldOperand(rdi, GlobalObject::kNativeContextOffset)); |
1146 const int offset = Context::SlotOffset(Context::STRICT_ARGUMENTS_MAP_INDEX); | 1146 const int offset = |
| 1147 Context::SlotOffset(Context::STRICT_ARGUMENTS_BOILERPLATE_INDEX); |
1147 __ movp(rdi, Operand(rdi, offset)); | 1148 __ movp(rdi, Operand(rdi, offset)); |
1148 | 1149 |
1149 __ movp(FieldOperand(rax, JSObject::kMapOffset), rdi); | 1150 // Copy the JS object part. |
1150 __ LoadRoot(kScratchRegister, Heap::kEmptyFixedArrayRootIndex); | 1151 for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) { |
1151 __ movp(FieldOperand(rax, JSObject::kPropertiesOffset), kScratchRegister); | 1152 __ movp(rbx, FieldOperand(rdi, i)); |
1152 __ movp(FieldOperand(rax, JSObject::kElementsOffset), kScratchRegister); | 1153 __ movp(FieldOperand(rax, i), rbx); |
| 1154 } |
1153 | 1155 |
1154 // Get the length (smi tagged) and set that as an in-object property too. | 1156 // Get the length (smi tagged) and set that as an in-object property too. |
1155 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); | 1157 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); |
1156 __ movp(rcx, args.GetArgumentOperand(2)); | 1158 __ movp(rcx, args.GetArgumentOperand(2)); |
1157 __ movp(FieldOperand(rax, JSObject::kHeaderSize + | 1159 __ movp(FieldOperand(rax, JSObject::kHeaderSize + |
1158 Heap::kArgumentsLengthIndex * kPointerSize), | 1160 Heap::kArgumentsLengthIndex * kPointerSize), |
1159 rcx); | 1161 rcx); |
1160 | 1162 |
1161 // If there are no actual arguments, we're done. | 1163 // If there are no actual arguments, we're done. |
1162 Label done; | 1164 Label done; |
(...skipping 3776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4939 return_value_operand, | 4941 return_value_operand, |
4940 NULL); | 4942 NULL); |
4941 } | 4943 } |
4942 | 4944 |
4943 | 4945 |
4944 #undef __ | 4946 #undef __ |
4945 | 4947 |
4946 } } // namespace v8::internal | 4948 } } // namespace v8::internal |
4947 | 4949 |
4948 #endif // V8_TARGET_ARCH_X64 | 4950 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |