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_X64 | 5 #if V8_TARGET_ARCH_X64 |
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 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 // rcx - allocation site (loaded from vector[slot]). | 1322 // rcx - allocation site (loaded from vector[slot]). |
1323 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); | 1323 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); |
1324 __ cmpp(rdi, r8); | 1324 __ cmpp(rdi, r8); |
1325 __ j(not_equal, miss); | 1325 __ j(not_equal, miss); |
1326 | 1326 |
1327 // Increment the call count for monomorphic function calls. | 1327 // Increment the call count for monomorphic function calls. |
1328 IncrementCallCount(masm, rbx, rdx); | 1328 IncrementCallCount(masm, rbx, rdx); |
1329 | 1329 |
1330 __ movp(rbx, rcx); | 1330 __ movp(rbx, rcx); |
1331 __ movp(rdx, rdi); | 1331 __ movp(rdx, rdi); |
1332 __ Set(rax, arg_count()); | |
1333 ArrayConstructorStub stub(masm->isolate()); | 1332 ArrayConstructorStub stub(masm->isolate()); |
1334 __ TailCallStub(&stub); | 1333 __ TailCallStub(&stub); |
1335 } | 1334 } |
1336 | 1335 |
1337 | 1336 |
1338 void CallICStub::Generate(MacroAssembler* masm) { | 1337 void CallICStub::Generate(MacroAssembler* masm) { |
1339 // ----------- S t a t e ------------- | 1338 // ----------- S t a t e ------------- |
| 1339 // -- rax - number of arguments |
1340 // -- rdi - function | 1340 // -- rdi - function |
1341 // -- rdx - slot id | 1341 // -- rdx - slot id |
1342 // -- rbx - vector | 1342 // -- rbx - vector |
1343 // ----------------------------------- | 1343 // ----------------------------------- |
1344 Isolate* isolate = masm->isolate(); | 1344 Isolate* isolate = masm->isolate(); |
1345 Label extra_checks_or_miss, call, call_function, call_count_incremented; | 1345 Label extra_checks_or_miss, call, call_function, call_count_incremented; |
1346 int argc = arg_count(); | |
1347 StackArgumentsAccessor args(rsp, argc); | |
1348 ParameterCount actual(argc); | |
1349 | 1346 |
1350 // The checks. First, does rdi match the recorded monomorphic target? | 1347 // The checks. First, does rdi match the recorded monomorphic target? |
1351 __ SmiToInteger32(rdx, rdx); | 1348 __ SmiToInteger32(rdx, rdx); |
1352 __ movp(rcx, | 1349 __ movp(rcx, |
1353 FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize)); | 1350 FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize)); |
1354 | 1351 |
1355 // We don't know that we have a weak cell. We might have a private symbol | 1352 // We don't know that we have a weak cell. We might have a private symbol |
1356 // or an AllocationSite, but the memory is safe to examine. | 1353 // or an AllocationSite, but the memory is safe to examine. |
1357 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to | 1354 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to |
1358 // FixedArray. | 1355 // FixedArray. |
(...skipping 11 matching lines...) Expand all Loading... |
1370 __ j(not_equal, &extra_checks_or_miss); | 1367 __ j(not_equal, &extra_checks_or_miss); |
1371 | 1368 |
1372 // The compare above could have been a SMI/SMI comparison. Guard against this | 1369 // The compare above could have been a SMI/SMI comparison. Guard against this |
1373 // convincing us that we have a monomorphic JSFunction. | 1370 // convincing us that we have a monomorphic JSFunction. |
1374 __ JumpIfSmi(rdi, &extra_checks_or_miss); | 1371 __ JumpIfSmi(rdi, &extra_checks_or_miss); |
1375 | 1372 |
1376 __ bind(&call_function); | 1373 __ bind(&call_function); |
1377 // Increment the call count for monomorphic function calls. | 1374 // Increment the call count for monomorphic function calls. |
1378 IncrementCallCount(masm, rbx, rdx); | 1375 IncrementCallCount(masm, rbx, rdx); |
1379 | 1376 |
1380 __ Set(rax, argc); | |
1381 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), | 1377 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), |
1382 tail_call_mode()), | 1378 tail_call_mode()), |
1383 RelocInfo::CODE_TARGET); | 1379 RelocInfo::CODE_TARGET); |
1384 | 1380 |
1385 __ bind(&extra_checks_or_miss); | 1381 __ bind(&extra_checks_or_miss); |
1386 Label uninitialized, miss, not_allocation_site; | 1382 Label uninitialized, miss, not_allocation_site; |
1387 | 1383 |
1388 __ Cmp(rcx, TypeFeedbackVector::MegamorphicSentinel(isolate)); | 1384 __ Cmp(rcx, TypeFeedbackVector::MegamorphicSentinel(isolate)); |
1389 __ j(equal, &call); | 1385 __ j(equal, &call); |
1390 | 1386 |
(...skipping 23 matching lines...) Expand all Loading... |
1414 __ j(not_equal, &miss); | 1410 __ j(not_equal, &miss); |
1415 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), | 1411 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), |
1416 TypeFeedbackVector::MegamorphicSentinel(isolate)); | 1412 TypeFeedbackVector::MegamorphicSentinel(isolate)); |
1417 | 1413 |
1418 __ bind(&call); | 1414 __ bind(&call); |
1419 | 1415 |
1420 // Increment the call count for megamorphic function calls. | 1416 // Increment the call count for megamorphic function calls. |
1421 IncrementCallCount(masm, rbx, rdx); | 1417 IncrementCallCount(masm, rbx, rdx); |
1422 | 1418 |
1423 __ bind(&call_count_incremented); | 1419 __ bind(&call_count_incremented); |
1424 __ Set(rax, argc); | |
1425 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), | 1420 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), |
1426 RelocInfo::CODE_TARGET); | 1421 RelocInfo::CODE_TARGET); |
1427 | 1422 |
1428 __ bind(&uninitialized); | 1423 __ bind(&uninitialized); |
1429 | 1424 |
1430 // We are going monomorphic, provided we actually have a JSFunction. | 1425 // We are going monomorphic, provided we actually have a JSFunction. |
1431 __ JumpIfSmi(rdi, &miss); | 1426 __ JumpIfSmi(rdi, &miss); |
1432 | 1427 |
1433 // Goto miss case if we do not have a function. | 1428 // Goto miss case if we do not have a function. |
1434 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | 1429 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
(...skipping 12 matching lines...) Expand all Loading... |
1447 __ j(not_equal, &miss); | 1442 __ j(not_equal, &miss); |
1448 | 1443 |
1449 // Store the function. Use a stub since we need a frame for allocation. | 1444 // Store the function. Use a stub since we need a frame for allocation. |
1450 // rbx - vector | 1445 // rbx - vector |
1451 // rdx - slot (needs to be in smi form) | 1446 // rdx - slot (needs to be in smi form) |
1452 // rdi - function | 1447 // rdi - function |
1453 { | 1448 { |
1454 FrameScope scope(masm, StackFrame::INTERNAL); | 1449 FrameScope scope(masm, StackFrame::INTERNAL); |
1455 CreateWeakCellStub create_stub(isolate); | 1450 CreateWeakCellStub create_stub(isolate); |
1456 | 1451 |
| 1452 __ Integer32ToSmi(rax, rax); |
1457 __ Integer32ToSmi(rdx, rdx); | 1453 __ Integer32ToSmi(rdx, rdx); |
| 1454 __ Push(rax); |
1458 __ Push(rbx); | 1455 __ Push(rbx); |
1459 __ Push(rdx); | 1456 __ Push(rdx); |
1460 __ Push(rdi); | 1457 __ Push(rdi); |
1461 __ Push(rsi); | 1458 __ Push(rsi); |
1462 __ CallStub(&create_stub); | 1459 __ CallStub(&create_stub); |
1463 __ Pop(rsi); | 1460 __ Pop(rsi); |
1464 __ Pop(rdi); | 1461 __ Pop(rdi); |
1465 __ Pop(rdx); | 1462 __ Pop(rdx); |
1466 __ Pop(rbx); | 1463 __ Pop(rbx); |
| 1464 __ Pop(rax); |
1467 __ SmiToInteger32(rdx, rdx); | 1465 __ SmiToInteger32(rdx, rdx); |
| 1466 __ SmiToInteger32(rax, rax); |
1468 } | 1467 } |
1469 | 1468 |
1470 __ jmp(&call_function); | 1469 __ jmp(&call_function); |
1471 | 1470 |
1472 // We are here because tracing is on or we encountered a MISS case we can't | 1471 // We are here because tracing is on or we encountered a MISS case we can't |
1473 // handle here. | 1472 // handle here. |
1474 __ bind(&miss); | 1473 __ bind(&miss); |
1475 GenerateMiss(masm); | 1474 GenerateMiss(masm); |
1476 | 1475 |
1477 __ jmp(&call_count_incremented); | 1476 __ jmp(&call_count_incremented); |
1478 | 1477 |
1479 // Unreachable | 1478 // Unreachable |
1480 __ int3(); | 1479 __ int3(); |
1481 } | 1480 } |
1482 | 1481 |
1483 void CallICStub::GenerateMiss(MacroAssembler* masm) { | 1482 void CallICStub::GenerateMiss(MacroAssembler* masm) { |
1484 FrameScope scope(masm, StackFrame::INTERNAL); | 1483 FrameScope scope(masm, StackFrame::INTERNAL); |
1485 | 1484 |
| 1485 // Preserve the number of arguments. |
| 1486 __ Integer32ToSmi(rax, rax); |
| 1487 __ Push(rax); |
| 1488 |
1486 // Push the receiver and the function and feedback info. | 1489 // Push the receiver and the function and feedback info. |
1487 __ Integer32ToSmi(rdx, rdx); | 1490 __ Integer32ToSmi(rdx, rdx); |
1488 __ Push(rdi); | 1491 __ Push(rdi); |
1489 __ Push(rbx); | 1492 __ Push(rbx); |
1490 __ Push(rdx); | 1493 __ Push(rdx); |
1491 | 1494 |
1492 // Call the entry. | 1495 // Call the entry. |
1493 __ CallRuntime(Runtime::kCallIC_Miss); | 1496 __ CallRuntime(Runtime::kCallIC_Miss); |
1494 | 1497 |
1495 // Move result to edi and exit the internal frame. | 1498 // Move result to edi and exit the internal frame. |
1496 __ movp(rdi, rax); | 1499 __ movp(rdi, rax); |
| 1500 |
| 1501 // Restore number of arguments. |
| 1502 __ Pop(rax); |
| 1503 __ SmiToInteger32(rax, rax); |
1497 } | 1504 } |
1498 | 1505 |
1499 bool CEntryStub::NeedsImmovableCode() { | 1506 bool CEntryStub::NeedsImmovableCode() { |
1500 return false; | 1507 return false; |
1501 } | 1508 } |
1502 | 1509 |
1503 | 1510 |
1504 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { | 1511 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
1505 CEntryStub::GenerateAheadOfTime(isolate); | 1512 CEntryStub::GenerateAheadOfTime(isolate); |
1506 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); | 1513 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); |
(...skipping 3355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4862 kStackUnwindSpace, nullptr, return_value_operand, | 4869 kStackUnwindSpace, nullptr, return_value_operand, |
4863 NULL); | 4870 NULL); |
4864 } | 4871 } |
4865 | 4872 |
4866 #undef __ | 4873 #undef __ |
4867 | 4874 |
4868 } // namespace internal | 4875 } // namespace internal |
4869 } // namespace v8 | 4876 } // namespace v8 |
4870 | 4877 |
4871 #endif // V8_TARGET_ARCH_X64 | 4878 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |