OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 ~BlockConstPoolScope() { | 1502 ~BlockConstPoolScope() { |
1503 assem_->EndBlockConstPool(); | 1503 assem_->EndBlockConstPool(); |
1504 } | 1504 } |
1505 | 1505 |
1506 private: | 1506 private: |
1507 Assembler* assem_; | 1507 Assembler* assem_; |
1508 | 1508 |
1509 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockConstPoolScope); | 1509 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockConstPoolScope); |
1510 }; | 1510 }; |
1511 | 1511 |
| 1512 // Class for blocking sharing of code targets in constant pool. |
| 1513 class BlockCodeTargetSharingScope { |
| 1514 public: |
| 1515 explicit BlockCodeTargetSharingScope(Assembler* assem) : assem_(nullptr) { |
| 1516 Open(assem); |
| 1517 } |
| 1518 // This constructor does not initialize the scope. The user needs to |
| 1519 // explicitly call Open() before using it. |
| 1520 BlockCodeTargetSharingScope() : assem_(nullptr) {} |
| 1521 ~BlockCodeTargetSharingScope() { |
| 1522 Close(); |
| 1523 } |
| 1524 void Open(Assembler* assem) { |
| 1525 DCHECK_NULL(assem_); |
| 1526 DCHECK_NOT_NULL(assem); |
| 1527 assem_ = assem; |
| 1528 assem_->StartBlockCodeTargetSharing(); |
| 1529 } |
| 1530 |
| 1531 private: |
| 1532 void Close() { |
| 1533 if (assem_ != nullptr) { |
| 1534 assem_->EndBlockCodeTargetSharing(); |
| 1535 } |
| 1536 } |
| 1537 Assembler* assem_; |
| 1538 |
| 1539 DISALLOW_COPY_AND_ASSIGN(BlockCodeTargetSharingScope); |
| 1540 }; |
| 1541 |
1512 // Debugging | 1542 // Debugging |
1513 | 1543 |
1514 // Mark address of a debug break slot. | 1544 // Mark address of a debug break slot. |
1515 void RecordDebugBreakSlot(RelocInfo::Mode mode); | 1545 void RecordDebugBreakSlot(RelocInfo::Mode mode); |
1516 | 1546 |
1517 // Record the AST id of the CallIC being compiled, so that it can be placed | 1547 // Record the AST id of the CallIC being compiled, so that it can be placed |
1518 // in the relocation information. | 1548 // in the relocation information. |
1519 void SetRecordedAstId(TypeFeedbackId ast_id) { | 1549 void SetRecordedAstId(TypeFeedbackId ast_id) { |
1520 DCHECK(recorded_ast_id_.IsNone()); | 1550 DCHECK(recorded_ast_id_.IsNone()); |
1521 recorded_ast_id_ = ast_id; | 1551 recorded_ast_id_ = ast_id; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 TypeFeedbackId recorded_ast_id_; | 1698 TypeFeedbackId recorded_ast_id_; |
1669 | 1699 |
1670 int buffer_space() const { return reloc_info_writer.pos() - pc_; } | 1700 int buffer_space() const { return reloc_info_writer.pos() - pc_; } |
1671 | 1701 |
1672 // Decode branch instruction at pos and return branch target pos | 1702 // Decode branch instruction at pos and return branch target pos |
1673 int target_at(int pos); | 1703 int target_at(int pos); |
1674 | 1704 |
1675 // Patch branch instruction at pos to branch to given branch target pos | 1705 // Patch branch instruction at pos to branch to given branch target pos |
1676 void target_at_put(int pos, int target_pos); | 1706 void target_at_put(int pos, int target_pos); |
1677 | 1707 |
| 1708 // Prevent sharing of code target constant pool entries until |
| 1709 // EndBlockCodeTargetSharing is called. Calls to this function can be nested |
| 1710 // but must be followed by an equal number of call to |
| 1711 // EndBlockCodeTargetSharing. |
| 1712 void StartBlockCodeTargetSharing() { |
| 1713 ++code_target_sharing_blocked_nesting_; |
| 1714 } |
| 1715 |
| 1716 // Resume sharing of constant pool code target entries. Needs to be called |
| 1717 // as many times as StartBlockCodeTargetSharing to have an effect. |
| 1718 void EndBlockCodeTargetSharing() { |
| 1719 --code_target_sharing_blocked_nesting_; |
| 1720 } |
| 1721 |
1678 // Prevent contant pool emission until EndBlockConstPool is called. | 1722 // Prevent contant pool emission until EndBlockConstPool is called. |
1679 // Call to this function can be nested but must be followed by an equal | 1723 // Calls to this function can be nested but must be followed by an equal |
1680 // number of call to EndBlockConstpool. | 1724 // number of call to EndBlockConstpool. |
1681 void StartBlockConstPool() { | 1725 void StartBlockConstPool() { |
1682 if (const_pool_blocked_nesting_++ == 0) { | 1726 if (const_pool_blocked_nesting_++ == 0) { |
1683 // Prevent constant pool checks happening by setting the next check to | 1727 // Prevent constant pool checks happening by setting the next check to |
1684 // the biggest possible offset. | 1728 // the biggest possible offset. |
1685 next_buffer_check_ = kMaxInt; | 1729 next_buffer_check_ = kMaxInt; |
1686 } | 1730 } |
1687 } | 1731 } |
1688 | 1732 |
1689 // Resume constant pool emission. Need to be called as many time as | 1733 // Resume constant pool emission. Needs to be called as many times as |
1690 // StartBlockConstPool to have an effect. | 1734 // StartBlockConstPool to have an effect. |
1691 void EndBlockConstPool() { | 1735 void EndBlockConstPool() { |
1692 if (--const_pool_blocked_nesting_ == 0) { | 1736 if (--const_pool_blocked_nesting_ == 0) { |
1693 #ifdef DEBUG | 1737 #ifdef DEBUG |
1694 // Max pool start (if we need a jump and an alignment). | 1738 // Max pool start (if we need a jump and an alignment). |
1695 int start = pc_offset() + kInstrSize + 2 * kPointerSize; | 1739 int start = pc_offset() + kInstrSize + 2 * kPointerSize; |
1696 // Check the constant pool hasn't been blocked for too long. | 1740 // Check the constant pool hasn't been blocked for too long. |
1697 DCHECK(pending_32_bit_constants_.empty() || | 1741 DCHECK(pending_32_bit_constants_.empty() || |
1698 (start + pending_64_bit_constants_.size() * kDoubleSize < | 1742 (start + pending_64_bit_constants_.size() * kDoubleSize < |
1699 static_cast<size_t>(first_const_pool_32_use_ + | 1743 static_cast<size_t>(first_const_pool_32_use_ + |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1771 // Constants in the pool may be addresses of functions that gets relocated; | 1815 // Constants in the pool may be addresses of functions that gets relocated; |
1772 // if so, a relocation info entry is associated to the constant pool entry. | 1816 // if so, a relocation info entry is associated to the constant pool entry. |
1773 | 1817 |
1774 // Repeated checking whether the constant pool should be emitted is rather | 1818 // Repeated checking whether the constant pool should be emitted is rather |
1775 // expensive. By default we only check again once a number of instructions | 1819 // expensive. By default we only check again once a number of instructions |
1776 // has been generated. That also means that the sizing of the buffers is not | 1820 // has been generated. That also means that the sizing of the buffers is not |
1777 // an exact science, and that we rely on some slop to not overrun buffers. | 1821 // an exact science, and that we rely on some slop to not overrun buffers. |
1778 static constexpr int kCheckPoolIntervalInst = 32; | 1822 static constexpr int kCheckPoolIntervalInst = 32; |
1779 static constexpr int kCheckPoolInterval = kCheckPoolIntervalInst * kInstrSize; | 1823 static constexpr int kCheckPoolInterval = kCheckPoolIntervalInst * kInstrSize; |
1780 | 1824 |
| 1825 // Sharing of code target entries may be blocked in some code sequences. |
| 1826 int code_target_sharing_blocked_nesting_; |
| 1827 bool IsCodeTargetSharingAllowed() const { |
| 1828 return code_target_sharing_blocked_nesting_ == 0; |
| 1829 } |
1781 | 1830 |
1782 // Emission of the constant pool may be blocked in some code sequences. | 1831 // Emission of the constant pool may be blocked in some code sequences. |
1783 int const_pool_blocked_nesting_; // Block emission if this is not zero. | 1832 int const_pool_blocked_nesting_; // Block emission if this is not zero. |
1784 int no_const_pool_before_; // Block emission before this pc offset. | 1833 int no_const_pool_before_; // Block emission before this pc offset. |
1785 | 1834 |
1786 // Keep track of the first instruction requiring a constant pool entry | 1835 // Keep track of the first instruction requiring a constant pool entry |
1787 // since the previous constant pool was emitted. | 1836 // since the previous constant pool was emitted. |
1788 int first_const_pool_32_use_; | 1837 int first_const_pool_32_use_; |
1789 int first_const_pool_64_use_; | 1838 int first_const_pool_64_use_; |
1790 | 1839 |
(...skipping 22 matching lines...) Expand all Loading... |
1813 | 1862 |
1814 // Record reloc info for current pc_ | 1863 // Record reloc info for current pc_ |
1815 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); | 1864 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); |
1816 void ConstantPoolAddEntry(int position, RelocInfo::Mode rmode, | 1865 void ConstantPoolAddEntry(int position, RelocInfo::Mode rmode, |
1817 intptr_t value); | 1866 intptr_t value); |
1818 void ConstantPoolAddEntry(int position, double value); | 1867 void ConstantPoolAddEntry(int position, double value); |
1819 | 1868 |
1820 friend class RelocInfo; | 1869 friend class RelocInfo; |
1821 friend class CodePatcher; | 1870 friend class CodePatcher; |
1822 friend class BlockConstPoolScope; | 1871 friend class BlockConstPoolScope; |
| 1872 friend class BlockCodeTargetSharingScope; |
1823 friend class EnsureSpace; | 1873 friend class EnsureSpace; |
1824 }; | 1874 }; |
1825 | 1875 |
1826 constexpr int kNoCodeAgeSequenceLength = 3 * Assembler::kInstrSize; | 1876 constexpr int kNoCodeAgeSequenceLength = 3 * Assembler::kInstrSize; |
1827 | 1877 |
1828 class EnsureSpace BASE_EMBEDDED { | 1878 class EnsureSpace BASE_EMBEDDED { |
1829 public: | 1879 public: |
1830 INLINE(explicit EnsureSpace(Assembler* assembler)); | 1880 INLINE(explicit EnsureSpace(Assembler* assembler)); |
1831 }; | 1881 }; |
1832 | 1882 |
1833 class PatchingAssembler : public Assembler { | 1883 class PatchingAssembler : public Assembler { |
1834 public: | 1884 public: |
1835 PatchingAssembler(IsolateData isolate_data, byte* address, int instructions); | 1885 PatchingAssembler(IsolateData isolate_data, byte* address, int instructions); |
1836 ~PatchingAssembler(); | 1886 ~PatchingAssembler(); |
1837 | 1887 |
1838 void Emit(Address addr); | 1888 void Emit(Address addr); |
1839 void FlushICache(Isolate* isolate); | 1889 void FlushICache(Isolate* isolate); |
1840 }; | 1890 }; |
1841 | 1891 |
1842 | 1892 |
1843 } // namespace internal | 1893 } // namespace internal |
1844 } // namespace v8 | 1894 } // namespace v8 |
1845 | 1895 |
1846 #endif // V8_ARM_ASSEMBLER_ARM_H_ | 1896 #endif // V8_ARM_ASSEMBLER_ARM_H_ |
OLD | NEW |