OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { | 1039 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { |
1040 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); | 1040 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); |
1041 } | 1041 } |
1042 | 1042 |
1043 | 1043 |
1044 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { | 1044 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { |
1045 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); | 1045 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); |
1046 } | 1046 } |
1047 | 1047 |
1048 | 1048 |
1049 // static | 1049 void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { |
1050 void Builtins::Generate_FunctionCall(MacroAssembler* masm) { | |
1051 // Stack Layout: | |
1052 // rsp[0] : Return address | |
1053 // rsp[8] : Argument n | |
1054 // rsp[16] : Argument n-1 | |
1055 // ... | |
1056 // rsp[8 * n] : Argument 1 | |
1057 // rsp[8 * (n + 1)] : Receiver (callable to call) | |
1058 // | |
1059 // rax contains the number of arguments, n, not counting the receiver. | |
1060 // | |
1061 // 1. Make sure we have at least one argument. | |
1062 { | |
1063 Label done; | |
1064 __ testp(rax, rax); | |
1065 __ j(not_zero, &done, Label::kNear); | |
1066 __ PopReturnAddressTo(rbx); | |
1067 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
1068 __ PushReturnAddressFrom(rbx); | |
1069 __ incp(rax); | |
1070 __ bind(&done); | |
1071 } | |
1072 | |
1073 // 2. Get the callable to call (passed as receiver) from the stack. | |
1074 { | |
1075 StackArgumentsAccessor args(rsp, rax); | |
1076 __ movp(rdi, args.GetReceiverOperand()); | |
1077 } | |
1078 | |
1079 // 3. Shift arguments and return address one slot down on the stack | |
1080 // (overwriting the original receiver). Adjust argument count to make | |
1081 // the original first argument the new receiver. | |
1082 { | |
1083 Label loop; | |
1084 __ movp(rcx, rax); | |
1085 StackArgumentsAccessor args(rsp, rcx); | |
1086 __ bind(&loop); | |
1087 __ movp(rbx, args.GetArgumentOperand(1)); | |
1088 __ movp(args.GetArgumentOperand(0), rbx); | |
1089 __ decp(rcx); | |
1090 __ j(not_zero, &loop); // While non-zero. | |
1091 __ DropUnderReturnAddress(1, rbx); // Drop one slot under return address. | |
1092 __ decp(rax); // One fewer argument (first argument is new receiver). | |
1093 } | |
1094 | |
1095 // 4. Call the callable. | |
1096 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | |
1097 } | |
1098 | |
1099 | |
1100 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | |
1101 // ----------- S t a t e ------------- | 1050 // ----------- S t a t e ------------- |
1102 // -- rax : argc | 1051 // -- rax : argc |
1103 // -- rsp[0] : return address | 1052 // -- rsp[0] : return address |
1104 // -- rsp[8] : argArray | 1053 // -- rsp[8] : argArray |
1105 // -- rsp[16] : thisArg | 1054 // -- rsp[16] : thisArg |
1106 // -- rsp[24] : receiver | 1055 // -- rsp[24] : receiver |
1107 // ----------------------------------- | 1056 // ----------------------------------- |
1108 | 1057 |
1109 // 1. Load receiver into rdi, argArray into rax (if present), remove all | 1058 // 1. Load receiver into rdi, argArray into rax (if present), remove all |
1110 // arguments from the stack (including the receiver), and push thisArg (if | 1059 // arguments from the stack (including the receiver), and push thisArg (if |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 // 4c. The receiver is not callable, throw an appropriate TypeError. | 1118 // 4c. The receiver is not callable, throw an appropriate TypeError. |
1170 __ bind(&receiver_not_callable); | 1119 __ bind(&receiver_not_callable); |
1171 { | 1120 { |
1172 StackArgumentsAccessor args(rsp, 0); | 1121 StackArgumentsAccessor args(rsp, 0); |
1173 __ movp(args.GetReceiverOperand(), rdi); | 1122 __ movp(args.GetReceiverOperand(), rdi); |
1174 __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1, 1); | 1123 __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1, 1); |
1175 } | 1124 } |
1176 } | 1125 } |
1177 | 1126 |
1178 | 1127 |
| 1128 // static |
| 1129 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { |
| 1130 // Stack Layout: |
| 1131 // rsp[0] : Return address |
| 1132 // rsp[8] : Argument n |
| 1133 // rsp[16] : Argument n-1 |
| 1134 // ... |
| 1135 // rsp[8 * n] : Argument 1 |
| 1136 // rsp[8 * (n + 1)] : Receiver (callable to call) |
| 1137 // |
| 1138 // rax contains the number of arguments, n, not counting the receiver. |
| 1139 // |
| 1140 // 1. Make sure we have at least one argument. |
| 1141 { |
| 1142 Label done; |
| 1143 __ testp(rax, rax); |
| 1144 __ j(not_zero, &done, Label::kNear); |
| 1145 __ PopReturnAddressTo(rbx); |
| 1146 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 1147 __ PushReturnAddressFrom(rbx); |
| 1148 __ incp(rax); |
| 1149 __ bind(&done); |
| 1150 } |
| 1151 |
| 1152 // 2. Get the callable to call (passed as receiver) from the stack. |
| 1153 { |
| 1154 StackArgumentsAccessor args(rsp, rax); |
| 1155 __ movp(rdi, args.GetReceiverOperand()); |
| 1156 } |
| 1157 |
| 1158 // 3. Shift arguments and return address one slot down on the stack |
| 1159 // (overwriting the original receiver). Adjust argument count to make |
| 1160 // the original first argument the new receiver. |
| 1161 { |
| 1162 Label loop; |
| 1163 __ movp(rcx, rax); |
| 1164 StackArgumentsAccessor args(rsp, rcx); |
| 1165 __ bind(&loop); |
| 1166 __ movp(rbx, args.GetArgumentOperand(1)); |
| 1167 __ movp(args.GetArgumentOperand(0), rbx); |
| 1168 __ decp(rcx); |
| 1169 __ j(not_zero, &loop); // While non-zero. |
| 1170 __ DropUnderReturnAddress(1, rbx); // Drop one slot under return address. |
| 1171 __ decp(rax); // One fewer argument (first argument is new receiver). |
| 1172 } |
| 1173 |
| 1174 // 4. Call the callable. |
| 1175 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1176 } |
| 1177 |
| 1178 |
1179 void Builtins::Generate_ReflectApply(MacroAssembler* masm) { | 1179 void Builtins::Generate_ReflectApply(MacroAssembler* masm) { |
1180 // ----------- S t a t e ------------- | 1180 // ----------- S t a t e ------------- |
1181 // -- rax : argc | 1181 // -- rax : argc |
1182 // -- rsp[0] : return address | 1182 // -- rsp[0] : return address |
1183 // -- rsp[8] : argumentsList | 1183 // -- rsp[8] : argumentsList |
1184 // -- rsp[16] : thisArgument | 1184 // -- rsp[16] : thisArgument |
1185 // -- rsp[24] : target | 1185 // -- rsp[24] : target |
1186 // -- rsp[32] : receiver | 1186 // -- rsp[32] : receiver |
1187 // ----------------------------------- | 1187 // ----------------------------------- |
1188 | 1188 |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 __ ret(0); | 2296 __ ret(0); |
2297 } | 2297 } |
2298 | 2298 |
2299 | 2299 |
2300 #undef __ | 2300 #undef __ |
2301 | 2301 |
2302 } // namespace internal | 2302 } // namespace internal |
2303 } // namespace v8 | 2303 } // namespace v8 |
2304 | 2304 |
2305 #endif // V8_TARGET_ARCH_X64 | 2305 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |