| 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 #ifndef V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ | 5 #ifndef V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ |
| 6 #define V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ | 6 #define V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ |
| 7 | 7 |
| 8 #include "assembler.h" | 8 #include "assembler.h" |
| 9 #include "mips/assembler-mips.h" | 9 #include "mips/assembler-mips.h" |
| 10 #include "v8globals.h" | 10 #include "v8globals.h" |
| (...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 }; | 1607 }; |
| 1608 | 1608 |
| 1609 | 1609 |
| 1610 // The code patcher is used to patch (typically) small parts of code e.g. for | 1610 // The code patcher is used to patch (typically) small parts of code e.g. for |
| 1611 // debugging and other types of instrumentation. When using the code patcher | 1611 // debugging and other types of instrumentation. When using the code patcher |
| 1612 // the exact number of bytes specified must be emitted. It is not legal to emit | 1612 // the exact number of bytes specified must be emitted. It is not legal to emit |
| 1613 // relocation information. If any of these constraints are violated it causes | 1613 // relocation information. If any of these constraints are violated it causes |
| 1614 // an assertion to fail. | 1614 // an assertion to fail. |
| 1615 class CodePatcher { | 1615 class CodePatcher { |
| 1616 public: | 1616 public: |
| 1617 CodePatcher(byte* address, int instructions); | 1617 enum FlushICache { |
| 1618 FLUSH, |
| 1619 DONT_FLUSH |
| 1620 }; |
| 1621 |
| 1622 CodePatcher(byte* address, |
| 1623 int instructions, |
| 1624 FlushICache flush_cache = FLUSH); |
| 1618 virtual ~CodePatcher(); | 1625 virtual ~CodePatcher(); |
| 1619 | 1626 |
| 1620 // Macro assembler to emit code. | 1627 // Macro assembler to emit code. |
| 1621 MacroAssembler* masm() { return &masm_; } | 1628 MacroAssembler* masm() { return &masm_; } |
| 1622 | 1629 |
| 1623 // Emit an instruction directly. | 1630 // Emit an instruction directly. |
| 1624 void Emit(Instr instr); | 1631 void Emit(Instr instr); |
| 1625 | 1632 |
| 1626 // Emit an address directly. | 1633 // Emit an address directly. |
| 1627 void Emit(Address addr); | 1634 void Emit(Address addr); |
| 1628 | 1635 |
| 1629 // Change the condition part of an instruction leaving the rest of the current | 1636 // Change the condition part of an instruction leaving the rest of the current |
| 1630 // instruction unchanged. | 1637 // instruction unchanged. |
| 1631 void ChangeBranchCondition(Condition cond); | 1638 void ChangeBranchCondition(Condition cond); |
| 1632 | 1639 |
| 1633 private: | 1640 private: |
| 1634 byte* address_; // The address of the code being patched. | 1641 byte* address_; // The address of the code being patched. |
| 1635 int size_; // Number of bytes of the expected patch size. | 1642 int size_; // Number of bytes of the expected patch size. |
| 1636 MacroAssembler masm_; // Macro assembler used to generate the code. | 1643 MacroAssembler masm_; // Macro assembler used to generate the code. |
| 1644 FlushICache flush_cache_; // Whether to flush the I cache after patching. |
| 1637 }; | 1645 }; |
| 1638 | 1646 |
| 1639 | 1647 |
| 1640 | 1648 |
| 1641 #ifdef GENERATED_CODE_COVERAGE | 1649 #ifdef GENERATED_CODE_COVERAGE |
| 1642 #define CODE_COVERAGE_STRINGIFY(x) #x | 1650 #define CODE_COVERAGE_STRINGIFY(x) #x |
| 1643 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) | 1651 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) |
| 1644 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) | 1652 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) |
| 1645 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> | 1653 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> |
| 1646 #else | 1654 #else |
| 1647 #define ACCESS_MASM(masm) masm-> | 1655 #define ACCESS_MASM(masm) masm-> |
| 1648 #endif | 1656 #endif |
| 1649 | 1657 |
| 1650 } } // namespace v8::internal | 1658 } } // namespace v8::internal |
| 1651 | 1659 |
| 1652 #endif // V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ | 1660 #endif // V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ |
| OLD | NEW |