| 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 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_A64_ASSEMBLER_A64_H_ | 28 #ifndef V8_A64_ASSEMBLER_A64_H_ |
| 29 #define V8_A64_ASSEMBLER_A64_H_ | 29 #define V8_A64_ASSEMBLER_A64_H_ |
| 30 | 30 |
| 31 #include <list> | 31 #include <list> |
| 32 #include <map> |
| 32 | 33 |
| 33 #include "globals.h" | 34 #include "globals.h" |
| 34 #include "utils.h" | 35 #include "utils.h" |
| 35 #include "assembler.h" | 36 #include "assembler.h" |
| 36 #include "serialize.h" | 37 #include "serialize.h" |
| 37 #include "a64/instructions-a64.h" | 38 #include "a64/instructions-a64.h" |
| 38 #include "a64/cpu-a64.h" | 39 #include "a64/cpu-a64.h" |
| 39 | 40 |
| 40 | 41 |
| 41 namespace v8 { | 42 namespace v8 { |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 // | 723 // |
| 723 // The descriptor (desc) can be NULL. In that case, the code is finalized as | 724 // The descriptor (desc) can be NULL. In that case, the code is finalized as |
| 724 // usual, but the descriptor is not populated. | 725 // usual, but the descriptor is not populated. |
| 725 void GetCode(CodeDesc* desc); | 726 void GetCode(CodeDesc* desc); |
| 726 | 727 |
| 727 // Insert the smallest number of nop instructions | 728 // Insert the smallest number of nop instructions |
| 728 // possible to align the pc offset to a multiple | 729 // possible to align the pc offset to a multiple |
| 729 // of m. m must be a power of 2 (>= 4). | 730 // of m. m must be a power of 2 (>= 4). |
| 730 void Align(int m); | 731 void Align(int m); |
| 731 | 732 |
| 733 inline void Unreachable(); |
| 734 |
| 732 // Label -------------------------------------------------------------------- | 735 // Label -------------------------------------------------------------------- |
| 733 // Bind a label to the current pc. Note that labels can only be bound once, | 736 // Bind a label to the current pc. Note that labels can only be bound once, |
| 734 // and if labels are linked to other instructions, they _must_ be bound | 737 // and if labels are linked to other instructions, they _must_ be bound |
| 735 // before they go out of scope. | 738 // before they go out of scope. |
| 736 void bind(Label* label); | 739 void bind(Label* label); |
| 737 | 740 |
| 738 | 741 |
| 739 // RelocInfo and constant pool ---------------------------------------------- | 742 // RelocInfo and constant pool ---------------------------------------------- |
| 740 | 743 |
| 741 // Record relocation information for current pc_. | 744 // Record relocation information for current pc_. |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 static inline LoadStorePairOp LoadPairOpFor(const CPURegister& rt, | 1797 static inline LoadStorePairOp LoadPairOpFor(const CPURegister& rt, |
| 1795 const CPURegister& rt2); | 1798 const CPURegister& rt2); |
| 1796 static inline LoadStoreOp StoreOpFor(const CPURegister& rt); | 1799 static inline LoadStoreOp StoreOpFor(const CPURegister& rt); |
| 1797 static inline LoadStorePairOp StorePairOpFor(const CPURegister& rt, | 1800 static inline LoadStorePairOp StorePairOpFor(const CPURegister& rt, |
| 1798 const CPURegister& rt2); | 1801 const CPURegister& rt2); |
| 1799 static inline LoadStorePairNonTemporalOp LoadPairNonTemporalOpFor( | 1802 static inline LoadStorePairNonTemporalOp LoadPairNonTemporalOpFor( |
| 1800 const CPURegister& rt, const CPURegister& rt2); | 1803 const CPURegister& rt, const CPURegister& rt2); |
| 1801 static inline LoadStorePairNonTemporalOp StorePairNonTemporalOpFor( | 1804 static inline LoadStorePairNonTemporalOp StorePairNonTemporalOpFor( |
| 1802 const CPURegister& rt, const CPURegister& rt2); | 1805 const CPURegister& rt, const CPURegister& rt2); |
| 1803 | 1806 |
| 1807 // Remove the specified branch from the unbound label link chain. |
| 1808 // If available, a veneer for this label can be used for other branches in the |
| 1809 // chain if the link chain cannot be fixed up without this branch. |
| 1810 void RemoveBranchFromLabelLinkChain(Instruction* branch, |
| 1811 Label* label, |
| 1812 Instruction* label_veneer = NULL); |
| 1804 | 1813 |
| 1805 private: | 1814 private: |
| 1806 // Instruction helpers. | 1815 // Instruction helpers. |
| 1807 void MoveWide(const Register& rd, | 1816 void MoveWide(const Register& rd, |
| 1808 uint64_t imm, | 1817 uint64_t imm, |
| 1809 int shift, | 1818 int shift, |
| 1810 MoveWideImmediateOp mov_op); | 1819 MoveWideImmediateOp mov_op); |
| 1811 void DataProcShiftedRegister(const Register& rd, | 1820 void DataProcShiftedRegister(const Register& rd, |
| 1812 const Register& rn, | 1821 const Register& rn, |
| 1813 const Operand& operand, | 1822 const Operand& operand, |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 } | 1989 } |
| 1981 | 1990 |
| 1982 // Code generation | 1991 // Code generation |
| 1983 // The relocation writer's position is at least kGap bytes below the end of | 1992 // The relocation writer's position is at least kGap bytes below the end of |
| 1984 // the generated instructions. This is so that multi-instruction sequences do | 1993 // the generated instructions. This is so that multi-instruction sequences do |
| 1985 // not have to check for overflow. The same is true for writes of large | 1994 // not have to check for overflow. The same is true for writes of large |
| 1986 // relocation info entries, and debug strings encoded in the instruction | 1995 // relocation info entries, and debug strings encoded in the instruction |
| 1987 // stream. | 1996 // stream. |
| 1988 static const int kGap = 128; | 1997 static const int kGap = 128; |
| 1989 | 1998 |
| 1999 public: |
| 2000 class FarBranchInfo { |
| 2001 public: |
| 2002 FarBranchInfo(int offset, Label* label) |
| 2003 : pc_offset_(offset), label_(label) {} |
| 2004 // Offset of the branch in the code generation buffer. |
| 2005 int pc_offset_; |
| 2006 // The label branched to. |
| 2007 Label* label_; |
| 2008 }; |
| 2009 |
| 2010 protected: |
| 2011 // Information about unresolved (forward) branches. |
| 2012 // The Assembler is only allowed to delete out-of-date information from here |
| 2013 // after a label is bound. The MacroAssembler uses this information to |
| 2014 // generate veneers. |
| 2015 // |
| 2016 // The second member gives information about the unresolved branch. The first |
| 2017 // member of the pair is the maximum offset that the branch can reach in the |
| 2018 // buffer. The map is sorted according to this reachable offset, allowing to |
| 2019 // easily check when veneers need to be emitted. |
| 2020 // Note that the maximum reachable offset (first member of the pairs) should |
| 2021 // always be positive but has the same type as the return value for |
| 2022 // pc_offset() for convenience. |
| 2023 std::multimap<int, FarBranchInfo> unresolved_branches_; |
| 2024 |
| 2025 private: |
| 2026 // If a veneer is emitted for a branch instruction, that instruction must be |
| 2027 // removed from the associated label's link chain so that the assembler does |
| 2028 // not later attempt (likely unsuccessfully) to patch it to branch directly to |
| 2029 // the label. |
| 2030 void DeleteUnresolvedBranchInfoForLabel(Label* label); |
| 2031 |
| 1990 private: | 2032 private: |
| 1991 // TODO(jbramley): VIXL uses next_literal_pool_check_ and | 2033 // TODO(jbramley): VIXL uses next_literal_pool_check_ and |
| 1992 // literal_pool_monitor_ to determine when to consider emitting a literal | 2034 // literal_pool_monitor_ to determine when to consider emitting a literal |
| 1993 // pool. V8 doesn't use them, so they should either not be here at all, or | 2035 // pool. V8 doesn't use them, so they should either not be here at all, or |
| 1994 // should replace or be merged with next_buffer_check_ and | 2036 // should replace or be merged with next_buffer_check_ and |
| 1995 // const_pool_blocked_nesting_. | 2037 // const_pool_blocked_nesting_. |
| 1996 Instruction* next_literal_pool_check_; | 2038 Instruction* next_literal_pool_check_; |
| 1997 unsigned literal_pool_monitor_; | 2039 unsigned literal_pool_monitor_; |
| 1998 | 2040 |
| 1999 PositionsRecorder positions_recorder_; | 2041 PositionsRecorder positions_recorder_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 class EnsureSpace BASE_EMBEDDED { | 2085 class EnsureSpace BASE_EMBEDDED { |
| 2044 public: | 2086 public: |
| 2045 explicit EnsureSpace(Assembler* assembler) { | 2087 explicit EnsureSpace(Assembler* assembler) { |
| 2046 assembler->CheckBuffer(); | 2088 assembler->CheckBuffer(); |
| 2047 } | 2089 } |
| 2048 }; | 2090 }; |
| 2049 | 2091 |
| 2050 } } // namespace v8::internal | 2092 } } // namespace v8::internal |
| 2051 | 2093 |
| 2052 #endif // V8_A64_ASSEMBLER_A64_H_ | 2094 #endif // V8_A64_ASSEMBLER_A64_H_ |
| OLD | NEW |