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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 __ j(not_equal, | 1158 __ j(not_equal, |
1159 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1159 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
1160 RelocInfo::CODE_TARGET); | 1160 RelocInfo::CODE_TARGET); |
1161 | 1161 |
1162 ParameterCount expected(0); | 1162 ParameterCount expected(0); |
1163 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION, NullCallWrapper()); | 1163 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION, NullCallWrapper()); |
1164 } | 1164 } |
1165 | 1165 |
1166 | 1166 |
1167 static void Generate_PushAppliedArguments(MacroAssembler* masm, | 1167 static void Generate_PushAppliedArguments(MacroAssembler* masm, |
| 1168 const int vectorOffset, |
1168 const int argumentsOffset, | 1169 const int argumentsOffset, |
1169 const int indexOffset, | 1170 const int indexOffset, |
1170 const int limitOffset) { | 1171 const int limitOffset) { |
1171 Register receiver = LoadDescriptor::ReceiverRegister(); | 1172 Register receiver = LoadDescriptor::ReceiverRegister(); |
1172 Register key = LoadDescriptor::NameRegister(); | 1173 Register key = LoadDescriptor::NameRegister(); |
1173 Register slot = LoadDescriptor::SlotRegister(); | 1174 Register slot = LoadDescriptor::SlotRegister(); |
1174 Register vector = LoadWithVectorDescriptor::VectorRegister(); | 1175 Register vector = LoadWithVectorDescriptor::VectorRegister(); |
1175 | 1176 |
1176 // Copy all arguments from the array to the stack. | 1177 // Copy all arguments from the array to the stack. |
1177 Label entry, loop; | 1178 Label entry, loop; |
1178 __ movp(key, Operand(rbp, indexOffset)); | 1179 __ movp(key, Operand(rbp, indexOffset)); |
1179 __ jmp(&entry); | 1180 __ jmp(&entry); |
1180 __ bind(&loop); | 1181 __ bind(&loop); |
1181 __ movp(receiver, Operand(rbp, argumentsOffset)); // load arguments | 1182 __ movp(receiver, Operand(rbp, argumentsOffset)); // load arguments |
1182 | 1183 |
1183 // Use inline caching to speed up access to arguments. | 1184 // Use inline caching to speed up access to arguments. |
1184 Code::Kind kinds[] = {Code::KEYED_LOAD_IC}; | 1185 int slot_index = TypeFeedbackVector::PushAppliedArgumentsIndex(); |
1185 FeedbackVectorSpec spec(0, 1, kinds); | 1186 __ Move(slot, Smi::FromInt(slot_index)); |
1186 Handle<TypeFeedbackVector> feedback_vector = | 1187 __ movp(vector, Operand(rbp, vectorOffset)); |
1187 masm->isolate()->factory()->NewTypeFeedbackVector(&spec); | |
1188 int index = feedback_vector->GetIndex(FeedbackVectorICSlot(0)); | |
1189 __ Move(slot, Smi::FromInt(index)); | |
1190 __ Move(vector, feedback_vector); | |
1191 Handle<Code> ic = | 1188 Handle<Code> ic = |
1192 KeyedLoadICStub(masm->isolate(), LoadICState(kNoExtraICState)).GetCode(); | 1189 KeyedLoadICStub(masm->isolate(), LoadICState(kNoExtraICState)).GetCode(); |
1193 __ Call(ic, RelocInfo::CODE_TARGET); | 1190 __ Call(ic, RelocInfo::CODE_TARGET); |
1194 // It is important that we do not have a test instruction after the | 1191 // It is important that we do not have a test instruction after the |
1195 // call. A test instruction after the call is used to indicate that | 1192 // call. A test instruction after the call is used to indicate that |
1196 // we have generated an inline version of the keyed load. In this | 1193 // we have generated an inline version of the keyed load. In this |
1197 // case, we know that we are not generating a test instruction next. | 1194 // case, we know that we are not generating a test instruction next. |
1198 | 1195 |
1199 // Push the nth argument. | 1196 // Push the nth argument. |
1200 __ Push(rax); | 1197 __ Push(rax); |
(...skipping 26 matching lines...) Expand all Loading... |
1227 FrameScope frame_scope(masm, StackFrame::INTERNAL); | 1224 FrameScope frame_scope(masm, StackFrame::INTERNAL); |
1228 // Stack frame: | 1225 // Stack frame: |
1229 // rbp : Old base pointer | 1226 // rbp : Old base pointer |
1230 // rbp[8] : return address | 1227 // rbp[8] : return address |
1231 // rbp[16] : function arguments | 1228 // rbp[16] : function arguments |
1232 // rbp[24] : receiver | 1229 // rbp[24] : receiver |
1233 // rbp[32] : function | 1230 // rbp[32] : function |
1234 static const int kArgumentsOffset = kFPOnStackSize + kPCOnStackSize; | 1231 static const int kArgumentsOffset = kFPOnStackSize + kPCOnStackSize; |
1235 static const int kReceiverOffset = kArgumentsOffset + kPointerSize; | 1232 static const int kReceiverOffset = kArgumentsOffset + kPointerSize; |
1236 static const int kFunctionOffset = kReceiverOffset + kPointerSize; | 1233 static const int kFunctionOffset = kReceiverOffset + kPointerSize; |
| 1234 static const int kVectorOffset = |
| 1235 InternalFrameConstants::kCodeOffset - 1 * kPointerSize; |
| 1236 |
| 1237 // Push the vector. |
| 1238 __ movp(rdi, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
| 1239 __ movp(rdi, FieldOperand(rdi, SharedFunctionInfo::kFeedbackVectorOffset)); |
| 1240 __ Push(rdi); |
1237 | 1241 |
1238 __ Push(Operand(rbp, kFunctionOffset)); | 1242 __ Push(Operand(rbp, kFunctionOffset)); |
1239 __ Push(Operand(rbp, kArgumentsOffset)); | 1243 __ Push(Operand(rbp, kArgumentsOffset)); |
1240 if (targetIsArgument) { | 1244 if (targetIsArgument) { |
1241 __ InvokeBuiltin(Builtins::REFLECT_APPLY_PREPARE, CALL_FUNCTION); | 1245 __ InvokeBuiltin(Builtins::REFLECT_APPLY_PREPARE, CALL_FUNCTION); |
1242 } else { | 1246 } else { |
1243 __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION); | 1247 __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION); |
1244 } | 1248 } |
1245 | 1249 |
1246 Generate_CheckStackOverflow(masm, kFunctionOffset, kRaxIsSmiTagged); | 1250 Generate_CheckStackOverflow(masm, kFunctionOffset, kRaxIsSmiTagged); |
1247 | 1251 |
1248 // Push current index and limit. | 1252 // Push current index and limit, and receiver. |
1249 const int kLimitOffset = | 1253 const int kLimitOffset = kVectorOffset - 1 * kPointerSize; |
1250 StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize; | |
1251 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; | 1254 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; |
1252 __ Push(rax); // limit | 1255 __ Push(rax); // limit |
1253 __ Push(Immediate(0)); // index | 1256 __ Push(Immediate(0)); // index |
1254 | 1257 |
1255 // Get the receiver. | 1258 // Get the receiver. |
1256 __ movp(rbx, Operand(rbp, kReceiverOffset)); | 1259 __ movp(rbx, Operand(rbp, kReceiverOffset)); |
1257 | 1260 |
1258 // Check that the function is a JS function (otherwise it must be a proxy). | 1261 // Check that the function is a JS function (otherwise it must be a proxy). |
1259 Label push_receiver; | 1262 Label push_receiver; |
1260 __ movp(rdi, Operand(rbp, kFunctionOffset)); | 1263 __ movp(rdi, Operand(rbp, kFunctionOffset)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 __ bind(&use_global_proxy); | 1303 __ bind(&use_global_proxy); |
1301 __ movp(rbx, | 1304 __ movp(rbx, |
1302 Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 1305 Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
1303 __ movp(rbx, FieldOperand(rbx, GlobalObject::kGlobalProxyOffset)); | 1306 __ movp(rbx, FieldOperand(rbx, GlobalObject::kGlobalProxyOffset)); |
1304 | 1307 |
1305 // Push the receiver. | 1308 // Push the receiver. |
1306 __ bind(&push_receiver); | 1309 __ bind(&push_receiver); |
1307 __ Push(rbx); | 1310 __ Push(rbx); |
1308 | 1311 |
1309 // Loop over the arguments array, pushing each value to the stack | 1312 // Loop over the arguments array, pushing each value to the stack |
1310 Generate_PushAppliedArguments( | 1313 Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset, |
1311 masm, kArgumentsOffset, kIndexOffset, kLimitOffset); | 1314 kIndexOffset, kLimitOffset); |
1312 | 1315 |
1313 // Call the function. | 1316 // Call the function. |
1314 Label call_proxy; | 1317 Label call_proxy; |
1315 ParameterCount actual(rax); | 1318 ParameterCount actual(rax); |
1316 __ movp(rdi, Operand(rbp, kFunctionOffset)); | 1319 __ movp(rdi, Operand(rbp, kFunctionOffset)); |
1317 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | 1320 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
1318 __ j(not_equal, &call_proxy); | 1321 __ j(not_equal, &call_proxy); |
1319 __ InvokeFunction(rdi, actual, CALL_FUNCTION, NullCallWrapper()); | 1322 __ InvokeFunction(rdi, actual, CALL_FUNCTION, NullCallWrapper()); |
1320 | 1323 |
1321 frame_scope.GenerateLeaveFrame(); | 1324 frame_scope.GenerateLeaveFrame(); |
(...skipping 29 matching lines...) Expand all Loading... |
1351 // Stack frame: | 1354 // Stack frame: |
1352 // rbp : Old base pointer | 1355 // rbp : Old base pointer |
1353 // rbp[8] : return address | 1356 // rbp[8] : return address |
1354 // rbp[16] : original constructor (new.target) | 1357 // rbp[16] : original constructor (new.target) |
1355 // rbp[24] : arguments | 1358 // rbp[24] : arguments |
1356 // rbp[32] : constructor | 1359 // rbp[32] : constructor |
1357 static const int kNewTargetOffset = kFPOnStackSize + kPCOnStackSize; | 1360 static const int kNewTargetOffset = kFPOnStackSize + kPCOnStackSize; |
1358 static const int kArgumentsOffset = kNewTargetOffset + kPointerSize; | 1361 static const int kArgumentsOffset = kNewTargetOffset + kPointerSize; |
1359 static const int kFunctionOffset = kArgumentsOffset + kPointerSize; | 1362 static const int kFunctionOffset = kArgumentsOffset + kPointerSize; |
1360 | 1363 |
| 1364 static const int kVectorOffset = |
| 1365 InternalFrameConstants::kCodeOffset - 1 * kPointerSize; |
| 1366 |
| 1367 // Push the vector. |
| 1368 __ movp(rdi, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
| 1369 __ movp(rdi, FieldOperand(rdi, SharedFunctionInfo::kFeedbackVectorOffset)); |
| 1370 __ Push(rdi); |
| 1371 |
1361 // If newTarget is not supplied, set it to constructor | 1372 // If newTarget is not supplied, set it to constructor |
1362 Label validate_arguments; | 1373 Label validate_arguments; |
1363 __ movp(rax, Operand(rbp, kNewTargetOffset)); | 1374 __ movp(rax, Operand(rbp, kNewTargetOffset)); |
1364 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 1375 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
1365 __ j(not_equal, &validate_arguments, Label::kNear); | 1376 __ j(not_equal, &validate_arguments, Label::kNear); |
1366 __ movp(rax, Operand(rbp, kFunctionOffset)); | 1377 __ movp(rax, Operand(rbp, kFunctionOffset)); |
1367 __ movp(Operand(rbp, kNewTargetOffset), rax); | 1378 __ movp(Operand(rbp, kNewTargetOffset), rax); |
1368 | 1379 |
1369 // Validate arguments | 1380 // Validate arguments |
1370 __ bind(&validate_arguments); | 1381 __ bind(&validate_arguments); |
1371 __ Push(Operand(rbp, kFunctionOffset)); | 1382 __ Push(Operand(rbp, kFunctionOffset)); |
1372 __ Push(Operand(rbp, kArgumentsOffset)); | 1383 __ Push(Operand(rbp, kArgumentsOffset)); |
1373 __ Push(Operand(rbp, kNewTargetOffset)); | 1384 __ Push(Operand(rbp, kNewTargetOffset)); |
1374 __ InvokeBuiltin(Builtins::REFLECT_CONSTRUCT_PREPARE, CALL_FUNCTION); | 1385 __ InvokeBuiltin(Builtins::REFLECT_CONSTRUCT_PREPARE, CALL_FUNCTION); |
1375 | 1386 |
1376 Generate_CheckStackOverflow(masm, kFunctionOffset, kRaxIsSmiTagged); | 1387 Generate_CheckStackOverflow(masm, kFunctionOffset, kRaxIsSmiTagged); |
1377 | 1388 |
1378 // Push current index and limit. | 1389 // Push current index and limit. |
1379 const int kLimitOffset = | 1390 const int kLimitOffset = kVectorOffset - 1 * kPointerSize; |
1380 StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize; | |
1381 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; | 1391 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; |
1382 __ Push(rax); // limit | 1392 __ Push(rax); // limit |
1383 __ Push(Immediate(0)); // index | 1393 __ Push(Immediate(0)); // index |
1384 // Push the constructor function as callee. | 1394 // Push the constructor function as callee. |
1385 __ Push(Operand(rbp, kFunctionOffset)); | 1395 __ Push(Operand(rbp, kFunctionOffset)); |
1386 | 1396 |
1387 // Loop over the arguments array, pushing each value to the stack | 1397 // Loop over the arguments array, pushing each value to the stack |
1388 Generate_PushAppliedArguments( | 1398 Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset, |
1389 masm, kArgumentsOffset, kIndexOffset, kLimitOffset); | 1399 kIndexOffset, kLimitOffset); |
1390 | 1400 |
1391 // Use undefined feedback vector | 1401 // Use undefined feedback vector |
1392 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); | 1402 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); |
1393 __ movp(rdi, Operand(rbp, kFunctionOffset)); | 1403 __ movp(rdi, Operand(rbp, kFunctionOffset)); |
1394 __ movp(rcx, Operand(rbp, kNewTargetOffset)); | 1404 __ movp(rcx, Operand(rbp, kNewTargetOffset)); |
1395 | 1405 |
1396 // Call the function. | 1406 // Call the function. |
1397 CallConstructStub stub(masm->isolate(), SUPER_CONSTRUCTOR_CALL); | 1407 CallConstructStub stub(masm->isolate(), SUPER_CONSTRUCTOR_CALL); |
1398 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 1408 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
1399 | 1409 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1850 __ ret(0); | 1860 __ ret(0); |
1851 } | 1861 } |
1852 | 1862 |
1853 | 1863 |
1854 #undef __ | 1864 #undef __ |
1855 | 1865 |
1856 } // namespace internal | 1866 } // namespace internal |
1857 } // namespace v8 | 1867 } // namespace v8 |
1858 | 1868 |
1859 #endif // V8_TARGET_ARCH_X64 | 1869 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |