OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 } | 1398 } |
1399 | 1399 |
1400 | 1400 |
1401 void CodeStub::GenerateFPStubs(Isolate* isolate) { | 1401 void CodeStub::GenerateFPStubs(Isolate* isolate) { |
1402 // Floating-point code doesn't get special handling in ARM64, so there's | 1402 // Floating-point code doesn't get special handling in ARM64, so there's |
1403 // nothing to do here. | 1403 // nothing to do here. |
1404 USE(isolate); | 1404 USE(isolate); |
1405 } | 1405 } |
1406 | 1406 |
1407 | 1407 |
| 1408 static void JumpIfOOM(MacroAssembler* masm, |
| 1409 Register value, |
| 1410 Register scratch, |
| 1411 Label* oom_label) { |
| 1412 STATIC_ASSERT(Failure::OUT_OF_MEMORY_EXCEPTION == 3); |
| 1413 STATIC_ASSERT(kFailureTag == 3); |
| 1414 __ And(scratch, value, 0xf); |
| 1415 __ Cmp(scratch, 0xf); |
| 1416 __ B(eq, oom_label); |
| 1417 } |
| 1418 |
| 1419 |
1408 bool CEntryStub::NeedsImmovableCode() { | 1420 bool CEntryStub::NeedsImmovableCode() { |
1409 // CEntryStub stores the return address on the stack before calling into | 1421 // CEntryStub stores the return address on the stack before calling into |
1410 // C++ code. In some cases, the VM accesses this address, but it is not used | 1422 // C++ code. In some cases, the VM accesses this address, but it is not used |
1411 // when the C++ code returns to the stub because LR holds the return address | 1423 // when the C++ code returns to the stub because LR holds the return address |
1412 // in AAPCS64. If the stub is moved (perhaps during a GC), we could end up | 1424 // in AAPCS64. If the stub is moved (perhaps during a GC), we could end up |
1413 // returning to dead code. | 1425 // returning to dead code. |
1414 // TODO(jbramley): Whilst this is the only analysis that makes sense, I can't | 1426 // TODO(jbramley): Whilst this is the only analysis that makes sense, I can't |
1415 // find any comment to confirm this, and I don't hit any crashes whatever | 1427 // find any comment to confirm this, and I don't hit any crashes whatever |
1416 // this function returns. The anaylsis should be properly confirmed. | 1428 // this function returns. The anaylsis should be properly confirmed. |
1417 return true; | 1429 return true; |
1418 } | 1430 } |
1419 | 1431 |
1420 | 1432 |
1421 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { | 1433 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { |
1422 CEntryStub stub(1, kDontSaveFPRegs); | 1434 CEntryStub stub(1, kDontSaveFPRegs); |
1423 stub.GetCode(isolate); | 1435 stub.GetCode(isolate); |
1424 CEntryStub stub_fp(1, kSaveFPRegs); | 1436 CEntryStub stub_fp(1, kSaveFPRegs); |
1425 stub_fp.GetCode(isolate); | 1437 stub_fp.GetCode(isolate); |
1426 } | 1438 } |
1427 | 1439 |
1428 | 1440 |
1429 void CEntryStub::GenerateCore(MacroAssembler* masm, | 1441 void CEntryStub::GenerateCore(MacroAssembler* masm, |
1430 Label* throw_normal, | 1442 Label* throw_normal, |
1431 Label* throw_termination, | 1443 Label* throw_termination, |
| 1444 Label* throw_out_of_memory, |
1432 bool do_gc, | 1445 bool do_gc, |
1433 bool always_allocate) { | 1446 bool always_allocate) { |
1434 // x0 : Result parameter for PerformGC, if do_gc is true. | 1447 // x0 : Result parameter for PerformGC, if do_gc is true. |
1435 // x21 : argv | 1448 // x21 : argv |
1436 // x22 : argc | 1449 // x22 : argc |
1437 // x23 : target | 1450 // x23 : target |
1438 // | 1451 // |
1439 // The stack (on entry) holds the arguments and the receiver, with the | 1452 // The stack (on entry) holds the arguments and the receiver, with the |
1440 // receiver at the highest address: | 1453 // receiver at the highest address: |
1441 // | 1454 // |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1569 // x0 result The return code from the call, including the failure | 1582 // x0 result The return code from the call, including the failure |
1570 // code and details. | 1583 // code and details. |
1571 // x21 argv | 1584 // x21 argv |
1572 // x22 argc | 1585 // x22 argc |
1573 // x23 target | 1586 // x23 target |
1574 // Refer to the Failure class for details of the bit layout. | 1587 // Refer to the Failure class for details of the bit layout. |
1575 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); | 1588 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); |
1576 __ Tst(result, kFailureTypeTagMask << kFailureTagSize); | 1589 __ Tst(result, kFailureTypeTagMask << kFailureTagSize); |
1577 __ B(eq, &retry); // RETRY_AFTER_GC | 1590 __ B(eq, &retry); // RETRY_AFTER_GC |
1578 | 1591 |
| 1592 // Special handling of out-of-memory exceptions: Pass the failure result, |
| 1593 // rather than the exception descriptor. |
| 1594 JumpIfOOM(masm, result, x10, throw_out_of_memory); |
| 1595 |
1579 // Retrieve the pending exception. | 1596 // Retrieve the pending exception. |
1580 const Register& exception = result; | 1597 const Register& exception = result; |
1581 const Register& exception_address = x11; | 1598 const Register& exception_address = x11; |
1582 __ Mov(exception_address, | 1599 __ Mov(exception_address, |
1583 Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 1600 Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
1584 isolate))); | 1601 isolate))); |
1585 __ Ldr(exception, MemOperand(exception_address)); | 1602 __ Ldr(exception, MemOperand(exception_address)); |
1586 | 1603 |
| 1604 // See if we just retrieved an OOM exception. |
| 1605 JumpIfOOM(masm, exception, x10, throw_out_of_memory); |
| 1606 |
1587 // Clear the pending exception. | 1607 // Clear the pending exception. |
1588 __ Mov(x10, Operand(isolate->factory()->the_hole_value())); | 1608 __ Mov(x10, Operand(isolate->factory()->the_hole_value())); |
1589 __ Str(x10, MemOperand(exception_address)); | 1609 __ Str(x10, MemOperand(exception_address)); |
1590 | 1610 |
1591 // x0 exception The exception descriptor. | 1611 // x0 exception The exception descriptor. |
1592 // x21 argv | 1612 // x21 argv |
1593 // x22 argc | 1613 // x22 argc |
1594 // x23 target | 1614 // x23 target |
1595 | 1615 |
1596 // Special handling of termination exceptions, which are uncatchable by | 1616 // Special handling of termination exceptions, which are uncatchable by |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 // could be pushed onto the stack by called stubs and functions, and on the | 1690 // could be pushed onto the stack by called stubs and functions, and on the |
1671 // stack they can confuse the GC. However, we're only calling C functions | 1691 // stack they can confuse the GC. However, we're only calling C functions |
1672 // which can push arbitrary data onto the stack anyway, and so the GC won't | 1692 // which can push arbitrary data onto the stack anyway, and so the GC won't |
1673 // examine that part of the stack. | 1693 // examine that part of the stack. |
1674 __ Mov(argc, argc_input); | 1694 __ Mov(argc, argc_input); |
1675 __ Mov(target, target_input); | 1695 __ Mov(target, target_input); |
1676 __ Mov(argv, temp_argv); | 1696 __ Mov(argv, temp_argv); |
1677 | 1697 |
1678 Label throw_normal; | 1698 Label throw_normal; |
1679 Label throw_termination; | 1699 Label throw_termination; |
| 1700 Label throw_out_of_memory; |
1680 | 1701 |
1681 // Call the runtime function. | 1702 // Call the runtime function. |
1682 GenerateCore(masm, | 1703 GenerateCore(masm, |
1683 &throw_normal, | 1704 &throw_normal, |
1684 &throw_termination, | 1705 &throw_termination, |
| 1706 &throw_out_of_memory, |
1685 false, | 1707 false, |
1686 false); | 1708 false); |
1687 | 1709 |
1688 // If successful, the previous GenerateCore will have returned to the | 1710 // If successful, the previous GenerateCore will have returned to the |
1689 // calling code. Otherwise, we fall through into the following. | 1711 // calling code. Otherwise, we fall through into the following. |
1690 | 1712 |
1691 // Do space-specific GC and retry runtime call. | 1713 // Do space-specific GC and retry runtime call. |
1692 GenerateCore(masm, | 1714 GenerateCore(masm, |
1693 &throw_normal, | 1715 &throw_normal, |
1694 &throw_termination, | 1716 &throw_termination, |
| 1717 &throw_out_of_memory, |
1695 true, | 1718 true, |
1696 false); | 1719 false); |
1697 | 1720 |
1698 // Do full GC and retry runtime call one final time. | 1721 // Do full GC and retry runtime call one final time. |
1699 __ Mov(x0, reinterpret_cast<uint64_t>(Failure::InternalError())); | 1722 __ Mov(x0, reinterpret_cast<uint64_t>(Failure::InternalError())); |
1700 GenerateCore(masm, | 1723 GenerateCore(masm, |
1701 &throw_normal, | 1724 &throw_normal, |
1702 &throw_termination, | 1725 &throw_termination, |
| 1726 &throw_out_of_memory, |
1703 true, | 1727 true, |
1704 true); | 1728 true); |
1705 | 1729 |
1706 // We didn't execute a return case, so the stack frame hasn't been updated | 1730 // We didn't execute a return case, so the stack frame hasn't been updated |
1707 // (except for the return address slot). However, we don't need to initialize | 1731 // (except for the return address slot). However, we don't need to initialize |
1708 // jssp because the throw method will immediately overwrite it when it | 1732 // jssp because the throw method will immediately overwrite it when it |
1709 // unwinds the stack. | 1733 // unwinds the stack. |
1710 if (__ emit_debug_code()) { | 1734 if (__ emit_debug_code()) { |
1711 __ Mov(jssp, kDebugZapValue); | 1735 __ Mov(jssp, kDebugZapValue); |
1712 } | 1736 } |
1713 __ SetStackPointer(jssp); | 1737 __ SetStackPointer(jssp); |
1714 | 1738 |
1715 // Throw exceptions. | 1739 // Throw exceptions. |
1716 // If we throw an exception, we can end up re-entering CEntryStub before we | 1740 // If we throw an exception, we can end up re-entering CEntryStub before we |
1717 // pop the exit frame, so need to ensure that x21-x23 contain GC-safe values | 1741 // pop the exit frame, so need to ensure that x21-x23 contain GC-safe values |
1718 // here. | 1742 // here. |
| 1743 __ Bind(&throw_out_of_memory); |
| 1744 ASM_LOCATION("Throw out of memory"); |
| 1745 __ Mov(argv, 0); |
| 1746 __ Mov(argc, 0); |
| 1747 __ Mov(target, 0); |
| 1748 // Set external caught exception to false. |
| 1749 Isolate* isolate = masm->isolate(); |
| 1750 __ Mov(x2, Operand(ExternalReference(Isolate::kExternalCaughtExceptionAddress, |
| 1751 isolate))); |
| 1752 __ Str(xzr, MemOperand(x2)); |
| 1753 |
| 1754 // Set pending exception and x0 to out of memory exception. |
| 1755 Label already_have_failure; |
| 1756 JumpIfOOM(masm, x0, x10, &already_have_failure); |
| 1757 Failure* out_of_memory = Failure::OutOfMemoryException(0x1); |
| 1758 __ Mov(x0, Operand(reinterpret_cast<uint64_t>(out_of_memory))); |
| 1759 __ Bind(&already_have_failure); |
| 1760 __ Mov(x2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
| 1761 isolate))); |
| 1762 __ Str(x0, MemOperand(x2)); |
| 1763 // Fall through to the next label. |
1719 | 1764 |
1720 __ Bind(&throw_termination); | 1765 __ Bind(&throw_termination); |
1721 ASM_LOCATION("Throw termination"); | 1766 ASM_LOCATION("Throw termination"); |
1722 __ Mov(argv, 0); | 1767 __ Mov(argv, 0); |
1723 __ Mov(argc, 0); | 1768 __ Mov(argc, 0); |
1724 __ Mov(target, 0); | 1769 __ Mov(target, 0); |
1725 __ ThrowUncatchable(x0, x10, x11, x12, x13); | 1770 __ ThrowUncatchable(x0, x10, x11, x12, x13); |
1726 | 1771 |
1727 __ Bind(&throw_normal); | 1772 __ Bind(&throw_normal); |
1728 ASM_LOCATION("Throw normal"); | 1773 ASM_LOCATION("Throw normal"); |
(...skipping 3946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5675 MemOperand(fp, 6 * kPointerSize), | 5720 MemOperand(fp, 6 * kPointerSize), |
5676 NULL); | 5721 NULL); |
5677 } | 5722 } |
5678 | 5723 |
5679 | 5724 |
5680 #undef __ | 5725 #undef __ |
5681 | 5726 |
5682 } } // namespace v8::internal | 5727 } } // namespace v8::internal |
5683 | 5728 |
5684 #endif // V8_TARGET_ARCH_ARM64 | 5729 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |